Skip to content

Commit

Permalink
Mojo: Remove MessageQuotaChecker
Browse files Browse the repository at this point in the history
This is effectively dead code, enabled only by feature flags which must
be manually enabled and which were added for investigations that are
no longer being done. The feature flags are also removed.

Fixed: 1399511
Change-Id: I3e6462c728c1ee39848670a2bff4f29be61f1865
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4093879
Reviewed-by: Oksana Zhuravlova <oksamyt@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Ken Rockot <rockot@google.com>
Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1082320}
  • Loading branch information
krockot authored and Chromium LUCI CQ committed Dec 13, 2022
1 parent 6fa0640 commit 7308d4b
Show file tree
Hide file tree
Showing 21 changed files with 34 additions and 1,044 deletions.
7 changes: 2 additions & 5 deletions content/common/child_process_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "ipc/ipc_channel_mojo.h"
#include "ipc/ipc_logging.h"
#include "ipc/message_filter.h"
#include "mojo/public/cpp/bindings/lib/message_quota_checker.h"
#include "services/resource_coordinator/public/mojom/memory_instrumentation/constants.mojom.h"
#include "services/service_manager/public/cpp/interface_provider.h"

Expand Down Expand Up @@ -126,8 +125,7 @@ ChildProcessHostImpl::ChildProcessHostImpl(ChildProcessHostDelegate* delegate,
kChildProcessReceiverAttachmentName),
IPC::Channel::MODE_SERVER, this,
base::SingleThreadTaskRunner::GetCurrentDefault(),
base::SingleThreadTaskRunner::GetCurrentDefault(),
mojo::internal::MessageQuotaChecker::MaybeCreate());
base::SingleThreadTaskRunner::GetCurrentDefault());
} else if (ipc_mode_ == IpcMode::kNormal) {
child_process_.Bind(mojo::PendingRemote<mojom::ChildProcess>(
mojo_invitation_->AttachMessagePipe(
Expand Down Expand Up @@ -223,8 +221,7 @@ void ChildProcessHostImpl::CreateChannelMojo() {
channel_ = IPC::ChannelMojo::Create(
std::move(bootstrap), IPC::Channel::MODE_SERVER, this,
base::SingleThreadTaskRunner::GetCurrentDefault(),
base::SingleThreadTaskRunner::GetCurrentDefault(),
mojo::internal::MessageQuotaChecker::MaybeCreate());
base::SingleThreadTaskRunner::GetCurrentDefault());
}
DCHECK(channel_);

Expand Down
7 changes: 3 additions & 4 deletions gpu/ipc/client/gpu_channel_host.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "gpu/ipc/common/command_buffer_id.h"
#include "gpu/ipc/common/gpu_watchdog_timeout.h"
#include "ipc/ipc_channel_mojo.h"
#include "mojo/public/cpp/bindings/lib/message_quota_checker.h"
#include "mojo/public/cpp/bindings/sync_call_restrictions.h"
#include "url/gurl.h"

Expand Down Expand Up @@ -215,9 +214,9 @@ void GpuChannelHost::Listener::Initialize(
mojo::PendingAssociatedReceiver<mojom::GpuChannel> receiver,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) {
base::AutoLock lock(lock_);
channel_ = IPC::ChannelMojo::Create(
std::move(handle), IPC::Channel::MODE_CLIENT, this, io_task_runner,
io_task_runner, mojo::internal::MessageQuotaChecker::MaybeCreate());
channel_ =
IPC::ChannelMojo::Create(std::move(handle), IPC::Channel::MODE_CLIENT,
this, io_task_runner, io_task_runner);
DCHECK(channel_);
bool result = channel_->Connect();
DCHECK(result);
Expand Down
7 changes: 2 additions & 5 deletions ipc/ipc_channel_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "build/build_config.h"
#include "ipc/ipc_channel.h"
#include "ipc/ipc_channel_mojo.h"
#include "mojo/public/cpp/bindings/lib/message_quota_checker.h"
#include "mojo/public/cpp/system/message_pipe.h"

namespace IPC {
Expand Down Expand Up @@ -41,8 +40,7 @@ std::unique_ptr<Channel> Channel::CreateClient(
return ChannelMojo::Create(
mojo::ScopedMessagePipeHandle(channel_handle.mojo_handle),
Channel::MODE_CLIENT, listener, ipc_task_runner,
base::SingleThreadTaskRunner::GetCurrentDefault(),
mojo::internal::MessageQuotaChecker::MaybeCreate());
base::SingleThreadTaskRunner::GetCurrentDefault());
#endif
}

Expand All @@ -58,8 +56,7 @@ std::unique_ptr<Channel> Channel::CreateServer(
return ChannelMojo::Create(
mojo::ScopedMessagePipeHandle(channel_handle.mojo_handle),
Channel::MODE_SERVER, listener, ipc_task_runner,
base::SingleThreadTaskRunner::GetCurrentDefault(),
mojo::internal::MessageQuotaChecker::MaybeCreate());
base::SingleThreadTaskRunner::GetCurrentDefault());
#endif
}

Expand Down
15 changes: 2 additions & 13 deletions ipc/ipc_channel_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "base/task/single_thread_task_runner.h"
#include "build/build_config.h"
#include "ipc/ipc_channel_mojo.h"
#include "mojo/public/cpp/bindings/lib/message_quota_checker.h"

namespace IPC {

Expand All @@ -20,10 +19,7 @@ class PlatformChannelFactory : public ChannelFactory {
ChannelHandle handle,
Channel::Mode mode,
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner)
: handle_(handle),
mode_(mode),
ipc_task_runner_(ipc_task_runner),
quota_checker_(mojo::internal::MessageQuotaChecker::MaybeCreate()) {}
: handle_(handle), mode_(mode), ipc_task_runner_(ipc_task_runner) {}

PlatformChannelFactory(const PlatformChannelFactory&) = delete;
PlatformChannelFactory& operator=(const PlatformChannelFactory&) = delete;
Expand All @@ -35,25 +31,18 @@ class PlatformChannelFactory : public ChannelFactory {
DCHECK(handle_.is_mojo_channel_handle());
return ChannelMojo::Create(
mojo::ScopedMessagePipeHandle(handle_.mojo_handle), mode_, listener,
ipc_task_runner_, base::SingleThreadTaskRunner::GetCurrentDefault(),
quota_checker_);
ipc_task_runner_, base::SingleThreadTaskRunner::GetCurrentDefault());
#endif
}

scoped_refptr<base::SingleThreadTaskRunner> GetIPCTaskRunner() override {
return ipc_task_runner_;
}

scoped_refptr<mojo::internal::MessageQuotaChecker> GetQuotaChecker()
override {
return quota_checker_;
}

private:
ChannelHandle handle_;
Channel::Mode mode_;
scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner_;
scoped_refptr<mojo::internal::MessageQuotaChecker> quota_checker_;
};

} // namespace
Expand Down
8 changes: 0 additions & 8 deletions ipc/ipc_channel_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@
#include "base/task/single_thread_task_runner.h"
#include "ipc/ipc_channel.h"

namespace mojo {
namespace internal {
class MessageQuotaChecker;
} // namespace internal
} // namespace mojo

namespace IPC {

// Encapsulates how a Channel is created. A ChannelFactory can be
Expand All @@ -37,8 +31,6 @@ class COMPONENT_EXPORT(IPC) ChannelFactory {
virtual ~ChannelFactory() { }
virtual std::unique_ptr<Channel> BuildChannel(Listener* listener) = 0;
virtual scoped_refptr<base::SingleThreadTaskRunner> GetIPCTaskRunner() = 0;
virtual scoped_refptr<mojo::internal::MessageQuotaChecker>
GetQuotaChecker() = 0;
};

} // namespace IPC
Expand Down
24 changes: 6 additions & 18 deletions ipc/ipc_channel_mojo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/generic_pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/lib/message_quota_checker.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/thread_safe_proxy.h"
#include "mojo/public/cpp/system/platform_handle.h"
Expand All @@ -49,33 +48,25 @@ class MojoChannelFactory : public ChannelFactory {
: handle_(std::move(handle)),
mode_(mode),
ipc_task_runner_(ipc_task_runner),
proxy_task_runner_(proxy_task_runner),
quota_checker_(mojo::internal::MessageQuotaChecker::MaybeCreate()) {}
proxy_task_runner_(proxy_task_runner) {}

MojoChannelFactory(const MojoChannelFactory&) = delete;
MojoChannelFactory& operator=(const MojoChannelFactory&) = delete;

std::unique_ptr<Channel> BuildChannel(Listener* listener) override {
return ChannelMojo::Create(std::move(handle_), mode_, listener,
ipc_task_runner_, proxy_task_runner_,
quota_checker_);
ipc_task_runner_, proxy_task_runner_);
}

scoped_refptr<base::SingleThreadTaskRunner> GetIPCTaskRunner() override {
return ipc_task_runner_;
}

scoped_refptr<mojo::internal::MessageQuotaChecker> GetQuotaChecker()
override {
return quota_checker_;
}

private:
mojo::ScopedMessagePipeHandle handle_;
const Channel::Mode mode_;
scoped_refptr<base::SingleThreadTaskRunner> ipc_task_runner_;
scoped_refptr<base::SingleThreadTaskRunner> proxy_task_runner_;
scoped_refptr<mojo::internal::MessageQuotaChecker> quota_checker_;
};

