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

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: satorux comments in unittest 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
« no previous file with comments | « dbus/bus.h ('k') | dbus/bus_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dbus/bus.cc
diff --git a/dbus/bus.cc b/dbus/bus.cc
index 30b6cc31cfa8f15a888deba5fd993c1175dfc045..c7584fdf6deb18c833375b2e4b1dd6a2f4646ed4 100644
--- a/dbus/bus.cc
+++ b/dbus/bus.cc
@@ -235,6 +235,46 @@ ObjectProxy* Bus::GetObjectProxyWithOptions(const std::string& service_name,
return object_proxy.get();
}
+bool Bus::RemoveObjectProxy(const std::string& service_name,
+ const ObjectPath& object_path,
+ const base::Closure& 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,
+ const base::Closure& 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, callback));
+
+ object_proxy_table_.erase(iter);
+ return true;
+ }
+ return false;
+}
+
+void Bus::RemoveObjectProxyInternal(
+ scoped_refptr<dbus::ObjectProxy> object_proxy,
+ const base::Closure& callback) {
+ AssertOnDBusThread();
+
+ object_proxy.get()->Detach();
+
+ PostTaskToOriginThread(FROM_HERE, callback);
+}
+
ExportedObject* Bus::GetExportedObject(const ObjectPath& object_path) {
AssertOnOriginThread();
@@ -410,21 +450,11 @@ void Bus::RequestOwnershipInternal(const std::string& service_name,
success = RequestOwnershipAndBlock(service_name);
PostTaskToOriginThread(FROM_HERE,
- base::Bind(&Bus::OnOwnership,
- this,
- on_ownership_callback,
+ base::Bind(on_ownership_callback,
service_name,
success));
}
-void Bus::OnOwnership(OnOwnershipCallback on_ownership_callback,
- const std::string& service_name,
- bool success) {
- AssertOnOriginThread();
-
- on_ownership_callback.Run(service_name, success);
-}
-
bool Bus::RequestOwnershipAndBlock(const std::string& service_name) {
DCHECK(connection_);
// dbus_bus_request_name() is a blocking call.
« no previous file with comments | « dbus/bus.h ('k') | dbus/bus_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698