| Index: content/browser/child_process_launcher.cc
|
| diff --git a/content/browser/child_process_launcher.cc b/content/browser/child_process_launcher.cc
|
| index e67e107edc482ab36467ba14851588b37134fce6..6b88b049946b6e3165a108430f2bb2949814d283 100644
|
| --- a/content/browser/child_process_launcher.cc
|
| +++ b/content/browser/child_process_launcher.cc
|
| @@ -33,6 +33,7 @@
|
| #include "base/win/win_util.h"
|
| #include "content/common/sandbox_win.h"
|
| #include "content/public/common/sandbox_init.h"
|
| +#include "sandbox/win/src/sandbox_types.h"
|
| #elif defined(OS_MACOSX)
|
| #include "content/browser/bootstrap_sandbox_manager_mac.h"
|
| #include "content/browser/mach_broker_mac.h"
|
| @@ -65,7 +66,8 @@ typedef base::Callback<void(ZygoteHandle,
|
| base::ScopedFD,
|
| base::ScopedFD,
|
| #endif
|
| - base::Process)> NotifyCallback;
|
| + base::Process,
|
| + int)> NotifyCallback;
|
|
|
| void RecordHistogramsOnLauncherThread(base::TimeDelta launch_time) {
|
| DCHECK_CURRENTLY_ON(BrowserThread::PROCESS_LAUNCHER);
|
| @@ -89,15 +91,18 @@ void OnChildProcessStartedAndroid(const NotifyCallback& callback,
|
| base::ScopedFD ipcfd,
|
| base::ScopedFD mojo_fd,
|
| base::ProcessHandle handle) {
|
| + int launch_result = (handle == base::kNullProcessHandle)
|
| + ? LAUNCH_RESULT_FAILURE
|
| + : LAUNCH_RESULT_SUCCESS;
|
| // This can be called on the launcher thread or UI thread.
|
| base::TimeDelta launch_time = base::TimeTicks::Now() - begin_launch_time;
|
| BrowserThread::PostTask(
|
| BrowserThread::PROCESS_LAUNCHER, FROM_HERE,
|
| base::Bind(&RecordHistogramsOnLauncherThread, launch_time));
|
|
|
| - base::Closure callback_on_client_thread(
|
| - base::Bind(callback, nullptr, base::Passed(&ipcfd),
|
| - base::Passed(&mojo_fd), base::Passed(base::Process(handle))));
|
| + base::Closure callback_on_client_thread(base::Bind(
|
| + callback, nullptr, base::Passed(&ipcfd), base::Passed(&mojo_fd),
|
| + base::Passed(base::Process(handle)), launch_result));
|
| if (BrowserThread::CurrentlyOn(client_thread_id)) {
|
| callback_on_client_thread.Run();
|
| } else {
|
| @@ -120,6 +125,7 @@ void LaunchOnLauncherThread(const NotifyCallback& callback,
|
| std::unique_ptr<SandboxedProcessLauncherDelegate> delegate_deleter(delegate);
|
| #if !defined(OS_ANDROID)
|
| ZygoteHandle zygote = nullptr;
|
| + int launch_result = LAUNCH_RESULT_FAILURE;
|
| #endif
|
| #if defined(OS_WIN)
|
| bool launch_elevated = delegate->ShouldLaunchElevated();
|
| @@ -148,7 +154,8 @@ void LaunchOnLauncherThread(const NotifyCallback& callback,
|
| cmd_line->AppendSwitchASCII(
|
| mojo::edk::PlatformChannelPair::kMojoPlatformChannelHandleSwitch,
|
| base::UintToString(base::win::HandleToUint32(handles[0])));
|
| - process = StartSandboxedProcess(delegate, cmd_line, handles);
|
| + launch_result =
|
| + StartSandboxedProcess(delegate, cmd_line, handles, &process);
|
| }
|
| #elif defined(OS_POSIX)
|
| std::string process_type =
|
| @@ -335,11 +342,13 @@ void LaunchOnLauncherThread(const NotifyCallback& callback,
|
| #endif // else defined(OS_POSIX)
|
| #if !defined(OS_ANDROID)
|
| if (process.IsValid()) {
|
| + launch_result = LAUNCH_RESULT_SUCCESS;
|
| RecordHistogramsOnLauncherThread(base::TimeTicks::Now() -
|
| begin_launch_time);
|
| }
|
| BrowserThread::PostTask(client_thread_id, FROM_HERE,
|
| - base::Bind(callback, zygote, base::Passed(&process)));
|
| + base::Bind(callback, zygote, base::Passed(&process),
|
| + launch_result));
|
| #endif // !defined(OS_ANDROID)
|
| }
|
|
|
| @@ -500,7 +509,8 @@ void ChildProcessLauncher::DidLaunch(
|
| base::ScopedFD ipcfd,
|
| base::ScopedFD mojo_fd,
|
| #endif
|
| - base::Process process) {
|
| + base::Process process,
|
| + int error_code) {
|
| if (!process.IsValid())
|
| LOG(ERROR) << "Failed to launch child process";
|
|
|
| @@ -509,7 +519,8 @@ void ChildProcessLauncher::DidLaunch(
|
| #if defined(OS_ANDROID)
|
| std::move(ipcfd),
|
| #endif
|
| - std::move(process));
|
| + std::move(process),
|
| + error_code);
|
| } else {
|
| if (process.IsValid() && terminate_on_shutdown) {
|
| // On Posix, EnsureProcessTerminated can lead to 2 seconds of sleep! So
|
| @@ -525,7 +536,8 @@ void ChildProcessLauncher::Notify(ZygoteHandle zygote,
|
| #if defined(OS_ANDROID)
|
| base::ScopedFD ipcfd,
|
| #endif
|
| - base::Process process) {
|
| + base::Process process,
|
| + int error_code) {
|
| DCHECK(CalledOnValidThread());
|
| starting_ = false;
|
| process_ = std::move(process);
|
| @@ -543,7 +555,7 @@ void ChildProcessLauncher::Notify(ZygoteHandle zygote,
|
| client_->OnProcessLaunched();
|
| } else {
|
| termination_status_ = base::TERMINATION_STATUS_LAUNCH_FAILED;
|
| - client_->OnProcessLaunchFailed();
|
| + client_->OnProcessLaunchFailed(error_code);
|
| }
|
| }
|
|
|
|
|