| OLD | NEW |
| 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 204 |
| 205 // Called when an object proxy removal is complete. |
| 206 // Parameters identify the removed object proxy: |
| 207 // - the service name. |
| 208 // - the object path. |
| 209 // - options |
| 210 typedef base::Callback<void (const std::string&, const ObjectPath&, int)> |
| 211 OnRemoveObjectProxyCallback; |
| 212 |
| 205 // Gets the object proxy for the given service name and the object path. | 213 // Gets the object proxy for the given service name and the object path. |
| 206 // The caller must not delete the returned object. | 214 // The caller must not delete the returned object. |
| 207 // | 215 // |
| 208 // Returns an existing object proxy if the bus object already owns the | 216 // Returns an existing object proxy if the bus object already owns the |
| 209 // object proxy for the given service name and the object path. | 217 // object proxy for the given service name and the object path. |
| 210 // Never returns NULL. | 218 // Never returns NULL. |
| 211 // | 219 // |
| 212 // The bus will own all object proxies created by the bus, to ensure | 220 // 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 | 221 // that the object proxies are detached from remote objects at the |
| 214 // shutdown time of the bus. | 222 // shutdown time of the bus. |
| 215 // | 223 // |
| 216 // The object proxy is used to call methods of remote objects, and | 224 // The object proxy is used to call methods of remote objects, and |
| 217 // receive signals from them. | 225 // receive signals from them. |
| 218 // | 226 // |
| 219 // |service_name| looks like "org.freedesktop.NetworkManager", and | 227 // |service_name| looks like "org.freedesktop.NetworkManager", and |
| 220 // |object_path| looks like "/org/freedesktop/NetworkManager/Devices/0". | 228 // |object_path| looks like "/org/freedesktop/NetworkManager/Devices/0". |
| 221 // | 229 // |
| 222 // Must be called in the origin thread. | 230 // Must be called in the origin thread. |
| 223 virtual ObjectProxy* GetObjectProxy(const std::string& service_name, | 231 virtual ObjectProxy* GetObjectProxy(const std::string& service_name, |
| 224 const ObjectPath& object_path); | 232 const ObjectPath& object_path); |
| 225 | 233 |
| 226 // Same as above, but also takes a bitfield of ObjectProxy::Options. | 234 // Same as above, but also takes a bitfield of ObjectProxy::Options. |
| 227 // See object_proxy.h for available options. | 235 // See object_proxy.h for available options. |
| 228 virtual ObjectProxy* GetObjectProxyWithOptions( | 236 virtual ObjectProxy* GetObjectProxyWithOptions( |
| 229 const std::string& service_name, | 237 const std::string& service_name, |
| 230 const ObjectPath& object_path, | 238 const ObjectPath& object_path, |
| 231 int options); | 239 int options); |
| 232 | 240 |
| 241 // Removes the previously created object proxy for the given service |
| 242 // name and the object path and releases its memory. |
| 243 // |
| 244 // If and object proxy for the given service name and object was |
| 245 // created with GetObjectProxy, this function removes it from the |
| 246 // bus object and detaches the ObjectProxy, invalidating any pointer |
| 247 // previously acquired for it with GetObjectProxy. A subsequent call |
| 248 // to GetObjectProxy will return a new object. |
| 249 // |
| 250 // All the object proxies are detached from remote objects at the |
| 251 // shutdown time of the bus, but they can be detached early to reduce |
| 252 // memory footprint and used match rules for the bus connection. |
| 253 // |
| 254 // |service_name| looks like "org.freedesktop.NetworkManager", and |
| 255 // |object_path| looks like "/org/freedesktop/NetworkManager/Devices/0". |
| 256 // |callback| is called when the object proxy is successfully removed and |
| 257 // detached. |
| 258 // |
| 259 // The function returns true when there is an object proxy matching the |
| 260 // |service_name| and |object_path| to remove, and calls |callback| when it |
| 261 // is removed. Otherwise, it returns false and the |callback| function is |
| 262 // never called. |
| 263 // |
| 264 // Must be called in the origin thread. |
| 265 virtual bool RemoveObjectProxy(const std::string& service_name, |
| 266 const ObjectPath& object_path, |
| 267 OnRemoveObjectProxyCallback callback); |
| 268 |
| 269 // Same as above, but also takes a bitfield of ObjectProxy::Options. |
| 270 // See object_proxy.h for available options. |
| 271 virtual bool RemoveObjectProxyWithOptions( |
| 272 const std::string& service_name, |
| 273 const ObjectPath& object_path, |
| 274 int options, |
| 275 OnRemoveObjectProxyCallback callback); |
| 276 |
| 233 // Gets the exported object for the given object path. | 277 // Gets the exported object for the given object path. |
| 234 // The caller must not delete the returned object. | 278 // The caller must not delete the returned object. |
| 235 // | 279 // |
| 236 // Returns an existing exported object if the bus object already owns | 280 // Returns an existing exported object if the bus object already owns |
| 237 // the exported object for the given object path. Never returns NULL. | 281 // the exported object for the given object path. Never returns NULL. |
| 238 // | 282 // |
| 239 // The bus will own all exported objects created by the bus, to ensure | 283 // 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 | 284 // that the exported objects are unregistered at the shutdown time of |
| 241 // the bus. | 285 // the bus. |
| 242 // | 286 // |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 // Returns true if the bus is connected to D-Bus. | 486 // Returns true if the bus is connected to D-Bus. |
| 443 bool is_connected() { return connection_ != NULL; } | 487 bool is_connected() { return connection_ != NULL; } |
| 444 | 488 |
| 445 protected: | 489 protected: |
| 446 // This is protected, so we can define sub classes. | 490 // This is protected, so we can define sub classes. |
| 447 virtual ~Bus(); | 491 virtual ~Bus(); |
| 448 | 492 |
| 449 private: | 493 private: |
| 450 friend class base::RefCountedThreadSafe<Bus>; | 494 friend class base::RefCountedThreadSafe<Bus>; |
| 451 | 495 |
| 496 // Helper function used for RemoveObjectProxy(). |
| 497 void RemoveObjectProxyInternal(scoped_refptr<dbus::ObjectProxy> object_proxy, |
| 498 const std::string& service_name, |
| 499 const dbus::ObjectPath& object_path, |
| 500 int options, |
| 501 OnRemoveObjectProxyCallback callback); |
| 502 |
| 503 // Called when the object proxy removal is completed. |
| 504 void OnRemoveObjectProxy(OnRemoveObjectProxyCallback callback, |
| 505 const std::string& service_name, |
| 506 const dbus::ObjectPath& object_path, |
| 507 int options); |
| 508 |
| 452 // Helper function used for UnregisterExportedObject(). | 509 // Helper function used for UnregisterExportedObject(). |
| 453 void UnregisterExportedObjectInternal( | 510 void UnregisterExportedObjectInternal( |
| 454 scoped_refptr<dbus::ExportedObject> exported_object); | 511 scoped_refptr<dbus::ExportedObject> exported_object); |
| 455 | 512 |
| 456 // Helper function used for ShutdownOnDBusThreadAndBlock(). | 513 // Helper function used for ShutdownOnDBusThreadAndBlock(). |
| 457 void ShutdownOnDBusThreadAndBlockInternal(); | 514 void ShutdownOnDBusThreadAndBlockInternal(); |
| 458 | 515 |
| 459 // Helper function used for RequestOwnership(). | 516 // Helper function used for RequestOwnership(). |
| 460 void RequestOwnershipInternal(const std::string& service_name, | 517 void RequestOwnershipInternal(const std::string& service_name, |
| 461 OnOwnershipCallback on_ownership_callback); | 518 OnOwnershipCallback on_ownership_callback); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 int num_pending_timeouts_; | 604 int num_pending_timeouts_; |
| 548 | 605 |
| 549 std::string address_; | 606 std::string address_; |
| 550 | 607 |
| 551 DISALLOW_COPY_AND_ASSIGN(Bus); | 608 DISALLOW_COPY_AND_ASSIGN(Bus); |
| 552 }; | 609 }; |
| 553 | 610 |
| 554 } // namespace dbus | 611 } // namespace dbus |
| 555 | 612 |
| 556 #endif // DBUS_BUS_H_ | 613 #endif // DBUS_BUS_H_ |
| OLD | NEW |