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

Unified Diff: dbus/test_service.cc

Issue 177703006: dbus: Handle NameOwnerChanged in ObjectManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 months 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 21a885d0b67fa4a4ede39046fb3d8116cb26ecac..064b91ee60441eeb30563d65865a481c3299e9cc 100644
--- a/dbus/test_service.cc
+++ b/dbus/test_service.cc
@@ -142,6 +142,24 @@ void TestService::OnOwnership(base::Callback<void(bool)> callback,
on_name_obtained_.Signal();
}
+void TestService::ReleaseOwnership(base::Closure callback) {
+ bus_->GetDBusTaskRunner()->PostTask(
+ FROM_HERE,
+ base::Bind(&TestService::ReleaseOwnershipInternal,
+ base::Unretained(this),
+ callback));
+}
+
+void TestService::ReleaseOwnershipInternal(
+ base::Closure callback) {
+ bus_->ReleaseOwnership("org.chromium.TestService");
+ has_ownership_ = false;
+
+ bus_->GetOriginTaskRunner()->PostTask(
+ FROM_HERE,
+ callback);
+}
+
void TestService::OnExported(const std::string& interface_name,
const std::string& method_name,
bool success) {
@@ -443,11 +461,46 @@ void TestService::PerformAction(
AddObject(object_path);
else if (action == "RemoveObject")
RemoveObject(object_path);
+ else if (action == "ReleaseOwnership") {
+ ReleaseOwnership(base::Bind(&TestService::PerformActionResponse,
+ base::Unretained(this),
+ method_call, response_sender));
+ return;
+ } else if (action == "Ownership") {
+ ReleaseOwnership(base::Bind(&TestService::OwnershipReleased,
+ base::Unretained(this),
+ method_call, response_sender));
+ return;
+ }
scoped_ptr<Response> response = Response::FromMethodCall(method_call);
response_sender.Run(response.Pass());
}
+void TestService::PerformActionResponse(
+ MethodCall* method_call,
+ ExportedObject::ResponseSender response_sender) {
+ scoped_ptr<Response> response = Response::FromMethodCall(method_call);
+ response_sender.Run(response.Pass());
+}
+
+void TestService::OwnershipReleased(
+ MethodCall* method_call,
+ ExportedObject::ResponseSender response_sender) {
+ RequestOwnership(base::Bind(&TestService::OwnershipRegained,
+ base::Unretained(this),
+ method_call, response_sender));
+}
+
+
+void TestService::OwnershipRegained(
+ MethodCall* method_call,
+ ExportedObject::ResponseSender response_sender,
+ bool success) {
+ PerformActionResponse(method_call, response_sender);
+}
+
+
void TestService::GetManagedObjects(
MethodCall* method_call,
ExportedObject::ResponseSender response_sender) {
« 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