diff options
author | keybuk@chromium.org <keybuk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-10 01:12:52 +0000 |
---|---|---|
committer | keybuk@chromium.org <keybuk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-10 01:12:52 +0000 |
commit | 15e7b16ff24684e2678fe1b4964125b42a4c4018 (patch) | |
tree | 5f53e19b8a27e5af437e342d5464b110f4980a48 /dbus/test_service.cc | |
parent | 093fcf536f77186f754119854ab729e68c31f784 (diff) | |
download | chromium_src-15e7b16ff24684e2678fe1b4964125b42a4c4018.zip chromium_src-15e7b16ff24684e2678fe1b4964125b42a4c4018.tar.gz chromium_src-15e7b16ff24684e2678fe1b4964125b42a4c4018.tar.bz2 |
dbus: remove service name from ExportedObject
Well-known names in D-Bus are merely aliases to unique connection ids
maintained by the bus, they have no purpose in qualifying object paths
or interfaces and it's perfectly legimiate for a client to make
requests to the unique connection id (e.g. in response to a signal,
which does not reference the well-known name of the origin connection).
Remove the service_name member from dbus::ExportedObject, from its
constructor and from dbus::Bus::GetExportedObject and require code to
call dbus::Bus::RequestOwnership if a well-known name is desired. This
requires making that function callable from the origin thread with
a callback for the return value.
BUG=chromium-os:27101
TEST=dbus_unittests
Change-Id: Ib91de8b68ad9c3b432e224a2c715f0c2ca1af463
Review URL: http://codereview.chromium.org/9668018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125970 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'dbus/test_service.cc')
-rw-r--r-- | dbus/test_service.cc | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/dbus/test_service.cc b/dbus/test_service.cc index 23c4bc5..7532d5b 100644 --- a/dbus/test_service.cc +++ b/dbus/test_service.cc @@ -95,13 +95,21 @@ void TestService::SendTestSignalFromRootInternal(const std::string& message) { dbus::MessageWriter writer(&signal); writer.AppendString(message); + bus_->RequestOwnership("org.chromium.TestService", + base::Bind(&TestService::OnOwnership, + base::Unretained(this))); + // Use "/" just like dbus-send does. ExportedObject* root_object = - bus_->GetExportedObject("org.chromium.TestService", - dbus::ObjectPath("/")); + bus_->GetExportedObject(dbus::ObjectPath("/")); root_object->SendSignal(&signal); } +void TestService::OnOwnership(const std::string& service_name, + bool success) { + LOG_IF(ERROR, !success) << "Failed to own: " << service_name; +} + void TestService::OnExported(const std::string& interface_name, const std::string& method_name, bool success) { @@ -125,8 +133,11 @@ void TestService::Run(MessageLoop* message_loop) { bus_options.dbus_thread_message_loop_proxy = dbus_thread_message_loop_proxy_; bus_ = new Bus(bus_options); + bus_->RequestOwnership("org.chromium.TestService", + base::Bind(&TestService::OnOwnership, + base::Unretained(this))); + exported_object_ = bus_->GetExportedObject( - "org.chromium.TestService", dbus::ObjectPath("/org/chromium/TestObject")); int num_methods = 0; |