| Index: content/browser/child_process_launcher.cc
|
| diff --git a/content/browser/child_process_launcher.cc b/content/browser/child_process_launcher.cc
|
| index e497762aff8ebbd651e8467c6c0409ff7c8f8fe2..90b24253a2950a0a5745ee95d31dd7647c72aff4 100644
|
| --- a/content/browser/child_process_launcher.cc
|
| +++ b/content/browser/child_process_launcher.cc
|
| @@ -43,11 +43,46 @@
|
|
|
| namespace content {
|
|
|
| +ChildProcessLauncher::~ChildProcessLauncher() {}
|
| +
|
| +class ChildProcessLauncherImpl : public ChildProcessLauncher {
|
| + public:
|
| + ChildProcessLauncherImpl(
|
| +#if defined(OS_WIN)
|
| + SandboxedProcessLauncherDelegate* delegate,
|
| +#elif defined(OS_POSIX)
|
| + bool use_zygote,
|
| + const base::EnvironmentVector& environ,
|
| + int ipcfd,
|
| +#endif
|
| + CommandLine* cmd_line,
|
| + int child_process_id,
|
| + Client* client);
|
| +
|
| + virtual ~ChildProcessLauncherImpl();
|
| +
|
| + // ChildProcessLauncher implementation
|
| + virtual bool IsStarting() OVERRIDE;
|
| + virtual base::ProcessHandle GetHandle() OVERRIDE;
|
| + virtual base::TerminationStatus GetChildTerminationStatus(bool known_dead,
|
| + int* exit_code)
|
| + OVERRIDE;
|
| + virtual void SetProcessBackgrounded(bool background) OVERRIDE;
|
| + virtual void SetTerminateChildOnShutdown(bool terminate_on_shutdown) OVERRIDE;
|
| +
|
| + private:
|
| + class Context;
|
| +
|
| + scoped_refptr<Context> context_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ChildProcessLauncherImpl);
|
| +};
|
| +
|
| // Having the functionality of ChildProcessLauncher be in an internal
|
| // ref counted object allows us to automatically terminate the process when the
|
| // parent class destructs, while still holding on to state that we need.
|
| -class ChildProcessLauncher::Context
|
| - : public base::RefCountedThreadSafe<ChildProcessLauncher::Context> {
|
| +class ChildProcessLauncherImpl::Context
|
| + : public base::RefCountedThreadSafe<ChildProcessLauncherImpl::Context> {
|
| public:
|
| Context()
|
| : client_(NULL),
|
| @@ -124,10 +159,7 @@ class ChildProcessLauncher::Context
|
| } else {
|
| BrowserThread::PostTask(
|
| client_thread_id, FROM_HERE,
|
| - base::Bind(
|
| - &ChildProcessLauncher::Context::Notify,
|
| - this_object,
|
| - handle));
|
| + base::Bind(&Context::Notify, this_object, handle));
|
| }
|
| }
|
| #endif
|
| @@ -144,8 +176,8 @@ class ChildProcessLauncher::Context
|
| }
|
|
|
| private:
|
| - friend class base::RefCountedThreadSafe<ChildProcessLauncher::Context>;
|
| - friend class ChildProcessLauncher;
|
| + friend class base::RefCountedThreadSafe<Context>;
|
| + friend class ChildProcessLauncherImpl;
|
|
|
| ~Context() {
|
| Terminate();
|
| @@ -158,7 +190,7 @@ class ChildProcessLauncher::Context
|
| } else {
|
| BrowserThread::PostTask(
|
| BrowserThread::PROCESS_LAUNCHER, FROM_HERE,
|
| - base::Bind(&ChildProcessLauncher::Context::RecordLaunchHistograms,
|
| + base::Bind(&Context::RecordLaunchHistograms,
|
| launch_time));
|
| }
|
| }
|
| @@ -213,7 +245,7 @@ class ChildProcessLauncher::Context
|
| &files_to_register);
|
|
|
| StartChildProcess(cmd_line->argv(), files_to_register,
|
| - base::Bind(&ChildProcessLauncher::Context::OnChildProcessStarted,
|
| + base::Bind(&Context::OnChildProcessStarted,
|
| this_object, client_thread_id, begin_launch_time));
|
|
|
| #elif defined(OS_POSIX)
|
| @@ -409,7 +441,7 @@ class ChildProcessLauncher::Context
|
| };
|
|
|
|
|
| -ChildProcessLauncher::ChildProcessLauncher(
|
| +ChildProcessLauncherImpl::ChildProcessLauncherImpl(
|
| #if defined(OS_WIN)
|
| SandboxedProcessLauncherDelegate* delegate,
|
| #elif defined(OS_POSIX)
|
| @@ -436,20 +468,20 @@ ChildProcessLauncher::ChildProcessLauncher(
|
| client);
|
| }
|
|
|
| -ChildProcessLauncher::~ChildProcessLauncher() {
|
| +ChildProcessLauncherImpl::~ChildProcessLauncherImpl() {
|
| context_->ResetClient();
|
| }
|
|
|
| -bool ChildProcessLauncher::IsStarting() {
|
| +bool ChildProcessLauncherImpl::IsStarting() {
|
| return context_->starting_;
|
| }
|
|
|
| -base::ProcessHandle ChildProcessLauncher::GetHandle() {
|
| +base::ProcessHandle ChildProcessLauncherImpl::GetHandle() {
|
| DCHECK(!context_->starting_);
|
| return context_->process_.handle();
|
| }
|
|
|
| -base::TerminationStatus ChildProcessLauncher::GetChildTerminationStatus(
|
| +base::TerminationStatus ChildProcessLauncherImpl::GetChildTerminationStatus(
|
| bool known_dead,
|
| int* exit_code) {
|
| base::ProcessHandle handle = context_->process_.handle();
|
| @@ -485,18 +517,40 @@ base::TerminationStatus ChildProcessLauncher::GetChildTerminationStatus(
|
| return context_->termination_status_;
|
| }
|
|
|
| -void ChildProcessLauncher::SetProcessBackgrounded(bool background) {
|
| +void ChildProcessLauncherImpl::SetProcessBackgrounded(bool background) {
|
| BrowserThread::PostTask(
|
| BrowserThread::PROCESS_LAUNCHER, FROM_HERE,
|
| - base::Bind(
|
| - &ChildProcessLauncher::Context::SetProcessBackgrounded,
|
| - GetHandle(), background));
|
| + base::Bind(&Context::SetProcessBackgrounded, GetHandle(), background));
|
| }
|
|
|
| -void ChildProcessLauncher::SetTerminateChildOnShutdown(
|
| +void ChildProcessLauncherImpl::SetTerminateChildOnShutdown(
|
| bool terminate_on_shutdown) {
|
| if (context_.get())
|
| context_->set_terminate_child_on_shutdown(terminate_on_shutdown);
|
| }
|
|
|
| +scoped_ptr<ChildProcessLauncher> NewChildProcessLauncher(
|
| +#if defined(OS_WIN)
|
| + SandboxedProcessLauncherDelegate* delegate,
|
| +#elif defined(OS_POSIX)
|
| + bool use_zygote,
|
| + const base::EnvironmentVector& environ,
|
| + int ipcfd,
|
| +#endif
|
| + CommandLine* cmd_line,
|
| + int child_process_id,
|
| + ChildProcessLauncher::Client* client) {
|
| + return scoped_ptr<ChildProcessLauncher>(new ChildProcessLauncherImpl(
|
| +#if defined(OS_WIN)
|
| + delegate,
|
| +#elif defined(OS_POSIX)
|
| + use_zygote,
|
| + environ,
|
| + ipcfd,
|
| +#endif
|
| + cmd_line,
|
| + child_process_id,
|
| + client));
|
| +}
|
| +
|
| } // namespace content
|
|
|