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(
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()));
......@@ -1971,13 +1986,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());
......@@ -2064,8 +2076,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,
......
......@@ -269,6 +269,8 @@ class CONTENT_EXPORT RenderProcessHostImpl
private:
friend class VisitRelayingRenderProcessHost;
void MaybeActivateMojo();
// Creates and adds the IO thread message filters.
void CreateMessageFilters();
......@@ -309,6 +311,7 @@ class CONTENT_EXPORT RenderProcessHostImpl
#endif
scoped_ptr<MojoApplicationHost> mojo_application_host_;
bool mojo_activation_required_;
// The registered IPC listener objects. When this list is empty, we should
// delete ourselves.
......
......@@ -315,18 +315,9 @@ class WebUIMojoTest : public ContentBrowserTest {
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
// 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
// files. If the bindings file doesn't exist assume we're on such a bot and
// pass.
......@@ -352,7 +343,7 @@ IN_PROC_BROWSER_TEST_F(WebUIMojoTest, MAYBE_EndToEndPing) {
// Loads a webui page that contains mojo bindings and verifies that
// 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
// files. If the bindings file doesn't exist assume we're on such a bot and
// 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