Commit b19e2288 authored by Dominic Farolino's avatar Dominic Farolino Committed by Commit Bot

[MBI]: Migrate all RPHI::GetRemoteRouteProvider() calls through to ASGH

This CL adds a helper to RenderFrameProxyHost that retrieves a reference
to the relevant AgentSchedulingGroupHost via SiteInstanceImpl.

Via the helper above, this CL migrates the last
non-AgentSchedulingGroupHost call-site of
RenderProcessHostImpl::GetRemoteRouteProvider() to go through
AgentSchedulingGroupHost.

Furthermore, by usage of util::PassKey, this CL restricts the usage of
RenderProcessHostImpl::GetRemoteRouteProvider() to
AgentSchedulingGroupHost only, until we actually move the underlying
route provider implementation to AgentSchedulingGroupHost.

Bug: 1111231, 1132901
Change-Id: I18d73b5e8d9e30b871cbb373f276f58476a1785d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2433057Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarTal Pressman <talp@chromium.org>
Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Commit-Queue: Dominic Farolino <dom@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811424}
parent 8a5a2040
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/feature_list.h" #include "base/feature_list.h"
#include "base/supports_user_data.h" #include "base/supports_user_data.h"
#include "base/util/type_safety/pass_key.h"
#include "content/browser/renderer_host/render_process_host_impl.h" #include "content/browser/renderer_host/render_process_host_impl.h"
#include "content/common/agent_scheduling_group.mojom.h" #include "content/common/agent_scheduling_group.mojom.h"
#include "content/common/renderer.mojom.h" #include "content/common/renderer.mojom.h"
...@@ -28,6 +29,8 @@ using ::mojo::PendingRemote; ...@@ -28,6 +29,8 @@ using ::mojo::PendingRemote;
using ::mojo::Receiver; using ::mojo::Receiver;
using ::mojo::Remote; using ::mojo::Remote;
using PassKey = ::util::PassKey<AgentSchedulingGroupHost>;
static constexpr char kAgentGroupHostDataKey[] = static constexpr char kAgentGroupHostDataKey[] =
"AgentSchedulingGroupHostUserDataKey"; "AgentSchedulingGroupHostUserDataKey";
...@@ -224,11 +227,11 @@ void AgentSchedulingGroupHost::RemoveRoute(int32_t routing_id) { ...@@ -224,11 +227,11 @@ void AgentSchedulingGroupHost::RemoveRoute(int32_t routing_id) {
} }
mojom::RouteProvider* AgentSchedulingGroupHost::GetRemoteRouteProvider() { mojom::RouteProvider* AgentSchedulingGroupHost::GetRemoteRouteProvider() {
// TODO(talp): Either expose `GetRemoteRouteProvider` on `RenderProcessHost` // TODO(domfarolino): Remove `GetRemoteRouteProvider` from `RenderProcessHost`
// or change the `AgentSchedulingGroupHost` to take the impl. // and make `AgentSchedulingGroupHost` a fully-fledged RouteProvider.
RenderProcessHostImpl& process = RenderProcessHostImpl& process =
static_cast<RenderProcessHostImpl&>(process_); static_cast<RenderProcessHostImpl&>(process_);
return process.GetRemoteRouteProvider(); return process.GetRemoteRouteProvider(PassKey());
} }
void AgentSchedulingGroupHost::CreateFrame(mojom::CreateFrameParamsPtr params) { void AgentSchedulingGroupHost::CreateFrame(mojom::CreateFrameParamsPtr params) {
......
...@@ -184,9 +184,7 @@ RenderWidgetHostView* RenderFrameProxyHost::GetRenderWidgetHostView() { ...@@ -184,9 +184,7 @@ RenderWidgetHostView* RenderFrameProxyHost::GetRenderWidgetHostView() {
} }
bool RenderFrameProxyHost::Send(IPC::Message* msg) { bool RenderFrameProxyHost::Send(IPC::Message* msg) {
return static_cast<SiteInstanceImpl*>(site_instance_.get()) return GetAgentSchedulingGroup().Send(msg);
->GetAgentSchedulingGroup()
.Send(msg);
} }
bool RenderFrameProxyHost::OnMessageReceived(const IPC::Message& msg) { bool RenderFrameProxyHost::OnMessageReceived(const IPC::Message& msg) {
...@@ -283,6 +281,11 @@ bool RenderFrameProxyHost::InitRenderFrameProxy() { ...@@ -283,6 +281,11 @@ bool RenderFrameProxyHost::InitRenderFrameProxy() {
return true; return true;
} }
AgentSchedulingGroupHost& RenderFrameProxyHost::GetAgentSchedulingGroup() {
return static_cast<SiteInstanceImpl*>(site_instance_.get())
->GetAgentSchedulingGroup();
}
void RenderFrameProxyHost::OnAssociatedInterfaceRequest( void RenderFrameProxyHost::OnAssociatedInterfaceRequest(
const std::string& interface_name, const std::string& interface_name,
mojo::ScopedInterfaceEndpointHandle handle) { mojo::ScopedInterfaceEndpointHandle handle) {
...@@ -306,11 +309,9 @@ RenderFrameProxyHost::GetRemoteAssociatedInterfaces() { ...@@ -306,11 +309,9 @@ RenderFrameProxyHost::GetRemoteAssociatedInterfaces() {
if (!remote_associated_interfaces_) { if (!remote_associated_interfaces_) {
mojo::AssociatedRemote<blink::mojom::AssociatedInterfaceProvider> mojo::AssociatedRemote<blink::mojom::AssociatedInterfaceProvider>
remote_interfaces; remote_interfaces;
IPC::ChannelProxy* channel = GetProcess()->GetChannel(); IPC::ChannelProxy* channel = GetAgentSchedulingGroup().GetChannel();
if (channel) { if (channel) {
RenderProcessHostImpl* process = GetAgentSchedulingGroup().GetRemoteRouteProvider()->GetRoute(
static_cast<RenderProcessHostImpl*>(GetProcess());
process->GetRemoteRouteProvider()->GetRoute(
GetRoutingID(), remote_interfaces.BindNewEndpointAndPassReceiver()); GetRoutingID(), remote_interfaces.BindNewEndpointAndPassReceiver());
} else { } else {
// The channel may not be initialized in some tests environments. In this // The channel may not be initialized in some tests environments. In this
......
...@@ -212,6 +212,10 @@ class CONTENT_EXPORT RenderFrameProxyHost ...@@ -212,6 +212,10 @@ class CONTENT_EXPORT RenderFrameProxyHost
friend class RouteMessageEventInterceptor; friend class RouteMessageEventInterceptor;
friend class OpenURLInterceptor; friend class OpenURLInterceptor;
// Helper to retrieve the |AgentSchedulingGroup| this proxy host is associated
// with.
AgentSchedulingGroupHost& GetAgentSchedulingGroup();
// IPC::Listener // IPC::Listener
void OnAssociatedInterfaceRequest( void OnAssociatedInterfaceRequest(
const std::string& interface_name, const std::string& interface_name,
......
...@@ -2867,7 +2867,8 @@ void RenderProcessHostImpl::SetIsUsed() { ...@@ -2867,7 +2867,8 @@ void RenderProcessHostImpl::SetIsUsed() {
is_unused_ = false; is_unused_ = false;
} }
mojom::RouteProvider* RenderProcessHostImpl::GetRemoteRouteProvider() { mojom::RouteProvider* RenderProcessHostImpl::GetRemoteRouteProvider(
util::PassKey<AgentSchedulingGroupHost>) {
return remote_route_provider_.get(); return remote_route_provider_.get();
} }
......
...@@ -109,6 +109,7 @@ class GpuClient; ...@@ -109,6 +109,7 @@ class GpuClient;
namespace content { namespace content {
class AgentMetricsCollectorHost; class AgentMetricsCollectorHost;
class AgentSchedulingGroupHost;
class CodeCacheHostImpl; class CodeCacheHostImpl;
class FileSystemManagerImpl; class FileSystemManagerImpl;
class InProcessChildThreadParams; class InProcessChildThreadParams;
...@@ -279,7 +280,8 @@ class CONTENT_EXPORT RenderProcessHostImpl ...@@ -279,7 +280,8 @@ class CONTENT_EXPORT RenderProcessHostImpl
void DumpProfilingData(base::OnceClosure callback) override; void DumpProfilingData(base::OnceClosure callback) override;
#endif #endif
mojom::RouteProvider* GetRemoteRouteProvider(); mojom::RouteProvider* GetRemoteRouteProvider(
util::PassKey<AgentSchedulingGroupHost>);
// IPC::Sender via RenderProcessHost. // IPC::Sender via RenderProcessHost.
bool Send(IPC::Message* msg) override; bool Send(IPC::Message* msg) override;
......
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