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

Unified Diff: content/browser/utility_process_host_impl.cc

Issue 1877743002: Use token-based initialisation for the utility process MojoApplication. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Always use token init. Created 4 years, 8 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
« no previous file with comments | « content/browser/utility_process_host_impl.h ('k') | content/child/child_thread_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7e275aca9a37e2a78a16f265717c48d6b92b25cc..d59249619b34299e4a5e148e28a8cbe4174a5835 100644
--- a/content/browser/utility_process_host_impl.cc
+++ b/content/browser/utility_process_host_impl.cc
@@ -31,6 +31,7 @@
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/utility_process_host_client.h"
#include "content/public/common/content_switches.h"
+#include "content/public/common/mojo_channel_switches.h"
#include "content/public/common/process_type.h"
#include "content/public/common/sandbox_type.h"
#include "content/public/common/sandboxed_process_launcher_delegate.h"
@@ -247,12 +248,6 @@ bool UtilityProcessHostImpl::StartProcess() {
if (is_batch_mode_)
return true;
- bool mojo_result = mojo_application_host_->Init();
- if (!mojo_result) {
- NotifyAndDelete();
- return false;
- }
-
// Name must be set or metrics_service will crash in any test which
// launches a UtilityProcessHost.
process_.reset(new BrowserChildProcessHostImpl(PROCESS_TYPE_UTILITY, this));
@@ -264,6 +259,8 @@ bool UtilityProcessHostImpl::StartProcess() {
return false;
}
+ std::string mojo_token = mojo_application_host_->InitWithToken();
+
if (RenderProcessHost::run_renderer_in_process()) {
DCHECK(g_utility_main_thread_factory);
// See comment in RenderProcessHostImpl::Init() for the background on why we
@@ -271,9 +268,9 @@ bool UtilityProcessHostImpl::StartProcess() {
in_process_thread_.reset(
g_utility_main_thread_factory(InProcessChildThreadParams(
channel_id, BrowserThread::UnsafeGetMessageLoopForThread(
- BrowserThread::IO)->task_runner())));
+ BrowserThread::IO)->task_runner(),
+ mojo::MessagePipeHandle(), mojo_token)));
in_process_thread_->Start();
- OnProcessLaunched();
} else {
const base::CommandLine& browser_command_line =
*base::CommandLine::ForCurrentProcess();
@@ -350,6 +347,9 @@ bool UtilityProcessHostImpl::StartProcess() {
cmd_line->AppendSwitch(switches::kUtilityProcessRunningElevated);
#endif
+ cmd_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken,
+ mojo_token);
+
process_->Launch(
new UtilitySandboxedProcessLauncherDelegate(exposed_dir_,
run_elevated_,
@@ -396,17 +396,6 @@ void UtilityProcessHostImpl::OnProcessCrashed(int exit_code) {
exit_code));
}
-void UtilityProcessHostImpl::OnProcessLaunched() {
- DCHECK(mojo_application_host_);
- base::ProcessHandle handle;
- if (RenderProcessHost::run_renderer_in_process())
- handle = base::GetCurrentProcessHandle();
- else
- handle = process_->GetData().handle;
-
- mojo_application_host_->Activate(this, handle);
-}
-
void UtilityProcessHostImpl::NotifyAndDelete() {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
« no previous file with comments | « content/browser/utility_process_host_impl.h ('k') | content/child/child_thread_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698