Index: dbus/bus.cc |
diff --git a/dbus/bus.cc b/dbus/bus.cc |
index 30b6cc31cfa8f15a888deba5fd993c1175dfc045..b5ad7976b005f2ea276ceaa3f39eadfd1f65aa33 100644 |
--- a/dbus/bus.cc |
+++ b/dbus/bus.cc |
@@ -235,6 +235,67 @@ ObjectProxy* Bus::GetObjectProxyWithOptions(const std::string& service_name, |
return object_proxy.get(); |
} |
+bool Bus::RemoveObjectProxy(const std::string& service_name, |
+ const ObjectPath& object_path, |
+ OnRemoveObjectProxyCallback callback) { |
+ return RemoveObjectProxyWithOptions(service_name, object_path, |
+ ObjectProxy::DEFAULT_OPTIONS, |
+ callback); |
+} |
+ |
+bool Bus::RemoveObjectProxyWithOptions(const std::string& service_name, |
+ const dbus::ObjectPath& object_path, |
+ int options, |
+ OnRemoveObjectProxyCallback callback) { |
+ bool result; |
+ AssertOnOriginThread(); |
+ |
+ // Check if we have the requested object proxy. |
+ const ObjectProxyTable::key_type key(service_name + object_path.value(), |
+ options); |
+ ObjectProxyTable::iterator iter = object_proxy_table_.find(key); |
+ if (iter != object_proxy_table_.end()) { |
+ // Object is present. Remove it now and Detach in the DBus thread. |
+ result = true; |
+ PostTaskToDBusThread(FROM_HERE, base::Bind( |
+ &Bus::RemoveObjectProxyInternal, |
+ this, iter->second, service_name, object_path, options, callback)); |
+ |
+ object_proxy_table_.erase(iter); |
+ } else { |
Haruki Sato
2013/01/23 09:34:05
maybe returns in this if clause make it simpler?
e
deymo
2013/01/23 19:23:46
Done.
|
+ result = false; |
+ } |
+ return result; |
+} |
+ |
+void Bus::RemoveObjectProxyInternal( |
+ scoped_refptr<dbus::ObjectProxy> object_proxy, |
+ const std::string& service_name, |
+ const dbus::ObjectPath& object_path, |
+ int options, |
+ OnRemoveObjectProxyCallback callback) { |
+ AssertOnDBusThread(); |
+ |
+ object_proxy.get()->Detach(); |
+ |
+ PostTaskToOriginThread(FROM_HERE, |
+ base::Bind(&Bus::OnRemoveObjectProxy, |
+ this, |
+ callback, |
+ service_name, |
+ object_path, |
+ options)); |
+} |
+ |
+void Bus::OnRemoveObjectProxy(OnRemoveObjectProxyCallback callback, |
+ const std::string& service_name, |
+ const dbus::ObjectPath& object_path, |
+ int options) { |
+ AssertOnOriginThread(); |
+ |
+ callback.Run(service_name, object_path, options); |
+} |
+ |
ExportedObject* Bus::GetExportedObject(const ObjectPath& object_path) { |
AssertOnOriginThread(); |