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

Unified Diff: content/browser/utility_process_host_impl.cc

Issue 2099423002: Convert UtilityProcess to use MojoChild/ShellConnection for the shell handshake. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gpu
Patch Set: . Created 4 years, 6 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/content.gyp » ('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 89e9c9f9e75640d18e40d4e80a36da12e8ad8123..4debf70b740f42076725968aad15831228f46120 100644
--- a/content/browser/utility_process_host_impl.cc
+++ b/content/browser/utility_process_host_impl.cc
@@ -17,12 +17,15 @@
#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"
#include "build/build_config.h"
#include "content/browser/browser_child_process_host_impl.h"
-#include "content/browser/mojo/mojo_application_host.h"
+#include "content/browser/mojo/constants.h"
+#include "content/browser/mojo/mojo_child_connection.h"
+#include "content/browser/mojo/mojo_shell_context.h"
#include "content/browser/renderer_host/render_process_host_impl.h"
#include "content/common/child_process_host_impl.h"
#include "content/common/in_process_child_thread_params.h"
@@ -32,11 +35,13 @@
#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/mojo_shell_connection.h"
#include "content/public/common/process_type.h"
#include "content/public/common/sandbox_type.h"
#include "content/public/common/sandboxed_process_launcher_delegate.h"
#include "ipc/ipc_switches.h"
#include "mojo/edk/embedder/embedder.h"
+#include "services/shell/public/cpp/connection.h"
#include "services/shell/public/cpp/interface_provider.h"
#include "services/shell/public/cpp/interface_registry.h"
#include "ui/base/ui_base_switches.h"
@@ -162,8 +167,14 @@ UtilityProcessHostImpl::UtilityProcessHostImpl(
started_(false),
name_(base::ASCIIToUTF16("utility process")),
child_token_(mojo::edk::GenerateRandomToken()),
- mojo_application_host_(new MojoApplicationHost(child_token_)),
weak_ptr_factory_(this) {
+ 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()));
}
UtilityProcessHostImpl::~UtilityProcessHostImpl() {
@@ -228,13 +239,11 @@ bool UtilityProcessHostImpl::Start() {
}
shell::InterfaceRegistry* UtilityProcessHostImpl::GetInterfaceRegistry() {
- DCHECK(mojo_application_host_);
- return mojo_application_host_->interface_registry();
+ return mojo_child_connection_->connection()->GetInterfaceRegistry();
}
shell::InterfaceProvider* UtilityProcessHostImpl::GetRemoteInterfaces() {
- DCHECK(mojo_application_host_);
- return mojo_application_host_->remote_interfaces();
+ return mojo_child_connection_->connection()->GetRemoteInterfaces();
}
void UtilityProcessHostImpl::SetName(const base::string16& name) {
@@ -257,10 +266,6 @@ bool UtilityProcessHostImpl::StartProcess() {
if (is_batch_mode_)
return true;
- // Name must be set or metrics_service will crash in any test which
- // launches a UtilityProcessHost.
- process_.reset(new BrowserChildProcessHostImpl(PROCESS_TYPE_UTILITY, this,
- child_token_));
process_->SetName(name_);
std::string mojo_channel_token =
@@ -278,7 +283,7 @@ bool UtilityProcessHostImpl::StartProcess() {
g_utility_main_thread_factory(InProcessChildThreadParams(
std::string(), BrowserThread::UnsafeGetMessageLoopForThread(
BrowserThread::IO)->task_runner(),
- mojo_channel_token, mojo_application_host_->GetToken())));
+ mojo_channel_token, mojo_child_connection_->shell_client_token())));
in_process_thread_->Start();
} else {
const base::CommandLine& browser_command_line =
@@ -357,7 +362,7 @@ bool UtilityProcessHostImpl::StartProcess() {
#endif
cmd_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken,
- mojo_application_host_->GetToken());
+ mojo_child_connection_->shell_client_token());
process_->Launch(
new UtilitySandboxedProcessLauncherDelegate(exposed_dir_,
« no previous file with comments | « content/browser/utility_process_host_impl.h ('k') | content/content.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698