Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Unified Diff: chromeos/dbus/dbus.h

Issue 2842019: Allowed to construct a dbus::BusConnection object with NULL g_connection (Closed) Base URL: ssh://git@gitrw.chromium.org//common.git
Patch Set: fixed Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chromeos/dbus/dbus.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_;
« no previous file with comments | « no previous file | chromeos/dbus/dbus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698