scoped_dbus_error.h 810 B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef DBUS_SCOPED_DBUS_ERROR_H_
  5. #define DBUS_SCOPED_DBUS_ERROR_H_
  6. #include <dbus/dbus.h>
  7. #include "dbus/dbus_export.h"
  8. namespace dbus {
  9. // Utility class to ensure that DBusError is freed.
  10. class CHROME_DBUS_EXPORT ScopedDBusError {
  11. public:
  12. // Do not inline methods that call dbus_error_xxx() functions.
  13. // See http://crbug.com/416628
  14. ScopedDBusError();
  15. ~ScopedDBusError();
  16. DBusError* get() { return &error_; }
  17. bool is_set() const;
  18. const char* name() { return error_.name; }
  19. const char* message() { return error_.message; }
  20. private:
  21. DBusError error_;
  22. };
  23. } // namespace dbus
  24. #endif // DBUS_SCOPED_DBUS_ERROR_H_