Index: dbus/test_service.cc |
diff --git a/dbus/test_service.cc b/dbus/test_service.cc |
index 23c4bc556ef59f4e00b7aa1e5265235de0112ae9..7532d5bc5f178aa4706f120577a2944d9eb380e2 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; |