blob: 1484dbb81b4b300dd6cd874287b07e7ff1b85271 [file] [log] [blame]
adamk@chromium.org35c0eef2012-02-11 06:45:23 +09001// Copyright (c) 2012 The Chromium Authors. All rights reserved.
satorux@chromium.org163f1cb2011-08-18 05:58:12 +09002// 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.org163f1cb2011-08-18 05:58:12 +09007
8#include <dbus/dbus.h>
9
avakulenko28872192014-09-25 03:47:52 +090010#include "dbus/dbus_export.h"
11
satorux@chromium.org163f1cb2011-08-18 05:58:12 +090012namespace dbus {
13
14// Utility class to ensure that DBusError is freed.
avakulenko28872192014-09-25 03:47:52 +090015class CHROME_DBUS_EXPORT ScopedDBusError {
satorux@chromium.org163f1cb2011-08-18 05:58:12 +090016 public:
avakulenko28872192014-09-25 03:47:52 +090017 // Do not inline methods that call dbus_error_xxx() functions.
18 // See http://crbug.com/416628
19 ScopedDBusError();
20 ~ScopedDBusError();
satorux@chromium.org163f1cb2011-08-18 05:58:12 +090021
22 DBusError* get() { return &error_; }
avakulenko28872192014-09-25 03:47:52 +090023 bool is_set() const;
adamk@chromium.org35c0eef2012-02-11 06:45:23 +090024 const char* name() { return error_.name; }
satorux@chromium.org163f1cb2011-08-18 05:58:12 +090025 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_