Commit 60fbfeb6 authored by darin@chromium.org's avatar darin@chromium.org

Fix mojo startup

Defer until both OnProcessLaunched and ConnectTo have been called.

BUG=366644

Review URL: https://codereview.chromium.org/253843005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@267104 0039d316-1c4b-4281-b951-d872f2087c98
parent 01a891d7
...@@ -395,6 +395,7 @@ RenderProcessHostImpl::RenderProcessHostImpl( ...@@ -395,6 +395,7 @@ RenderProcessHostImpl::RenderProcessHostImpl(
is_self_deleted_(false), is_self_deleted_(false),
#endif #endif
pending_views_(0), pending_views_(0),
mojo_activation_required_(false),
visible_widgets_(0), visible_widgets_(0),
backgrounded_(true), backgrounded_(true),
is_initialized_(false), is_initialized_(false),
...@@ -604,6 +605,20 @@ bool RenderProcessHostImpl::Init() { ...@@ -604,6 +605,20 @@ bool RenderProcessHostImpl::Init() {
return true; 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() { void RenderProcessHostImpl::CreateMessageFilters() {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
AddFilter(new ResourceSchedulerFilter(GetID())); AddFilter(new ResourceSchedulerFilter(GetID()));
...@@ -1971,13 +1986,10 @@ void RenderProcessHostImpl::OnProcessLaunched() { ...@@ -1971,13 +1986,10 @@ void RenderProcessHostImpl::OnProcessLaunched() {
Source<RenderProcessHost>(this), Source<RenderProcessHost>(this),
NotificationService::NoDetails()); NotificationService::NoDetails());
// TODO(darin): This is blocked on security review. Un-commenting this will // Allow Mojo to be setup before the renderer sees any Chrome IPC messages.
// allow Mojo calls from all renderers. // This way, Mojo can be safely used from the renderer in response to any
#if 0 // Chrome IPC message.
// Let the Mojo system get setup on the child process side before any other MaybeActivateMojo();
// IPCs arrive. This way those may safely generate Mojo-related RPCs.
mojo_application_host_->Activate(this, GetHandle());
#endif
while (!queued_messages_.empty()) { while (!queued_messages_.empty()) {
Send(queued_messages_.front()); Send(queued_messages_.front());
...@@ -2064,8 +2076,8 @@ void RenderProcessHostImpl::DecrementWorkerRefCount() { ...@@ -2064,8 +2076,8 @@ void RenderProcessHostImpl::DecrementWorkerRefCount() {
void RenderProcessHostImpl::ConnectTo( void RenderProcessHostImpl::ConnectTo(
const base::StringPiece& service_name, const base::StringPiece& service_name,
mojo::ScopedMessagePipeHandle handle) { mojo::ScopedMessagePipeHandle handle) {
if (!mojo_application_host_->did_activate()) mojo_activation_required_ = true;
mojo_application_host_->Activate(this, GetHandle()); MaybeActivateMojo();
mojo::AllocationScope scope; mojo::AllocationScope scope;
mojo_application_host_->shell_client()->AcceptConnection(service_name, mojo_application_host_->shell_client()->AcceptConnection(service_name,
......
...@@ -269,6 +269,8 @@ class CONTENT_EXPORT RenderProcessHostImpl ...@@ -269,6 +269,8 @@ class CONTENT_EXPORT RenderProcessHostImpl
private: private:
friend class VisitRelayingRenderProcessHost; friend class VisitRelayingRenderProcessHost;
void MaybeActivateMojo();
// Creates and adds the IO thread message filters. // Creates and adds the IO thread message filters.
void CreateMessageFilters(); void CreateMessageFilters();
...@@ -309,6 +311,7 @@ class CONTENT_EXPORT RenderProcessHostImpl ...@@ -309,6 +311,7 @@ class CONTENT_EXPORT RenderProcessHostImpl
#endif #endif
scoped_ptr<MojoApplicationHost> mojo_application_host_; scoped_ptr<MojoApplicationHost> mojo_application_host_;
bool mojo_activation_required_;
// The registered IPC listener objects. When this list is empty, we should // The registered IPC listener objects. When this list is empty, we should
// delete ourselves. // delete ourselves.
......
...@@ -315,18 +315,9 @@ class WebUIMojoTest : public ContentBrowserTest { ...@@ -315,18 +315,9 @@ class WebUIMojoTest : public ContentBrowserTest {
DISALLOW_COPY_AND_ASSIGN(WebUIMojoTest); DISALLOW_COPY_AND_ASSIGN(WebUIMojoTest);
}; };
// Temporarily disabled due to flakiness on Windows. http://crbug.com/366644
#if defined(OS_WIN)
#define MAYBE_EndToEndPing DISABLED_EndToEndPing
#define MAYBE_EndToEndEcho DISABLED_EndToEndEcho
#else
#define MAYBE_EndToEndPing EndToEndPing
#define MAYBE_EndToEndEcho EndToEndEcho
#endif
// Loads a webui page that contains mojo bindings and verifies a message makes // Loads a webui page that contains mojo bindings and verifies a message makes
// it from the browser to the page and back. // it from the browser to the page and back.
IN_PROC_BROWSER_TEST_F(WebUIMojoTest, MAYBE_EndToEndPing) { IN_PROC_BROWSER_TEST_F(WebUIMojoTest, EndToEndPing) {
// Currently there is no way to have a generated file included in the isolate // Currently there is no way to have a generated file included in the isolate
// files. If the bindings file doesn't exist assume we're on such a bot and // files. If the bindings file doesn't exist assume we're on such a bot and
// pass. // pass.
...@@ -352,7 +343,7 @@ IN_PROC_BROWSER_TEST_F(WebUIMojoTest, MAYBE_EndToEndPing) { ...@@ -352,7 +343,7 @@ IN_PROC_BROWSER_TEST_F(WebUIMojoTest, MAYBE_EndToEndPing) {
// Loads a webui page that contains mojo bindings and verifies that // Loads a webui page that contains mojo bindings and verifies that
// parameters are passed back correctly from JavaScript. // parameters are passed back correctly from JavaScript.
IN_PROC_BROWSER_TEST_F(WebUIMojoTest, MAYBE_EndToEndEcho) { IN_PROC_BROWSER_TEST_F(WebUIMojoTest, EndToEndEcho) {
// Currently there is no way to have a generated file included in the isolate // Currently there is no way to have a generated file included in the isolate
// files. If the bindings file doesn't exist assume we're on such a bot and // files. If the bindings file doesn't exist assume we're on such a bot and
// pass. // pass.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment