| Index: content/browser/utility_process_host_impl.cc
|
| diff --git a/content/browser/utility_process_host_impl.cc b/content/browser/utility_process_host_impl.cc
|
| index 15443ff230cd386f84913c03300ed6ac9a1c1043..3d74b30f381b588d625f55c2db59de4144cc457e 100644
|
| --- a/content/browser/utility_process_host_impl.cc
|
| +++ b/content/browser/utility_process_host_impl.cc
|
| @@ -17,6 +17,7 @@
|
| #include "base/process/process_handle.h"
|
| #include "base/run_loop.h"
|
| #include "base/sequenced_task_runner.h"
|
| +#include "base/strings/stringprintf.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "base/synchronization/lock.h"
|
| #include "base/synchronization/waitable_event.h"
|
| @@ -164,9 +165,15 @@
|
| #endif
|
| started_(false),
|
| name_(base::ASCIIToUTF16("utility process")),
|
| + child_token_(mojo::edk::GenerateRandomToken()),
|
| weak_ptr_factory_(this) {
|
| - process_.reset(new BrowserChildProcessHostImpl(
|
| - PROCESS_TYPE_UTILITY, this, kUtilityMojoApplicationName));
|
| + process_.reset(new BrowserChildProcessHostImpl(PROCESS_TYPE_UTILITY, this,
|
| + child_token_));
|
| + mojo_child_connection_.reset(new MojoChildConnection(
|
| + kUtilityMojoApplicationName,
|
| + base::StringPrintf("%d_0", process_->GetData().id), child_token_,
|
| + MojoShellContext::GetConnectorForIOThread(),
|
| + BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)));
|
| }
|
|
|
| UtilityProcessHostImpl::~UtilityProcessHostImpl() {
|
| @@ -231,7 +238,7 @@
|
| }
|
|
|
| shell::InterfaceProvider* UtilityProcessHostImpl::GetRemoteInterfaces() {
|
| - return process_->child_connection()->GetRemoteInterfaces();
|
| + return mojo_child_connection_->GetRemoteInterfaces();
|
| }
|
|
|
| void UtilityProcessHostImpl::SetName(const base::string16& name) {
|
| @@ -255,7 +262,13 @@
|
| return true;
|
|
|
| process_->SetName(name_);
|
| - process_->GetHost()->CreateChannelMojo();
|
| +
|
| + std::string mojo_channel_token =
|
| + process_->GetHost()->CreateChannelMojo(child_token_);
|
| + if (mojo_channel_token.empty()) {
|
| + NotifyAndDelete(LAUNCH_RESULT_FAILURE);
|
| + return false;
|
| + }
|
|
|
| if (RenderProcessHost::run_renderer_in_process()) {
|
| DCHECK(g_utility_main_thread_factory);
|
| @@ -265,8 +278,7 @@
|
| g_utility_main_thread_factory(InProcessChildThreadParams(
|
| std::string(), BrowserThread::UnsafeGetMessageLoopForThread(
|
| BrowserThread::IO)->task_runner(),
|
| - std::string(),
|
| - process_->child_connection()->service_token())));
|
| + mojo_channel_token, mojo_child_connection_->service_token())));
|
| in_process_thread_->Start();
|
| } else {
|
| const base::CommandLine& browser_command_line =
|
| @@ -303,6 +315,8 @@
|
|
|
| cmd_line->AppendSwitchASCII(switches::kProcessType,
|
| switches::kUtilityProcess);
|
| + cmd_line->AppendSwitchASCII(switches::kMojoChannelToken,
|
| + mojo_channel_token);
|
| std::string locale = GetContentClient()->browser()->GetApplicationLocale();
|
| cmd_line->AppendSwitchASCII(switches::kLang, locale);
|
|
|
| @@ -342,6 +356,9 @@
|
| cmd_line->AppendSwitch(switches::kUtilityProcessRunningElevated);
|
| #endif
|
|
|
| + cmd_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken,
|
| + mojo_child_connection_->service_token());
|
| +
|
| process_->Launch(
|
| new UtilitySandboxedProcessLauncherDelegate(exposed_dir_,
|
| run_elevated_,
|
|
|