Index: chromeos/dbus/dbus.h |
diff --git a/chromeos/dbus/dbus.h b/chromeos/dbus/dbus.h |
index 47758678e423a723b8598b5355119a50a436ed8a..9ac1a1f5088f353259e4fa5e1c1a95521de6d91d 100644 |
--- a/chromeos/dbus/dbus.h |
+++ b/chromeos/dbus/dbus.h |
@@ -34,11 +34,14 @@ class BusConnection { |
typedef ::DBusGConnection* value_type; |
BusConnection(const BusConnection& x) |
- : object_(dbus_g_connection_ref(x.object_)) { |
+ : object_(x.object_) { |
+ if (object_) |
+ ::dbus_g_connection_ref(object_); |
} |
~BusConnection() { |
- ::dbus_g_connection_unref(object_); |
+ if (object_) |
+ ::dbus_g_connection_unref(object_); |
} |
BusConnection& operator=(BusConnection x) { |
@@ -51,6 +54,14 @@ class BusConnection { |
return object_; |
} |
+ operator bool() const { |
+ return object_; |
+ } |
+ |
+ bool HasConnection() const { |
+ return object_; |
+ } |
+ |
private: |
friend void swap(BusConnection& x, BusConnection& y); |
@@ -61,7 +72,6 @@ class BusConnection { |
// Constructor takes ownership |
explicit BusConnection(::DBusGConnection* x) |
: object_(x) { |
- DCHECK(object_) << "Constructing BusConnection with NULL object."; |
} |
value_type object_; |