adamk@chromium.org | 35c0eef | 2012-02-11 06:45:23 +0900 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef DBUS_SCOPED_DBUS_ERROR_H_ |
| 6 | #define DBUS_SCOPED_DBUS_ERROR_H_ |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 7 | |
| 8 | #include <dbus/dbus.h> |
| 9 | |
avakulenko | 2887219 | 2014-09-25 03:47:52 +0900 | [diff] [blame] | 10 | #include "dbus/dbus_export.h" |
| 11 | |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 12 | namespace dbus { |
| 13 | |
| 14 | // Utility class to ensure that DBusError is freed. |
avakulenko | 2887219 | 2014-09-25 03:47:52 +0900 | [diff] [blame] | 15 | class CHROME_DBUS_EXPORT ScopedDBusError { |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 16 | public: |
avakulenko | 2887219 | 2014-09-25 03:47:52 +0900 | [diff] [blame] | 17 | // Do not inline methods that call dbus_error_xxx() functions. |
| 18 | // See http://crbug.com/416628 |
| 19 | ScopedDBusError(); |
| 20 | ~ScopedDBusError(); |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 21 | |
| 22 | DBusError* get() { return &error_; } |
avakulenko | 2887219 | 2014-09-25 03:47:52 +0900 | [diff] [blame] | 23 | bool is_set() const; |
adamk@chromium.org | 35c0eef | 2012-02-11 06:45:23 +0900 | [diff] [blame] | 24 | const char* name() { return error_.name; } |
satorux@chromium.org | 163f1cb | 2011-08-18 05:58:12 +0900 | [diff] [blame] | 25 | const char* message() { return error_.message; } |
| 26 | |
| 27 | private: |
| 28 | DBusError error_; |
| 29 | }; |
| 30 | |
| 31 | } // namespace dbus |
| 32 | |
| 33 | #endif // DBUS_SCOPED_DBUS_ERROR_H_ |