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

Side by Side Diff: dbus/bus.h

Issue 12022004: D-Bus: ObjectProxy remove function for Bus object. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: satorux comments in unittest Created 7 years, 10 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 | dbus/bus.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) 2012 The Chromium Authors. All rights reserved. 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 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 DBUS_BUS_H_ 5 #ifndef DBUS_BUS_H_
6 #define DBUS_BUS_H_ 6 #define DBUS_BUS_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 194
195 // Creates a Bus object. The actual connection will be established when 195 // Creates a Bus object. The actual connection will be established when
196 // Connect() is called. 196 // Connect() is called.
197 explicit Bus(const Options& options); 197 explicit Bus(const Options& options);
198 198
199 // Called when an ownership request is complete. 199 // Called when an ownership request is complete.
200 // Parameters: 200 // Parameters:
201 // - the requested service name. 201 // - the requested service name.
202 // - whether ownership has been obtained or not. 202 // - whether ownership has been obtained or not.
203 typedef base::Callback<void (const std::string&, bool)> OnOwnershipCallback; 203 typedef base::Callback<void (const std::string&, bool)> OnOwnershipCallback;
204 // TODO(satorux): Remove the service name parameter as the caller of
205 // RequestOwnership() knows the service name.
204 206
205 // Gets the object proxy for the given service name and the object path. 207 // Gets the object proxy for the given service name and the object path.
206 // The caller must not delete the returned object. 208 // The caller must not delete the returned object.
207 // 209 //
208 // Returns an existing object proxy if the bus object already owns the 210 // Returns an existing object proxy if the bus object already owns the
209 // object proxy for the given service name and the object path. 211 // object proxy for the given service name and the object path.
210 // Never returns NULL. 212 // Never returns NULL.
211 // 213 //
212 // The bus will own all object proxies created by the bus, to ensure 214 // The bus will own all object proxies created by the bus, to ensure
213 // that the object proxies are detached from remote objects at the 215 // that the object proxies are detached from remote objects at the
214 // shutdown time of the bus. 216 // shutdown time of the bus.
215 // 217 //
216 // The object proxy is used to call methods of remote objects, and 218 // The object proxy is used to call methods of remote objects, and
217 // receive signals from them. 219 // receive signals from them.
218 // 220 //
219 // |service_name| looks like "org.freedesktop.NetworkManager", and 221 // |service_name| looks like "org.freedesktop.NetworkManager", and
220 // |object_path| looks like "/org/freedesktop/NetworkManager/Devices/0". 222 // |object_path| looks like "/org/freedesktop/NetworkManager/Devices/0".
221 // 223 //
222 // Must be called in the origin thread. 224 // Must be called in the origin thread.
223 virtual ObjectProxy* GetObjectProxy(const std::string& service_name, 225 virtual ObjectProxy* GetObjectProxy(const std::string& service_name,
224 const ObjectPath& object_path); 226 const ObjectPath& object_path);
225 227
226 // Same as above, but also takes a bitfield of ObjectProxy::Options. 228 // Same as above, but also takes a bitfield of ObjectProxy::Options.
227 // See object_proxy.h for available options. 229 // See object_proxy.h for available options.
228 virtual ObjectProxy* GetObjectProxyWithOptions( 230 virtual ObjectProxy* GetObjectProxyWithOptions(
229 const std::string& service_name, 231 const std::string& service_name,
230 const ObjectPath& object_path, 232 const ObjectPath& object_path,
231 int options); 233 int options);
232 234
235 // Removes the previously created object proxy for the given service
236 // name and the object path and releases its memory.
237 //
238 // If and object proxy for the given service name and object was
239 // created with GetObjectProxy, this function removes it from the
240 // bus object and detaches the ObjectProxy, invalidating any pointer
241 // previously acquired for it with GetObjectProxy. A subsequent call
242 // to GetObjectProxy will return a new object.
243 //
244 // All the object proxies are detached from remote objects at the
245 // shutdown time of the bus, but they can be detached early to reduce
246 // memory footprint and used match rules for the bus connection.
247 //
248 // |service_name| looks like "org.freedesktop.NetworkManager", and
249 // |object_path| looks like "/org/freedesktop/NetworkManager/Devices/0".
250 // |callback| is called when the object proxy is successfully removed and
251 // detached.
252 //
253 // The function returns true when there is an object proxy matching the
254 // |service_name| and |object_path| to remove, and calls |callback| when it
255 // is removed. Otherwise, it returns false and the |callback| function is
256 // never called. The |callback| argument must not be null.
257 //
258 // Must be called in the origin thread.
259 virtual bool RemoveObjectProxy(const std::string& service_name,
260 const ObjectPath& object_path,
261 const base::Closure& callback);
262
263 // Same as above, but also takes a bitfield of ObjectProxy::Options.
264 // See object_proxy.h for available options.
265 virtual bool RemoveObjectProxyWithOptions(
266 const std::string& service_name,
267 const ObjectPath& object_path,
268 int options,
269 const base::Closure& callback);
270
233 // Gets the exported object for the given object path. 271 // Gets the exported object for the given object path.
234 // The caller must not delete the returned object. 272 // The caller must not delete the returned object.
235 // 273 //
236 // Returns an existing exported object if the bus object already owns 274 // Returns an existing exported object if the bus object already owns
237 // the exported object for the given object path. Never returns NULL. 275 // the exported object for the given object path. Never returns NULL.
238 // 276 //
239 // The bus will own all exported objects created by the bus, to ensure 277 // The bus will own all exported objects created by the bus, to ensure
240 // that the exported objects are unregistered at the shutdown time of 278 // that the exported objects are unregistered at the shutdown time of
241 // the bus. 279 // the bus.
242 // 280 //
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 // Returns true if the bus is connected to D-Bus. 480 // Returns true if the bus is connected to D-Bus.
443 bool is_connected() { return connection_ != NULL; } 481 bool is_connected() { return connection_ != NULL; }
444 482
445 protected: 483 protected:
446 // This is protected, so we can define sub classes. 484 // This is protected, so we can define sub classes.
447 virtual ~Bus(); 485 virtual ~Bus();
448 486
449 private: 487 private:
450 friend class base::RefCountedThreadSafe<Bus>; 488 friend class base::RefCountedThreadSafe<Bus>;
451 489
490 // Helper function used for RemoveObjectProxy().
491 void RemoveObjectProxyInternal(scoped_refptr<dbus::ObjectProxy> object_proxy,
492 const base::Closure& callback);
493
452 // Helper function used for UnregisterExportedObject(). 494 // Helper function used for UnregisterExportedObject().
453 void UnregisterExportedObjectInternal( 495 void UnregisterExportedObjectInternal(
454 scoped_refptr<dbus::ExportedObject> exported_object); 496 scoped_refptr<dbus::ExportedObject> exported_object);
455 497
456 // Helper function used for ShutdownOnDBusThreadAndBlock(). 498 // Helper function used for ShutdownOnDBusThreadAndBlock().
457 void ShutdownOnDBusThreadAndBlockInternal(); 499 void ShutdownOnDBusThreadAndBlockInternal();
458 500
459 // Helper function used for RequestOwnership(). 501 // Helper function used for RequestOwnership().
460 void RequestOwnershipInternal(const std::string& service_name, 502 void RequestOwnershipInternal(const std::string& service_name,
461 OnOwnershipCallback on_ownership_callback); 503 OnOwnershipCallback on_ownership_callback);
462 504
463 // Called when the ownership request is completed.
464 void OnOwnership(OnOwnershipCallback on_ownership_callback,
465 const std::string& service_name,
466 bool success);
467
468 // Processes the all incoming data to the connection, if any. 505 // Processes the all incoming data to the connection, if any.
469 // 506 //
470 // BLOCKING CALL. 507 // BLOCKING CALL.
471 void ProcessAllIncomingDataIfAny(); 508 void ProcessAllIncomingDataIfAny();
472 509
473 // Called when a watch object is added. Used to start monitoring the 510 // Called when a watch object is added. Used to start monitoring the
474 // file descriptor used for D-Bus communication. 511 // file descriptor used for D-Bus communication.
475 dbus_bool_t OnAddWatch(DBusWatch* raw_watch); 512 dbus_bool_t OnAddWatch(DBusWatch* raw_watch);
476 513
477 // Called when a watch object is removed. 514 // Called when a watch object is removed.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 int num_pending_timeouts_; 584 int num_pending_timeouts_;
548 585
549 std::string address_; 586 std::string address_;
550 587
551 DISALLOW_COPY_AND_ASSIGN(Bus); 588 DISALLOW_COPY_AND_ASSIGN(Bus);
552 }; 589 };
553 590
554 } // namespace dbus 591 } // namespace dbus
555 592
556 #endif // DBUS_BUS_H_ 593 #endif // DBUS_BUS_H_
OLDNEW
« no previous file with comments | « no previous file | dbus/bus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698