class ThreadSafeChannelProxy : public mojo::ThreadSafeProxy {
Expand Down Expand Up @@ -135,11 +126,9 @@ std::unique_ptr<ChannelMojo> ChannelMojo::Create(
Mode mode,
Listener* listener,
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner,
const scoped_refptr<base::SingleThreadTaskRunner>& proxy_task_runner,
const scoped_refptr<mojo::internal::MessageQuotaChecker>& quota_checker) {
const scoped_refptr<base::SingleThreadTaskRunner>& proxy_task_runner) {
return base::WrapUnique(new ChannelMojo(std::move(handle), mode, listener,
ipc_task_runner, proxy_task_runner,
quota_checker));
ipc_task_runner, proxy_task_runner));
}

// static
Expand Down Expand Up @@ -167,12 +156,11 @@ ChannelMojo::ChannelMojo(
Mode mode,
Listener* listener,
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner,
const scoped_refptr<base::SingleThreadTaskRunner>& proxy_task_runner,
const scoped_refptr<mojo::internal::MessageQuotaChecker>& quota_checker)
const scoped_refptr<base::SingleThreadTaskRunner>& proxy_task_runner)
: task_runner_(ipc_task_runner), pipe_(handle.get()), listener_(listener) {
weak_ptr_ = weak_factory_.GetWeakPtr();
bootstrap_ = MojoBootstrap::Create(std::move(handle), mode, ipc_task_runner,
proxy_task_runner, quota_checker);
proxy_task_runner);
}

