diff options
author | dpapad@chromium.org <dpapad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-14 20:22:53 +0000 |
---|---|---|
committer | dpapad@chromium.org <dpapad@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-14 20:22:53 +0000 |
commit | 02743b707e2743cd0f0916e3b405191a48fa3947 (patch) | |
tree | 2b0c0be422f99a2e0dce81c6de92f9a8bc80b969 /dbus/bus.cc | |
parent | 7f58f3f417a0598ad796ca7de7b14a38252d91bd (diff) | |
download | chromium_src-02743b707e2743cd0f0916e3b405191a48fa3947.zip chromium_src-02743b707e2743cd0f0916e3b405191a48fa3947.tar.gz chromium_src-02743b707e2743cd0f0916e3b405191a48fa3947.tar.bz2 |
Revert 121920 - dbus: add ObjectPath type
Rather than use std::string for object paths, add a dbus::ObjectPath type
that wraps one while allowing more type-safety. This solves all sorts of
issues with confusing object paths for strings, and allows us to do
Properties code using templates disambiguating them from strings.
BUG=chromium:109194
TEST=built and run tests
Change-Id: Icaf6f19daea4af23a9d2ec0ed76d2cbd379d680e
Review URL: http://codereview.chromium.org/9378039
TBR=keybuk@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9363045
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121923 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'dbus/bus.cc')
-rw-r--r-- | dbus/bus.cc | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/dbus/bus.cc b/dbus/bus.cc index 3b2f059..0c6a421 100644 --- a/dbus/bus.cc +++ b/dbus/bus.cc @@ -16,7 +16,6 @@ #include "base/threading/thread_restrictions.h" #include "base/time.h" #include "dbus/exported_object.h" -#include "dbus/object_path.h" #include "dbus/object_proxy.h" #include "dbus/scoped_dbus_error.h" @@ -208,19 +207,18 @@ Bus::~Bus() { } ObjectProxy* Bus::GetObjectProxy(const std::string& service_name, - const ObjectPath& object_path) { + const std::string& object_path) { return GetObjectProxyWithOptions(service_name, object_path, ObjectProxy::DEFAULT_OPTIONS); } ObjectProxy* Bus::GetObjectProxyWithOptions(const std::string& service_name, - const dbus::ObjectPath& object_path, + const std::string& object_path, int options) { AssertOnOriginThread(); // Check if we already have the requested object proxy. - const ObjectProxyTable::key_type key(service_name + object_path.value(), - options); + const ObjectProxyTable::key_type key(service_name + object_path, options); ObjectProxyTable::iterator iter = object_proxy_table_.find(key); if (iter != object_proxy_table_.end()) { return iter->second; @@ -234,11 +232,11 @@ ObjectProxy* Bus::GetObjectProxyWithOptions(const std::string& service_name, } ExportedObject* Bus::GetExportedObject(const std::string& service_name, - const ObjectPath& object_path) { + const std::string& object_path) { AssertOnOriginThread(); // Check if we already have the requested exported object. - const std::string key = service_name + object_path.value(); + const std::string key = service_name + object_path; ExportedObjectTable::iterator iter = exported_object_table_.find(key); if (iter != exported_object_table_.end()) { return iter->second; @@ -523,7 +521,7 @@ void Bus::RemoveMatch(const std::string& match_rule, DBusError* error) { match_rules_added_.erase(match_rule); } -bool Bus::TryRegisterObjectPath(const ObjectPath& object_path, +bool Bus::TryRegisterObjectPath(const std::string& object_path, const DBusObjectPathVTable* vtable, void* user_data, DBusError* error) { @@ -532,13 +530,13 @@ bool Bus::TryRegisterObjectPath(const ObjectPath& object_path, if (registered_object_paths_.find(object_path) != registered_object_paths_.end()) { - LOG(ERROR) << "Object path already registered: " << object_path.value(); + LOG(ERROR) << "Object path already registered: " << object_path; return false; } const bool success = dbus_connection_try_register_object_path( connection_, - object_path.value().c_str(), + object_path.c_str(), vtable, user_data, error); @@ -547,20 +545,20 @@ bool Bus::TryRegisterObjectPath(const ObjectPath& object_path, return success; } -void Bus::UnregisterObjectPath(const ObjectPath& object_path) { +void Bus::UnregisterObjectPath(const std::string& object_path) { DCHECK(connection_); AssertOnDBusThread(); if (registered_object_paths_.find(object_path) == registered_object_paths_.end()) { LOG(ERROR) << "Requested to unregister an unknown object path: " - << object_path.value(); + << object_path; return; } const bool success = dbus_connection_unregister_object_path( connection_, - object_path.value().c_str()); + object_path.c_str()); CHECK(success) << "Unable to allocate memory"; registered_object_paths_.erase(object_path); } |