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

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

Issue 236813002: Move Mojo channel initialization closer to IPC::Channel setup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixup Created 6 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
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 a1fb9f888cb71d3ae2f3d4634843fc2a2ac517bf..aa3a391d4af3b330a9079aa756d0dac115b3685b 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -65,6 +65,7 @@
#include "content/browser/media/media_internals.h"
#include "content/browser/message_port_message_filter.h"
#include "content/browser/mime_registry_message_filter.h"
+#include "content/browser/mojo/mojo_application_host.h"
#include "content/browser/plugin_service_impl.h"
#include "content/browser/profiler_message_filter.h"
#include "content/browser/push_messaging_message_filter.h"
@@ -87,7 +88,6 @@
#include "content/browser/renderer_host/pepper/pepper_message_filter.h"
#include "content/browser/renderer_host/pepper/pepper_renderer_connection.h"
#include "content/browser/renderer_host/render_message_filter.h"
-#include "content/browser/renderer_host/render_process_host_mojo_impl.h"
#include "content/browser/renderer_host/render_view_host_delegate.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/browser/renderer_host/render_widget_helper.h"
@@ -113,6 +113,7 @@
#include "content/common/child_process_messages.h"
#include "content/common/content_switches_internal.h"
#include "content/common/gpu/gpu_messages.h"
+#include "content/common/mojo/mojo_messages.h"
#include "content/common/resource_messages.h"
#include "content/common/view_messages.h"
#include "content/port/browser/render_widget_host_view_frame_subscriber.h"
@@ -138,6 +139,8 @@
#include "ipc/ipc_logging.h"
#include "ipc/ipc_switches.h"
#include "media/base/media_switches.h"
+#include "mojo/embedder/platform_channel_pair.h"
+#include "mojo/public/cpp/bindings/allocation_scope.h"
#include "net/url_request/url_request_context_getter.h"
#include "ppapi/shared_impl/ppapi_switches.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -548,6 +551,7 @@ bool RenderProcessHostImpl::Init() {
this,
BrowserThread::GetMessageLoopProxyForThread(
BrowserThread::IO).get()));
+ InitializeMojo();
sky 2014/04/16 17:18:10 We don't need to wait for process to launch?
darin (slow to review) 2014/04/16 23:26:04 No, we don't. This is all just setting up the chan
// Call the embedder first so that their IPC filters have priority.
GetContentClient()->browser()->RenderProcessWillLaunch(this);
@@ -608,6 +612,19 @@ bool RenderProcessHostImpl::Init() {
return true;
}
+void RenderProcessHostImpl::InitializeMojo() {
+ mojo_application_host_.reset(new MojoApplicationHost());
+ mojo_application_host_->Init();
+
+ mojo::InterfacePipe<IRenderProcess, mojo::AnyInterface> pipe;
+ render_process_.reset(pipe.handle_to_self.Pass(), this);
+
+ // TODO(darin): Figure out what URL to use for the RenderProcess service.
+ mojo::AllocationScope scope;
+ mojo_application_host_->shell_client()->AcceptConnection(
+ "content:render_process", pipe.handle_to_peer.Pass());
+}
+
void RenderProcessHostImpl::CreateMessageFilters() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
AddFilter(new ResourceSchedulerFilter(GetID()));
@@ -1917,7 +1934,8 @@ void RenderProcessHostImpl::ProcessDied(bool already_dead) {
ClearTransportDIBCache();
- render_process_host_mojo_.reset();
+ render_process_.reset();
+ mojo_application_host_.reset();
// It's possible that one of the calls out to the observers might have caused
// this object to be no longer needed.
@@ -2052,6 +2070,10 @@ void RenderProcessHostImpl::OnProcessLaunched() {
Source<RenderProcessHost>(this),
NotificationService::NoDetails());
+ // Let the Mojo system get setup on the child process side before any other
+ // IPCs arrive. This way those may safely generate Mojo-related RPCs.
+ mojo_application_host_->Activate(this, GetHandle());
+
while (!queued_messages_.empty()) {
Send(queued_messages_.front());
queued_messages_.pop();
@@ -2061,9 +2083,6 @@ void RenderProcessHostImpl::OnProcessLaunched() {
if (WebRTCInternals::GetInstance()->aec_dump_enabled())
EnableAecDump(WebRTCInternals::GetInstance()->aec_dump_file_path());
#endif
-
- if (render_process_host_mojo_.get())
- render_process_host_mojo_->OnProcessLaunched();
}
scoped_refptr<AudioRendererHost>
@@ -2140,9 +2159,8 @@ void RenderProcessHostImpl::DecrementWorkerRefCount() {
void RenderProcessHostImpl::SetWebUIHandle(
int32 view_routing_id,
mojo::ScopedMessagePipeHandle handle) {
- if (!render_process_host_mojo_)
- render_process_host_mojo_.reset(new RenderProcessHostMojoImpl(this));
- render_process_host_mojo_->SetWebUIHandle(view_routing_id, handle.Pass());
+ DCHECK(!render_process_.is_null());
+ render_process_->SetWebUIHandle(view_routing_id, handle.Pass());
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698