| 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 <dbus/dbus.h> | 8 #include <dbus/dbus.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 class Thread; | 25 class Thread; |
| 26 } | 26 } |
| 27 | 27 |
| 28 namespace tracked_objects { | 28 namespace tracked_objects { |
| 29 class Location; | 29 class Location; |
| 30 } | 30 } |
| 31 | 31 |
| 32 namespace dbus { | 32 namespace dbus { |
| 33 | 33 |
| 34 class ExportedObject; | 34 class ExportedObject; |
| 35 class ObjectManager; |
| 35 class ObjectProxy; | 36 class ObjectProxy; |
| 36 | 37 |
| 37 // Bus is used to establish a connection with D-Bus, create object | 38 // Bus is used to establish a connection with D-Bus, create object |
| 38 // proxies, and export objects. | 39 // proxies, and export objects. |
| 39 // | 40 // |
| 40 // For asynchronous operations such as an asynchronous method call, the | 41 // For asynchronous operations such as an asynchronous method call, the |
| 41 // bus object will use a task runner to monitor the underlying file | 42 // bus object will use a task runner to monitor the underlying file |
| 42 // descriptor used for D-Bus communication. By default, the bus will use | 43 // descriptor used for D-Bus communication. By default, the bus will use |
| 43 // the current thread's task runner. If |dbus_task_runner| option is | 44 // the current thread's task runner. If |dbus_task_runner| option is |
| 44 // specified, the bus will use that task runner instead. | 45 // specified, the bus will use that task runner instead. |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 | 296 |
| 296 // Unregisters the exported object for the given object path |object_path|. | 297 // Unregisters the exported object for the given object path |object_path|. |
| 297 // | 298 // |
| 298 // Getting an exported object for the same object path after this call | 299 // Getting an exported object for the same object path after this call |
| 299 // will return a new object, method calls on any remaining copies of the | 300 // will return a new object, method calls on any remaining copies of the |
| 300 // previous object will not be called. | 301 // previous object will not be called. |
| 301 // | 302 // |
| 302 // Must be called in the origin thread. | 303 // Must be called in the origin thread. |
| 303 virtual void UnregisterExportedObject(const ObjectPath& object_path); | 304 virtual void UnregisterExportedObject(const ObjectPath& object_path); |
| 304 | 305 |
| 306 |
| 307 // Gets an object manager for the given remote object path |object_path| |
| 308 // exported by the service |service_name|. |
| 309 // |
| 310 // Returns an existing object manager if the bus object already owns a |
| 311 // matching object manager, never returns NULL. |
| 312 // |
| 313 // The caller must not delete the returned object, the bus retains ownership |
| 314 // of all object managers. |
| 315 // |
| 316 // Must be called in the origin thread. |
| 317 virtual ObjectManager* GetObjectManager(const std::string& service_name, |
| 318 const ObjectPath& object_path); |
| 319 |
| 320 // Unregisters the object manager for the given remote object path |
| 321 // |object_path| exported by the srevice |service_name|. |
| 322 // |
| 323 // Getting an object manager for the same remote object after this call |
| 324 // will return a new object, method calls on any remaining copies of the |
| 325 // previous object are not permitted. |
| 326 // |
| 327 // Must be called in the origin thread. |
| 328 virtual void RemoveObjectManager(const std::string& service_name, |
| 329 const ObjectPath& object_path); |
| 330 |
| 331 // Instructs all registered object managers to retrieve their set of managed |
| 332 // objects from their respective remote objects. There is no need to call this |
| 333 // manually, this is called automatically by the D-Bus thread manager once |
| 334 // implementation classes are registered. |
| 335 virtual void GetManagedObjects(); |
| 336 |
| 305 // Shuts down the bus and blocks until it's done. More specifically, this | 337 // Shuts down the bus and blocks until it's done. More specifically, this |
| 306 // function does the following: | 338 // function does the following: |
| 307 // | 339 // |
| 308 // - Unregisters the object paths | 340 // - Unregisters the object paths |
| 309 // - Releases the service names | 341 // - Releases the service names |
| 310 // - Closes the connection to dbus-daemon. | 342 // - Closes the connection to dbus-daemon. |
| 311 // | 343 // |
| 312 // This function can be called multiple times and it is no-op for the 2nd time | 344 // This function can be called multiple times and it is no-op for the 2nd time |
| 313 // calling. | 345 // calling. |
| 314 // | 346 // |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 scoped_refptr<dbus::ObjectProxy> > ObjectProxyTable; | 633 scoped_refptr<dbus::ObjectProxy> > ObjectProxyTable; |
| 602 ObjectProxyTable object_proxy_table_; | 634 ObjectProxyTable object_proxy_table_; |
| 603 | 635 |
| 604 // ExportedObjectTable is used to hold the exported objects created by | 636 // ExportedObjectTable is used to hold the exported objects created by |
| 605 // the bus object. Key is a concatenated string of service name + | 637 // the bus object. Key is a concatenated string of service name + |
| 606 // object path, like "org.chromium.TestService/org/chromium/TestObject". | 638 // object path, like "org.chromium.TestService/org/chromium/TestObject". |
| 607 typedef std::map<const dbus::ObjectPath, | 639 typedef std::map<const dbus::ObjectPath, |
| 608 scoped_refptr<dbus::ExportedObject> > ExportedObjectTable; | 640 scoped_refptr<dbus::ExportedObject> > ExportedObjectTable; |
| 609 ExportedObjectTable exported_object_table_; | 641 ExportedObjectTable exported_object_table_; |
| 610 | 642 |
| 643 // ObjectManagerTable is used to hold the object managers created by the |
| 644 // bus object. Key is a concatenated string of service name + object path, |
| 645 // like "org.chromium.TestService/org/chromium/TestObject". |
| 646 typedef std::map<std::string, |
| 647 scoped_refptr<dbus::ObjectManager> > ObjectManagerTable; |
| 648 ObjectManagerTable object_manager_table_; |
| 649 |
| 611 bool async_operations_set_up_; | 650 bool async_operations_set_up_; |
| 612 bool shutdown_completed_; | 651 bool shutdown_completed_; |
| 613 | 652 |
| 614 // Counters to make sure that OnAddWatch()/OnRemoveWatch() and | 653 // Counters to make sure that OnAddWatch()/OnRemoveWatch() and |
| 615 // OnAddTimeout()/OnRemoveTimeou() are balanced. | 654 // OnAddTimeout()/OnRemoveTimeou() are balanced. |
| 616 int num_pending_watches_; | 655 int num_pending_watches_; |
| 617 int num_pending_timeouts_; | 656 int num_pending_timeouts_; |
| 618 | 657 |
| 619 std::string address_; | 658 std::string address_; |
| 620 base::Closure on_disconnected_closure_; | 659 base::Closure on_disconnected_closure_; |
| 621 | 660 |
| 622 DISALLOW_COPY_AND_ASSIGN(Bus); | 661 DISALLOW_COPY_AND_ASSIGN(Bus); |
| 623 }; | 662 }; |
| 624 | 663 |
| 625 } // namespace dbus | 664 } // namespace dbus |
| 626 | 665 |
| 627 #endif // DBUS_BUS_H_ | 666 #endif // DBUS_BUS_H_ |
| OLD | NEW |