Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Unified Diff: dbus/bus.cc

Issue 12022004: D-Bus: ObjectProxy remove function for Bus object. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Haruki's suggestions. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: dbus/bus.cc
diff --git a/dbus/bus.cc b/dbus/bus.cc
index 30b6cc31cfa8f15a888deba5fd993c1175dfc045..4b5a43558fee4e98ecad439c5082ab63ad612804 100644
--- a/dbus/bus.cc
+++ b/dbus/bus.cc
@@ -235,6 +235,64 @@ 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) {
+ 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.
+ PostTaskToDBusThread(FROM_HERE, base::Bind(
+ &Bus::RemoveObjectProxyInternal,
+ this, iter->second, service_name, object_path, options, callback));
+
+ object_proxy_table_.erase(iter);
+ return true;
+ }
+ return false;
+}
+
+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));
satorux1 2013/01/25 01:46:06 I think you don't need OnRemoveObjectProxy. You s
deymo 2013/01/25 20:50:55 Done.
+}
+
+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();

Powered by Google App Engine
This is Rietveld 408576698