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 5#ifndef DBUS_SCOPED_DBUS_ERROR_H_ 6#define DBUS_SCOPED_DBUS_ERROR_H_ 7 8#include <dbus/dbus.h> 9 10#include "dbus/dbus_export.h" 11 12namespace dbus { 13 14// Utility class to ensure that DBusError is freed. 15class CHROME_DBUS_EXPORT ScopedDBusError { 16 public: 17 // Do not inline methods that call dbus_error_xxx() functions. 18 // See http://crbug.com/416628 19 ScopedDBusError(); 20 ~ScopedDBusError(); 21 22 DBusError* get() { return &error_; } 23 bool is_set() const; 24 const char* name() { return error_.name; } 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_ 34