Index: dbus/bus.h |
diff --git a/dbus/bus.h b/dbus/bus.h |
index 792eb8310d32c79b1eb29d1468ea1be027db54ee..bb81b32f9406441d846b2643770dc5198f979673 100644 |
--- a/dbus/bus.h |
+++ b/dbus/bus.h |
@@ -14,6 +14,7 @@ |
#include "base/callback.h" |
#include "base/memory/ref_counted.h" |
#include "base/memory/scoped_ptr.h" |
+#include "base/synchronization/waitable_event.h" |
#include "base/threading/platform_thread.h" |
#include "base/tracked_objects.h" |
@@ -225,6 +226,18 @@ class Bus : public base::RefCountedThreadSafe<Bus> { |
// Must be called in the origin thread. |
virtual void Shutdown(OnShutdownCallback callback); |
+ // Similar to ShutdownAndBlock(), but this function is used to |
+ // synchronously shut down the bus that uses the D-Bus thread. This |
+ // function is intended to be used at the very end of the browser |
+ // shutdown, where it makes more sense to shut down the bus |
+ // synchronously, than trying to make it asynchronous. |
+ // |
+ // BLOCKING CALL, but must be called in the origin thread. |
+ virtual void ShutdownAndBlockWithDBusThread(); |
stevenjb
2011/09/01 17:53:44
Do we need to expose both ShutdownAndBlock and Shu
satorux1
2011/09/01 17:57:30
ShutdownAndBlock() is already used in wifi_data_pr
stevenjb
2011/09/01 18:19:33
OK. In that case I suggest we name this ShutdownOn
|
+ |
+ // Returns true if the shutdown has been completed. |
+ bool shutdown_completed() { return shutdown_completed_; } |
+ |
// |
// The public functions below are not intended to be used in client |
// code. These are used to implement ObjectProxy and ExportedObject. |
@@ -384,6 +397,9 @@ class Bus : public base::RefCountedThreadSafe<Bus> { |
// Helper function used for Shutdown(). |
void ShutdownInternal(OnShutdownCallback callback); |
+ // Helper function used for ShutdownAndBlockWithDBusThread(). |
+ void ShutdownAndBlockWithDBusThreadInternal(); |
+ |
// Processes the all incoming data to the connection, if any. |
// |
// BLOCKING CALL. |
@@ -427,6 +443,7 @@ class Bus : public base::RefCountedThreadSafe<Bus> { |
const BusType bus_type_; |
const ConnectionType connection_type_; |
base::Thread* dbus_thread_; |
+ base::WaitableEvent on_shutdown_; |
DBusConnection* connection_; |
MessageLoop* origin_loop_; |
@@ -455,6 +472,7 @@ class Bus : public base::RefCountedThreadSafe<Bus> { |
ExportedObjectTable exported_object_table_; |
bool async_operations_set_up_; |
+ bool shutdown_completed_; |
// Counters to make sure that OnAddWatch()/OnRemoveWatch() and |
// OnAddTimeout()/OnRemoveTimeou() are balanced. |