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

Unified Diff: services/service_manager/background/background_service_manager.cc

Issue 2646033002: mash: Exit the root process if the window manager service crashes (Closed)
Patch Set: review comments Created 3 years, 11 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
Index: services/service_manager/background/background_service_manager.cc
diff --git a/services/service_manager/background/background_service_manager.cc b/services/service_manager/background/background_service_manager.cc
index 09b2e86403d2aac3c3e72664e8578fe06a374450..d74a8a61b34d032446aa9d7b984a8a513f4fbae3 100644
--- a/services/service_manager/background/background_service_manager.cc
+++ b/services/service_manager/background/background_service_manager.cc
@@ -25,6 +25,19 @@
#include "services/service_manager/standalone/context.h"
namespace service_manager {
+namespace {
+
+// Calls |callback| on |callback_task_runner|'s thread.
+void CallCallbackWithIdentity(
+ const scoped_refptr<base::TaskRunner> callback_task_runner,
+ const base::Callback<void(const Identity&)>& callback,
+ const Identity& identity) {
+ DCHECK(callback);
+ DCHECK(identity.IsValid());
+ callback_task_runner->PostTask(FROM_HERE, base::Bind(callback, identity));
+}
+
+} // namespace
BackgroundServiceManager::BackgroundServiceManager(
service_manager::ServiceProcessLauncher::Delegate* launcher_delegate,
@@ -62,6 +75,29 @@ void BackgroundServiceManager::RegisterService(
base::Passed(&pid_receiver_request)));
}
+void BackgroundServiceManager::SetInstanceQuitCallback(
+ base::Callback<void(const Identity&)> callback) {
+ DCHECK(callback);
+ // Hop to the background thread. The provided callback will be called on
+ // whichever thread called this function.
+ background_thread_.task_runner()->PostTask(
+ FROM_HERE,
+ base::Bind(
+ &BackgroundServiceManager::SetInstanceQuitCallbackOnBackgroundThread,
+ base::Unretained(this), base::ThreadTaskRunnerHandle::Get(),
+ callback));
+}
+
+void BackgroundServiceManager::SetInstanceQuitCallbackOnBackgroundThread(
+ const scoped_refptr<base::SingleThreadTaskRunner>& callback_task_runner,
+ const base::Callback<void(const Identity&)>& callback) {
+ DCHECK(callback_task_runner);
+ DCHECK(callback);
+ // Calls |callback| with the identity of the service that is quitting.
+ context_->service_manager()->SetInstanceQuitCallback(
+ base::Bind(&CallCallbackWithIdentity, callback_task_runner, callback));
+}
+
void BackgroundServiceManager::InitializeOnBackgroundThread(
service_manager::ServiceProcessLauncher::Delegate* launcher_delegate,
std::unique_ptr<base::Value> catalog_contents) {
« no previous file with comments | « services/service_manager/background/background_service_manager.h ('k') | services/service_manager/background/tests/OWNERS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698