Index: dbus/bus.cc |
diff --git a/dbus/bus.cc b/dbus/bus.cc |
index 28257f8c5085fd51fbda17861f2de48052546e43..738fd29faa456c60e13d30e501664cffa71d7352 100644 |
--- a/dbus/bus.cc |
+++ b/dbus/bus.cc |
@@ -267,7 +267,7 @@ bool Bus::RemoveObjectProxyWithOptions(const std::string& service_name, |
if (iter != object_proxy_table_.end()) { |
scoped_refptr<ObjectProxy> object_proxy = iter->second; |
object_proxy_table_.erase(iter); |
- // Object is present. Remove it now and Detach in the DBus thread. |
+ // Object is present. Remove it now and Detach on the DBus thread. |
GetDBusTaskRunner()->PostTask( |
FROM_HERE, |
base::Bind(&Bus::RemoveObjectProxyInternal, |
@@ -351,7 +351,8 @@ ObjectManager* Bus::GetObjectManager(const std::string& service_name, |
} |
void Bus::RemoveObjectManager(const std::string& service_name, |
- const ObjectPath& object_path) { |
+ const ObjectPath& object_path, |
+ const base::Closure& callback) { |
AssertOnOriginThread(); |
satorux1
2014/08/28 04:00:01
add: DCHECK(!callback.is_null()); to make it clear
armansito
2014/08/28 15:37:59
Done.
|
const ObjectManagerTable::key_type key(service_name + object_path.value()); |
@@ -359,8 +360,25 @@ void Bus::RemoveObjectManager(const std::string& service_name, |
if (iter == object_manager_table_.end()) |
return; |
+ // ObjectManager is present. Remove it now and CleanUp in the DBus thread. |
satorux1
2014/08/28 04:00:01
in -> on ?
armansito
2014/08/28 15:37:59
Done.
|
scoped_refptr<ObjectManager> object_manager = iter->second; |
object_manager_table_.erase(iter); |
+ |
+ GetDBusTaskRunner()->PostTask( |
+ FROM_HERE, |
+ base::Bind(&Bus::RemoveObjectManagerInternal, |
+ this, object_manager, callback)); |
+} |
+ |
+void Bus::RemoveObjectManagerInternal( |
+ scoped_refptr<dbus::ObjectManager> object_manager, |
+ const base::Closure& callback) { |
+ AssertOnDBusThread(); |
+ DCHECK(object_manager.get()); |
+ |
+ object_manager->CleanUp(); |
+ |
+ GetOriginTaskRunner()->PostTask(FROM_HERE, callback); |
} |
void Bus::GetManagedObjects() { |
@@ -460,6 +478,12 @@ void Bus::ShutdownAndBlock() { |
iter->second->Detach(); |
} |
+ // Clean up the object managers. |
+ for (ObjectManagerTable::iterator iter = object_manager_table_.begin(); |
+ iter != object_manager_table_.end(); ++iter) { |
+ iter->second->CleanUp(); |
+ } |
+ |
// Release object proxies and exported objects here. We should do this |
// here rather than in the destructor to avoid memory leaks due to |
// cyclic references. |