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

[MBI] Bind AgentSchedulingGroup(Host) mojo interfaces.

The interfaces are still empty and don't do anything.

Bug: 1111231
Change-Id: I778d365eaaaf53cf8e9855bc131f1cebc69d4f11
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2374186Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Reviewed-by: default avatarDominic Farolino <dom@chromium.org>
Commit-Queue: Tal Pressman <talp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803324}
parent f87fd634
...@@ -14,10 +14,10 @@ namespace content { ...@@ -14,10 +14,10 @@ namespace content {
namespace { namespace {
using IPC::ChannelProxy; using ::IPC::ChannelProxy;
using IPC::Listener; using ::IPC::Listener;
using mojom::CreateFrameParamsPtr; using ::mojo::PendingRemote;
using mojom::RouteProvider; using ::mojo::Receiver;
static constexpr char kAgentGroupHostDataKey[] = static constexpr char kAgentGroupHostDataKey[] =
"AgentSchedulingGroupHostUserDataKey"; "AgentSchedulingGroupHostUserDataKey";
...@@ -36,6 +36,7 @@ class AgentGroupHostUserData : public base::SupportsUserData::Data { ...@@ -36,6 +36,7 @@ class AgentGroupHostUserData : public base::SupportsUserData::Data {
private: private:
std::unique_ptr<AgentSchedulingGroupHost> agent_group_; std::unique_ptr<AgentSchedulingGroupHost> agent_group_;
}; };
} // namespace } // namespace
// static // static
...@@ -57,7 +58,10 @@ AgentSchedulingGroupHost* AgentSchedulingGroupHost::Get( ...@@ -57,7 +58,10 @@ AgentSchedulingGroupHost* AgentSchedulingGroupHost::Get(
AgentSchedulingGroupHost::AgentSchedulingGroupHost(RenderProcessHost& process) AgentSchedulingGroupHost::AgentSchedulingGroupHost(RenderProcessHost& process)
: process_(process) { : process_(process) {
process_.GetRendererInterface()->CreateAgentSchedulingGroup(); DCHECK_CURRENTLY_ON(BrowserThread::UI);
process_.GetRendererInterface()->CreateAgentSchedulingGroup(
receiver_.BindNewPipeAndPassRemote(),
mojo_remote_.BindNewPipeAndPassReceiver());
} }
// 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
...@@ -85,13 +89,13 @@ void AgentSchedulingGroupHost::RemoveRoute(int32_t routing_id) { ...@@ -85,13 +89,13 @@ void AgentSchedulingGroupHost::RemoveRoute(int32_t routing_id) {
process_.RemoveRoute(routing_id); process_.RemoveRoute(routing_id);
} }
RouteProvider* AgentSchedulingGroupHost::GetRemoteRouteProvider() { mojom::RouteProvider* AgentSchedulingGroupHost::GetRemoteRouteProvider() {
RenderProcessHostImpl& process = RenderProcessHostImpl& process =
static_cast<RenderProcessHostImpl&>(process_); static_cast<RenderProcessHostImpl&>(process_);
return process.GetRemoteRouteProvider(); return process.GetRemoteRouteProvider();
} }
void AgentSchedulingGroupHost::CreateFrame(CreateFrameParamsPtr params) { void AgentSchedulingGroupHost::CreateFrame(mojom::CreateFrameParamsPtr params) {
process_.GetRendererInterface()->CreateFrame(std::move(params)); process_.GetRendererInterface()->CreateFrame(std::move(params));
} }
......
...@@ -6,13 +6,12 @@ ...@@ -6,13 +6,12 @@
#define CONTENT_BROWSER_RENDERER_HOST_AGENT_SCHEDULING_GROUP_HOST_H_ #define CONTENT_BROWSER_RENDERER_HOST_AGENT_SCHEDULING_GROUP_HOST_H_
#include <stdint.h> #include <stdint.h>
#include <memory>
#include "content/common/agent_scheduling_group.mojom.h" #include "content/common/agent_scheduling_group.mojom.h"
#include "content/common/associated_interfaces.mojom-forward.h" #include "content/common/associated_interfaces.mojom-forward.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "content/common/renderer.mojom-forward.h" #include "content/common/renderer.mojom-forward.h"
#include "ipc/ipc_listener.h" #include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/remote.h"
namespace IPC { namespace IPC {
...@@ -34,7 +33,8 @@ class SiteInstance; ...@@ -34,7 +33,8 @@ class SiteInstance;
// //
// An AgentSchedulingGroupHost is stored as (and owned by) UserData on the // An AgentSchedulingGroupHost is stored as (and owned by) UserData on the
// RenderProcessHost. // RenderProcessHost.
class CONTENT_EXPORT AgentSchedulingGroupHost { class CONTENT_EXPORT AgentSchedulingGroupHost
: public mojom::AgentSchedulingGroupHost {
public: public:
// Get the appropriate AgentSchedulingGroupHost for the given |instance| and // Get the appropriate AgentSchedulingGroupHost for the given |instance| and
// |process|. For now, each RenderProcessHost has a single // |process|. For now, each RenderProcessHost has a single
...@@ -45,7 +45,7 @@ class CONTENT_EXPORT AgentSchedulingGroupHost { ...@@ -45,7 +45,7 @@ class CONTENT_EXPORT AgentSchedulingGroupHost {
// Should not be called explicitly. Use Get() instead. // Should not be called explicitly. Use Get() instead.
explicit AgentSchedulingGroupHost(RenderProcessHost& process); explicit AgentSchedulingGroupHost(RenderProcessHost& process);
~AgentSchedulingGroupHost(); ~AgentSchedulingGroupHost() override;
RenderProcessHost* GetProcess(); RenderProcessHost* GetProcess();
...@@ -65,14 +65,13 @@ class CONTENT_EXPORT AgentSchedulingGroupHost { ...@@ -65,14 +65,13 @@ class CONTENT_EXPORT AgentSchedulingGroupHost {
// The RenderProcessHost this AgentSchedulingGroup is assigned to. // The RenderProcessHost this AgentSchedulingGroup is assigned to.
RenderProcessHost& process_; RenderProcessHost& process_;
// Internal implementation of content::mojom::AgentSchedulingGroupHost, used // Implementation of `mojom::AgentSchedulingGroupHost`, used for responding to
// for responding to calls from the (renderer-side) AgentSchedulingGroup. // calls from the (renderer-side) `AgentSchedulingGroup`.
std::unique_ptr<content::mojom::AgentSchedulingGroupHost> mojo_impl_; mojo::Receiver<mojom::AgentSchedulingGroupHost> receiver_{this};
// Remote stub of content::mojom::AgentSchedulingGroup, used for sending calls // Remote stub of `mojom::AgentSchedulingGroup`, used for sending calls to the
// to the (renderer-side) AgentSchedulingGroup. // (renderer-side) `AgentSchedulingGroup`.
std::unique_ptr<mojo::Remote<content::mojom::AgentSchedulingGroup>> mojo::Remote<mojom::AgentSchedulingGroup> mojo_remote_;
mojo_remote_;
}; };
} // namespace content } // namespace content
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
module content.mojom; module content.mojom;
import "content/common/agent_scheduling_group.mojom";
import "content/common/document_scoped_interface_bundle.mojom"; import "content/common/document_scoped_interface_bundle.mojom";
import "content/common/native_types.mojom"; import "content/common/native_types.mojom";
import "content/public/common/web_preferences.mojom"; import "content/public/common/web_preferences.mojom";
...@@ -257,8 +258,13 @@ interface Renderer { ...@@ -257,8 +258,13 @@ interface Renderer {
// Tells the renderer to create a new RenderFrame. // Tells the renderer to create a new RenderFrame.
CreateFrame(CreateFrameParams params); CreateFrame(CreateFrameParams params);
// Tells the renderer to create a new AgentSchedulingGroup. // Tells the renderer to create a new AgentSchedulingGroup, that will
CreateAgentSchedulingGroup(); // communicate via the pending |agent_scheduling_group_host| and
// |agent_scheduling_group|.
CreateAgentSchedulingGroup(
pending_remote<AgentSchedulingGroupHost> agent_scheduling_group_host,
pending_receiver<AgentSchedulingGroup> agent_scheduling_group
);
// Tells the renderer to create a new RenderFrameProxy object with // Tells the renderer to create a new RenderFrameProxy object with
// |routing_id|. |render_view_routing_id| identifies the // |routing_id|. |render_view_routing_id| identifies the
......
...@@ -6,7 +6,19 @@ ...@@ -6,7 +6,19 @@
namespace content { namespace content {
AgentSchedulingGroup::AgentSchedulingGroup() = default; AgentSchedulingGroup::AgentSchedulingGroup(
mojo::PendingRemote<mojom::AgentSchedulingGroupHost> host_remote,
mojo::PendingReceiver<mojom::AgentSchedulingGroup> receiver,
base::OnceCallback<void(const AgentSchedulingGroup*)>
mojo_disconnect_handler)
// TODO(crbug.com/1111231): Mojo interfaces should be associated with
// per-ASG task runners instead of default.
: receiver_(this, std::move(receiver)),
host_remote_(std::move(host_remote)) {
receiver_.set_disconnect_handler(
base::BindOnce(std::move(mojo_disconnect_handler), this));
}
AgentSchedulingGroup::~AgentSchedulingGroup() = default; AgentSchedulingGroup::~AgentSchedulingGroup() = default;
} // namespace content } // namespace content
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
#ifndef CONTENT_RENDERER_AGENT_SCHEDULING_GROUP_H_ #ifndef CONTENT_RENDERER_AGENT_SCHEDULING_GROUP_H_
#define CONTENT_RENDERER_AGENT_SCHEDULING_GROUP_H_ #define CONTENT_RENDERER_AGENT_SCHEDULING_GROUP_H_
#include <memory> #include "base/callback.h"
#include "content/common/agent_scheduling_group.mojom.h" #include "content/common/agent_scheduling_group.mojom.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/remote.h"
namespace content { namespace content {
...@@ -18,10 +18,16 @@ namespace content { ...@@ -18,10 +18,16 @@ namespace content {
// Blink's unit of scheduling and performance isolation, which is the only way // Blink's unit of scheduling and performance isolation, which is the only way
// to obtain ordering guarantees between different Mojo (associated) interfaces // to obtain ordering guarantees between different Mojo (associated) interfaces
// and legacy IPC messages. // and legacy IPC messages.
class CONTENT_EXPORT AgentSchedulingGroup { class CONTENT_EXPORT AgentSchedulingGroup : public mojom::AgentSchedulingGroup {
public: public:
explicit AgentSchedulingGroup(); // |mojo_disconnect_handler| will be called with |this| when |receiver| is
~AgentSchedulingGroup(); // disconnected.
AgentSchedulingGroup(
mojo::PendingRemote<mojom::AgentSchedulingGroupHost> host_remote,
mojo::PendingReceiver<mojom::AgentSchedulingGroup> receiver,
base::OnceCallback<void(const AgentSchedulingGroup*)>
mojo_disconnect_handler);
~AgentSchedulingGroup() override;
AgentSchedulingGroup(const AgentSchedulingGroup&) = delete; AgentSchedulingGroup(const AgentSchedulingGroup&) = delete;
AgentSchedulingGroup(const AgentSchedulingGroup&&) = delete; AgentSchedulingGroup(const AgentSchedulingGroup&&) = delete;
...@@ -29,14 +35,13 @@ class CONTENT_EXPORT AgentSchedulingGroup { ...@@ -29,14 +35,13 @@ class CONTENT_EXPORT AgentSchedulingGroup {
AgentSchedulingGroup& operator=(const AgentSchedulingGroup&&) = delete; AgentSchedulingGroup& operator=(const AgentSchedulingGroup&&) = delete;
private: private:
// Internal implementation of content::mojom::AgentSchedulingGroup, used for // Implementation of `mojom::AgentSchedulingGroup`, used for responding to
// responding to calls from the (browser-side) AgentSchedulingGroupHost. // calls from the (browser-side) `AgentSchedulingGroupHost`.
std::unique_ptr<content::mojom::AgentSchedulingGroup> mojo_impl_; mojo::Receiver<mojom::AgentSchedulingGroup> receiver_;
// Remote stub of content::mojom::AgentSchedulingGroupHost, used for sending // Remote stub of mojom::AgentSchedulingGroupHost, used for sending calls to
// calls to the (browser-side) AgentSchedulingGroupHost. // the (browser-side) AgentSchedulingGroupHost.
std::unique_ptr<mojo::Remote<content::mojom::AgentSchedulingGroupHost>> mojo::Remote<mojom::AgentSchedulingGroupHost> host_remote_;
mojo_remote_;
}; };
} // namespace content } // namespace content
......
...@@ -579,6 +579,10 @@ RenderThreadImpl::RenderThreadImpl( ...@@ -579,6 +579,10 @@ RenderThreadImpl::RenderThreadImpl(
void RenderThreadImpl::Init() { void RenderThreadImpl::Init() {
TRACE_EVENT0("startup", "RenderThreadImpl::Init"); TRACE_EVENT0("startup", "RenderThreadImpl::Init");
remove_agent_scheduling_group_callback_ =
base::BindRepeating(&RenderThreadImpl::RemoveAgentSchedulingGroup,
weak_factory_.GetWeakPtr());
GetContentClient()->renderer()->PostIOThreadCreated(GetIOTaskRunner().get()); GetContentClient()->renderer()->PostIOThreadCreated(GetIOTaskRunner().get());
base::trace_event::TraceLog::GetInstance()->SetThreadSortIndex( base::trace_event::TraceLog::GetInstance()->SetThreadSortIndex(
...@@ -1859,8 +1863,21 @@ void RenderThreadImpl::CreateFrame(mojom::CreateFrameParamsPtr params) { ...@@ -1859,8 +1863,21 @@ void RenderThreadImpl::CreateFrame(mojom::CreateFrameParamsPtr params) {
params->has_committed_real_load); params->has_committed_real_load);
} }
void RenderThreadImpl::CreateAgentSchedulingGroup() { void RenderThreadImpl::RemoveAgentSchedulingGroup(
agent_scheduling_groups_.emplace(std::make_unique<AgentSchedulingGroup>()); const AgentSchedulingGroup* agent_scheduling_group) {
DCHECK(agent_scheduling_group);
DCHECK(base::Contains(agent_scheduling_groups_, agent_scheduling_group));
auto it = agent_scheduling_groups_.find(agent_scheduling_group);
agent_scheduling_groups_.erase(it);
}
void RenderThreadImpl::CreateAgentSchedulingGroup(
mojo::PendingRemote<mojom::AgentSchedulingGroupHost>
agent_scheduling_group_host,
mojo::PendingReceiver<mojom::AgentSchedulingGroup> agent_scheduling_group) {
agent_scheduling_groups_.emplace(std::make_unique<AgentSchedulingGroup>(
std::move(agent_scheduling_group_host), std::move(agent_scheduling_group),
remove_agent_scheduling_group_callback_));
} }
void RenderThreadImpl::CreateFrameProxy( void RenderThreadImpl::CreateFrameProxy(
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "base/cancelable_callback.h" #include "base/cancelable_callback.h"
#include "base/clang_profiling_buildflags.h" #include "base/clang_profiling_buildflags.h"
#include "base/containers/unique_ptr_adapters.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/discardable_memory_allocator.h" #include "base/memory/discardable_memory_allocator.h"
#include "base/memory/memory_pressure_listener.h" #include "base/memory/memory_pressure_listener.h"
...@@ -28,6 +29,7 @@ ...@@ -28,6 +29,7 @@
#include "base/time/time.h" #include "base/time/time.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "content/child/child_thread_impl.h" #include "content/child/child_thread_impl.h"
#include "content/common/agent_scheduling_group.mojom.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
#include "content/common/frame.mojom.h" #include "content/common/frame.mojom.h"
#include "content/common/frame_replication_state.h" #include "content/common/frame_replication_state.h"
...@@ -443,7 +445,11 @@ class CONTENT_EXPORT RenderThreadImpl ...@@ -443,7 +445,11 @@ class CONTENT_EXPORT RenderThreadImpl
void CreateView(mojom::CreateViewParamsPtr params) override; void CreateView(mojom::CreateViewParamsPtr params) override;
void DestroyView(int32_t view_id) override; void DestroyView(int32_t view_id) override;
void CreateFrame(mojom::CreateFrameParamsPtr params) override; void CreateFrame(mojom::CreateFrameParamsPtr params) override;
void CreateAgentSchedulingGroup() override; void CreateAgentSchedulingGroup(
mojo::PendingRemote<mojom::AgentSchedulingGroupHost>
agent_scheduling_group_host,
mojo::PendingReceiver<mojom::AgentSchedulingGroup> agent_scheduling_group)
override;
void CreateFrameProxy( void CreateFrameProxy(
int32_t routing_id, int32_t routing_id,
int32_t render_view_routing_id, int32_t render_view_routing_id,
...@@ -508,6 +514,11 @@ class CONTENT_EXPORT RenderThreadImpl ...@@ -508,6 +514,11 @@ class CONTENT_EXPORT RenderThreadImpl
void OnRendererInterfaceReceiver( void OnRendererInterfaceReceiver(
mojo::PendingAssociatedReceiver<mojom::Renderer> receiver); mojo::PendingAssociatedReceiver<mojom::Renderer> receiver);
void RemoveAgentSchedulingGroup(
const AgentSchedulingGroup* agent_scheduling_group);
base::RepeatingCallback<void(const AgentSchedulingGroup*)>
remove_agent_scheduling_group_callback_;
std::unique_ptr<base::DiscardableMemoryAllocator> std::unique_ptr<base::DiscardableMemoryAllocator>
discardable_memory_allocator_; discardable_memory_allocator_;
...@@ -616,7 +627,8 @@ class CONTENT_EXPORT RenderThreadImpl ...@@ -616,7 +627,8 @@ class CONTENT_EXPORT RenderThreadImpl
mojo::AssociatedRemote<mojom::RenderMessageFilter> render_message_filter_; mojo::AssociatedRemote<mojom::RenderMessageFilter> render_message_filter_;
std::set<std::unique_ptr<AgentSchedulingGroup>> agent_scheduling_groups_; std::set<std::unique_ptr<AgentSchedulingGroup>, base::UniquePtrComparator>
agent_scheduling_groups_;
RendererMemoryMetrics purge_and_suspend_memory_metrics_; RendererMemoryMetrics purge_and_suspend_memory_metrics_;
bool needs_to_record_first_active_paint_; bool needs_to_record_first_active_paint_;
......
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