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

Unified Diff: content/browser/renderer_host/render_process_host_impl.cc

Issue 2680973006: Mojo EDK: Add safe process connection API (Closed)
Patch Set: Created 3 years, 10 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
Index: content/browser/renderer_host/render_process_host_impl.cc
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index 79eeee2ffcf4a1e6665a8871fc4bfd83e2e16baa..09091528fe014fc03ebcdf5dc99f254035818e41 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -831,6 +831,7 @@ bool RenderProcessHostImpl::Init() {
// null, so we re-initialize it here.
if (!channel_)
InitializeChannelProxy();
+ DCHECK(pending_connection_);
// Unpause the Channel briefly. This will be paused again below if we launch a
// real child process. Note that messages may be sent in the short window
@@ -911,7 +912,7 @@ bool RenderProcessHostImpl::Init() {
// at this stage.
child_process_launcher_.reset(new ChildProcessLauncher(
base::MakeUnique<RendererSandboxedProcessLauncherDelegate>(),
- std::move(cmd_line), GetID(), this, child_token_,
+ std::move(cmd_line), GetID(), this, std::move(pending_connection_),
base::Bind(&RenderProcessHostImpl::OnMojoError, id_)));
channel_->Pause();
@@ -934,9 +935,6 @@ void RenderProcessHostImpl::EnableSendQueue() {
}
void RenderProcessHostImpl::InitializeChannelProxy() {
- // Generate a token used to identify the new child process.
- child_token_ = mojo::edk::GenerateRandomToken();
-
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner =
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO);
@@ -961,10 +959,11 @@ void RenderProcessHostImpl::InitializeChannelProxy() {
}
// Establish a ServiceManager connection for the new render service instance.
- child_connection_.reset(new ChildConnection(
- mojom::kRendererServiceName,
- base::StringPrintf("%d_%d", id_, instance_id_++), child_token_, connector,
- io_task_runner));
+ pending_connection_.reset(new mojo::edk::PendingProcessConnection);
+ child_connection_.reset(
+ new ChildConnection(mojom::kRendererServiceName,
+ base::StringPrintf("%d_%d", id_, instance_id_++),
+ *pending_connection_, connector, io_task_runner));
// Send an interface request to bootstrap the IPC::Channel. Note that this
// request will happily sit on the pipe until the process is launched and

Powered by Google App Engine
This is Rietveld 408576698