| Index: content/browser/child_process_launcher.cc
|
| diff --git a/content/browser/child_process_launcher.cc b/content/browser/child_process_launcher.cc
|
| index a97eb3b63da5f11982fb0483379ad457d823c008..40d78e0cae0d3ceb1dbb215e067282cf0b777955 100644
|
| --- a/content/browser/child_process_launcher.cc
|
| +++ b/content/browser/child_process_launcher.cc
|
| @@ -39,10 +39,8 @@
|
| #elif defined(OS_POSIX)
|
| #include "base/memory/singleton.h"
|
| #include "content/browser/renderer_host/render_sandbox_host_linux.h"
|
| -#include "content/browser/zygote_host/zygote_communication_linux.h"
|
| #include "content/browser/zygote_host/zygote_host_impl_linux.h"
|
| #include "content/common/child_process_sandbox_support_impl_linux.h"
|
| -#include "content/public/browser/zygote_handle_linux.h"
|
| #endif
|
|
|
| #if defined(OS_POSIX)
|
| @@ -55,7 +53,7 @@
|
|
|
| namespace {
|
|
|
| -typedef base::Callback<void(ZygoteHandle,
|
| +typedef base::Callback<void(bool,
|
| #if defined(OS_ANDROID)
|
| base::ScopedFD,
|
| #endif
|
| @@ -89,7 +87,7 @@
|
| base::Bind(&RecordHistogramsOnLauncherThread, launch_time));
|
|
|
| base::Closure callback_on_client_thread(
|
| - base::Bind(callback, nullptr, base::Passed(&ipcfd),
|
| + base::Bind(callback, false, base::Passed(&ipcfd),
|
| base::Passed(base::Process(handle))));
|
| if (BrowserThread::CurrentlyOn(client_thread_id)) {
|
| callback_on_client_thread.Run();
|
| @@ -110,15 +108,15 @@
|
| base::CommandLine* cmd_line) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::PROCESS_LAUNCHER);
|
| scoped_ptr<SandboxedProcessLauncherDelegate> delegate_deleter(delegate);
|
| -#if !defined(OS_ANDROID)
|
| - ZygoteHandle zygote = nullptr;
|
| -#endif
|
| #if defined(OS_WIN)
|
| + bool use_zygote = false;
|
| bool launch_elevated = delegate->ShouldLaunchElevated();
|
| #elif defined(OS_MACOSX)
|
| + bool use_zygote = false;
|
| base::EnvironmentMap env = delegate->GetEnvironment();
|
| base::ScopedFD ipcfd = delegate->TakeIpcFd();
|
| #elif defined(OS_POSIX) && !defined(OS_ANDROID)
|
| + bool use_zygote = delegate->ShouldUseZygote();
|
| base::EnvironmentMap env = delegate->GetEnvironment();
|
| base::ScopedFD ipcfd = delegate->TakeIpcFd();
|
| #endif
|
| @@ -201,16 +199,8 @@
|
| // child termination.
|
|
|
| #if !defined(OS_MACOSX)
|
| - ZygoteHandle* zygote_handle = delegate->GetZygote();
|
| - // If |zygote_handle| is null, a zygote should not be used.
|
| - if (zygote_handle) {
|
| - // This code runs on the PROCESS_LAUNCHER thread so race conditions are not
|
| - // an issue with the lazy initialization.
|
| - if (*zygote_handle == nullptr) {
|
| - *zygote_handle = CreateZygote();
|
| - }
|
| - zygote = *zygote_handle;
|
| - base::ProcessHandle handle = zygote->ForkRequest(
|
| + if (use_zygote) {
|
| + base::ProcessHandle handle = ZygoteHostImpl::GetInstance()->ForkRequest(
|
| cmd_line->argv(), std::move(files_to_register), process_type);
|
| process = base::Process(handle);
|
| } else
|
| @@ -289,11 +279,13 @@
|
| begin_launch_time);
|
| }
|
| BrowserThread::PostTask(client_thread_id, FROM_HERE,
|
| - base::Bind(callback, zygote, base::Passed(&process)));
|
| + base::Bind(callback,
|
| + use_zygote,
|
| + base::Passed(&process)));
|
| #endif // !defined(OS_ANDROID)
|
| }
|
|
|
| -void TerminateOnLauncherThread(ZygoteHandle zygote, base::Process process) {
|
| +void TerminateOnLauncherThread(bool zygote, base::Process process) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::PROCESS_LAUNCHER);
|
| #if defined(OS_ANDROID)
|
| VLOG(1) << "ChromeProcess: Stopping process with handle "
|
| @@ -309,7 +301,7 @@
|
| if (zygote) {
|
| // If the renderer was created via a zygote, we have to proxy the reaping
|
| // through the zygote process.
|
| - zygote->EnsureProcessTerminated(process.Handle());
|
| + ZygoteHostImpl::GetInstance()->EnsureProcessTerminated(process.Handle());
|
| } else
|
| #endif // !OS_MACOSX
|
| base::EnsureProcessTerminated(std::move(process));
|
| @@ -339,7 +331,7 @@
|
| : client_(client),
|
| termination_status_(base::TERMINATION_STATUS_NORMAL_TERMINATION),
|
| exit_code_(RESULT_CODE_NORMAL_EXIT),
|
| - zygote_(nullptr),
|
| + zygote_(false),
|
| starting_(true),
|
| #if defined(ADDRESS_SANITIZER) || defined(LEAK_SANITIZER) || \
|
| defined(MEMORY_SANITIZER) || defined(THREAD_SANITIZER) || \
|
| @@ -409,8 +401,8 @@
|
| DCHECK(CalledOnValidThread());
|
| #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
|
| if (zygote_) {
|
| - termination_status_ = zygote_->GetTerminationStatus(
|
| - process_.Handle(), known_dead, &exit_code_);
|
| + termination_status_ = ZygoteHostImpl::GetInstance()->
|
| + GetTerminationStatus(process_.Handle(), known_dead, &exit_code_);
|
| } else if (known_dead) {
|
| termination_status_ =
|
| base::GetKnownDeadTerminationStatus(process_.Handle(), &exit_code_);
|
| @@ -443,7 +435,7 @@
|
| void ChildProcessLauncher::DidLaunch(
|
| base::WeakPtr<ChildProcessLauncher> instance,
|
| bool terminate_on_shutdown,
|
| - ZygoteHandle zygote,
|
| + bool zygote,
|
| #if defined(OS_ANDROID)
|
| base::ScopedFD ipcfd,
|
| #endif
|
| @@ -468,11 +460,12 @@
|
| }
|
| }
|
|
|
| -void ChildProcessLauncher::Notify(ZygoteHandle zygote,
|
| -#if defined(OS_ANDROID)
|
| - base::ScopedFD ipcfd,
|
| -#endif
|
| - base::Process process) {
|
| +void ChildProcessLauncher::Notify(
|
| + bool zygote,
|
| +#if defined(OS_ANDROID)
|
| + base::ScopedFD ipcfd,
|
| +#endif
|
| + base::Process process) {
|
| DCHECK(CalledOnValidThread());
|
| starting_ = false;
|
| process_ = std::move(process);
|
|
|