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

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: fix uninitialized members 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
« no previous file with comments | « 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..0d99d5795350a0d638f3beaeaaa3f1f4571d31cb 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 /* success */) {
+}
+
+} // 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)));
// Use "/" just like dbus-send does.
ExportedObject* root_object =
@@ -103,22 +111,28 @@ 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) {
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_ownership_ = success;
LOG_IF(ERROR, !success) << "Failed to own: " << service_name;
+ callback.Run(success);
}
void TestService::OnExported(const std::string& interface_name,
@@ -146,7 +160,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"));
« no previous file with comments | « dbus/test_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698