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

Side by Side Diff: src/common/chromeos/dbus/dbus.h

Issue 2133004: Proxy Constructor for peer proxy. (Closed) Base URL: http://src.chromium.org/git/chromiumos.git
Patch Set: Created 10 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/common/chromeos/dbus/dbus.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROMEOS_DBUS_H_ 5 #ifndef CHROMEOS_DBUS_H_
6 #define CHROMEOS_DBUS_H_ 6 #define CHROMEOS_DBUS_H_
7 7
8 #include <dbus/dbus-glib.h> 8 #include <dbus/dbus-glib.h>
9 #include <glib-object.h> 9 #include <glib-object.h>
10 10
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } 98 }
99 99
100 // Equivalent to Proxy(connection, name, path, interface, false). 100 // Equivalent to Proxy(connection, name, path, interface, false).
101 Proxy(const BusConnection& connection, 101 Proxy(const BusConnection& connection,
102 const char* name, 102 const char* name,
103 const char* path, 103 const char* path,
104 const char* interface) 104 const char* interface)
105 : object_(GetGProxy(connection, name, path, interface, false)) { 105 : object_(GetGProxy(connection, name, path, interface, false)) {
106 } 106 }
107 107
108 // Creates a peer proxy using dbus_g_proxy_new_for_peer.
109 Proxy(const BusConnection& connection,
110 const char* path,
111 const char* interface)
112 : object_(GetGPeerProxy(connection, path, interface)) {
113 }
114
108 Proxy(const Proxy& x) 115 Proxy(const Proxy& x)
109 : object_(x.object_) { 116 : object_(x.object_) {
110 if (object_) 117 if (object_)
111 ::g_object_ref(object_); 118 ::g_object_ref(object_);
112 } 119 }
113 120
114 ~Proxy() { 121 ~Proxy() {
115 if (object_) 122 if (object_)
116 ::g_object_unref(object_); 123 ::g_object_unref(object_);
117 } 124 }
(...skipping 20 matching lines...) Expand all
138 return object_; 145 return object_;
139 } 146 }
140 147
141 private: 148 private:
142 static value_type GetGProxy(const BusConnection& connection, 149 static value_type GetGProxy(const BusConnection& connection,
143 const char* name, 150 const char* name,
144 const char* path, 151 const char* path,
145 const char* interface, 152 const char* interface,
146 bool connect_to_name_owner); 153 bool connect_to_name_owner);
147 154
155 static value_type GetGPeerProxy(const BusConnection& connection,
156 const char* path,
157 const char* interface);
158
148 operator int() const; // for safe bool cast 159 operator int() const; // for safe bool cast
149 friend void swap(Proxy& x, Proxy& y); 160 friend void swap(Proxy& x, Proxy& y);
150 161
151 value_type object_; 162 value_type object_;
152 }; 163 };
153 164
154 inline void swap(Proxy& x, Proxy& y) { 165 inline void swap(Proxy& x, Proxy& y) {
155 std::swap(x.object_, y.object_); 166 std::swap(x.object_, y.object_);
156 } 167 }
157 168
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 BusConnection GetSystemBusConnection(); 350 BusConnection GetSystemBusConnection();
340 351
341 // \brief Returns a private connection to a bus at |address|. 352 // \brief Returns a private connection to a bus at |address|.
342 353
343 BusConnection GetPrivateBusConnection(const char* address); 354 BusConnection GetPrivateBusConnection(const char* address);
344 355
345 } // namespace dbus 356 } // namespace dbus
346 } // namespace chromeos 357 } // namespace chromeos
347 358
348 #endif // CHROMEOS_DBUS_H_ 359 #endif // CHROMEOS_DBUS_H_
OLDNEW
« no previous file with comments | « no previous file | src/common/chromeos/dbus/dbus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698