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

Unified Diff: dbus/bus.cc

Issue 9668018: dbus: remove service name from ExportedObject (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: pay more attention when fixing mock Created 8 years, 9 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 3b2f059c5975cad4ac06e92245e758320db1a52a..e391bc578b976d01a9de8857ff43a4813f78b2cd 100644
--- a/dbus/bus.cc
+++ b/dbus/bus.cc
@@ -233,20 +233,18 @@ ObjectProxy* Bus::GetObjectProxyWithOptions(const std::string& service_name,
return object_proxy.get();
}
-ExportedObject* Bus::GetExportedObject(const std::string& service_name,
- const ObjectPath& object_path) {
+ExportedObject* Bus::GetExportedObject(const ObjectPath& object_path) {
AssertOnOriginThread();
// Check if we already have the requested exported object.
- const std::string key = service_name + object_path.value();
- ExportedObjectTable::iterator iter = exported_object_table_.find(key);
+ ExportedObjectTable::iterator iter = exported_object_table_.find(object_path);
if (iter != exported_object_table_.end()) {
return iter->second;
}
scoped_refptr<ExportedObject> exported_object =
- new ExportedObject(this, service_name, object_path);
- exported_object_table_[key] = exported_object;
+ new ExportedObject(this, object_path);
+ exported_object_table_[object_path] = exported_object;
return exported_object.get();
}
@@ -339,7 +337,40 @@ void Bus::ShutdownOnDBusThreadAndBlock() {
LOG_IF(ERROR, !signaled) << "Failed to shutdown the bus";
}
-bool Bus::RequestOwnership(const std::string& service_name) {
+void Bus::RequestOwnership(const std::string& service_name,
+ OnOwnershipCallback on_ownership_callback) {
+ AssertOnOriginThread();
+
+ PostTaskToDBusThread(FROM_HERE, base::Bind(
+ &Bus::RequestOwnershipInternal,
+ this, service_name, on_ownership_callback));
+}
+
+void Bus::RequestOwnershipInternal(const std::string& service_name,
+ OnOwnershipCallback on_ownership_callback) {
+ AssertOnDBusThread();
+
+ bool success = Connect();
+ if (success)
+ success = RequestOwnershipAndBlock(service_name);
+
+ PostTaskToOriginThread(FROM_HERE,
+ base::Bind(&Bus::OnOwnership,
+ this,
+ 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.
AssertOnDBusThread();
« 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