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

Unified Diff: content/browser/browser_child_process_host_impl.cc

Issue 2221153003: Establish MojoChildConnection from BrowserChildProcessHostImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@renderer-channel
Patch Set: rebase Created 4 years, 4 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/browser_child_process_host_impl.h ('k') | content/browser/gpu/gpu_process_host.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/browser_child_process_host_impl.cc
diff --git a/content/browser/browser_child_process_host_impl.cc b/content/browser/browser_child_process_host_impl.cc
index afc52015320fecafb9abc463abf4a979e56945f4..f276125e36013c3682259edae95bf33aa0d7a36d 100644
--- a/content/browser/browser_child_process_host_impl.cc
+++ b/content/browser/browser_child_process_host_impl.cc
@@ -17,6 +17,7 @@
#include "base/metrics/histogram.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h"
+#include "base/strings/stringprintf.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
@@ -24,6 +25,8 @@
#include "content/browser/histogram_message_filter.h"
#include "content/browser/loader/resource_message_filter.h"
#include "content/browser/memory/memory_message_filter.h"
+#include "content/browser/mojo/mojo_child_connection.h"
+#include "content/browser/mojo/mojo_shell_context.h"
#include "content/browser/profiler_message_filter.h"
#include "content/browser/tracing/trace_message_filter.h"
#include "content/common/child_process_host_impl.h"
@@ -34,6 +37,7 @@
#include "content/public/browser/child_process_data.h"
#include "content/public/browser/content_browser_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/result_codes.h"
#include "ipc/attachment_broker.h"
@@ -83,16 +87,14 @@ void NotifyProcessKilled(const ChildProcessData& data, int exit_code) {
BrowserChildProcessHost* BrowserChildProcessHost::Create(
content::ProcessType process_type,
BrowserChildProcessHostDelegate* delegate) {
- return new BrowserChildProcessHostImpl(
- process_type, delegate, mojo::edk::GenerateRandomToken());
+ return Create(process_type, delegate, std::string());
}
BrowserChildProcessHost* BrowserChildProcessHost::Create(
content::ProcessType process_type,
BrowserChildProcessHostDelegate* delegate,
- const std::string& mojo_child_token) {
- return new BrowserChildProcessHostImpl(
- process_type, delegate, mojo_child_token);
+ const std::string& service_name) {
+ return new BrowserChildProcessHostImpl(process_type, delegate, service_name);
}
BrowserChildProcessHost* BrowserChildProcessHost::FromID(int child_process_id) {
@@ -135,10 +137,10 @@ void BrowserChildProcessHostImpl::RemoveObserver(
BrowserChildProcessHostImpl::BrowserChildProcessHostImpl(
content::ProcessType process_type,
BrowserChildProcessHostDelegate* delegate,
- const std::string& mojo_child_token)
+ const std::string& service_name)
: data_(process_type),
delegate_(delegate),
- mojo_child_token_(mojo_child_token),
+ child_token_(mojo::edk::GenerateRandomToken()),
power_monitor_message_broadcaster_(this),
is_channel_connected_(false),
notify_child_disconnected_(false),
@@ -168,6 +170,14 @@ BrowserChildProcessHostImpl::BrowserChildProcessHostImpl(
GetContentClient()->browser()->BrowserChildProcessHostCreated(this);
power_monitor_message_broadcaster_.Init();
+
+ if (!service_name.empty()) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ child_connection_.reset(new MojoChildConnection(
+ service_name, base::StringPrintf("%d", data_.id), child_token_,
+ MojoShellContext::GetConnectorForIOThread(),
+ base::ThreadTaskRunnerHandle::Get()));
+ }
}
BrowserChildProcessHostImpl::~BrowserChildProcessHostImpl() {
@@ -236,13 +246,18 @@ void BrowserChildProcessHostImpl::Launch(
cmd_line->CopySwitchesFrom(browser_command_line, kForwardSwitches,
arraysize(kForwardSwitches));
+ if (child_connection_) {
+ cmd_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken,
+ child_connection_->service_token());
+ }
+
notify_child_disconnected_ = true;
child_process_.reset(new ChildProcessLauncher(
delegate,
cmd_line,
data_.id,
this,
- mojo_child_token_,
+ child_token_,
base::Bind(&BrowserChildProcessHostImpl::OnMojoError,
weak_factory_.GetWeakPtr(),
base::ThreadTaskRunnerHandle::Get()),
@@ -278,11 +293,6 @@ void BrowserChildProcessHostImpl::SetHandle(base::ProcessHandle handle) {
data_.handle = handle;
}
-shell::InterfaceProvider* BrowserChildProcessHostImpl::GetRemoteInterfaces() {
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
- return delegate_->GetRemoteInterfaces();
-}
-
void BrowserChildProcessHostImpl::ForceShutdown() {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
g_child_process_list.Get().remove(this);
@@ -297,6 +307,14 @@ void BrowserChildProcessHostImpl::AddFilter(BrowserMessageFilter* filter) {
child_process_host_->AddFilter(filter->GetFilter());
}
+shell::InterfaceProvider* BrowserChildProcessHostImpl::GetRemoteInterfaces() {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ if (!child_connection_)
+ return nullptr;
+
+ return child_connection_->GetRemoteInterfaces();
+}
+
void BrowserChildProcessHostImpl::HistogramBadMessageTerminated(
int process_type) {
UMA_HISTOGRAM_ENUMERATION("ChildProcess.BadMessgeTerminated", process_type,
« no previous file with comments | « content/browser/browser_child_process_host_impl.h ('k') | content/browser/gpu/gpu_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698