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

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

Issue 253843005: Fix mojo startup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: re-enable tests on windows 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 5ce5e599bde2418bc37fd530267810ddcb7cc4df..32246aed47381fb3799b434162a8c70e8c9ccdca 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -395,6 +395,7 @@ RenderProcessHostImpl::RenderProcessHostImpl(
is_self_deleted_(false),
#endif
pending_views_(0),
+ mojo_activation_required_(false),
visible_widgets_(0),
backgrounded_(true),
is_initialized_(false),
@@ -604,6 +605,20 @@ bool RenderProcessHostImpl::Init() {
return true;
}
+void RenderProcessHostImpl::MaybeActivateMojo() {
+ // TODO(darin): Following security review, we can unconditionally initialize
+ // Mojo in all renderers. We will then be able to directly call Activate()
+ // from OnProcessLaunched.
+ if (!mojo_activation_required_)
+ return; // Waiting on someone to require Mojo.
+
+ if (!GetHandle())
+ return; // Waiting on renderer startup.
+
+ if (!mojo_application_host_->did_activate())
+ mojo_application_host_->Activate(this, GetHandle());
+}
+
void RenderProcessHostImpl::CreateMessageFilters() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
AddFilter(new ResourceSchedulerFilter(GetID()));
@@ -1972,13 +1987,10 @@ 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
+ // Allow Mojo to be setup before the renderer sees any Chrome IPC messages.
+ // This way, Mojo can be safely used from the renderer in response to any
+ // Chrome IPC message.
+ MaybeActivateMojo();
while (!queued_messages_.empty()) {
Send(queued_messages_.front());
@@ -2065,8 +2077,8 @@ void RenderProcessHostImpl::DecrementWorkerRefCount() {
void RenderProcessHostImpl::ConnectTo(
const base::StringPiece& service_name,
mojo::ScopedMessagePipeHandle handle) {
- if (!mojo_application_host_->did_activate())
- mojo_application_host_->Activate(this, GetHandle());
+ mojo_activation_required_ = true;
+ MaybeActivateMojo();
mojo::AllocationScope scope;
mojo_application_host_->shell_client()->AcceptConnection(service_name,
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.h ('k') | content/browser/webui/web_ui_mojo_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698