Commit 57e1d8ff authored by Dominic Farolino's avatar Dominic Farolino Committed by Commit Bot

AgentSchedulingGroupHost::SetUpMojo() is only called when set up is needed

Before crrev.com/c/2490442, we had SetUpMojoIfNeeded() calls in places
where it was ambiguous whether the AgentSchedulingGroupHost mojos needed
to be initialized or not.

After that CL, the lifetimes of the AgentSchedulingGroupHost mojos match
those of the RenderProcessHostImpl, and we removed some calls to
SetUpMojoIfNeeded(), and left the only callsites that were required to
actually setup mojo.

By way of a follow-up, this CL renames the method to SetUpMojo(), and
changes its implementation to assert that the AgentSchedulingGroupHost
mojos are unbound and need to be bound.

Bug: 1111231
Change-Id: I963fc51a99a665ed729abca6f023f33338d4e2c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2533161
Commit-Queue: Dominic Farolino <dom@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Reviewed-by: default avatarTal Pressman <talp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827332}
parent d2ed6c38
...@@ -124,13 +124,13 @@ AgentSchedulingGroupHost::AgentSchedulingGroupHost(RenderProcessHost& process, ...@@ -124,13 +124,13 @@ AgentSchedulingGroupHost::AgentSchedulingGroupHost(RenderProcessHost& process,
mojo_remote_(should_associate) { mojo_remote_(should_associate) {
process_.AddObserver(this); process_.AddObserver(this);
// The RenderProcessHost's channel and other mojo interfaces are initialized // The RenderProcessHost's channel and other mojo interfaces are bound by the
// by the time this class is constructed, so we eagerly initialize this // time this class is constructed, so we eagerly initialize this class's mojos
// class's mojos so they have the same bind lifetime as those of the // so they have the same bind lifetime as those of the RenderProcessHost.
// RenderProcessHost. Furthermore, when the RenderProcessHost's channel and // Furthermore, when the RenderProcessHost's channel and mojo interfaces get
// mojo interfaces get reset and reinitialized, we'll be notified so that we // reset and reinitialized, we'll be notified so that we can reset and
// can reset and reinitialize ours as well. // reinitialize ours as well.
SetUpMojoIfNeeded(); SetUpMojo();
} }
// DO NOT USE |process_| HERE! At this point it (or at least parts of it) is no // DO NOT USE |process_| HERE! At this point it (or at least parts of it) is no
...@@ -151,15 +151,14 @@ void AgentSchedulingGroupHost::RenderProcessExited( ...@@ -151,15 +151,14 @@ void AgentSchedulingGroupHost::RenderProcessExited(
ResetMojo(); ResetMojo();
// RenderProcessHostImpl will attempt to call this method later if it has not // RenderProcessHostImpl will attempt to call this method later if it has not
// already been called. We call it now since `SetUpMojoIfNeeded()` relies on // already been called. We call it now since `SetUpMojo()` relies on it being
// it being called, thus setting up the IPC channel and mojom::Renderer // called, thus setting up the IPC ChannelProxy and mojom::Renderer interface.
// interface.
process_.EnableSendQueue(); process_.EnableSendQueue();
// We call this so that we can immediately queue IPC and mojo messages on the // We call this so that we can immediately queue IPC and mojo messages on the
// new channel/interfaces that are bound for the next renderer process, should // new channel/interfaces that are bound for the next renderer process, should
// one eventually be spun up. // one eventually be spun up.
SetUpMojoIfNeeded(); SetUpMojo();
} }
void AgentSchedulingGroupHost::RenderProcessHostDestroyed( void AgentSchedulingGroupHost::RenderProcessHostDestroyed(
...@@ -298,31 +297,16 @@ void AgentSchedulingGroupHost::ResetMojo() { ...@@ -298,31 +297,16 @@ void AgentSchedulingGroupHost::ResetMojo() {
associated_interface_provider_receivers_.Clear(); associated_interface_provider_receivers_.Clear();
} }
void AgentSchedulingGroupHost::SetUpMojoIfNeeded() { void AgentSchedulingGroupHost::SetUpMojo() {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
// We don't DCHECK |process_.IsInitializedAndNotDead()| here because we may
// end up here after the render process has died but before the
// RenderProcessHostImpl is re-initialized (and thus not considered dead
// anymore).
// The RenderProcessHostImpl's renderer interface must be initialized at this // The RenderProcessHostImpl's renderer interface must be initialized at this
// at this point. // at this point. We don't DCHECK |process_.IsInitializedAndNotDead()| here
// because we may end up here after the render process has died but before
// RenderProcessHostImpl::Init() is called. Therefore, the process can
// accept IPCs that will be queued for the next render process if one is spun
// up.
DCHECK(process_.GetRendererInterface()); DCHECK(process_.GetRendererInterface());
// Make sure that the bind state of all of this class's mojos are equivalent.
if (state_ == LifecycleState::kBound) {
DCHECK(mojo_remote_.is_bound());
DCHECK(receiver_.is_bound());
DCHECK(remote_route_provider_.is_bound());
DCHECK(route_provider_receiver_.is_bound());
return;
}
DCHECK(!mojo_remote_.is_bound());
DCHECK(!receiver_.is_bound());
DCHECK(!remote_route_provider_.is_bound());
DCHECK(!route_provider_receiver_.is_bound());
DCHECK(state_ == LifecycleState::kNewborn || DCHECK(state_ == LifecycleState::kNewborn ||
state_ == LifecycleState::kRenderProcessExited); state_ == LifecycleState::kRenderProcessExited);
......
...@@ -160,7 +160,7 @@ class CONTENT_EXPORT AgentSchedulingGroupHost ...@@ -160,7 +160,7 @@ class CONTENT_EXPORT AgentSchedulingGroupHost
void RenderProcessHostDestroyed(RenderProcessHost* host) override; void RenderProcessHostDestroyed(RenderProcessHost* host) override;
void ResetMojo(); void ResetMojo();
void SetUpMojoIfNeeded(); void SetUpMojo();
void SetState(LifecycleState state); void SetState(LifecycleState state);
......
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