void ChannelMojo::ForwardMessage(mojo::Message message) {
Expand Down
6 changes: 2 additions & 4 deletions ipc/ipc_channel_mojo.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ class COMPONENT_EXPORT(IPC) ChannelMojo
Mode mode,
Listener* listener,
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner,
const scoped_refptr<base::SingleThreadTaskRunner>& proxy_task_runner,
const scoped_refptr<mojo::internal::MessageQuotaChecker>& quota_checker);
const scoped_refptr<base::SingleThreadTaskRunner>& proxy_task_runner);

// Create a factory object for ChannelMojo.
// The factory is used to create Mojo-based ChannelProxy family.
Expand Down Expand Up @@ -102,8 +101,7 @@ class COMPONENT_EXPORT(IPC) ChannelMojo
Mode mode,
Listener* listener,
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner,
const scoped_refptr<base::SingleThreadTaskRunner>& proxy_task_runner,
const scoped_refptr<mojo::internal::MessageQuotaChecker>& quota_checker);
const scoped_refptr<base::SingleThreadTaskRunner>& proxy_task_runner);

void ForwardMessage(mojo::Message message);

Expand Down
9 changes: 0 additions & 9 deletions ipc/ipc_channel_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,6 @@ void ChannelProxy::Context::Clear() {

// Called on the IPC::Channel thread
void ChannelProxy::Context::OnSendMessage(std::unique_ptr<Message> message) {
if (quota_checker_)
quota_checker_->AfterMessagesDequeued(1);

if (!channel_) {
OnChannelClosed();
return;
Expand Down Expand Up @@ -422,9 +419,6 @@ void ChannelProxy::Context::AddGenericAssociatedInterfaceForIOThread(
}

void ChannelProxy::Context::Send(Message* message) {
if (quota_checker_)
quota_checker_->BeforeMessagesEnqueued(1);

ipc_task_runner()->PostTask(
FROM_HERE, base::BindOnce(&ChannelProxy::Context::OnSendMessage, this,
base::WrapUnique(message)));
Expand Down Expand Up @@ -503,9 +497,6 @@ void ChannelProxy::Init(std::unique_ptr<ChannelFactory> factory,
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(!did_init_);

DCHECK(!context_->quota_checker_);
context_->quota_checker_ = factory->GetQuotaChecker();

if (create_pipe_now) {
// Create the channel immediately. This effectively sets up the
// low-level pipe so that the client can connect. Without creating
Expand Down
4 changes: 0 additions & 4 deletions ipc/ipc_channel_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "ipc/ipc_sender.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/generic_pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/lib/message_quota_checker.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_associated_remote.h"
#include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
Expand Down Expand Up @@ -368,9 +367,6 @@ class COMPONENT_EXPORT(IPC) ChannelProxy : public Sender {
std::unique_ptr<Channel> channel_;
bool channel_connected_called_;

// The quota checker associated with this channel, if any.
scoped_refptr<mojo::internal::MessageQuotaChecker> quota_checker_;

// Lock for |channel_| value. This is only relevant in the context of
// thread-safe send.
base::Lock channel_lifetime_lock_;
Expand Down
23 changes: 5 additions & 18 deletions ipc/ipc_mojo_bootstrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,9 @@ class ChannelAssociatedGroupController
ChannelAssociatedGroupController(
bool set_interface_id_namespace_bit,
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner,
const scoped_refptr<base::SingleThreadTaskRunner>& proxy_task_runner,
const scoped_refptr<mojo::internal::MessageQuotaChecker>& quota_checker)
const scoped_refptr<base::SingleThreadTaskRunner>& proxy_task_runner)
: task_runner_(ipc_task_runner),
proxy_task_runner_(proxy_task_runner),
quota_checker_(quota_checker),
set_interface_id_namespace_bit_(set_interface_id_namespace_bit),
dispatcher_(this),
control_message_handler_(this),
Expand Down Expand Up @@ -202,8 +200,6 @@ class ChannelAssociatedGroupController
base::AutoLock lock(outgoing_messages_lock_);
std::swap(outgoing_messages, outgoing_messages_);
}
if (quota_checker_ && outgoing_messages.size())
quota_checker_->AfterMessagesDequeued(outgoing_messages.size());

for (auto& message : outgoing_messages)
SendMessage(&message);
Expand All @@ -220,8 +216,6 @@ class ChannelAssociatedGroupController
base::BindOnce(&ChannelAssociatedGroupController::OnPipeError,
base::Unretained(this)));
connector_->set_enforce_errors_from_incoming_receiver(false);
if (quota_checker_)
connector_->SetMessageQuotaChecker(quota_checker_);

// Don't let the Connector do any sort of queuing on our behalf. Individual
// messages bound for the IPC::ChannelProxy thread (i.e. that vast majority
Expand Down Expand Up @@ -272,9 +266,6 @@ class ChannelAssociatedGroupController
connector_.reset();

base::AutoLock lock(outgoing_messages_lock_);
if (quota_checker_ && outgoing_messages_.size())
quota_checker_->AfterMessagesDequeued(outgoing_messages_.size());

outgoing_messages_.clear();
}

Expand Down Expand Up @@ -821,8 +812,6 @@ class ChannelAssociatedGroupController
if (!connector_ || paused_) {
if (!shut_down_) {
base::AutoLock lock(outgoing_messages_lock_);
if (quota_checker_)
quota_checker_->BeforeMessagesEnqueued(1);
outgoing_messages_.emplace_back(std::move(*message));
}
return true;
Expand Down Expand Up @@ -1163,7 +1152,6 @@ class ChannelAssociatedGroupController
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;

const scoped_refptr<base::SingleThreadTaskRunner> proxy_task_runner_;
const scoped_refptr<mojo::internal::MessageQuotaChecker> quota_checker_;
const bool set_interface_id_namespace_bit_;
bool paused_ = false;
std::unique_ptr<mojo::Connector> connector_;
Expand Down Expand Up @@ -1292,12 +1280,11 @@ std::unique_ptr<MojoBootstrap> MojoBootstrap::Create(
mojo::ScopedMessagePipeHandle handle,
Channel::Mode mode,
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner,
const scoped_refptr<base::SingleThreadTaskRunner>& proxy_task_runner,
const scoped_refptr<mojo::internal::MessageQuotaChecker>& quota_checker) {
const scoped_refptr<base::SingleThreadTaskRunner>& proxy_task_runner) {
return std::make_unique<MojoBootstrapImpl>(
std::move(handle), base::MakeRefCounted<ChannelAssociatedGroupController>(
mode == Channel::MODE_SERVER, ipc_task_runner,
proxy_task_runner, quota_checker));
std::move(handle),
base::MakeRefCounted<ChannelAssociatedGroupController>(
mode == Channel::MODE_SERVER, ipc_task_runner, proxy_task_runner));
}

} // namespace IPC
4 changes: 1 addition & 3 deletions ipc/ipc_mojo_bootstrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "ipc/ipc_listener.h"
#include "mojo/public/cpp/bindings/associated_group.h"
#include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/lib/message_quota_checker.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/system/message_pipe.h"

Expand Down Expand Up @@ -102,8 +101,7 @@ class COMPONENT_EXPORT(IPC) MojoBootstrap {
mojo::ScopedMessagePipeHandle handle,
Channel::Mode mode,
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner,
const scoped_refptr<base::SingleThreadTaskRunner>& proxy_task_runner,
const scoped_refptr<mojo::internal::MessageQuotaChecker>& quota_checker);
const scoped_refptr<base::SingleThreadTaskRunner>& proxy_task_runner);

// Initialize the Channel pipe and interface endpoints. This performs all
// setup except actually starting to read messages off the pipe.
Expand Down
Loading

0 comments on commit 7308d4b

Please sign in to comment.