X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fdbus%2Fbus.cc;h=3cad3c8909d584ab3942472ed5ff9e3360cbb598;hb=3545e9f2671f595d2a2f3ee75ca0393b01e35ef6;hp=28257f8c5085fd51fbda17861f2de48052546e43;hpb=7d210d4c7e9ba36e635eabc5b5780495f8a63292;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/dbus/bus.cc b/src/dbus/bus.cc index 28257f8..3cad3c8 100644 --- a/src/dbus/bus.cc +++ b/src/dbus/bus.cc @@ -267,7 +267,7 @@ bool Bus::RemoveObjectProxyWithOptions(const std::string& service_name, if (iter != object_proxy_table_.end()) { scoped_refptr 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, @@ -350,17 +350,54 @@ ObjectManager* Bus::GetObjectManager(const std::string& service_name, return object_manager.get(); } -void Bus::RemoveObjectManager(const std::string& service_name, - const ObjectPath& object_path) { +bool Bus::RemoveObjectManager(const std::string& service_name, + const ObjectPath& object_path, + const base::Closure& callback) { AssertOnOriginThread(); + DCHECK(!callback.is_null()); const ObjectManagerTable::key_type key(service_name + object_path.value()); ObjectManagerTable::iterator iter = object_manager_table_.find(key); if (iter == object_manager_table_.end()) - return; + return false; + // ObjectManager is present. Remove it now and CleanUp on the DBus thread. scoped_refptr object_manager = iter->second; object_manager_table_.erase(iter); + + GetDBusTaskRunner()->PostTask( + FROM_HERE, + base::Bind(&Bus::RemoveObjectManagerInternal, + this, object_manager, callback)); + + return true; +} + +void Bus::RemoveObjectManagerInternal( + scoped_refptr object_manager, + const base::Closure& callback) { + AssertOnDBusThread(); + DCHECK(object_manager.get()); + + object_manager->CleanUp(); + + // The ObjectManager has to be deleted on the origin thread since it was + // created there. + GetOriginTaskRunner()->PostTask( + FROM_HERE, + base::Bind(&Bus::RemoveObjectManagerInternalHelper, + this, object_manager, callback)); +} + +void Bus::RemoveObjectManagerInternalHelper( + scoped_refptr object_manager, + const base::Closure& callback) { + AssertOnOriginThread(); + DCHECK(object_manager.get()); + + // Release the object manager and run the callback. + object_manager = NULL; + callback.Run(); } void Bus::GetManagedObjects() { @@ -460,6 +497,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.