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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 // Must be called in the origin thread. | 293 // Must be called in the origin thread. |
294 virtual void UnregisterExportedObject(const ObjectPath& object_path); | 294 virtual void UnregisterExportedObject(const ObjectPath& object_path); |
295 | 295 |
296 // Shuts down the bus and blocks until it's done. More specifically, this | 296 // Shuts down the bus and blocks until it's done. More specifically, this |
297 // function does the following: | 297 // function does the following: |
298 // | 298 // |
299 // - Unregisters the object paths | 299 // - Unregisters the object paths |
300 // - Releases the service names | 300 // - Releases the service names |
301 // - Closes the connection to dbus-daemon. | 301 // - Closes the connection to dbus-daemon. |
302 // | 302 // |
| 303 // This function can be called multiple times and it is no-op for the 2nd time |
| 304 // calling. |
| 305 // |
303 // BLOCKING CALL. | 306 // BLOCKING CALL. |
304 virtual void ShutdownAndBlock(); | 307 virtual void ShutdownAndBlock(); |
305 | 308 |
306 // Similar to ShutdownAndBlock(), but this function is used to | 309 // Similar to ShutdownAndBlock(), but this function is used to |
307 // synchronously shut down the bus that uses the D-Bus thread. This | 310 // synchronously shut down the bus that uses the D-Bus thread. This |
308 // function is intended to be used at the very end of the browser | 311 // function is intended to be used at the very end of the browser |
309 // shutdown, where it makes more sense to shut down the bus | 312 // shutdown, where it makes more sense to shut down the bus |
310 // synchronously, than trying to make it asynchronous. | 313 // synchronously, than trying to make it asynchronous. |
311 // | 314 // |
312 // BLOCKING CALL, but must be called in the origin thread. | 315 // BLOCKING CALL, but must be called in the origin thread. |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 void OnRemoveTimeout(DBusTimeout* raw_timeout); | 530 void OnRemoveTimeout(DBusTimeout* raw_timeout); |
528 | 531 |
529 // Called when the "enabled" status of |raw_timeout| is toggled. | 532 // Called when the "enabled" status of |raw_timeout| is toggled. |
530 void OnToggleTimeout(DBusTimeout* raw_timeout); | 533 void OnToggleTimeout(DBusTimeout* raw_timeout); |
531 | 534 |
532 // Called when the dispatch status (i.e. if any incoming data is | 535 // Called when the dispatch status (i.e. if any incoming data is |
533 // available) is changed. | 536 // available) is changed. |
534 void OnDispatchStatusChanged(DBusConnection* connection, | 537 void OnDispatchStatusChanged(DBusConnection* connection, |
535 DBusDispatchStatus status); | 538 DBusDispatchStatus status); |
536 | 539 |
| 540 // Called when the connection is diconnected. |
| 541 void OnConnectionDisconnected(DBusConnection* connection); |
| 542 |
537 // Callback helper functions. Redirects to the corresponding member function. | 543 // Callback helper functions. Redirects to the corresponding member function. |
538 static dbus_bool_t OnAddWatchThunk(DBusWatch* raw_watch, void* data); | 544 static dbus_bool_t OnAddWatchThunk(DBusWatch* raw_watch, void* data); |
539 static void OnRemoveWatchThunk(DBusWatch* raw_watch, void* data); | 545 static void OnRemoveWatchThunk(DBusWatch* raw_watch, void* data); |
540 static void OnToggleWatchThunk(DBusWatch* raw_watch, void* data); | 546 static void OnToggleWatchThunk(DBusWatch* raw_watch, void* data); |
541 static dbus_bool_t OnAddTimeoutThunk(DBusTimeout* raw_timeout, void* data); | 547 static dbus_bool_t OnAddTimeoutThunk(DBusTimeout* raw_timeout, void* data); |
542 static void OnRemoveTimeoutThunk(DBusTimeout* raw_timeout, void* data); | 548 static void OnRemoveTimeoutThunk(DBusTimeout* raw_timeout, void* data); |
543 static void OnToggleTimeoutThunk(DBusTimeout* raw_timeout, void* data); | 549 static void OnToggleTimeoutThunk(DBusTimeout* raw_timeout, void* data); |
544 static void OnDispatchStatusChangedThunk(DBusConnection* connection, | 550 static void OnDispatchStatusChangedThunk(DBusConnection* connection, |
545 DBusDispatchStatus status, | 551 DBusDispatchStatus status, |
546 void* data); | 552 void* data); |
| 553 |
| 554 // Calls OnConnectionDisconnected if the Diconnected signal is received. |
| 555 static DBusHandlerResult OnConnectionDisconnectedFilter( |
| 556 DBusConnection *connection, |
| 557 DBusMessage *message, |
| 558 void *user_data); |
| 559 |
547 const BusType bus_type_; | 560 const BusType bus_type_; |
548 const ConnectionType connection_type_; | 561 const ConnectionType connection_type_; |
549 scoped_refptr<base::MessageLoopProxy> dbus_thread_message_loop_proxy_; | 562 scoped_refptr<base::MessageLoopProxy> dbus_thread_message_loop_proxy_; |
550 base::WaitableEvent on_shutdown_; | 563 base::WaitableEvent on_shutdown_; |
551 DBusConnection* connection_; | 564 DBusConnection* connection_; |
552 | 565 |
553 scoped_refptr<base::MessageLoopProxy> origin_message_loop_proxy_; | 566 scoped_refptr<base::MessageLoopProxy> origin_message_loop_proxy_; |
554 base::PlatformThreadId origin_thread_id_; | 567 base::PlatformThreadId origin_thread_id_; |
555 | 568 |
556 std::set<std::string> owned_service_names_; | 569 std::set<std::string> owned_service_names_; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 int num_pending_timeouts_; | 601 int num_pending_timeouts_; |
589 | 602 |
590 std::string address_; | 603 std::string address_; |
591 | 604 |
592 DISALLOW_COPY_AND_ASSIGN(Bus); | 605 DISALLOW_COPY_AND_ASSIGN(Bus); |
593 }; | 606 }; |
594 | 607 |
595 } // namespace dbus | 608 } // namespace dbus |
596 | 609 |
597 #endif // DBUS_BUS_H_ | 610 #endif // DBUS_BUS_H_ |
OLD | NEW |