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

Unified Diff: content/browser/child_process_launcher.cc

Issue 98603007: Launches a privileged utility process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleans up ChildProcessLauncher implementations. Created 6 years, 11 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
Index: content/browser/child_process_launcher.cc
diff --git a/content/browser/child_process_launcher.cc b/content/browser/child_process_launcher.cc
index 721cd5a88ede6cc6eeb7907bdecbfd35b7a5ff6d..22aa71106ef73e550e3cf3e6b9283537ad0fc1d4 100644
--- a/content/browser/child_process_launcher.cc
+++ b/content/browser/child_process_launcher.cc
@@ -32,6 +32,7 @@
#include "base/android/jni_android.h"
#include "content/browser/android/child_process_launcher_android.h"
#elif defined(OS_POSIX)
+#include "base/memory/shared_memory.h"
#include "base/memory/singleton.h"
#include "content/browser/renderer_host/render_sandbox_host_linux.h"
#include "content/browser/zygote_host/zygote_host_impl_linux.h"
@@ -39,6 +40,7 @@
#endif
#if defined(OS_POSIX)
+#include "base/metrics/stats_table.h"
#include "base/posix/global_descriptors.h"
#endif
@@ -71,6 +73,7 @@ class ChildProcessLauncher::Context
void Launch(
#if defined(OS_WIN)
SandboxedProcessLauncherDelegate* delegate,
+ bool launch_elevated,
#elif defined(OS_ANDROID)
int ipcfd,
#elif defined(OS_POSIX)
@@ -100,6 +103,7 @@ class ChildProcessLauncher::Context
child_process_id,
#if defined(OS_WIN)
delegate,
+ launch_elevated,
#elif defined(OS_ANDROID)
ipcfd,
#elif defined(OS_POSIX)
@@ -107,6 +111,7 @@ class ChildProcessLauncher::Context
environ,
ipcfd,
#endif
+
jam 2014/01/30 21:41:03 nit: drop the empty line
Drew Haven 2014/01/31 20:00:12 Done.
cmd_line));
}
@@ -183,6 +188,7 @@ class ChildProcessLauncher::Context
int child_process_id,
#if defined(OS_WIN)
SandboxedProcessLauncherDelegate* delegate,
+ bool launch_elevated,
#elif defined(OS_ANDROID)
int ipcfd,
#elif defined(OS_POSIX)
@@ -195,19 +201,36 @@ class ChildProcessLauncher::Context
base::TimeTicks begin_launch_time = base::TimeTicks::Now();
#if defined(OS_WIN)
- scoped_ptr<SandboxedProcessLauncherDelegate> delegate_deleter(delegate);
- base::ProcessHandle handle = StartSandboxedProcess(delegate, cmd_line);
-#elif defined(OS_ANDROID)
- // Android WebView runs in single process, ensure that we never get here
- // when running in single process mode.
- CHECK(!cmd_line->HasSwitch(switches::kSingleProcess));
-
+ base::ProcessHandle handle = base::kNullProcessHandle;
+ if (launch_elevated) {
+ base::LaunchOptions options;
+ options.start_hidden = true;
+ base::LaunchElevatedProcess(*cmd_line, options, &handle);
+ } else {
+ scoped_ptr<SandboxedProcessLauncherDelegate> delegate_deleter(delegate);
+ handle = StartSandboxedProcess(delegate, cmd_line);
+ }
+#elif defined(OS_POSIX)
std::string process_type =
cmd_line->GetSwitchValueASCII(switches::kProcessType);
std::vector<FileDescriptorInfo> files_to_register;
files_to_register.push_back(
FileDescriptorInfo(kPrimaryIPCChannel,
- base::FileDescriptor(ipcfd, false)));
+ base::FileDescriptor(ipcfd, false)));
+ base::StatsTable* stats_table = base::StatsTable::current();
jam 2014/01/30 21:41:03 this, and some of the other changes in this file a
Drew Haven 2014/01/31 20:00:12 Done.
+ if (stats_table &&
+ base::SharedMemory::IsHandleValid(
+ stats_table->GetSharedMemoryHandle())) {
+ files_to_register.push_back(
+ FileDescriptorInfo(kStatsTableSharedMemFd,
+ stats_table->GetSharedMemoryHandle()));
+ }
+#endif
+
+#if defined(OS_ANDROID)
+ // Android WebView runs in single process, ensure that we never get here
+ // when running in single process mode.
+ CHECK(!cmd_line->HasSwitch(switches::kSingleProcess));
GetContentClient()->browser()->
GetAdditionalMappedFilesForChildProcess(*cmd_line, child_process_id,
@@ -223,13 +246,6 @@ class ChildProcessLauncher::Context
// child termination.
file_util::ScopedFD ipcfd_closer(&ipcfd);
- std::string process_type =
- cmd_line->GetSwitchValueASCII(switches::kProcessType);
- std::vector<FileDescriptorInfo> files_to_register;
- files_to_register.push_back(
- FileDescriptorInfo(kPrimaryIPCChannel,
- base::FileDescriptor(ipcfd, false)));
-
#if !defined(OS_MACOSX)
GetContentClient()->browser()->
GetAdditionalMappedFilesForChildProcess(*cmd_line, child_process_id,
@@ -330,7 +346,11 @@ class ChildProcessLauncher::Context
zygote_ = zygote;
#endif
if (client_) {
- client_->OnProcessLaunched();
+ if (handle) {
+ client_->OnProcessLaunched();
+ } else {
+ client_->OnProcessLaunchFailed();
+ }
} else {
Terminate();
}
@@ -368,7 +388,7 @@ class ChildProcessLauncher::Context
#endif
base::ProcessHandle handle) {
#if defined(OS_ANDROID)
- LOG(INFO) << "ChromeProcess: Stopping process with handle " << handle;
+ VLOG(0) << "ChromeProcess: Stopping process with handle " << handle;
StopChildProcess(handle);
#else
base::Process process(handle);
@@ -413,6 +433,7 @@ class ChildProcessLauncher::Context
ChildProcessLauncher::ChildProcessLauncher(
#if defined(OS_WIN)
SandboxedProcessLauncherDelegate* delegate,
+ bool launch_elevated,
#elif defined(OS_POSIX)
bool use_zygote,
const base::EnvironmentMap& environ,
@@ -425,6 +446,7 @@ ChildProcessLauncher::ChildProcessLauncher(
context_->Launch(
#if defined(OS_WIN)
delegate,
+ launch_elevated,
#elif defined(OS_ANDROID)
ipcfd,
#elif defined(OS_POSIX)
@@ -464,14 +486,22 @@ base::TerminationStatus ChildProcessLauncher::GetChildTerminationStatus(
if (context_->zygote_) {
context_->termination_status_ = ZygoteHostImpl::GetInstance()->
GetTerminationStatus(handle, known_dead, &context_->exit_code_);
- } else
+ } else if (known_dead) {
+ context_->termination_status_ =
+ base::GetKnownDeadTerminationStatus(handle, &context_->exit_code_);
+ } else {
#elif defined(OS_MACOSX)
if (known_dead) {
context_->termination_status_ =
base::GetKnownDeadTerminationStatus(handle, &context_->exit_code_);
- } else
-#endif
+ } else {
+#elif defined(OS_ANDROID)
+ if (IsChildProcessOomProtected(handle)) {
+ context_->termination_status_ = base::TERMINATION_STATUS_OOM_PROTECTED;
+ } else {
+#else
{
+#endif
context_->termination_status_ =
base::GetTerminationStatus(handle, &context_->exit_code_);
}

Powered by Google App Engine
This is Rietveld 408576698