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

Unified Diff: chrome/service/service_process.cc

Issue 7736002: Make the mac service process handling code clean itself up properly as far as launchd is concerned. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add launchd test Created 9 years, 4 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 | « chrome/service/service_process.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/service/service_process.cc
diff --git a/chrome/service/service_process.cc b/chrome/service/service_process.cc
index 8fc8e95de3187ddbeea61e139bbbe6747a36c172..49292eff7aee0aa38131cd64b846744f3f7b2874 100644
--- a/chrome/service/service_process.cc
+++ b/chrome/service/service_process.cc
@@ -210,8 +210,9 @@ bool ServiceProcess::Initialize(MessageLoopForUI* message_loop,
// After the IPC server has started we signal that the service process is
// ready.
- if (!state->SignalReady(io_thread_->message_loop_proxy(),
- NewRunnableMethod(this, &ServiceProcess::Shutdown))) {
+ if (!service_process_state_->SignalReady(
+ io_thread_->message_loop_proxy(),
+ NewRunnableMethod(this, &ServiceProcess::Terminate))) {
return false;
}
@@ -241,7 +242,23 @@ bool ServiceProcess::Teardown() {
// This method is called when a shutdown command is received from IPC channel
// or there was an error in the IPC channel.
void ServiceProcess::Shutdown() {
- // Quit the main message loop.
+#if defined(OS_MACOSX)
+ // On MacOS X the service must be removed from the launchd job list.
+ // http://www.chromium.org/developers/design-documents/service-processes
+ // The best way to do that is to go through the ForceServiceProcessShutdown
+ // path. If it succeeds Terminate() will be called from the handler registered
+ // via service_process_state_->SignalReady().
+ // On failure call Terminate() directly to force the process to actually
+ // terminate.
+ if (!ForceServiceProcessShutdown("", 0)) {
+ Terminate();
+ }
+#else
+ Terminate();
+#endif
+}
+
+void ServiceProcess::Terminate() {
main_message_loop_->PostTask(FROM_HERE, new MessageLoop::QuitTask());
}
« no previous file with comments | « chrome/service/service_process.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698