Chromium Code Reviews| Index: dbus/test_service.cc |
| diff --git a/dbus/test_service.cc b/dbus/test_service.cc |
| index 87c6e01ba704d590b9c2ec558d8e06ed78027250..f3277982b66731b6f4194452a5a5bb593a6a97cf 100644 |
| --- a/dbus/test_service.cc |
| +++ b/dbus/test_service.cc |
| @@ -13,6 +13,13 @@ |
| #include "dbus/object_path.h" |
| #include "dbus/property.h" |
| +namespace { |
| + |
| +void EmptyCallback(bool b) { |
|
satorux1
2012/11/07 01:42:25
b -> /* success */
Haruki Sato
2012/11/12 04:59:43
Done. Thanks.
|
| +} |
| + |
| +} // namespace |
| + |
| namespace dbus { |
| // Echo, SlowEcho, AsyncEcho, BrokenMethod, GetAll, Get, Set. |
| @@ -95,7 +102,8 @@ void TestService::SendTestSignalFromRootInternal(const std::string& message) { |
| bus_->RequestOwnership("org.chromium.TestService", |
| base::Bind(&TestService::OnOwnership, |
| - base::Unretained(this))); |
| + base::Unretained(this), |
| + base::Bind(EmptyCallback))); |
|
satorux1
2012/11/07 01:42:25
base::Bind(&EmptyCallback)
Haruki Sato
2012/11/12 04:59:43
Done. Thanks.
|
| // Use "/" just like dbus-send does. |
| ExportedObject* root_object = |
| @@ -103,22 +111,33 @@ void TestService::SendTestSignalFromRootInternal(const std::string& message) { |
| root_object->SendSignal(&signal); |
| } |
| -void TestService::RequestOwnership() { |
| +void TestService::RequestOwnership(base::Callback<void(bool)> callback) { |
| message_loop()->PostTask( |
| FROM_HERE, |
| base::Bind(&TestService::RequestOwnershipInternal, |
| - base::Unretained(this))); |
| + base::Unretained(this), |
| + callback)); |
| } |
| -void TestService::RequestOwnershipInternal() { |
| +void TestService::RequestOwnershipInternal( |
| + base::Callback<void(bool)> callback) { |
| + requesting_ownership = true; |
| bus_->RequestOwnership("org.chromium.TestService", |
| base::Bind(&TestService::OnOwnership, |
| - base::Unretained(this))); |
| + base::Unretained(this), |
| + callback)); |
| } |
| -void TestService::OnOwnership(const std::string& service_name, |
| +void TestService::OnOwnership(base::Callback<void(bool)> callback, |
| + const std::string& service_name, |
| bool success) { |
| + has_name_ownership = success; |
| LOG_IF(ERROR, !success) << "Failed to own: " << service_name; |
| + callback.Run(success); |
| +} |
| + |
| +bool TestService::HasOwnership() { |
| + return has_name_ownership; |
| } |
| void TestService::OnExported(const std::string& interface_name, |
| @@ -146,7 +165,8 @@ void TestService::Run(MessageLoop* message_loop) { |
| bus_->RequestOwnership("org.chromium.TestService", |
| base::Bind(&TestService::OnOwnership, |
| - base::Unretained(this))); |
| + base::Unretained(this), |
| + base::Bind(EmptyCallback))); |
| exported_object_ = bus_->GetExportedObject( |
| dbus::ObjectPath("/org/chromium/TestObject")); |