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

Unified Diff: dbus/test_service.cc

Issue 11358111: Make SignalSenderVerificationTest more robust (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 1 month 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
« dbus/test_service.h ('K') | « dbus/test_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"));
« dbus/test_service.h ('K') | « dbus/test_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698