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

[MBI]: Migrate RenderThread::GetRemoteRouteProvider() calls through ASG

This CL migrates all calls to RT::GetRemoteRouteProvider() through ASG,
so that it is the sole mojom::RouteProvider* in the renderer. This CL
further restricts the usage of RT::GetRemoteRouteProvider to ASG via
util::PassKey.

For now, we still delegate to the RenderThread implementation to provide
AssociatedInterfaceProvider routes. A subsequent CL will make
AgentSchedulingGroup a fully-fledged RouteProvider, and we'll remove the
RenderThread::GetRemoteRouteProvider public API then.

Bug: 1132901
Change-Id: Idbd9311c777736d0a478da7a66718baa4e723275
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2433590Reviewed-by: default avatarNasko Oskov <nasko@chromium.org>
Reviewed-by: default avatarTal Pressman <talp@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Commit-Queue: Dominic Farolino <dom@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812026}
parent 06167167
......@@ -12,6 +12,7 @@
#include "base/callback.h"
#include "base/metrics/user_metrics_action.h"
#include "base/single_thread_task_runner.h"
#include "base/util/type_safety/pass_key.h"
#include "content/common/content_export.h"
#include "content/public/child/child_thread.h"
#include "ipc/ipc_channel_proxy.h"
......@@ -42,6 +43,8 @@ class Extension;
} // namespace v8
namespace content {
class AgentSchedulingGroup;
namespace mojom {
class RouteProvider;
} // namespace mojom
......@@ -79,7 +82,8 @@ class CONTENT_EXPORT RenderThread : virtual public ChildThread {
virtual void AddObserver(RenderThreadObserver* observer) = 0;
virtual void RemoveObserver(RenderThreadObserver* observer) = 0;
virtual mojom::RouteProvider* GetRemoteRouteProvider() = 0;
virtual mojom::RouteProvider* GetRemoteRouteProvider(
util::PassKey<AgentSchedulingGroup>) = 0;
// Set the ResourceDispatcher delegate object for this process.
virtual void SetResourceDispatcherDelegate(
......
......@@ -171,7 +171,8 @@ void MockRenderThread::RemoveObserver(RenderThreadObserver* observer) {
observers_.RemoveObserver(observer);
}
mojom::RouteProvider* MockRenderThread::GetRemoteRouteProvider() {
mojom::RouteProvider* MockRenderThread::GetRemoteRouteProvider(
util::PassKey<AgentSchedulingGroup>) {
return GetStaticRemoteRouteProvider();
}
......
......@@ -11,6 +11,7 @@
#include "base/observer_list.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string16.h"
#include "base/util/type_safety/pass_key.h"
#include "build/build_config.h"
#include "content/public/common/widget_type.h"
#include "content/public/renderer/render_thread.h"
......@@ -69,7 +70,8 @@ class MockRenderThread : public RenderThread {
void RemoveFilter(IPC::MessageFilter* filter) override;
void AddObserver(RenderThreadObserver* observer) override;
void RemoveObserver(RenderThreadObserver* observer) override;
mojom::RouteProvider* GetRemoteRouteProvider() override;
mojom::RouteProvider* GetRemoteRouteProvider(
util::PassKey<AgentSchedulingGroup>) override;
void SetResourceDispatcherDelegate(
ResourceDispatcherDelegate* delegate) override;
void RecordAction(const base::UserMetricsAction& action) override;
......
......@@ -139,6 +139,10 @@ void AgentSchedulingGroup::RemoveRoute(int32_t routing_id) {
RenderThread::Get()->RemoveRoute(routing_id);
}
mojom::RouteProvider* AgentSchedulingGroup::GetRemoteRouteProvider() {
return render_thread_.GetRemoteRouteProvider(PassKey());
}
void AgentSchedulingGroup::CreateView(mojom::CreateViewParamsPtr params) {
ToImpl(render_thread_).CreateView(std::move(params), PassKey());
}
......
......@@ -61,6 +61,8 @@ class CONTENT_EXPORT AgentSchedulingGroup
void AddRoute(int32_t routing_id, IPC::Listener* listener);
void RemoveRoute(int32_t routing_id);
mojom::RouteProvider* GetRemoteRouteProvider();
private:
// `MaybeAssociatedReceiver` and `MaybeAssociatedRemote` are temporary helper
// classes that allow us to switch between using associated and non-associated
......
......@@ -2893,7 +2893,7 @@ RenderFrameImpl::GetRemoteAssociatedInterfaces() {
if (!remote_associated_interfaces_) {
mojo::PendingAssociatedRemote<blink::mojom::AssociatedInterfaceProvider>
remote_interfaces;
RenderThread::Get()->GetRemoteRouteProvider()->GetRoute(
agent_scheduling_group_.GetRemoteRouteProvider()->GetRoute(
routing_id_, remote_interfaces.InitWithNewEndpointAndPassReceiver());
remote_associated_interfaces_ =
std::make_unique<blink::AssociatedInterfaceProvider>(
......
......@@ -752,7 +752,7 @@ RenderFrameProxy::GetRemoteAssociatedInterfaces() {
if (!remote_associated_interfaces_) {
mojo::PendingAssociatedRemote<blink::mojom::AssociatedInterfaceProvider>
remote_interfaces;
RenderThread::Get()->GetRemoteRouteProvider()->GetRoute(
agent_scheduling_group_.GetRemoteRouteProvider()->GetRoute(
routing_id_, remote_interfaces.InitWithNewEndpointAndPassReceiver());
remote_associated_interfaces_ =
std::make_unique<blink::AssociatedInterfaceProvider>(
......
......@@ -959,7 +959,8 @@ RenderThreadImpl::CreateVideoFrameCompositorTaskRunner() {
return video_frame_compositor_task_runner_;
}
mojom::RouteProvider* RenderThreadImpl::GetRemoteRouteProvider() {
mojom::RouteProvider* RenderThreadImpl::GetRemoteRouteProvider(
util::PassKey<AgentSchedulingGroup>) {
if (!remote_route_provider_) {
DCHECK(GetChannel());
GetChannel()->GetRemoteAssociatedInterface(&remote_route_provider_);
......
......@@ -431,7 +431,8 @@ class CONTENT_EXPORT RenderThreadImpl
video_frame_compositor_task_runner_ = task_runner;
}
mojom::RouteProvider* GetRemoteRouteProvider() override;
mojom::RouteProvider* GetRemoteRouteProvider(
util::PassKey<AgentSchedulingGroup>) override;
private:
friend class RenderThreadImplBrowserTest;
......
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