Commit 01a03fc7 authored by Tal Pressman's avatar Tal Pressman Committed by Commit Bot

[MBI] Stop consulting RenderProcessHost/RenderThread on IPC listener lookup.

All listeners should be registered on the AgentSchedulingGroup(Host), so
there shouldn't be a need for this delegation.
This follows-up on a comment from crrev.com/c/2513958.

Bug: 1111231
Change-Id: I69e13cbc1cadd1c7d2dc7b5b425353adabd4c364
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2526667
Commit-Queue: Tal Pressman <talp@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Reviewed-by: default avatarDominic Farolino <dom@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826602}
parent 60944a5f
......@@ -7,12 +7,12 @@
#include "base/feature_list.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/common/agent_scheduling_group.mojom.h"
#include "content/common/renderer.mojom.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/content_features.h"
#include "ipc/ipc_message.h"
namespace content {
......@@ -29,8 +29,6 @@ using ::mojo::PendingRemote;
using ::mojo::Receiver;
using ::mojo::Remote;
using PassKey = ::util::PassKey<AgentSchedulingGroupHost>;
static constexpr char kAgentGroupHostDataKey[] =
"AgentSchedulingGroupHostUserDataKey";
......@@ -49,10 +47,6 @@ class AgentGroupHostUserData : public base::SupportsUserData::Data {
std::unique_ptr<AgentSchedulingGroupHost> agent_group_;
};
RenderProcessHostImpl& ToImpl(RenderProcessHost& process) {
return static_cast<RenderProcessHostImpl&>(process);
}
} // namespace
// MaybeAssociatedReceiver:
......@@ -349,15 +343,9 @@ void AgentSchedulingGroupHost::SetUpMojoIfNeeded() {
}
Listener* AgentSchedulingGroupHost::GetListener(int32_t routing_id) {
if (routing_id == MSG_ROUTING_CONTROL)
return &process_;
if (auto* listener = listener_map_.Lookup(routing_id))
return listener;
DCHECK_NE(routing_id, MSG_ROUTING_CONTROL);
// TODO(crbug.com/1111231): Can/should we log it when we find the listener on
// the process but not here?
return ToImpl(process_).GetListener(PassKey(), routing_id);
return listener_map_.Lookup(routing_id);
}
} // namespace content
......@@ -2526,12 +2526,6 @@ void RenderProcessHostImpl::RegisterMojoInterfaces() {
std::move(registry), std::move(child_host_pending_receiver_));
}
IPC::Listener* RenderProcessHostImpl::GetListener(
util::PassKey<AgentSchedulingGroupHost>,
int32_t routing_id) {
return listeners_.Lookup(routing_id);
}
void RenderProcessHostImpl::CreateEmbeddedFrameSinkProvider(
mojo::PendingReceiver<blink::mojom::EmbeddedFrameSinkProvider> receiver) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
......
......@@ -762,12 +762,6 @@ class CONTENT_EXPORT RenderProcessHostImpl
// Registers Mojo interfaces to be exposed to the renderer.
void RegisterMojoInterfaces();
// TODO(crbug.com/1132901): We'll be able to remove this method once
// `AgentSchedulingGroupHost` maintains its own map of IPC::Listeners, but for
// now we'll let it delegate to this class.
IPC::Listener* GetListener(util::PassKey<AgentSchedulingGroupHost>,
int32_t routing_id);
// mojom::RendererHost
using BrowserHistogramCallback =
mojom::RendererHost::GetBrowserHistogramCallback;
......
......@@ -843,8 +843,4 @@ bool ChildThreadImpl::IsInBrowserProcess() const {
return static_cast<bool>(browser_process_io_runner_);
}
IPC::Listener* ChildThreadImpl::GetListener(int32_t routing_id) {
return router_.GetRoute(routing_id);
}
} // namespace content
......@@ -161,11 +161,6 @@ class CONTENT_EXPORT ChildThreadImpl : public IPC::Listener,
bool IsInBrowserProcess() const;
// TODO(1132901) We'll be able to move this method once |AgentSchedulingGroup|
// maintains its own map of IPC::Listeners, but for now we'll let it delegate
// to this class.
virtual IPC::Listener* GetListener(int32_t routing_id);
private:
// TODO(crbug.com/1111231): This class is a friend so that it can call our
// private mojo implementation methods, acting as a pass-through. This is only
......
......@@ -234,15 +234,9 @@ void AgentSchedulingGroup::GetAssociatedInterface(
}
Listener* AgentSchedulingGroup::GetListener(int32_t routing_id) {
if (routing_id == MSG_ROUTING_CONTROL)
return &ToImpl(render_thread_);
DCHECK_NE(routing_id, MSG_ROUTING_CONTROL);
if (auto* listener = listener_map_.Lookup(routing_id))
return listener;
// TODO(crbug.com/1111231): Can/should we log it when we find the listener on
// the render thread but not here?
return ToImpl(render_thread_).GetListener(routing_id);
return listener_map_.Lookup(routing_id);
}
} // namespace content
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