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 @@ ...@@ -7,12 +7,12 @@
#include "base/feature_list.h" #include "base/feature_list.h"
#include "base/supports_user_data.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/browser/renderer_host/render_process_host_impl.h"
#include "content/common/agent_scheduling_group.mojom.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" #include "content/public/common/content_features.h"
#include "ipc/ipc_message.h"
namespace content { namespace content {
...@@ -29,8 +29,6 @@ using ::mojo::PendingRemote; ...@@ -29,8 +29,6 @@ using ::mojo::PendingRemote;
using ::mojo::Receiver; using ::mojo::Receiver;
using ::mojo::Remote; using ::mojo::Remote;
using PassKey = ::util::PassKey<AgentSchedulingGroupHost>;
static constexpr char kAgentGroupHostDataKey[] = static constexpr char kAgentGroupHostDataKey[] =
"AgentSchedulingGroupHostUserDataKey"; "AgentSchedulingGroupHostUserDataKey";
...@@ -49,10 +47,6 @@ class AgentGroupHostUserData : public base::SupportsUserData::Data { ...@@ -49,10 +47,6 @@ class AgentGroupHostUserData : public base::SupportsUserData::Data {
std::unique_ptr<AgentSchedulingGroupHost> agent_group_; std::unique_ptr<AgentSchedulingGroupHost> agent_group_;
}; };
RenderProcessHostImpl& ToImpl(RenderProcessHost& process) {
return static_cast<RenderProcessHostImpl&>(process);
}
} // namespace } // namespace
// MaybeAssociatedReceiver: // MaybeAssociatedReceiver:
...@@ -349,15 +343,9 @@ void AgentSchedulingGroupHost::SetUpMojoIfNeeded() { ...@@ -349,15 +343,9 @@ void AgentSchedulingGroupHost::SetUpMojoIfNeeded() {
} }
Listener* AgentSchedulingGroupHost::GetListener(int32_t routing_id) { Listener* AgentSchedulingGroupHost::GetListener(int32_t routing_id) {
if (routing_id == MSG_ROUTING_CONTROL) DCHECK_NE(routing_id, MSG_ROUTING_CONTROL);
return &process_;
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 return listener_map_.Lookup(routing_id);
// the process but not here?
return ToImpl(process_).GetListener(PassKey(), routing_id);
} }
} // namespace content } // namespace content
...@@ -2526,12 +2526,6 @@ void RenderProcessHostImpl::RegisterMojoInterfaces() { ...@@ -2526,12 +2526,6 @@ void RenderProcessHostImpl::RegisterMojoInterfaces() {
std::move(registry), std::move(child_host_pending_receiver_)); 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( void RenderProcessHostImpl::CreateEmbeddedFrameSinkProvider(
mojo::PendingReceiver<blink::mojom::EmbeddedFrameSinkProvider> receiver) { mojo::PendingReceiver<blink::mojom::EmbeddedFrameSinkProvider> receiver) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
......
...@@ -762,12 +762,6 @@ class CONTENT_EXPORT RenderProcessHostImpl ...@@ -762,12 +762,6 @@ class CONTENT_EXPORT RenderProcessHostImpl
// Registers Mojo interfaces to be exposed to the renderer. // Registers Mojo interfaces to be exposed to the renderer.
void RegisterMojoInterfaces(); 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 // mojom::RendererHost
using BrowserHistogramCallback = using BrowserHistogramCallback =
mojom::RendererHost::GetBrowserHistogramCallback; mojom::RendererHost::GetBrowserHistogramCallback;
......
...@@ -843,8 +843,4 @@ bool ChildThreadImpl::IsInBrowserProcess() const { ...@@ -843,8 +843,4 @@ bool ChildThreadImpl::IsInBrowserProcess() const {
return static_cast<bool>(browser_process_io_runner_); return static_cast<bool>(browser_process_io_runner_);
} }
IPC::Listener* ChildThreadImpl::GetListener(int32_t routing_id) {
return router_.GetRoute(routing_id);
}
} // namespace content } // namespace content
...@@ -161,11 +161,6 @@ class CONTENT_EXPORT ChildThreadImpl : public IPC::Listener, ...@@ -161,11 +161,6 @@ class CONTENT_EXPORT ChildThreadImpl : public IPC::Listener,
bool IsInBrowserProcess() const; 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: private:
// TODO(crbug.com/1111231): This class is a friend so that it can call our // 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 // private mojo implementation methods, acting as a pass-through. This is only
......
...@@ -234,15 +234,9 @@ void AgentSchedulingGroup::GetAssociatedInterface( ...@@ -234,15 +234,9 @@ void AgentSchedulingGroup::GetAssociatedInterface(
} }
Listener* AgentSchedulingGroup::GetListener(int32_t routing_id) { Listener* AgentSchedulingGroup::GetListener(int32_t routing_id) {
if (routing_id == MSG_ROUTING_CONTROL) DCHECK_NE(routing_id, MSG_ROUTING_CONTROL);
return &ToImpl(render_thread_);
if (auto* listener = listener_map_.Lookup(routing_id)) return 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);
} }
} // namespace content } // 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