Index: dbus/bus.cc |
diff --git a/dbus/bus.cc b/dbus/bus.cc |
index 6bd404c96622bc67c0ddbd0254f33cfa86694fa2..bef20813f715e922174305915303e796509cda6c 100644 |
--- a/dbus/bus.cc |
+++ b/dbus/bus.cc |
@@ -211,6 +211,10 @@ Bus::~Bus() { |
// DCHECK_EQ(0, num_pending_timeouts_); |
} |
+void Bus::SetDisconnectedCallback(const base::Closure& closure) { |
+ on_disconnected_closure_ = closure; |
+} |
+ |
ObjectProxy* Bus::GetObjectProxy(const std::string& service_name, |
const ObjectPath& object_path) { |
return GetObjectProxyWithOptions(service_name, object_path, |
@@ -373,6 +377,14 @@ bool Bus::Connect() { |
return true; |
} |
+void Bus::CloseConnection() { |
+ // dbus_connection_close is blocking call. |
+ AssertOnDBusThread(); |
+ |
+ if (connection_type_ == PRIVATE) |
+ dbus_connection_close(connection_); |
+} |
+ |
void Bus::ShutdownAndBlock() { |
AssertOnDBusThread(); |
@@ -875,6 +887,9 @@ void Bus::OnConnectionDisconnected(DBusConnection* connection) { |
return; |
DCHECK(!dbus_connection_get_is_connected(connection)); |
+ if (!on_disconnected_closure_.is_null()) |
+ PostTaskToOriginThread(FROM_HERE, on_disconnected_closure_); |
+ |
if (shutdown_completed_) |
return; // Do nothing if the shutdown is already completed. |