Commit f590e5ef authored by Tal Pressman's avatar Tal Pressman Committed by Commit Bot

[MBI] Move renderer object creation to AgentSchedulingGroup.

The IPCs to create/destroy the Render* objects were already moved to
AgentSchedulingGroup, but until now it delegated the implementation to
RenderThreadImpl. This CL moves the actual implementation to
AgentSchedulingGroup.

Bug: 1111231
Change-Id: I5ade91a18c72882781eba159b9708aea7f857945
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2485659
Commit-Queue: Tal Pressman <talp@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Reviewed-by: default avatarDominic Farolino <dom@chromium.org>
Cr-Commit-Position: refs/heads/master@{#819716}
parent fa30f411
......@@ -7,7 +7,10 @@
#include "base/feature_list.h"
#include "base/util/type_safety/pass_key.h"
#include "content/public/common/content_features.h"
#include "content/renderer/compositor/compositor_dependencies.h"
#include "content/renderer/render_frame_proxy.h"
#include "content/renderer/render_thread_impl.h"
#include "content/renderer/render_view_impl.h"
namespace content {
......@@ -128,16 +131,50 @@ mojom::RouteProvider* AgentSchedulingGroup::GetRemoteRouteProvider() {
}
void AgentSchedulingGroup::CreateView(mojom::CreateViewParamsPtr params) {
ToImpl(render_thread_).CreateView(std::move(params), PassKey());
RenderThreadImpl& renderer = ToImpl(render_thread_);
RenderViewImpl::Create(
*this, &renderer, std::move(params), RenderWidget::ShowCallback(),
// TODO(crbug.com/1111231): Use proper per-ASG task-runner.
renderer.GetWebMainThreadScheduler()->DefaultTaskRunner());
}
void AgentSchedulingGroup::DestroyView(int32_t view_id,
DestroyViewCallback callback) {
ToImpl(render_thread_).DestroyView(view_id, std::move(callback), PassKey());
RenderViewImpl* view = RenderViewImpl::FromRoutingID(view_id);
DCHECK(view);
// This IPC can be called from re-entrant contexts. We can't destroy a
// RenderViewImpl while references still exist on the stack, so we dispatch a
// non-nestable task. This method is called exactly once by the browser
// process, and is used to release ownership of the corresponding
// RenderViewImpl instance. https://crbug.com/1000035.
base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask(
FROM_HERE, base::BindOnce(
[](RenderViewImpl* view, DestroyViewCallback callback) {
view->Destroy();
std::move(callback).Run();
},
base::Unretained(view), std::move(callback)));
}
void AgentSchedulingGroup::CreateFrame(mojom::CreateFrameParamsPtr params) {
ToImpl(render_thread_).CreateFrame(std::move(params), PassKey());
mojo::PendingRemote<service_manager::mojom::InterfaceProvider>
interface_provider(
std::move(params->interface_bundle->interface_provider));
mojo::PendingRemote<blink::mojom::BrowserInterfaceBroker>
browser_interface_broker(
std::move(params->interface_bundle->browser_interface_broker));
RenderFrameImpl::CreateFrame(
*this, params->routing_id, std::move(interface_provider),
std::move(browser_interface_broker), params->previous_routing_id,
params->opener_frame_token, params->parent_routing_id,
params->previous_sibling_routing_id, params->frame_token,
params->devtools_frame_token, params->replication_state,
&ToImpl(render_thread_), std::move(params->widget_params),
std::move(params->frame_owner_properties),
params->has_committed_real_load);
}
void AgentSchedulingGroup::CreateFrameProxy(
......@@ -148,10 +185,9 @@ void AgentSchedulingGroup::CreateFrameProxy(
const FrameReplicationState& replicated_state,
const base::UnguessableToken& frame_token,
const base::UnguessableToken& devtools_frame_token) {
ToImpl(render_thread_)
.CreateFrameProxy(routing_id, render_view_routing_id, opener_frame_token,
parent_routing_id, replicated_state, frame_token,
devtools_frame_token, PassKey());
RenderFrameProxy::CreateFrameProxy(
*this, routing_id, render_view_routing_id, opener_frame_token,
parent_routing_id, replicated_state, frame_token, devtools_frame_token);
}
void AgentSchedulingGroup::BindAssociatedRouteProvider(
......
......@@ -1639,72 +1639,6 @@ gpu::GpuChannelHost* RenderThreadImpl::GetGpuChannel() {
return gpu_->GetGpuChannel().get();
}
void RenderThreadImpl::CreateView(mojom::CreateViewParamsPtr params,
PassKey<AgentSchedulingGroup>) {
CompositorDependencies* compositor_deps = this;
is_scroll_animator_enabled_ = params->web_preferences.enable_scroll_animator;
// TODO(crbug.com/1111231): For as long as views are created via the
// `Renderer` interface (as opposed to `AgentSchedulingGroup`), we will always
// have *exactly one* `AgentSchedulingGroup` in the process.
DCHECK_EQ(agent_scheduling_groups_.size(), 1ul);
AgentSchedulingGroup& agent_scheduling_group =
*agent_scheduling_groups_.begin()->get();
RenderViewImpl::Create(agent_scheduling_group, compositor_deps,
std::move(params), RenderWidget::ShowCallback(),
GetWebMainThreadScheduler()->DefaultTaskRunner());
}
void RenderThreadImpl::DestroyView(
int32_t view_id,
mojom::AgentSchedulingGroup::DestroyViewCallback callback,
PassKey<AgentSchedulingGroup>) {
RenderViewImpl* view = RenderViewImpl::FromRoutingID(view_id);
DCHECK(view);
// This IPC can be called from re-entrant contexts. We can't destroy a
// RenderViewImpl while references still exist on the stack, so we dispatch a
// non-nestable task. This method is called exactly once by the browser
// process, and is used to release ownership of the corresponding
// RenderViewImpl instance. https://crbug.com/1000035.
base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask(
FROM_HERE,
base::BindOnce(
[](RenderViewImpl* view,
mojom::AgentSchedulingGroup::DestroyViewCallback callback) {
view->Destroy();
std::move(callback).Run();
},
base::Unretained(view), std::move(callback)));
}
void RenderThreadImpl::CreateFrame(mojom::CreateFrameParamsPtr params,
PassKey<AgentSchedulingGroup>) {
CompositorDependencies* compositor_deps = this;
mojo::PendingRemote<service_manager::mojom::InterfaceProvider>
interface_provider(
std::move(params->interface_bundle->interface_provider));
mojo::PendingRemote<blink::mojom::BrowserInterfaceBroker>
browser_interface_broker(
std::move(params->interface_bundle->browser_interface_broker));
// TODO(crbug.com/1111231): For as long as frames are created via the
// `Renderer` interface (as opposed to `AgentSchedulingGroup`), we will always
// have *exactly one* `AgentSchedulingGroup` in the process.
DCHECK_EQ(agent_scheduling_groups_.size(), 1ul);
AgentSchedulingGroup& agent_scheduling_group =
*agent_scheduling_groups_.begin()->get();
RenderFrameImpl::CreateFrame(
agent_scheduling_group, params->routing_id, std::move(interface_provider),
std::move(browser_interface_broker), params->previous_routing_id,
params->opener_frame_token, params->parent_routing_id,
params->previous_sibling_routing_id, params->frame_token,
params->devtools_frame_token, params->replication_state, compositor_deps,
std::move(params->widget_params),
std::move(params->frame_owner_properties),
params->has_committed_real_load);
}
void RenderThreadImpl::CreateAgentSchedulingGroup(
mojo::PendingRemote<mojom::AgentSchedulingGroupHost>
agent_scheduling_group_host,
......@@ -1724,28 +1658,6 @@ void RenderThreadImpl::CreateAssociatedAgentSchedulingGroup(
std::move(agent_scheduling_group)));
}
void RenderThreadImpl::CreateFrameProxy(
int32_t routing_id,
int32_t render_view_routing_id,
const base::Optional<base::UnguessableToken>& opener_frame_token,
int32_t parent_routing_id,
const FrameReplicationState& replicated_state,
const base::UnguessableToken& frame_token,
const base::UnguessableToken& devtools_frame_token,
PassKey<AgentSchedulingGroup>) {
// TODO(crbug.com/1111231): For as long as frame proxies are created via the
// `Renderer` interface (as opposed to `AgentSchedulingGroup`), we will always
// have *exactly one* `AgentSchedulingGroup` in the process.
DCHECK_EQ(agent_scheduling_groups_.size(), 1ul);
AgentSchedulingGroup& agent_scheduling_group =
*agent_scheduling_groups_.begin()->get();
RenderFrameProxy::CreateFrameProxy(agent_scheduling_group, routing_id,
render_view_routing_id, opener_frame_token,
parent_routing_id, replicated_state,
frame_token, devtools_frame_token);
}
void RenderThreadImpl::OnNetworkConnectionChanged(
net::NetworkChangeNotifier::ConnectionType type,
double max_bandwidth_mbps) {
......
......@@ -207,24 +207,6 @@ class CONTENT_EXPORT RenderThreadImpl
// viz::mojom::CompositingModeWatcher implementation.
void CompositingModeFallbackToSoftware() override;
// Formerly in mojom::Renderer (moved to mojom::AgentSchedulingGroup):
void CreateView(mojom::CreateViewParamsPtr params,
util::PassKey<AgentSchedulingGroup>);
void DestroyView(int32_t view_id,
mojom::AgentSchedulingGroup::DestroyViewCallback,
util::PassKey<AgentSchedulingGroup>);
void CreateFrame(mojom::CreateFrameParamsPtr params,
util::PassKey<AgentSchedulingGroup>);
void CreateFrameProxy(
int32_t routing_id,
int32_t render_view_routing_id,
const base::Optional<base::UnguessableToken>& opener_frame_token,
int32_t parent_routing_id,
const FrameReplicationState& replicated_state,
const base::UnguessableToken& frame_token,
const base::UnguessableToken& devtools_frame_token,
util::PassKey<AgentSchedulingGroup>);
// Whether gpu compositing is being used or is disabled for software
// compositing. Clients of the compositor should give resources that match
// the appropriate mode.
......
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