Index: content/browser/child_process_launcher.cc |
=================================================================== |
--- content/browser/child_process_launcher.cc (revision 86552) |
+++ content/browser/child_process_launcher.cc (working copy) |
@@ -44,7 +44,8 @@ |
Context() |
: client_(NULL), |
client_thread_id_(BrowserThread::UI), |
- starting_(true) |
+ starting_(true), |
+ terminate_child_on_shutdown_(true) |
#if defined(OS_LINUX) |
, zygote_(false) |
#endif |
@@ -87,6 +88,10 @@ |
client_ = NULL; |
} |
+ void set_terminate_child_on_shutdown(bool terminate_on_shutdown) { |
+ terminate_child_on_shutdown_ = terminate_on_shutdown; |
+ } |
+ |
private: |
friend class base::RefCountedThreadSafe<ChildProcessLauncher::Context>; |
friend class ChildProcessLauncher; |
@@ -210,6 +215,9 @@ |
if (!process_.handle()) |
return; |
+ if (!terminate_child_on_shutdown_) |
+ return; |
+ |
// On Posix, EnsureProcessTerminated can lead to 2 seconds of sleep! So |
// don't this on the UI/IO threads. |
BrowserThread::PostTask( |
@@ -257,6 +265,9 @@ |
BrowserThread::ID client_thread_id_; |
base::Process process_; |
bool starting_; |
+ // Controls whether the child process should be terminated on browser |
+ // shutdown. Default behavior is to terminate the child. |
+ bool terminate_child_on_shutdown_; |
#if defined(OS_LINUX) |
bool zygote_; |
@@ -333,3 +344,10 @@ |
&ChildProcessLauncher::Context::SetProcessBackgrounded, |
background)); |
} |
+ |
+void ChildProcessLauncher::SetTerminateChildOnShutdown( |
+ bool terminate_on_shutdown) { |
+ if (context_) |
+ context_->set_terminate_child_on_shutdown(terminate_on_shutdown); |
+} |
+ |