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

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: more missing deps 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 8a72016625c5d5818bb382913e4753f9b4b5c758..f9e92717138acb1f33327cf8910033771c580e35 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -64,6 +64,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"
@@ -86,7 +87,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"
@@ -112,6 +112,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"
@@ -137,6 +138,8 @@
#include "ipc/ipc_logging.h"
#include "ipc/ipc_switches.h"
#include "media/base/media_switches.h"
+#include "mojo/common/common_type_converters.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"
@@ -543,6 +546,10 @@ bool RenderProcessHostImpl::Init() {
BrowserThread::GetMessageLoopProxyForThread(
BrowserThread::IO).get()));
+ // Setup the Mojo channel.
+ mojo_application_host_.reset(new MojoApplicationHost());
+ mojo_application_host_->Init();
+
// Call the embedder first so that their IPC filters have priority.
GetContentClient()->browser()->RenderProcessWillLaunch(this);
@@ -1897,7 +1904,7 @@ void RenderProcessHostImpl::ProcessDied(bool already_dead) {
ClearTransportDIBCache();
- render_process_host_mojo_.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.
@@ -2032,6 +2039,14 @@ void RenderProcessHostImpl::OnProcessLaunched() {
Source<RenderProcessHost>(this),
NotificationService::NoDetails());
+ // TODO(darin): This is blocked on security review. Un-commenting this will
+ // allow Mojo calls from all renderers.
+#if 0
+ // 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());
+#endif
+
while (!queued_messages_.empty()) {
Send(queued_messages_.front());
queued_messages_.pop();
@@ -2041,9 +2056,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>
@@ -2117,12 +2129,15 @@ void RenderProcessHostImpl::DecrementWorkerRefCount() {
Cleanup();
}
-void RenderProcessHostImpl::SetWebUIHandle(
- int32 view_routing_id,
+void RenderProcessHostImpl::ConnectTo(
+ const base::StringPiece& service_name,
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());
+ if (!mojo_application_host_->did_activate())
+ mojo_application_host_->Activate(this, GetHandle());
+
+ mojo::AllocationScope scope;
+ mojo_application_host_->shell_client()->AcceptConnection(service_name,
+ handle.Pass());
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698