Commit 25d1eaee authored by Tal Pressman's avatar Tal Pressman Committed by Commit Bot

[MBI] Conditionally associate AgentSchedulingGroup mojos.

As part of MBI, most widget/view/frame-related messages will go through
the AgentSchedulingGroup instead of RenderProcess/RenderThread. That can
change the ordering in which messages are handled, and may break some
assumptions we are currently making. In order to enable testing and
experimentation with this ordering change, this CL makes the ASG
interfaces channel-associated, thus preserving the current message order.
This will allow us to migrate all the currently channel-associated
interfaces to be associated with the ASG, and control the ordering via a
flag.

Bug: 1111231
Change-Id: Id04d90c748a2ce2cbb47d1cde7892fa99b1aac70
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2386859
Commit-Queue: Tal Pressman <talp@chromium.org>
Reviewed-by: default avatarCharlie Reis <creis@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarDominic Farolino <dom@chromium.org>
Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806525}
parent 609f5982
...@@ -5,10 +5,13 @@ ...@@ -5,10 +5,13 @@
#include <memory> #include <memory>
#include "base/feature_list.h"
#include "base/supports_user_data.h" #include "base/supports_user_data.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/renderer.mojom.h" #include "content/common/renderer.mojom.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/common/content_features.h"
namespace content { namespace content {
...@@ -16,8 +19,14 @@ namespace { ...@@ -16,8 +19,14 @@ namespace {
using ::IPC::ChannelProxy; using ::IPC::ChannelProxy;
using ::IPC::Listener; using ::IPC::Listener;
using ::mojo::AssociatedReceiver;
using ::mojo::AssociatedRemote;
using ::mojo::PendingAssociatedReceiver;
using ::mojo::PendingAssociatedRemote;
using ::mojo::PendingReceiver;
using ::mojo::PendingRemote; using ::mojo::PendingRemote;
using ::mojo::Receiver; using ::mojo::Receiver;
using ::mojo::Remote;
static constexpr char kAgentGroupHostDataKey[] = static constexpr char kAgentGroupHostDataKey[] =
"AgentSchedulingGroupHostUserDataKey"; "AgentSchedulingGroupHostUserDataKey";
...@@ -39,6 +48,63 @@ class AgentGroupHostUserData : public base::SupportsUserData::Data { ...@@ -39,6 +48,63 @@ class AgentGroupHostUserData : public base::SupportsUserData::Data {
} // namespace } // namespace
// MaybeAssociatedReceiver:
AgentSchedulingGroupHost::MaybeAssociatedReceiver::MaybeAssociatedReceiver(
AgentSchedulingGroupHost& host,
bool should_associate) {
if (should_associate) {
receiver_.emplace<AssociatedReceiver<mojom::AgentSchedulingGroupHost>>(
&host);
} else {
receiver_.emplace<Receiver<mojom::AgentSchedulingGroupHost>>(&host);
}
}
AgentSchedulingGroupHost::MaybeAssociatedReceiver::~MaybeAssociatedReceiver() =
default;
PendingRemote<mojom::AgentSchedulingGroupHost>
AgentSchedulingGroupHost::MaybeAssociatedReceiver::BindNewPipeAndPassRemote() {
return absl::get<Receiver<mojom::AgentSchedulingGroupHost>>(receiver_)
.BindNewPipeAndPassRemote();
}
PendingAssociatedRemote<mojom::AgentSchedulingGroupHost>
AgentSchedulingGroupHost::MaybeAssociatedReceiver::
BindNewEndpointAndPassRemote() {
return absl::get<AssociatedReceiver<mojom::AgentSchedulingGroupHost>>(
receiver_)
.BindNewEndpointAndPassRemote();
}
// MaybeAssociatedRemote:
AgentSchedulingGroupHost::MaybeAssociatedRemote::MaybeAssociatedRemote(
bool should_associate) {
if (should_associate) {
remote_ = AssociatedRemote<mojom::AgentSchedulingGroup>();
} else {
remote_ = Remote<mojom::AgentSchedulingGroup>();
}
}
AgentSchedulingGroupHost::MaybeAssociatedRemote::~MaybeAssociatedRemote() =
default;
PendingReceiver<mojom::AgentSchedulingGroup>
AgentSchedulingGroupHost::MaybeAssociatedRemote::BindNewPipeAndPassReceiver() {
return absl::get<Remote<mojom::AgentSchedulingGroup>>(remote_)
.BindNewPipeAndPassReceiver();
}
PendingAssociatedReceiver<mojom::AgentSchedulingGroup>
AgentSchedulingGroupHost::MaybeAssociatedRemote::
BindNewEndpointAndPassReceiver() {
return absl::get<AssociatedRemote<mojom::AgentSchedulingGroup>>(remote_)
.BindNewEndpointAndPassReceiver();
}
// AgentSchedulingGroupHost:
// static // static
AgentSchedulingGroupHost* AgentSchedulingGroupHost::Get( AgentSchedulingGroupHost* AgentSchedulingGroupHost::Get(
const SiteInstance& instance, const SiteInstance& instance,
...@@ -57,11 +123,26 @@ AgentSchedulingGroupHost* AgentSchedulingGroupHost::Get( ...@@ -57,11 +123,26 @@ AgentSchedulingGroupHost* AgentSchedulingGroupHost::Get(
} }
AgentSchedulingGroupHost::AgentSchedulingGroupHost(RenderProcessHost& process) AgentSchedulingGroupHost::AgentSchedulingGroupHost(RenderProcessHost& process)
: process_(process) { : AgentSchedulingGroupHost(
process,
!base::FeatureList::IsEnabled(
features::kMbiDetachAgentSchedulingGroupFromChannel)) {}
AgentSchedulingGroupHost::AgentSchedulingGroupHost(RenderProcessHost& process,
bool should_associate)
: process_(process),
receiver_(*this, should_associate),
mojo_remote_(should_associate) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
process_.GetRendererInterface()->CreateAgentSchedulingGroup( if (should_associate) {
receiver_.BindNewPipeAndPassRemote(), process_.GetRendererInterface()->CreateAssociatedAgentSchedulingGroup(
mojo_remote_.BindNewPipeAndPassReceiver()); receiver_.BindNewEndpointAndPassRemote(),
mojo_remote_.BindNewEndpointAndPassReceiver());
} else {
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
......
...@@ -11,8 +11,11 @@ ...@@ -11,8 +11,11 @@
#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 "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/remote.h"
#include "third_party/abseil-cpp/absl/types/variant.h"
namespace IPC { namespace IPC {
class ChannelProxy; class ChannelProxy;
...@@ -43,7 +46,8 @@ class CONTENT_EXPORT AgentSchedulingGroupHost ...@@ -43,7 +46,8 @@ class CONTENT_EXPORT AgentSchedulingGroupHost
static AgentSchedulingGroupHost* Get(const SiteInstance& instance, static AgentSchedulingGroupHost* Get(const SiteInstance& instance,
RenderProcessHost& process); RenderProcessHost& process);
// Should not be called explicitly. Use Get() instead. // Utility ctor, forwarding to the main ctor below.
// Should not be called explicitly. Use `Get()` instead.
explicit AgentSchedulingGroupHost(RenderProcessHost& process); explicit AgentSchedulingGroupHost(RenderProcessHost& process);
~AgentSchedulingGroupHost() override; ~AgentSchedulingGroupHost() override;
...@@ -64,16 +68,70 @@ class CONTENT_EXPORT AgentSchedulingGroupHost ...@@ -64,16 +68,70 @@ class CONTENT_EXPORT AgentSchedulingGroupHost
void DestroyView(int32_t routing_id); void DestroyView(int32_t routing_id);
private: private:
// `MaybeAssociatedReceiver` and `MaybeAssociatedRemote` are temporary helper
// classes that allow us to switch between using associated and non-associated
// mojo interfaces. This behavior is controlled by the
// `kMbiDetachAgentSchedulingGroupFromChannel` feature flag.
// Associated interfaces are associated with the IPC channel (transitively,
// via the `Renderer` interface), thus preserving cross-agent scheduling group
// message order. Non-associated interfaces are independent from each other
// and do not preserve message order between agent scheduling groups.
// TODO(crbug.com/1111231): Remove these once we can remove the flag.
class MaybeAssociatedReceiver {
public:
MaybeAssociatedReceiver(AgentSchedulingGroupHost& host,
bool should_associate);
~MaybeAssociatedReceiver();
mojo::PendingRemote<mojom::AgentSchedulingGroupHost>
BindNewPipeAndPassRemote() WARN_UNUSED_RESULT;
mojo::PendingAssociatedRemote<mojom::AgentSchedulingGroupHost>
BindNewEndpointAndPassRemote() WARN_UNUSED_RESULT;
private:
absl::variant<
// This is required to make the variant default constructible. After the
// ctor body finishes, the variant will never hold this alternative.
absl::monostate,
mojo::Receiver<mojom::AgentSchedulingGroupHost>,
mojo::AssociatedReceiver<mojom::AgentSchedulingGroupHost>>
receiver_;
};
class MaybeAssociatedRemote {
public:
explicit MaybeAssociatedRemote(bool should_associate);
~MaybeAssociatedRemote();
mojo::PendingReceiver<mojom::AgentSchedulingGroup>
BindNewPipeAndPassReceiver() WARN_UNUSED_RESULT;
mojo::PendingAssociatedReceiver<mojom::AgentSchedulingGroup>
BindNewEndpointAndPassReceiver() WARN_UNUSED_RESULT;
private:
absl::variant<mojo::Remote<mojom::AgentSchedulingGroup>,
mojo::AssociatedRemote<mojom::AgentSchedulingGroup>>
remote_;
};
// Main constructor.
// |should_associate| determines whether the `AgentSchedulingGroupHost` and
// `AgentSchedulingGroup` mojos should be associated with the `Renderer` or
// not. If they are, message order will be preserved across the entire
// process. If not, ordering will only be preserved inside an
// `AgentSchedulingGroup`.
AgentSchedulingGroupHost(RenderProcessHost& process, bool should_associate);
// The RenderProcessHost this AgentSchedulingGroup is assigned to. // The RenderProcessHost this AgentSchedulingGroup is assigned to.
RenderProcessHost& process_; RenderProcessHost& process_;
// Implementation of `mojom::AgentSchedulingGroupHost`, used for responding to // Implementation of `mojom::AgentSchedulingGroupHost`, used for responding to
// calls from the (renderer-side) `AgentSchedulingGroup`. // calls from the (renderer-side) `AgentSchedulingGroup`.
mojo::Receiver<mojom::AgentSchedulingGroupHost> receiver_{this}; MaybeAssociatedReceiver receiver_;
// Remote stub of `mojom::AgentSchedulingGroup`, used for sending calls to the // Remote stub of `mojom::AgentSchedulingGroup`, used for sending calls to the
// (renderer-side) `AgentSchedulingGroup`. // (renderer-side) `AgentSchedulingGroup`.
mojo::Remote<mojom::AgentSchedulingGroup> mojo_remote_; MaybeAssociatedRemote mojo_remote_;
}; };
} // namespace content } // namespace content
......
...@@ -260,12 +260,24 @@ interface Renderer { ...@@ -260,12 +260,24 @@ interface Renderer {
// Tells the renderer to create a new AgentSchedulingGroup, that will // Tells the renderer to create a new AgentSchedulingGroup, that will
// communicate via the pending |agent_scheduling_group_host| and // communicate via the pending |agent_scheduling_group_host| and
// |agent_scheduling_group|. // |agent_scheduling_group|. This will create "independent" interfaces that
// are not associated with the IPC channel, which will not guarantee any order
// across agent scheduling groups.
CreateAgentSchedulingGroup( CreateAgentSchedulingGroup(
pending_remote<AgentSchedulingGroupHost> agent_scheduling_group_host, pending_remote<AgentSchedulingGroupHost> agent_scheduling_group_host,
pending_receiver<AgentSchedulingGroup> agent_scheduling_group pending_receiver<AgentSchedulingGroup> agent_scheduling_group
); );
// Tells the renderer to create a new AgentSchedulingGroup, that will
// communicate via the pending |agent_scheduling_group_host| and
// |agent_scheduling_group|. This will create channel-associated interfaces
// that will preserve message ordering across agent scheduling groups.
CreateAssociatedAgentSchedulingGroup(
pending_associated_remote<AgentSchedulingGroupHost>
agent_scheduling_group_host,
pending_associated_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
// RenderView to be associated with this proxy. The new proxy's opener should // RenderView to be associated with this proxy. The new proxy's opener should
......
...@@ -349,6 +349,14 @@ const base::Feature kLogJsConsoleMessages { ...@@ -349,6 +349,14 @@ const base::Feature kLogJsConsoleMessages {
const base::Feature kLowPriorityIframes{"LowPriorityIframes", const base::Feature kLowPriorityIframes{"LowPriorityIframes",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
// Removes the association between the `AgentSchedulingGroup` interfaces and the
// IPC Channel. This will break ordering guarantees between different agent
// scheduling groups (ordering withing a group is still preserved).
// DO NOT USE! The feature is not yet fully implemented. See crbug.com/1111231.
const base::Feature kMbiDetachAgentSchedulingGroupFromChannel{
"MbiDetachAgentSchedulingGroupFromChannel",
base::FEATURE_DISABLED_BY_DEFAULT};
// If this feature is enabled, media-device enumerations use a cache that is // If this feature is enabled, media-device enumerations use a cache that is
// invalidated upon notifications sent by base::SystemMonitor. If disabled, the // invalidated upon notifications sent by base::SystemMonitor. If disabled, the
// cache is considered invalid on every enumeration request. // cache is considered invalid on every enumeration request.
......
...@@ -82,6 +82,8 @@ CONTENT_EXPORT extern const base::Feature kLazyInitializeMediaControls; ...@@ -82,6 +82,8 @@ CONTENT_EXPORT extern const base::Feature kLazyInitializeMediaControls;
CONTENT_EXPORT extern const base::Feature kLegacyWindowsDWriteFontFallback; CONTENT_EXPORT extern const base::Feature kLegacyWindowsDWriteFontFallback;
CONTENT_EXPORT extern const base::Feature kLogJsConsoleMessages; CONTENT_EXPORT extern const base::Feature kLogJsConsoleMessages;
CONTENT_EXPORT extern const base::Feature kLowPriorityIframes; CONTENT_EXPORT extern const base::Feature kLowPriorityIframes;
CONTENT_EXPORT extern const base::Feature
kMbiDetachAgentSchedulingGroupFromChannel;
CONTENT_EXPORT extern const base::Feature kMediaDevicesSystemMonitorCache; CONTENT_EXPORT extern const base::Feature kMediaDevicesSystemMonitorCache;
CONTENT_EXPORT extern const base::Feature kMojoDedicatedThread; CONTENT_EXPORT extern const base::Feature kMojoDedicatedThread;
CONTENT_EXPORT extern const base::Feature kMojoVideoCapture; CONTENT_EXPORT extern const base::Feature kMojoVideoCapture;
......
...@@ -4,19 +4,92 @@ ...@@ -4,19 +4,92 @@
#include "content/renderer/agent_scheduling_group.h" #include "content/renderer/agent_scheduling_group.h"
#include "base/feature_list.h"
#include "content/public/common/content_features.h"
namespace content { namespace content {
using ::mojo::AssociatedReceiver;
using ::mojo::AssociatedRemote;
using ::mojo::PendingAssociatedReceiver;
using ::mojo::PendingAssociatedRemote;
using ::mojo::PendingReceiver;
using ::mojo::PendingRemote;
using ::mojo::Receiver;
using ::mojo::Remote;
// MaybeAssociatedReceiver:
AgentSchedulingGroup::MaybeAssociatedReceiver::MaybeAssociatedReceiver(
AgentSchedulingGroup& impl,
PendingReceiver<mojom::AgentSchedulingGroup> receiver,
base::OnceClosure disconnect_handler)
: receiver_(absl::in_place_type<Receiver<mojom::AgentSchedulingGroup>>,
&impl,
std::move(receiver)) {
if (disconnect_handler)
absl::get<Receiver<mojom::AgentSchedulingGroup>>(receiver_)
.set_disconnect_handler(std::move(disconnect_handler));
}
AgentSchedulingGroup::MaybeAssociatedReceiver::MaybeAssociatedReceiver(
AgentSchedulingGroup& impl,
PendingAssociatedReceiver<mojom::AgentSchedulingGroup> receiver,
base::OnceClosure disconnect_handler)
: receiver_(
absl::in_place_type<AssociatedReceiver<mojom::AgentSchedulingGroup>>,
&impl,
std::move(receiver)) {
if (disconnect_handler)
absl::get<AssociatedReceiver<mojom::AgentSchedulingGroup>>(receiver_)
.set_disconnect_handler(std::move(disconnect_handler));
}
AgentSchedulingGroup::MaybeAssociatedReceiver::~MaybeAssociatedReceiver() =
default;
// MaybeAssociatedRemote:
AgentSchedulingGroup::MaybeAssociatedRemote::MaybeAssociatedRemote(
PendingRemote<mojom::AgentSchedulingGroupHost> host_remote)
: remote_(absl::in_place_type<Remote<mojom::AgentSchedulingGroupHost>>,
std::move(host_remote)) {}
AgentSchedulingGroup::MaybeAssociatedRemote::MaybeAssociatedRemote(
PendingAssociatedRemote<mojom::AgentSchedulingGroupHost> host_remote)
: remote_(absl::in_place_type<
AssociatedRemote<mojom::AgentSchedulingGroupHost>>,
std::move(host_remote)) {}
AgentSchedulingGroup::MaybeAssociatedRemote::~MaybeAssociatedRemote() = default;
// AgentSchedulingGroup:
AgentSchedulingGroup::AgentSchedulingGroup(
PendingRemote<mojom::AgentSchedulingGroupHost> host_remote,
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),
base::BindOnce(std::move(mojo_disconnect_handler), this)),
host_remote_(std::move(host_remote)) {
DCHECK(base::FeatureList::IsEnabled(
features::kMbiDetachAgentSchedulingGroupFromChannel));
}
AgentSchedulingGroup::AgentSchedulingGroup( AgentSchedulingGroup::AgentSchedulingGroup(
mojo::PendingRemote<mojom::AgentSchedulingGroupHost> host_remote, PendingAssociatedRemote<mojom::AgentSchedulingGroupHost> host_remote,
mojo::PendingReceiver<mojom::AgentSchedulingGroup> receiver, PendingAssociatedReceiver<mojom::AgentSchedulingGroup> receiver,
base::OnceCallback<void(const AgentSchedulingGroup*)> base::OnceCallback<void(const AgentSchedulingGroup*)>
mojo_disconnect_handler) mojo_disconnect_handler)
// TODO(crbug.com/1111231): Mojo interfaces should be associated with // TODO(crbug.com/1111231): Mojo interfaces should be associated with
// per-ASG task runners instead of default. // per-ASG task runners instead of default.
: receiver_(this, std::move(receiver)), : receiver_(*this,
std::move(receiver),
base::BindOnce(std::move(mojo_disconnect_handler), this)),
host_remote_(std::move(host_remote)) { host_remote_(std::move(host_remote)) {
receiver_.set_disconnect_handler( DCHECK(!base::FeatureList::IsEnabled(
base::BindOnce(std::move(mojo_disconnect_handler), this)); features::kMbiDetachAgentSchedulingGroupFromChannel));
} }
AgentSchedulingGroup::~AgentSchedulingGroup() = default; AgentSchedulingGroup::~AgentSchedulingGroup() = default;
......
...@@ -8,8 +8,11 @@ ...@@ -8,8 +8,11 @@
#include "base/callback.h" #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/associated_receiver.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/remote.h"
#include "third_party/abseil-cpp/absl/types/variant.h"
namespace content { namespace content {
...@@ -27,6 +30,12 @@ class CONTENT_EXPORT AgentSchedulingGroup : public mojom::AgentSchedulingGroup { ...@@ -27,6 +30,12 @@ class CONTENT_EXPORT AgentSchedulingGroup : public mojom::AgentSchedulingGroup {
mojo::PendingReceiver<mojom::AgentSchedulingGroup> receiver, mojo::PendingReceiver<mojom::AgentSchedulingGroup> receiver,
base::OnceCallback<void(const AgentSchedulingGroup*)> base::OnceCallback<void(const AgentSchedulingGroup*)>
mojo_disconnect_handler); mojo_disconnect_handler);
AgentSchedulingGroup(
mojo::PendingAssociatedRemote<mojom::AgentSchedulingGroupHost>
host_remote,
mojo::PendingAssociatedReceiver<mojom::AgentSchedulingGroup> receiver,
base::OnceCallback<void(const AgentSchedulingGroup*)>
mojo_disconnect_handler);
~AgentSchedulingGroup() override; ~AgentSchedulingGroup() override;
AgentSchedulingGroup(const AgentSchedulingGroup&) = delete; AgentSchedulingGroup(const AgentSchedulingGroup&) = delete;
...@@ -35,13 +44,55 @@ class CONTENT_EXPORT AgentSchedulingGroup : public mojom::AgentSchedulingGroup { ...@@ -35,13 +44,55 @@ class CONTENT_EXPORT AgentSchedulingGroup : public mojom::AgentSchedulingGroup {
AgentSchedulingGroup& operator=(const AgentSchedulingGroup&&) = delete; AgentSchedulingGroup& operator=(const AgentSchedulingGroup&&) = delete;
private: private:
// `MaybeAssociatedReceiver` and `MaybeAssociatedRemote` are temporary helper
// classes that allow us to switch between using associated and non-associated
// mojo interfaces. This behavior is controlled by the
// `kMbiDetachAgentSchedulingGroupFromChannel` feature flag.
// Associated interfaces are associated with the IPC channel (transitively,
// via the `Renderer` interface), thus preserving cross-agent scheduling group
// message order. Non-associated interfaces are independent from each other
// and do not preserve message order between agent scheduling groups.
// TODO(crbug.com/1111231): Remove these once we can remove the flag.
class MaybeAssociatedReceiver {
public:
MaybeAssociatedReceiver(
AgentSchedulingGroup& impl,
mojo::PendingReceiver<mojom::AgentSchedulingGroup> receiver,
base::OnceClosure disconnect_handler);
MaybeAssociatedReceiver(
AgentSchedulingGroup& impl,
mojo::PendingAssociatedReceiver<mojom::AgentSchedulingGroup> receiver,
base::OnceClosure disconnect_handler);
~MaybeAssociatedReceiver();
private:
absl::variant<mojo::Receiver<mojom::AgentSchedulingGroup>,
mojo::AssociatedReceiver<mojom::AgentSchedulingGroup>>
receiver_;
};
class MaybeAssociatedRemote {
public:
explicit MaybeAssociatedRemote(
mojo::PendingRemote<mojom::AgentSchedulingGroupHost> host_remote);
explicit MaybeAssociatedRemote(
mojo::PendingAssociatedRemote<mojom::AgentSchedulingGroupHost>
host_remote);
~MaybeAssociatedRemote();
private:
absl::variant<mojo::Remote<mojom::AgentSchedulingGroupHost>,
mojo::AssociatedRemote<mojom::AgentSchedulingGroupHost>>
remote_;
};
// Implementation of `mojom::AgentSchedulingGroup`, used for responding to // Implementation of `mojom::AgentSchedulingGroup`, used for responding to
// calls from the (browser-side) `AgentSchedulingGroupHost`. // calls from the (browser-side) `AgentSchedulingGroupHost`.
mojo::Receiver<mojom::AgentSchedulingGroup> receiver_; MaybeAssociatedReceiver receiver_;
// Remote stub of mojom::AgentSchedulingGroupHost, used for sending calls to // Remote stub of mojom::AgentSchedulingGroupHost, used for sending calls to
// the (browser-side) AgentSchedulingGroupHost. // the (browser-side) AgentSchedulingGroupHost.
mojo::Remote<mojom::AgentSchedulingGroupHost> host_remote_; MaybeAssociatedRemote host_remote_;
}; };
} // namespace content } // namespace content
......
...@@ -1875,6 +1875,16 @@ void RenderThreadImpl::CreateAgentSchedulingGroup( ...@@ -1875,6 +1875,16 @@ void RenderThreadImpl::CreateAgentSchedulingGroup(
remove_agent_scheduling_group_callback_)); remove_agent_scheduling_group_callback_));
} }
void RenderThreadImpl::CreateAssociatedAgentSchedulingGroup(
mojo::PendingAssociatedRemote<mojom::AgentSchedulingGroupHost>
agent_scheduling_group_host,
mojo::PendingAssociatedReceiver<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(
int32_t routing_id, int32_t routing_id,
int32_t render_view_routing_id, int32_t render_view_routing_id,
......
...@@ -448,6 +448,11 @@ class CONTENT_EXPORT RenderThreadImpl ...@@ -448,6 +448,11 @@ class CONTENT_EXPORT RenderThreadImpl
agent_scheduling_group_host, agent_scheduling_group_host,
mojo::PendingReceiver<mojom::AgentSchedulingGroup> agent_scheduling_group) mojo::PendingReceiver<mojom::AgentSchedulingGroup> agent_scheduling_group)
override; override;
void CreateAssociatedAgentSchedulingGroup(
mojo::PendingAssociatedRemote<mojom::AgentSchedulingGroupHost>
agent_scheduling_group_host,
mojo::PendingAssociatedReceiver<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,
......
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