| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/child_process_launcher.h" | 5 #include "content/browser/child_process_launcher.h" |
| 6 | 6 |
| 7 #include <utility> // For std::pair. | 7 #include <utility> // For std::pair. |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 // ref counted object allows us to automatically terminate the process when the | 51 // ref counted object allows us to automatically terminate the process when the |
| 52 // parent class destructs, while still holding on to state that we need. | 52 // parent class destructs, while still holding on to state that we need. |
| 53 class ChildProcessLauncher::Context | 53 class ChildProcessLauncher::Context |
| 54 : public base::RefCountedThreadSafe<ChildProcessLauncher::Context> { | 54 : public base::RefCountedThreadSafe<ChildProcessLauncher::Context> { |
| 55 public: | 55 public: |
| 56 Context() | 56 Context() |
| 57 : client_(NULL), | 57 : client_(NULL), |
| 58 client_thread_id_(BrowserThread::UI), | 58 client_thread_id_(BrowserThread::UI), |
| 59 termination_status_(base::TERMINATION_STATUS_NORMAL_TERMINATION), | 59 termination_status_(base::TERMINATION_STATUS_NORMAL_TERMINATION), |
| 60 exit_code_(RESULT_CODE_NORMAL_EXIT), | 60 exit_code_(RESULT_CODE_NORMAL_EXIT), |
| 61 starting_(true) | 61 starting_(true), |
| 62 terminate_child_on_shutdown_(true) |
| 62 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 63 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 63 , zygote_(false) | 64 , zygote_(false) |
| 64 #endif | 65 #endif |
| 65 { | 66 { |
| 66 #if defined(OS_POSIX) | |
| 67 terminate_child_on_shutdown_ = !CommandLine::ForCurrentProcess()-> | |
| 68 HasSwitch(switches::kChildCleanExit); | |
| 69 #else | |
| 70 terminate_child_on_shutdown_ = true; | |
| 71 #endif | |
| 72 } | 67 } |
| 73 | 68 |
| 74 void Launch( | 69 void Launch( |
| 75 SandboxedProcessLauncherDelegate* delegate, | 70 SandboxedProcessLauncherDelegate* delegate, |
| 76 CommandLine* cmd_line, | 71 CommandLine* cmd_line, |
| 77 int child_process_id, | 72 int child_process_id, |
| 78 Client* client) { | 73 Client* client) { |
| 79 client_ = client; | 74 client_ = client; |
| 80 | 75 |
| 81 CHECK(BrowserThread::GetCurrentThreadIdentifier(&client_thread_id_)); | 76 CHECK(BrowserThread::GetCurrentThreadIdentifier(&client_thread_id_)); |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 | 487 |
| 493 void ChildProcessLauncher::SetProcessBackgrounded(bool background) { | 488 void ChildProcessLauncher::SetProcessBackgrounded(bool background) { |
| 494 BrowserThread::PostTask( | 489 BrowserThread::PostTask( |
| 495 BrowserThread::PROCESS_LAUNCHER, FROM_HERE, | 490 BrowserThread::PROCESS_LAUNCHER, FROM_HERE, |
| 496 base::Bind( | 491 base::Bind( |
| 497 &ChildProcessLauncher::Context::SetProcessBackgrounded, | 492 &ChildProcessLauncher::Context::SetProcessBackgrounded, |
| 498 GetHandle(), background)); | 493 GetHandle(), background)); |
| 499 } | 494 } |
| 500 | 495 |
| 501 void ChildProcessLauncher::SetTerminateChildOnShutdown( | 496 void ChildProcessLauncher::SetTerminateChildOnShutdown( |
| 502 bool terminate_on_shutdown) { | 497 bool terminate_on_shutdown) { |
| 503 if (context_.get()) | 498 if (context_.get()) |
| 504 context_->set_terminate_child_on_shutdown(terminate_on_shutdown); | 499 context_->set_terminate_child_on_shutdown(terminate_on_shutdown); |
| 505 } | 500 } |
| 506 | 501 |
| 507 } // namespace content | 502 } // namespace content |
| OLD | NEW |