diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-01-23 17:21:03 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-01-23 16:25:15 +0000 |
commit | c551f43206405019121bd2b2c93714319a0a3300 (patch) | |
tree | 1f48c30631c421fd4bbb3c36da20183c8a2ed7d7 /chromium/ipc | |
parent | 7961cea6d1041e3e454dae6a1da660b453efd238 (diff) | |
download | qtwebengine-chromium-c551f43206405019121bd2b2c93714319a0a3300.tar.gz |
BASELINE: Update Chromium to 79.0.3945.139
Change-Id: I336b7182fab9bca80b709682489c07db112eaca5
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/ipc')
-rw-r--r-- | chromium/ipc/BUILD.gn | 10 | ||||
-rw-r--r-- | chromium/ipc/SECURITY_OWNERS | 3 | ||||
-rw-r--r-- | chromium/ipc/ipc_channel.h | 24 | ||||
-rw-r--r-- | chromium/ipc/ipc_channel_mojo.cc | 7 | ||||
-rw-r--r-- | chromium/ipc/ipc_channel_mojo_unittest.cc | 125 | ||||
-rw-r--r-- | chromium/ipc/ipc_cpu_perftest.cc | 16 | ||||
-rw-r--r-- | chromium/ipc/ipc_message_pipe_reader.cc | 22 | ||||
-rw-r--r-- | chromium/ipc/ipc_message_pipe_reader.h | 14 | ||||
-rw-r--r-- | chromium/ipc/ipc_message_start.h | 16 | ||||
-rw-r--r-- | chromium/ipc/ipc_message_utils.h | 2 | ||||
-rw-r--r-- | chromium/ipc/ipc_mojo_bootstrap.cc | 26 | ||||
-rw-r--r-- | chromium/ipc/ipc_mojo_bootstrap.h | 7 | ||||
-rw-r--r-- | chromium/ipc/ipc_mojo_bootstrap_unittest.cc | 35 | ||||
-rw-r--r-- | chromium/ipc/ipc_mojo_perftest.cc | 120 | ||||
-rw-r--r-- | chromium/ipc/ipc_perftest_util.cc | 6 | ||||
-rw-r--r-- | chromium/ipc/ipc_perftest_util.h | 4 | ||||
-rw-r--r-- | chromium/ipc/ipc_sync_channel_unittest.cc | 2 | ||||
-rw-r--r-- | chromium/ipc/ipc_test.mojom | 9 | ||||
-rw-r--r-- | chromium/ipc/ipc_test_base.h | 4 |
19 files changed, 246 insertions, 206 deletions
diff --git a/chromium/ipc/BUILD.gn b/chromium/ipc/BUILD.gn index 50127fcd855..1bf3d501201 100644 --- a/chromium/ipc/BUILD.gn +++ b/chromium/ipc/BUILD.gn @@ -104,16 +104,6 @@ component("ipc") { "//base", ] - # TODO(https://crbug.com/916130): AFDO causes a substantial size increase in - # nacl_helper that originates from here. This is apparently due to some - # mixture of inlining, CFI, and (potentially) speculative devirtualization. - # Work around that by locally disabling AFDO. - # - # nacl_helper is only available on Linux. - if (is_linux) { - configs -= [ "//build/config/compiler:afdo" ] - } - if (enable_ipc_fuzzer) { public_configs = [ "//tools/ipc_fuzzer:ipc_fuzzer_config" ] } diff --git a/chromium/ipc/SECURITY_OWNERS b/chromium/ipc/SECURITY_OWNERS index 096a7943702..52a73b09636 100644 --- a/chromium/ipc/SECURITY_OWNERS +++ b/chromium/ipc/SECURITY_OWNERS @@ -12,9 +12,10 @@ estark@chromium.org kenrb@chromium.org kerrnel@chromium.org kinuko@chromium.org -meacer@chromium.org mbarbella@chromium.org +meacer@chromium.org mkwst@chromium.org +mpdenton@chromium.org nasko@chromium.org ochang@chromium.org palmer@chromium.org diff --git a/chromium/ipc/ipc_channel.h b/chromium/ipc/ipc_channel.h index 3a5abf0219d..04395f091e2 100644 --- a/chromium/ipc/ipc_channel.h +++ b/chromium/ipc/ipc_channel.h @@ -110,6 +110,8 @@ class COMPONENT_EXPORT(IPC) Channel : public Sender { const std::string& name, mojo::ScopedInterfaceEndpointHandle handle) = 0; + // Remove this after done with migrating all AsscoiatedInterfacePtr to + // AsscoiatedRemote. // Template helper to add an interface factory to this channel. template <typename Interface> using AssociatedInterfaceFactory = @@ -122,6 +124,18 @@ class COMPONENT_EXPORT(IPC) Channel : public Sender { base::Bind(&BindAssociatedInterfaceRequest<Interface>, factory)); } + // Template helper to add an interface factory to this channel. + template <typename Interface> + using AssociatedReceiverFactory = + base::Callback<void(mojo::PendingAssociatedReceiver<Interface>)>; + template <typename Interface> + void AddAssociatedInterface( + const AssociatedReceiverFactory<Interface>& factory) { + AddGenericAssociatedInterface( + Interface::Name_, + base::Bind(&BindPendingAssociatedReceiver<Interface>, factory)); + } + // Remove this after done with migrating all AsscoiatedInterfacePtr to // AsscoiatedRemote. // Template helper to request a remote associated interface. @@ -142,6 +156,8 @@ class COMPONENT_EXPORT(IPC) Channel : public Sender { } private: + // Remove this after done with migrating all AsscoiatedInterfacePtr to + // AsscoiatedRemote. template <typename Interface> static void BindAssociatedInterfaceRequest( const AssociatedInterfaceFactory<Interface>& factory, @@ -149,6 +165,14 @@ class COMPONENT_EXPORT(IPC) Channel : public Sender { factory.Run( mojo::AssociatedInterfaceRequest<Interface>(std::move(handle))); } + + template <typename Interface> + static void BindPendingAssociatedReceiver( + const AssociatedReceiverFactory<Interface>& factory, + mojo::ScopedInterfaceEndpointHandle handle) { + factory.Run( + mojo::PendingAssociatedReceiver<Interface>(std::move(handle))); + } }; // The maximum message size in bytes. Attempting to receive a message of this diff --git a/chromium/ipc/ipc_channel_mojo.cc b/chromium/ipc/ipc_channel_mojo.cc index 8cfe044db52..6e34266f9cf 100644 --- a/chromium/ipc/ipc_channel_mojo.cc +++ b/chromium/ipc/ipc_channel_mojo.cc @@ -26,7 +26,8 @@ #include "ipc/ipc_mojo_bootstrap.h" #include "ipc/ipc_mojo_handle_attachment.h" #include "ipc/native_handle_type_converters.h" -#include "mojo/public/cpp/bindings/binding.h" +#include "mojo/public/cpp/bindings/associated_remote.h" +#include "mojo/public/cpp/bindings/pending_associated_receiver.h" #include "mojo/public/cpp/system/platform_handle.h" namespace IPC { @@ -150,8 +151,8 @@ bool ChannelMojo::Connect() { WillConnect(); - mojom::ChannelAssociatedPtr sender; - mojom::ChannelAssociatedRequest receiver; + mojo::AssociatedRemote<mojom::Channel> sender; + mojo::PendingAssociatedReceiver<mojom::Channel> receiver; bootstrap_->Connect(&sender, &receiver); DCHECK(!message_reader_); diff --git a/chromium/ipc/ipc_channel_mojo_unittest.cc b/chromium/ipc/ipc_channel_mojo_unittest.cc index aecb8dcd9f7..32b7882e005 100644 --- a/chromium/ipc/ipc_channel_mojo_unittest.cc +++ b/chromium/ipc/ipc_channel_mojo_unittest.cc @@ -48,7 +48,10 @@ #include "ipc/ipc_test_base.h" #include "ipc/ipc_test_channel_listener.h" #include "mojo/core/embedder/embedder.h" +#include "mojo/public/cpp/bindings/associated_receiver.h" +#include "mojo/public/cpp/bindings/associated_remote.h" #include "mojo/public/cpp/bindings/lib/validation_errors.h" +#include "mojo/public/cpp/bindings/pending_associated_receiver.h" #include "mojo/public/cpp/system/wait.h" #include "testing/gtest/include/gtest/gtest.h" @@ -252,7 +255,8 @@ TEST_F(IPCChannelMojoTest, SendFailWithPendingMessages) { class ListenerThatBindsATestStructPasser : public IPC::Listener, public IPC::mojom::TestStructPasser { public: - ListenerThatBindsATestStructPasser() : binding_(this) {} + ListenerThatBindsATestStructPasser() = default; + ~ListenerThatBindsATestStructPasser() override = default; bool OnMessageReceived(const IPC::Message& message) override { return true; } @@ -264,15 +268,16 @@ class ListenerThatBindsATestStructPasser : public IPC::Listener, const std::string& interface_name, mojo::ScopedInterfaceEndpointHandle handle) override { CHECK_EQ(interface_name, IPC::mojom::TestStructPasser::Name_); - binding_.Bind( - IPC::mojom::TestStructPasserAssociatedRequest(std::move(handle))); + receiver_.Bind( + mojo::PendingAssociatedReceiver<IPC::mojom::TestStructPasser>( + std::move(handle))); } private: // IPC::mojom::TestStructPasser: void Pass(IPC::mojom::TestStructPtr) override { NOTREACHED(); } - mojo::AssociatedBinding<IPC::mojom::TestStructPasser> binding_; + mojo::AssociatedReceiver<IPC::mojom::TestStructPasser> receiver_{this}; }; class ListenerThatExpectsNoError : public IPC::Listener { @@ -311,9 +316,9 @@ DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT( Connect(&listener); wait_to_connect_loop.Run(); - IPC::mojom::TestStructPasserAssociatedPtr passer; + mojo::AssociatedRemote<IPC::mojom::TestStructPasser> passer; channel()->GetAssociatedInterfaceSupport()->GetRemoteAssociatedInterface( - &passer); + passer.BindNewEndpointAndPassReceiver()); // This avoids hitting DCHECKs in the serialization code meant to stop us from // making such "mistakes" as the one we're about to make below. @@ -661,7 +666,7 @@ class ListenerWithSimpleAssociatedInterface static const int kNumMessages; explicit ListenerWithSimpleAssociatedInterface(base::OnceClosure quit_closure) - : quit_closure_(std::move(quit_closure)), binding_(this) {} + : quit_closure_(std::move(quit_closure)) {} ~ListenerWithSimpleAssociatedInterface() override = default; @@ -678,8 +683,9 @@ class ListenerWithSimpleAssociatedInterface void RegisterInterfaceFactory(IPC::Channel* channel) { channel->GetAssociatedInterfaceSupport()->AddAssociatedInterface( - base::BindRepeating(&ListenerWithSimpleAssociatedInterface::BindRequest, - base::Unretained(this))); + base::BindRepeating( + &ListenerWithSimpleAssociatedInterface::BindReceiver, + base::Unretained(this))); } private: @@ -700,16 +706,17 @@ class ListenerWithSimpleAssociatedInterface std::move(quit_closure_).Run(); } - void BindRequest(IPC::mojom::SimpleTestDriverAssociatedRequest request) { - DCHECK(!binding_.is_bound()); - binding_.Bind(std::move(request)); + void BindReceiver( + mojo::PendingAssociatedReceiver<IPC::mojom::SimpleTestDriver> receiver) { + DCHECK(!receiver_.is_bound()); + receiver_.Bind(std::move(receiver)); } int32_t next_expected_value_ = 0; int num_messages_received_ = 0; base::OnceClosure quit_closure_; - mojo::AssociatedBinding<IPC::mojom::SimpleTestDriver> binding_; + mojo::AssociatedReceiver<IPC::mojom::SimpleTestDriver> receiver_{this}; }; const int ListenerWithSimpleAssociatedInterface::kNumMessages = 1000; @@ -724,7 +731,7 @@ class ListenerSendingAssociatedMessages : public IPC::Listener { void OnChannelConnected(int32_t peer_pid) override { DCHECK(channel_); channel_->GetAssociatedInterfaceSupport()->GetRemoteAssociatedInterface( - &driver_); + driver_.BindNewEndpointAndPassReceiver()); // Send a bunch of interleaved messages, alternating between the associated // interface and a legacy IPC::Message. @@ -743,7 +750,7 @@ class ListenerSendingAssociatedMessages : public IPC::Listener { void OnQuitAck() { std::move(quit_closure_).Run(); } IPC::Channel* channel_ = nullptr; - IPC::mojom::SimpleTestDriverAssociatedPtr driver_; + mojo::AssociatedRemote<IPC::mojom::SimpleTestDriver> driver_; base::OnceClosure quit_closure_; }; @@ -850,7 +857,7 @@ class ListenerWithSimpleProxyAssociatedInterface explicit ListenerWithSimpleProxyAssociatedInterface( base::OnceClosure quit_closure) - : quit_closure_(std::move(quit_closure)), binding_(this) {} + : quit_closure_(std::move(quit_closure)) {} ~ListenerWithSimpleProxyAssociatedInterface() override = default; @@ -869,8 +876,9 @@ class ListenerWithSimpleProxyAssociatedInterface const std::string& interface_name, mojo::ScopedInterfaceEndpointHandle handle) override { DCHECK_EQ(interface_name, IPC::mojom::SimpleTestDriver::Name_); - binding_.Bind( - IPC::mojom::SimpleTestDriverAssociatedRequest(std::move(handle))); + receiver_.Bind( + mojo::PendingAssociatedReceiver<IPC::mojom::SimpleTestDriver>( + std::move(handle))); } bool received_all_messages() const { @@ -891,20 +899,21 @@ class ListenerWithSimpleProxyAssociatedInterface void RequestQuit(RequestQuitCallback callback) override { std::move(callback).Run(); - binding_.Close(); + receiver_.reset(); std::move(quit_closure_).Run(); } - void BindRequest(IPC::mojom::SimpleTestDriverAssociatedRequest request) { - DCHECK(!binding_.is_bound()); - binding_.Bind(std::move(request)); + void BindReceiver( + mojo::PendingAssociatedReceiver<IPC::mojom::SimpleTestDriver> receiver) { + DCHECK(!receiver_.is_bound()); + receiver_.Bind(std::move(receiver)); } int32_t next_expected_value_ = 0; int num_messages_received_ = 0; base::OnceClosure quit_closure_; - mojo::AssociatedBinding<IPC::mojom::SimpleTestDriver> binding_; + mojo::AssociatedReceiver<IPC::mojom::SimpleTestDriver> receiver_{this}; }; const int ListenerWithSimpleProxyAssociatedInterface::kNumMessages = 1000; @@ -949,7 +958,7 @@ class ChannelProxyClient { IPC::ChannelProxy* proxy() { return runner_->proxy(); } private: - base::test::TaskEnvironment task_environment_; + base::test::SingleThreadTaskEnvironment task_environment_; std::unique_ptr<ChannelProxyRunner> runner_; }; @@ -968,7 +977,7 @@ DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT_WITH_CUSTOM_FIXTURE( // Send a bunch of interleaved messages, alternating between the associated // interface and a legacy IPC::Message. - IPC::mojom::SimpleTestDriverAssociatedPtr driver; + mojo::AssociatedRemote<IPC::mojom::SimpleTestDriver> driver; proxy()->GetRemoteAssociatedInterface(&driver); for (int i = 0; i < ListenerWithSimpleProxyAssociatedInterface::kNumMessages; ++i) { @@ -987,8 +996,7 @@ class ListenerWithIndirectProxyAssociatedInterface public IPC::mojom::IndirectTestDriver, public IPC::mojom::PingReceiver { public: - ListenerWithIndirectProxyAssociatedInterface() - : driver_binding_(this), ping_receiver_binding_(this) {} + ListenerWithIndirectProxyAssociatedInterface() : driver_binding_(this) {} ~ListenerWithIndirectProxyAssociatedInterface() override = default; // IPC::Listener: @@ -1000,7 +1008,8 @@ class ListenerWithIndirectProxyAssociatedInterface DCHECK(!driver_binding_.is_bound()); DCHECK_EQ(interface_name, IPC::mojom::IndirectTestDriver::Name_); driver_binding_.Bind( - IPC::mojom::IndirectTestDriverAssociatedRequest(std::move(handle))); + mojo::PendingAssociatedReceiver<IPC::mojom::IndirectTestDriver>( + std::move(handle))); } void set_ping_handler(const base::RepeatingClosure& handler) { @@ -1009,9 +1018,9 @@ class ListenerWithIndirectProxyAssociatedInterface private: // IPC::mojom::IndirectTestDriver: - void GetPingReceiver( - IPC::mojom::PingReceiverAssociatedRequest request) override { - ping_receiver_binding_.Bind(std::move(request)); + void GetPingReceiver(mojo::PendingAssociatedReceiver<IPC::mojom::PingReceiver> + receiver) override { + ping_receiver_receiver_.Bind(std::move(receiver)); } // IPC::mojom::PingReceiver: @@ -1021,7 +1030,8 @@ class ListenerWithIndirectProxyAssociatedInterface } mojo::AssociatedBinding<IPC::mojom::IndirectTestDriver> driver_binding_; - mojo::AssociatedBinding<IPC::mojom::PingReceiver> ping_receiver_binding_; + mojo::AssociatedReceiver<IPC::mojom::PingReceiver> ping_receiver_receiver_{ + this}; base::RepeatingClosure ping_handler_; }; @@ -1058,10 +1068,10 @@ DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT_WITH_CUSTOM_FIXTURE( // message we send will still be dispatched properly even though the remote // endpoint may not have been bound yet by the time the message is initially // processed on the IO thread. - IPC::mojom::IndirectTestDriverAssociatedPtr driver; - IPC::mojom::PingReceiverAssociatedPtr ping_receiver; + mojo::AssociatedRemote<IPC::mojom::IndirectTestDriver> driver; + mojo::AssociatedRemote<IPC::mojom::PingReceiver> ping_receiver; proxy()->GetRemoteAssociatedInterface(&driver); - driver->GetPingReceiver(mojo::MakeRequest(&ping_receiver)); + driver->GetPingReceiver(ping_receiver.BindNewEndpointAndPassReceiver()); base::RunLoop loop; ping_receiver->Ping(loop.QuitClosure()); @@ -1074,7 +1084,7 @@ class ListenerWithSyncAssociatedInterface : public IPC::Listener, public IPC::mojom::SimpleTestDriver { public: - ListenerWithSyncAssociatedInterface() : binding_(this) {} + ListenerWithSyncAssociatedInterface() = default; ~ListenerWithSyncAssociatedInterface() override = default; void set_sync_sender(IPC::Sender* sync_sender) { sync_sender_ = sync_sender; } @@ -1085,7 +1095,7 @@ class ListenerWithSyncAssociatedInterface loop.Run(); } - void CloseBinding() { binding_.Close(); } + void CloseBinding() { receiver_.reset(); } void set_response_value(int32_t response) { response_value_ = response; @@ -1126,15 +1136,17 @@ class ListenerWithSyncAssociatedInterface void OnAssociatedInterfaceRequest( const std::string& interface_name, mojo::ScopedInterfaceEndpointHandle handle) override { - DCHECK(!binding_.is_bound()); + DCHECK(!receiver_.is_bound()); DCHECK_EQ(interface_name, IPC::mojom::SimpleTestDriver::Name_); - binding_.Bind( - IPC::mojom::SimpleTestDriverAssociatedRequest(std::move(handle))); + receiver_.Bind( + mojo::PendingAssociatedReceiver<IPC::mojom::SimpleTestDriver>( + std::move(handle))); } - void BindRequest(IPC::mojom::SimpleTestDriverAssociatedRequest request) { - DCHECK(!binding_.is_bound()); - binding_.Bind(std::move(request)); + void BindReceiver( + mojo::PendingAssociatedReceiver<IPC::mojom::SimpleTestDriver> receiver) { + DCHECK(!receiver_.is_bound()); + receiver_.Bind(std::move(receiver)); } IPC::Sender* sync_sender_ = nullptr; @@ -1142,7 +1154,7 @@ class ListenerWithSyncAssociatedInterface int32_t response_value_ = 0; base::OnceClosure quit_closure_; - mojo::AssociatedBinding<IPC::mojom::SimpleTestDriver> binding_; + mojo::AssociatedReceiver<IPC::mojom::SimpleTestDriver> receiver_{this}; }; class SyncReplyReader : public IPC::MessageReplyDeserializer { @@ -1178,7 +1190,7 @@ TEST_F(IPCChannelProxyMojoTest, SyncAssociatedInterface) { // Verify that we can send a sync IPC and service an incoming sync request // while waiting on it listener.set_response_value(42); - IPC::mojom::SimpleTestClientAssociatedPtr client; + mojo::AssociatedRemote<IPC::mojom::SimpleTestClient> client; proxy()->GetRemoteAssociatedInterface(&client); int32_t received_value; EXPECT_TRUE(client->RequestValue(&received_value)); @@ -1208,7 +1220,8 @@ TEST_F(IPCChannelProxyMojoTest, SyncAssociatedInterface) { class SimpleTestClientImpl : public IPC::mojom::SimpleTestClient, public IPC::Listener { public: - SimpleTestClientImpl() : binding_(this) {} + SimpleTestClientImpl() = default; + ~SimpleTestClientImpl() override = default; void set_driver(IPC::mojom::SimpleTestDriver* driver) { driver_ = driver; } void set_sync_sender(IPC::Sender* sync_sender) { sync_sender_ = sync_sender; } @@ -1259,15 +1272,16 @@ class SimpleTestClientImpl : public IPC::mojom::SimpleTestClient, void OnAssociatedInterfaceRequest( const std::string& interface_name, mojo::ScopedInterfaceEndpointHandle handle) override { - DCHECK(!binding_.is_bound()); + DCHECK(!receiver_.is_bound()); DCHECK_EQ(interface_name, IPC::mojom::SimpleTestClient::Name_); - binding_.Bind( - IPC::mojom::SimpleTestClientAssociatedRequest(std::move(handle))); + receiver_.Bind( + mojo::PendingAssociatedReceiver<IPC::mojom::SimpleTestClient>( + std::move(handle))); } bool use_sync_sender_ = false; - mojo::AssociatedBinding<IPC::mojom::SimpleTestClient> binding_; + mojo::AssociatedReceiver<IPC::mojom::SimpleTestClient> receiver_{this}; IPC::Sender* sync_sender_ = nullptr; IPC::mojom::SimpleTestDriver* driver_ = nullptr; std::unique_ptr<base::RunLoop> run_loop_; @@ -1282,7 +1296,7 @@ DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT_WITH_CUSTOM_FIXTURE(SyncAssociatedInterface, client_impl.set_sync_sender(proxy()); RunProxy(); - IPC::mojom::SimpleTestDriverAssociatedPtr driver; + mojo::AssociatedRemote<IPC::mojom::SimpleTestDriver> driver; proxy()->GetRemoteAssociatedInterface(&driver); client_impl.set_driver(driver.get()); @@ -1414,14 +1428,15 @@ TEST_F(IPCChannelProxyMojoTest, AssociatedRequestClose) { CreateProxy(&listener); RunProxy(); - IPC::mojom::AssociatedInterfaceVendorAssociatedPtr vendor; + mojo::AssociatedRemote<IPC::mojom::AssociatedInterfaceVendor> vendor; proxy()->GetRemoteAssociatedInterface(&vendor); - IPC::mojom::SimpleTestDriverAssociatedPtr tester; - vendor->GetTestInterface(mojo::MakeRequest(&tester)); + mojo::AssociatedRemote<IPC::mojom::SimpleTestDriver> tester; + vendor->GetTestInterface(tester.BindNewEndpointAndPassReceiver()); base::RunLoop run_loop; - tester.set_connection_error_handler(run_loop.QuitClosure()); + tester.set_disconnect_handler(run_loop.QuitClosure()); run_loop.Run(); + tester.reset(); proxy()->GetRemoteAssociatedInterface(&tester); EXPECT_TRUE(WaitForClientShutdown()); DestroyProxy(); diff --git a/chromium/ipc/ipc_cpu_perftest.cc b/chromium/ipc/ipc_cpu_perftest.cc index 3a5d8f80278..c5cd5c44ffe 100644 --- a/chromium/ipc/ipc_cpu_perftest.cc +++ b/chromium/ipc/ipc_cpu_perftest.cc @@ -20,7 +20,8 @@ #include "ipc/ipc_test_base.h" #include "mojo/core/test/mojo_test_base.h" #include "mojo/core/test/multiprocess_test_helper.h" -#include "mojo/public/cpp/bindings/binding.h" +#include "mojo/public/cpp/bindings/pending_remote.h" +#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/system/message_pipe.h" namespace IPC { @@ -276,7 +277,8 @@ class MojoSteadyPingPongTest : public mojo::core::test::MojoTestBase { mojo::MessagePipeHandle mp_handle(mp); mojo::ScopedMessagePipeHandle scoped_mp(mp_handle); - ping_receiver_.Bind(IPC::mojom::ReflectorPtrInfo(std::move(scoped_mp), 0u)); + ping_receiver_.Bind( + mojo::PendingRemote<IPC::mojom::Reflector>(std::move(scoped_mp), 0u)); LockThreadAffinity thread_locker(kSharedCore); std::vector<TestParams> params_list = GetDefaultTestParams(); @@ -293,7 +295,7 @@ class MojoSteadyPingPongTest : public mojo::core::test::MojoTestBase { ping_receiver_->Quit(); - ignore_result(ping_receiver_.PassInterface().PassHandle().release()); + ignore_result(ping_receiver_.Unbind().PassPipe().release()); } void OnHello(const std::string& value) { @@ -380,7 +382,7 @@ class MojoSteadyPingPongTest : public mojo::core::test::MojoTestBase { std::string label_; bool sync_ = false; - IPC::mojom::ReflectorPtr ping_receiver_; + mojo::Remote<IPC::mojom::Reflector> ping_receiver_; int count_down_ = 0; int frame_count_down_ = 0; @@ -394,7 +396,7 @@ class MojoSteadyPingPongTest : public mojo::core::test::MojoTestBase { }; DEFINE_TEST_CLIENT_WITH_PIPE(PingPongClient, MojoSteadyPingPongTest, h) { - base::test::TaskEnvironment task_environment; + base::test::SingleThreadTaskEnvironment task_environment; return RunPingPongClient(h); } @@ -402,14 +404,14 @@ DEFINE_TEST_CLIENT_WITH_PIPE(PingPongClient, MojoSteadyPingPongTest, h) { // instead of raw IPC::Messages. TEST_F(MojoSteadyPingPongTest, AsyncPingPong) { RunTestClient("PingPongClient", [&](MojoHandle h) { - base::test::TaskEnvironment task_environment; + base::test::SingleThreadTaskEnvironment task_environment; RunPingPongServer(h, "Mojo_CPU_Async", false); }); } TEST_F(MojoSteadyPingPongTest, SyncPingPong) { RunTestClient("PingPongClient", [&](MojoHandle h) { - base::test::TaskEnvironment task_environment; + base::test::SingleThreadTaskEnvironment task_environment; RunPingPongServer(h, "Mojo_CPU_Sync", true); }); } diff --git a/chromium/ipc/ipc_message_pipe_reader.cc b/chromium/ipc/ipc_message_pipe_reader.cc index b055d413f45..a78972c6179 100644 --- a/chromium/ipc/ipc_message_pipe_reader.cc +++ b/chromium/ipc/ipc_message_pipe_reader.cc @@ -23,18 +23,18 @@ namespace internal { MessagePipeReader::MessagePipeReader( mojo::MessagePipeHandle pipe, - mojom::ChannelAssociatedPtr sender, - mojo::AssociatedInterfaceRequest<mojom::Channel> receiver, + mojo::AssociatedRemote<mojom::Channel> sender, + mojo::PendingAssociatedReceiver<mojom::Channel> receiver, MessagePipeReader::Delegate* delegate) : delegate_(delegate), sender_(std::move(sender)), - binding_(this, std::move(receiver)) { - sender_.set_connection_error_handler( - base::Bind(&MessagePipeReader::OnPipeError, base::Unretained(this), - MOJO_RESULT_FAILED_PRECONDITION)); - binding_.set_connection_error_handler( - base::Bind(&MessagePipeReader::OnPipeError, base::Unretained(this), - MOJO_RESULT_FAILED_PRECONDITION)); + receiver_(this, std::move(receiver)) { + sender_.set_disconnect_handler(base::Bind(&MessagePipeReader::OnPipeError, + base::Unretained(this), + MOJO_RESULT_FAILED_PRECONDITION)); + receiver_.set_disconnect_handler(base::Bind(&MessagePipeReader::OnPipeError, + base::Unretained(this), + MOJO_RESULT_FAILED_PRECONDITION)); } MessagePipeReader::~MessagePipeReader() { @@ -45,8 +45,8 @@ MessagePipeReader::~MessagePipeReader() { void MessagePipeReader::Close() { DCHECK(thread_checker_.CalledOnValidThread()); sender_.reset(); - if (binding_.is_bound()) - binding_.Close(); + if (receiver_.is_bound()) + receiver_.reset(); } bool MessagePipeReader::Send(std::unique_ptr<Message> message) { diff --git a/chromium/ipc/ipc_message_pipe_reader.h b/chromium/ipc/ipc_message_pipe_reader.h index e1c3fd494cb..8b09cf70234 100644 --- a/chromium/ipc/ipc_message_pipe_reader.h +++ b/chromium/ipc/ipc_message_pipe_reader.h @@ -18,7 +18,9 @@ #include "base/threading/thread_checker.h" #include "ipc/ipc.mojom.h" #include "ipc/ipc_message.h" -#include "mojo/public/cpp/bindings/associated_binding.h" +#include "mojo/public/cpp/bindings/associated_receiver.h" +#include "mojo/public/cpp/bindings/associated_remote.h" +#include "mojo/public/cpp/bindings/pending_associated_receiver.h" #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h" #include "mojo/public/cpp/system/core.h" #include "mojo/public/cpp/system/message_pipe.h" @@ -66,8 +68,8 @@ class COMPONENT_EXPORT(IPC) MessagePipeReader : public mojom::Channel { // // Note that MessagePipeReader doesn't delete |delegate|. MessagePipeReader(mojo::MessagePipeHandle pipe, - mojom::ChannelAssociatedPtr sender, - mojo::AssociatedInterfaceRequest<mojom::Channel> receiver, + mojo::AssociatedRemote<mojom::Channel> sender, + mojo::PendingAssociatedReceiver<mojom::Channel> receiver, Delegate* delegate); ~MessagePipeReader() override; @@ -85,7 +87,7 @@ class COMPONENT_EXPORT(IPC) MessagePipeReader : public mojom::Channel { void GetRemoteInterface(const std::string& name, mojo::ScopedInterfaceEndpointHandle handle); - mojom::ChannelAssociatedPtr& sender() { return sender_; } + mojo::AssociatedRemote<mojom::Channel>& sender() { return sender_; } protected: void OnPipeClosed(); @@ -101,8 +103,8 @@ class COMPONENT_EXPORT(IPC) MessagePipeReader : public mojom::Channel { // |delegate_| is null once the message pipe is closed. Delegate* delegate_; - mojom::ChannelAssociatedPtr sender_; - mojo::AssociatedBinding<mojom::Channel> binding_; + mojo::AssociatedRemote<mojom::Channel> sender_; + mojo::AssociatedReceiver<mojom::Channel> receiver_; base::ThreadChecker thread_checker_; DISALLOW_COPY_AND_ASSIGN(MessagePipeReader); diff --git a/chromium/ipc/ipc_message_start.h b/chromium/ipc/ipc_message_start.h index 93bc399be78..f69f0072c31 100644 --- a/chromium/ipc/ipc_message_start.h +++ b/chromium/ipc/ipc_message_start.h @@ -24,10 +24,6 @@ enum IPCMessageStart { GpuChannelMsgStart, MediaMsgStart, PpapiMsgStart, - DOMStorageMsgStart, - ResourceMsgStart, - BlobMsgStart, - MidiMsgStart, ChromeMsgStart, DragMsgStart, PrintMsgStart, @@ -39,34 +35,22 @@ enum IPCMessageStart { ChromotingMsgStart, BrowserPluginMsgStart, AndroidWebViewMsgStart, - MediaPlayerMsgStart, - TracingMsgStart, PeerConnectionTrackerMsgStart, - WebRtcLoggingMsgStart, - TtsMsgStart, NaClHostMsgStart, EncryptedMediaMsgStart, CastMsgStart, - ChromeExtensionMsgStart, GinJavaBridgeMsgStart, ChromeUtilityPrintingMsgStart, OzoneGpuMsgStart, WebTestMsgStart, NetworkHintsMsgStart, - CastMediaMsgStart, - SyncCompositorMsgStart, ExtensionsGuestViewMsgStart, GuestViewMsgStart, - // Note: CastCryptoMsgStart and CastChannelMsgStart reserved for Chromecast - // internal code. Contact gunsch@ before changing/removing. - CastCryptoMsgStart, - CastChannelMsgStart, IPCTestMsgStart, MediaPlayerDelegateMsgStart, SurfaceViewManagerMsgStart, ExtensionWorkerMsgStart, SubresourceFilterMsgStart, - ChromeAppsMsgStart, UnfreezableFrameMsgStart, LastIPCMsgStart // Must come last. }; diff --git a/chromium/ipc/ipc_message_utils.h b/chromium/ipc/ipc_message_utils.h index 642a7a3d315..fd4ff2358e7 100644 --- a/chromium/ipc/ipc_message_utils.h +++ b/chromium/ipc/ipc_message_utils.h @@ -973,7 +973,7 @@ struct ParamTraits<base::flat_map<Key, Mapped, Compare>> { return false; } - *r = param_type(std::move(vect), base::KEEP_FIRST_OF_DUPES); + *r = param_type(std::move(vect)); return true; } static void Log(const param_type& p, std::string* l) { diff --git a/chromium/ipc/ipc_mojo_bootstrap.cc b/chromium/ipc/ipc_mojo_bootstrap.cc index f038a95a8e2..39d29ddbc96 100644 --- a/chromium/ipc/ipc_mojo_bootstrap.cc +++ b/chromium/ipc/ipc_mojo_bootstrap.cc @@ -124,15 +124,15 @@ class ChannelAssociatedGroupController : task_runner_(ipc_task_runner), proxy_task_runner_(proxy_task_runner), set_interface_id_namespace_bit_(set_interface_id_namespace_bit), - filters_(this), + dispatcher_(this), control_message_handler_(this), control_message_proxy_thunk_(this), control_message_proxy_(&control_message_proxy_thunk_) { thread_checker_.DetachFromThread(); control_message_handler_.SetDescription( "IPC::mojom::Bootstrap [master] PipeControlMessageHandler"); - filters_.Append<mojo::MessageHeaderValidator>( - "IPC::mojom::Bootstrap [master] MessageHeaderValidator"); + dispatcher_.SetValidator(std::make_unique<mojo::MessageHeaderValidator>( + "IPC::mojom::Bootstrap [master] MessageHeaderValidator")); GetMemoryDumpProvider().AddController(this); } @@ -166,7 +166,7 @@ class ChannelAssociatedGroupController connector_.reset(new mojo::Connector( std::move(handle), mojo::Connector::SINGLE_THREADED_SEND, task_runner_)); - connector_->set_incoming_receiver(&filters_); + connector_->set_incoming_receiver(&dispatcher_); connector_->set_connection_error_handler( base::Bind(&ChannelAssociatedGroupController::OnPipeError, base::Unretained(this))); @@ -202,8 +202,9 @@ class ChannelAssociatedGroupController SendMessage(&message); } - void CreateChannelEndpoints(mojom::ChannelAssociatedPtr* sender, - mojom::ChannelAssociatedRequest* receiver) { + void CreateChannelEndpoints( + mojo::AssociatedRemote<mojom::Channel>* sender, + mojo::PendingAssociatedReceiver<mojom::Channel>* receiver) { mojo::InterfaceId sender_id, receiver_id; if (set_interface_id_namespace_bit_) { sender_id = 1 | mojo::kInterfaceIdNamespaceMask; @@ -228,8 +229,10 @@ class ChannelAssociatedGroupController mojo::ScopedInterfaceEndpointHandle receiver_handle = CreateScopedInterfaceEndpointHandle(receiver_id); - sender->Bind(mojom::ChannelAssociatedPtrInfo(std::move(sender_handle), 0)); - *receiver = mojom::ChannelAssociatedRequest(std::move(receiver_handle)); + sender->Bind(mojo::PendingAssociatedRemote<mojom::Channel>( + std::move(sender_handle), 0)); + *receiver = mojo::PendingAssociatedReceiver<mojom::Channel>( + std::move(receiver_handle)); } void ShutDown() { @@ -983,7 +986,7 @@ class ChannelAssociatedGroupController const bool set_interface_id_namespace_bit_; bool paused_ = false; std::unique_ptr<mojo::Connector> connector_; - mojo::FilterChain filters_; + mojo::MessageDispatcher dispatcher_; mojo::PipeControlMessageHandler control_message_handler_; ControlMessageProxyThunk control_message_proxy_thunk_; @@ -1059,8 +1062,9 @@ class MojoBootstrapImpl : public MojoBootstrap { } private: - void Connect(mojom::ChannelAssociatedPtr* sender, - mojom::ChannelAssociatedRequest* receiver) override { + void Connect( + mojo::AssociatedRemote<mojom::Channel>* sender, + mojo::PendingAssociatedReceiver<mojom::Channel>* receiver) override { controller_->Bind(std::move(handle_)); controller_->CreateChannelEndpoints(sender, receiver); } diff --git a/chromium/ipc/ipc_mojo_bootstrap.h b/chromium/ipc/ipc_mojo_bootstrap.h index c2778b60e09..89262846ead 100644 --- a/chromium/ipc/ipc_mojo_bootstrap.h +++ b/chromium/ipc/ipc_mojo_bootstrap.h @@ -18,6 +18,8 @@ #include "ipc/ipc_channel.h" #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/pending_associated_receiver.h" #include "mojo/public/cpp/system/message_pipe.h" namespace IPC { @@ -43,8 +45,9 @@ class COMPONENT_EXPORT(IPC) MojoBootstrap { const scoped_refptr<base::SingleThreadTaskRunner>& proxy_task_runner); // Start the handshake over the underlying message pipe. - virtual void Connect(mojom::ChannelAssociatedPtr* sender, - mojom::ChannelAssociatedRequest* receiver) = 0; + virtual void Connect( + mojo::AssociatedRemote<mojom::Channel>* sender, + mojo::PendingAssociatedReceiver<mojom::Channel>* receiver) = 0; // Stop transmitting messages and start queueing them instead. virtual void Pause() = 0; diff --git a/chromium/ipc/ipc_mojo_bootstrap_unittest.cc b/chromium/ipc/ipc_mojo_bootstrap_unittest.cc index 63c0f83d911..2b6dd979c33 100644 --- a/chromium/ipc/ipc_mojo_bootstrap_unittest.cc +++ b/chromium/ipc/ipc_mojo_bootstrap_unittest.cc @@ -14,7 +14,7 @@ #include "ipc/ipc.mojom.h" #include "ipc/ipc_test_base.h" #include "mojo/core/test/multiprocess_test_helper.h" -#include "mojo/public/cpp/bindings/associated_binding.h" +#include "mojo/public/cpp/bindings/associated_receiver.h" namespace { @@ -30,15 +30,16 @@ class Connection { sender_->SetPeerPid(sender_id); } - void TakeReceiver(IPC::mojom::ChannelAssociatedRequest* receiver) { + void TakeReceiver( + mojo::PendingAssociatedReceiver<IPC::mojom::Channel>* receiver) { *receiver = std::move(receiver_); } - IPC::mojom::ChannelAssociatedPtr& GetSender() { return sender_; } + mojo::AssociatedRemote<IPC::mojom::Channel>& GetSender() { return sender_; } private: - IPC::mojom::ChannelAssociatedPtr sender_; - IPC::mojom::ChannelAssociatedRequest receiver_; + mojo::AssociatedRemote<IPC::mojom::Channel> sender_; + mojo::PendingAssociatedReceiver<IPC::mojom::Channel> receiver_; std::unique_ptr<IPC::MojoBootstrap> bootstrap_; }; @@ -51,13 +52,13 @@ class PeerPidReceiver : public IPC::mojom::Channel { }; PeerPidReceiver( - IPC::mojom::ChannelAssociatedRequest request, + mojo::PendingAssociatedReceiver<IPC::mojom::Channel> receiver, const base::Closure& on_peer_pid_set, MessageExpectation message_expectation = MessageExpectation::kNotExpected) - : binding_(this, std::move(request)), + : receiver_(this, std::move(receiver)), on_peer_pid_set_(on_peer_pid_set), message_expectation_(message_expectation) { - binding_.set_connection_error_handler(disconnect_run_loop_.QuitClosure()); + receiver_.set_disconnect_handler(disconnect_run_loop_.QuitClosure()); } ~PeerPidReceiver() override { @@ -91,7 +92,7 @@ class PeerPidReceiver : public IPC::mojom::Channel { void RunUntilDisconnect() { disconnect_run_loop_.Run(); } private: - mojo::AssociatedBinding<IPC::mojom::Channel> binding_; + mojo::AssociatedReceiver<IPC::mojom::Channel> receiver_; const base::Closure on_peer_pid_set_; MessageExpectation message_expectation_; int32_t peer_pid_ = -1; @@ -107,7 +108,7 @@ class IPCMojoBootstrapTest : public testing::Test { }; TEST_F(IPCMojoBootstrapTest, Connect) { - base::test::TaskEnvironment task_environment; + base::test::SingleThreadTaskEnvironment task_environment; Connection connection( IPC::MojoBootstrap::Create( helper_.StartChild("IPCMojoBootstrapTestClient"), @@ -115,7 +116,7 @@ TEST_F(IPCMojoBootstrapTest, Connect) { base::ThreadTaskRunnerHandle::Get()), kTestServerPid); - IPC::mojom::ChannelAssociatedRequest receiver; + mojo::PendingAssociatedReceiver<IPC::mojom::Channel> receiver; connection.TakeReceiver(&receiver); base::RunLoop run_loop; @@ -132,7 +133,7 @@ TEST_F(IPCMojoBootstrapTest, Connect) { MULTIPROCESS_TEST_MAIN_WITH_SETUP( IPCMojoBootstrapTestClientTestChildMain, ::mojo::core::test::MultiprocessTestHelper::ChildSetup) { - base::test::TaskEnvironment task_environment; + base::test::SingleThreadTaskEnvironment task_environment; Connection connection( IPC::MojoBootstrap::Create( std::move(mojo::core::test::MultiprocessTestHelper::primordial_pipe), @@ -140,7 +141,7 @@ MULTIPROCESS_TEST_MAIN_WITH_SETUP( base::ThreadTaskRunnerHandle::Get()), kTestClientPid); - IPC::mojom::ChannelAssociatedRequest receiver; + mojo::PendingAssociatedReceiver<IPC::mojom::Channel> receiver; connection.TakeReceiver(&receiver); base::RunLoop run_loop; @@ -153,7 +154,7 @@ MULTIPROCESS_TEST_MAIN_WITH_SETUP( } TEST_F(IPCMojoBootstrapTest, ReceiveEmptyMessage) { - base::test::TaskEnvironment task_environment; + base::test::SingleThreadTaskEnvironment task_environment; Connection connection( IPC::MojoBootstrap::Create( helper_.StartChild("IPCMojoBootstrapTestEmptyMessage"), @@ -161,7 +162,7 @@ TEST_F(IPCMojoBootstrapTest, ReceiveEmptyMessage) { base::ThreadTaskRunnerHandle::Get()), kTestServerPid); - IPC::mojom::ChannelAssociatedRequest receiver; + mojo::PendingAssociatedReceiver<IPC::mojom::Channel> receiver; connection.TakeReceiver(&receiver); base::RunLoop run_loop; @@ -180,7 +181,7 @@ TEST_F(IPCMojoBootstrapTest, ReceiveEmptyMessage) { MULTIPROCESS_TEST_MAIN_WITH_SETUP( IPCMojoBootstrapTestEmptyMessageTestChildMain, ::mojo::core::test::MultiprocessTestHelper::ChildSetup) { - base::test::TaskEnvironment task_environment; + base::test::SingleThreadTaskEnvironment task_environment; Connection connection( IPC::MojoBootstrap::Create( std::move(mojo::core::test::MultiprocessTestHelper::primordial_pipe), @@ -188,7 +189,7 @@ MULTIPROCESS_TEST_MAIN_WITH_SETUP( base::ThreadTaskRunnerHandle::Get()), kTestClientPid); - IPC::mojom::ChannelAssociatedRequest receiver; + mojo::PendingAssociatedReceiver<IPC::mojom::Channel> receiver; connection.TakeReceiver(&receiver); auto& sender = connection.GetSender(); diff --git a/chromium/ipc/ipc_mojo_perftest.cc b/chromium/ipc/ipc_mojo_perftest.cc index 56aaf2c08c6..94b49205f62 100644 --- a/chromium/ipc/ipc_mojo_perftest.cc +++ b/chromium/ipc/ipc_mojo_perftest.cc @@ -25,9 +25,14 @@ #include "mojo/core/embedder/embedder.h" #include "mojo/core/test/mojo_test_base.h" #include "mojo/core/test/multiprocess_test_helper.h" -#include "mojo/public/cpp/bindings/associated_binding_set.h" -#include "mojo/public/cpp/bindings/binding.h" -#include "mojo/public/cpp/bindings/binding_set.h" +#include "mojo/public/cpp/bindings/associated_receiver_set.h" +#include "mojo/public/cpp/bindings/associated_remote.h" +#include "mojo/public/cpp/bindings/pending_associated_receiver.h" +#include "mojo/public/cpp/bindings/pending_receiver.h" +#include "mojo/public/cpp/bindings/pending_remote.h" +#include "mojo/public/cpp/bindings/receiver.h" +#include "mojo/public/cpp/bindings/receiver_set.h" +#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/system/message_pipe.h" namespace IPC { @@ -284,7 +289,8 @@ class MojoInterfacePerfTest : public mojo::core::test::MojoTestBase { mojo::MessagePipeHandle mp_handle(mp); mojo::ScopedMessagePipeHandle scoped_mp(mp_handle); - ping_receiver_.Bind(IPC::mojom::ReflectorPtrInfo(std::move(scoped_mp), 0u)); + ping_receiver_.Bind( + mojo::PendingRemote<IPC::mojom::Reflector>(std::move(scoped_mp), 0u)); LockThreadAffinity thread_locker(kSharedCore); std::vector<PingPongTestParams> params = GetDefaultTestParams(); @@ -299,7 +305,7 @@ class MojoInterfacePerfTest : public mojo::core::test::MojoTestBase { ping_receiver_->Quit(); - ignore_result(ping_receiver_.PassInterface().PassHandle().release()); + ignore_result(ping_receiver_.Unbind().PassPipe().release()); } void OnPong(const std::string& value) { @@ -356,7 +362,7 @@ class MojoInterfacePerfTest : public mojo::core::test::MojoTestBase { int count_down_; std::string label_; std::string payload_; - IPC::mojom::ReflectorPtr ping_receiver_; + mojo::Remote<IPC::mojom::Reflector> ping_receiver_; std::unique_ptr<base::PerfTimeLogger> perf_logger_; DISALLOW_COPY_AND_ASSIGN(MojoInterfacePerfTest); @@ -367,31 +373,34 @@ class InterfacePassingTestDriverImpl : public mojom::InterfacePassingTestDriver, public: InterfacePassingTestDriverImpl(mojo::ScopedMessagePipeHandle handle, const base::Closure& quit_closure) - : binding_(this, - mojom::InterfacePassingTestDriverRequest(std::move(handle))), + : receiver_(this, + mojo::PendingReceiver<mojom::InterfacePassingTestDriver>( + std::move(handle))), quit_closure_(quit_closure) {} ~InterfacePassingTestDriverImpl() override { - ignore_result(binding_.Unbind().PassMessagePipe().release()); + ignore_result(receiver_.Unbind().PassPipe().release()); } private: // mojom::InterfacePassingTestDriver implementation: void Init(InitCallback callback) override { std::move(callback).Run(); } - void GetPingReceiver(std::vector<mojom::PingReceiverRequest> requests, - GetPingReceiverCallback callback) override { - for (auto& request : requests) - ping_receiver_bindings_.AddBinding(this, std::move(request)); - ping_receiver_bindings_.CloseAllBindings(); + void GetPingReceiver( + std::vector<mojo::PendingReceiver<mojom::PingReceiver>> receivers, + GetPingReceiverCallback callback) override { + for (auto& receiver : receivers) + ping_receiver_receivers_.Add(this, std::move(receiver)); + ping_receiver_receivers_.Clear(); std::move(callback).Run(); } void GetAssociatedPingReceiver( - std::vector<mojom::PingReceiverAssociatedRequest> requests, + std::vector<mojo::PendingAssociatedReceiver<mojom::PingReceiver>> + receivers, GetAssociatedPingReceiverCallback callback) override { - for (auto& request : requests) - ping_receiver_associated_bindings_.AddBinding(this, std::move(request)); - ping_receiver_associated_bindings_.CloseAllBindings(); + for (auto& receiver : receivers) + ping_receiver_associated_receivers_.Add(this, std::move(receiver)); + ping_receiver_associated_receivers_.Clear(); std::move(callback).Run(); } @@ -403,10 +412,10 @@ class InterfacePassingTestDriverImpl : public mojom::InterfacePassingTestDriver, // mojom::PingReceiver implementation: void Ping(PingCallback callback) override { std::move(callback).Run(); } - mojo::BindingSet<mojom::PingReceiver> ping_receiver_bindings_; - mojo::AssociatedBindingSet<mojom::PingReceiver> - ping_receiver_associated_bindings_; - mojo::Binding<mojom::InterfacePassingTestDriver> binding_; + mojo::ReceiverSet<mojom::PingReceiver> ping_receiver_receivers_; + mojo::AssociatedReceiverSet<mojom::PingReceiver> + ping_receiver_associated_receivers_; + mojo::Receiver<mojom::InterfacePassingTestDriver> receiver_; base::Closure quit_closure_; }; @@ -424,14 +433,14 @@ class MojoInterfacePassingPerfTest : public mojo::core::test::MojoTestBase { mojo::MessagePipeHandle mp_handle(mp); mojo::ScopedMessagePipeHandle scoped_mp(mp_handle); - driver_ptr_.Bind( - mojom::InterfacePassingTestDriverPtrInfo(std::move(scoped_mp), 0u)); + driver_remote_.Bind(mojo::PendingRemote<mojom::InterfacePassingTestDriver>( + std::move(scoped_mp), 0u)); auto params = GetDefaultInterfacePassingTestParams(); LockThreadAffinity thread_locker(kSharedCore); for (size_t i = 0; i < params.size(); ++i) { - driver_ptr_->Init( + driver_remote_->Init( base::Bind(&MojoInterfacePassingPerfTest::OnInitCallback, base::Unretained(this))); rounds_ = count_down_ = params[i].rounds(); @@ -442,9 +451,9 @@ class MojoInterfacePassingPerfTest : public mojo::core::test::MojoTestBase { run_loop.Run(); } - driver_ptr_->Quit(); + driver_remote_->Quit(); - ignore_result(driver_ptr_.PassInterface().PassHandle().release()); + ignore_result(driver_remote_.Unbind().PassPipe().release()); } void OnInitCallback() { @@ -458,33 +467,34 @@ class MojoInterfacePassingPerfTest : public mojo::core::test::MojoTestBase { void DoNextRound() { if (associated_) { - std::vector<mojom::PingReceiverAssociatedPtr> associated_interfaces( - num_interfaces_); + std::vector<mojo::AssociatedRemote<mojom::PingReceiver>> + associated_remotes(num_interfaces_); - std::vector<mojom::PingReceiverAssociatedRequest> requests( - num_interfaces_); + std::vector<mojo::PendingAssociatedReceiver<mojom::PingReceiver>> + receivers(num_interfaces_); for (size_t i = 0; i < num_interfaces_; ++i) { - requests[i] = mojo::MakeRequest(&associated_interfaces[i]); + receivers[i] = associated_remotes[i].BindNewEndpointAndPassReceiver(); // Force the interface pointer to do full initialization. - associated_interfaces[i].get(); + associated_remotes[i].get(); } - driver_ptr_->GetAssociatedPingReceiver( - std::move(requests), + driver_remote_->GetAssociatedPingReceiver( + std::move(receivers), base::Bind(&MojoInterfacePassingPerfTest::OnGetReceiverCallback, base::Unretained(this))); } else { - std::vector<mojom::PingReceiverPtr> interfaces(num_interfaces_); + std::vector<mojo::Remote<mojom::PingReceiver>> remotes(num_interfaces_); - std::vector<mojom::PingReceiverRequest> requests(num_interfaces_); + std::vector<mojo::PendingReceiver<mojom::PingReceiver>> receivers( + num_interfaces_); for (size_t i = 0; i < num_interfaces_; ++i) { - requests[i] = mojo::MakeRequest(&interfaces[i]); + receivers[i] = remotes[i].BindNewPipeAndPassReceiver(); // Force the interface pointer to do full initialization. - interfaces[i].get(); + remotes[i].get(); } - driver_ptr_->GetPingReceiver( - std::move(requests), + driver_remote_->GetPingReceiver( + std::move(receivers), base::Bind(&MojoInterfacePassingPerfTest::OnGetReceiverCallback, base::Unretained(this))); } @@ -526,7 +536,7 @@ class MojoInterfacePassingPerfTest : public mojo::core::test::MojoTestBase { bool associated_ = false; std::unique_ptr<base::PerfTimeLogger> perf_logger_; - mojom::InterfacePassingTestDriverPtr driver_ptr_; + mojo::Remote<mojom::InterfacePassingTestDriver> driver_remote_; base::Closure quit_closure_; @@ -536,7 +546,7 @@ class MojoInterfacePassingPerfTest : public mojo::core::test::MojoTestBase { DEFINE_TEST_CLIENT_WITH_PIPE(InterfacePassingClient, MojoInterfacePassingPerfTest, h) { - base::test::TaskEnvironment task_environment; + base::test::SingleThreadTaskEnvironment task_environment; return RunInterfacePassingClient(h); } @@ -571,7 +581,7 @@ using MojoInProcessInterfacePassingPerfTest = InProcessPerfTest<MojoInterfacePassingPerfTest>; DEFINE_TEST_CLIENT_WITH_PIPE(PingPongClient, MojoInterfacePerfTest, h) { - base::test::TaskEnvironment task_environment; + base::test::SingleThreadTaskEnvironment task_environment; return RunPingPongClient(h); } @@ -579,7 +589,7 @@ DEFINE_TEST_CLIENT_WITH_PIPE(PingPongClient, MojoInterfacePerfTest, h) { // raw IPC::Messages. TEST_F(MojoInterfacePerfTest, MultiprocessPingPong) { RunTestClient("PingPongClient", [&](MojoHandle h) { - base::test::TaskEnvironment task_environment; + base::test::SingleThreadTaskEnvironment task_environment; RunPingPongServer(h, "Multiprocess"); }); } @@ -587,21 +597,21 @@ TEST_F(MojoInterfacePerfTest, MultiprocessPingPong) { TEST_F(MojoInterfacePerfTest, MultiprocessSyncPing) { sync_ = true; RunTestClient("PingPongClient", [&](MojoHandle h) { - base::test::TaskEnvironment task_environment; + base::test::SingleThreadTaskEnvironment task_environment; RunPingPongServer(h, "MultiprocessSync"); }); } TEST_F(MojoInterfacePassingPerfTest, MultiprocessInterfacePassing) { RunTestClient("InterfacePassingClient", [&](MojoHandle h) { - base::test::TaskEnvironment task_environment; + base::test::SingleThreadTaskEnvironment task_environment; RunInterfacePassingServer(h, "InterfacePassing", false /* associated */); }); } TEST_F(MojoInterfacePassingPerfTest, MultiprocessAssociatedInterfacePassing) { RunTestClient("InterfacePassingClient", [&](MojoHandle h) { - base::test::TaskEnvironment task_environment; + base::test::SingleThreadTaskEnvironment task_environment; RunInterfacePassingServer(h, "AssociatedInterfacePassing", true /* associated*/); }); @@ -618,7 +628,7 @@ TEST_P(MojoInProcessInterfacePerfTest, MultiThreadPingPong) { FROM_HERE, base::BindOnce(base::IgnoreResult(&RunPingPongClient), client_handle)); - base::test::TaskEnvironment task_environment; + base::test::SingleThreadTaskEnvironment task_environment; RunPingPongServer(server_handle, "SingleProcess"); } @@ -626,7 +636,7 @@ TEST_P(MojoInProcessInterfacePerfTest, SingleThreadPingPong) { MojoHandle server_handle, client_handle; CreateMessagePipe(&server_handle, &client_handle); - base::test::TaskEnvironment task_environment; + base::test::SingleThreadTaskEnvironment task_environment; mojo::MessagePipeHandle mp_handle(client_handle); mojo::ScopedMessagePipeHandle scoped_mp(mp_handle); LockThreadAffinity thread_locker(kSharedCore); @@ -650,7 +660,7 @@ TEST_P(MojoInProcessInterfacePassingPerfTest, MultiThreadInterfacePassing) { FROM_HERE, base::BindOnce(base::IgnoreResult(&RunInterfacePassingClient), client_handle)); - base::test::TaskEnvironment task_environment; + base::test::SingleThreadTaskEnvironment task_environment; RunInterfacePassingServer(server_handle, "SingleProcess", false /* associated */); } @@ -666,7 +676,7 @@ TEST_P(MojoInProcessInterfacePassingPerfTest, FROM_HERE, base::BindOnce(base::IgnoreResult(&RunInterfacePassingClient), client_handle)); - base::test::TaskEnvironment task_environment; + base::test::SingleThreadTaskEnvironment task_environment; RunInterfacePassingServer(server_handle, "SingleProcess", true /* associated */); } @@ -675,7 +685,7 @@ TEST_P(MojoInProcessInterfacePassingPerfTest, SingleThreadInterfacePassing) { MojoHandle server_handle, client_handle; CreateMessagePipe(&server_handle, &client_handle); - base::test::TaskEnvironment task_environment; + base::test::SingleThreadTaskEnvironment task_environment; mojo::MessagePipeHandle mp_handle(client_handle); mojo::ScopedMessagePipeHandle scoped_mp(mp_handle); LockThreadAffinity thread_locker(kSharedCore); @@ -690,7 +700,7 @@ TEST_P(MojoInProcessInterfacePassingPerfTest, MojoHandle server_handle, client_handle; CreateMessagePipe(&server_handle, &client_handle); - base::test::TaskEnvironment task_environment; + base::test::SingleThreadTaskEnvironment task_environment; mojo::MessagePipeHandle mp_handle(client_handle); mojo::ScopedMessagePipeHandle scoped_mp(mp_handle); LockThreadAffinity thread_locker(kSharedCore); @@ -836,7 +846,7 @@ class CallbackPerfTest : public testing::Test { private: base::Thread client_thread_; - base::test::TaskEnvironment task_environment_; + base::test::SingleThreadTaskEnvironment task_environment_; int message_count_; int count_down_; std::string payload_; diff --git a/chromium/ipc/ipc_perftest_util.cc b/chromium/ipc/ipc_perftest_util.cc index 3d491899400..cf35d3cda12 100644 --- a/chromium/ipc/ipc_perftest_util.cc +++ b/chromium/ipc/ipc_perftest_util.cc @@ -123,10 +123,12 @@ int MojoPerfTestClient::Run(MojoHandle handle) { ReflectorImpl::ReflectorImpl(mojo::ScopedMessagePipeHandle handle, const base::Closure& quit_closure) : quit_closure_(quit_closure), - binding_(this, IPC::mojom::ReflectorRequest(std::move(handle))) {} + receiver_( + this, + mojo::PendingReceiver<IPC::mojom::Reflector>(std::move(handle))) {} ReflectorImpl::~ReflectorImpl() { - ignore_result(binding_.Unbind().PassMessagePipe().release()); + ignore_result(receiver_.Unbind().PassPipe().release()); } void ReflectorImpl::Ping(const std::string& value, PingCallback callback) { diff --git a/chromium/ipc/ipc_perftest_util.h b/chromium/ipc/ipc_perftest_util.h index 5925e3db345..a2d3cfd40e1 100644 --- a/chromium/ipc/ipc_perftest_util.h +++ b/chromium/ipc/ipc_perftest_util.h @@ -23,7 +23,7 @@ #include "ipc/ipc_message.h" #include "ipc/ipc_sender.h" #include "ipc/ipc_test.mojom.h" -#include "mojo/public/cpp/bindings/binding.h" +#include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/system/core.h" #if defined(OS_WIN) @@ -119,7 +119,7 @@ class ReflectorImpl : public IPC::mojom::Reflector { void Quit() override; base::Closure quit_closure_; - mojo::Binding<IPC::mojom::Reflector> binding_; + mojo::Receiver<IPC::mojom::Reflector> receiver_; }; } // namespace IPC diff --git a/chromium/ipc/ipc_sync_channel_unittest.cc b/chromium/ipc/ipc_sync_channel_unittest.cc index bee31c53ffd..31a734b8eca 100644 --- a/chromium/ipc/ipc_sync_channel_unittest.cc +++ b/chromium/ipc/ipc_sync_channel_unittest.cc @@ -291,7 +291,7 @@ void RunTest(std::vector<Worker*> workers) { class IPCSyncChannelTest : public testing::Test { private: - base::test::TaskEnvironment task_environment_; + base::test::SingleThreadTaskEnvironment task_environment_; }; //------------------------------------------------------------------------------ diff --git a/chromium/ipc/ipc_test.mojom b/chromium/ipc/ipc_test.mojom index fc24e37c090..04c4b0e7fad 100644 --- a/chromium/ipc/ipc_test.mojom +++ b/chromium/ipc/ipc_test.mojom @@ -32,7 +32,7 @@ interface TestStructPasser { }; interface IndirectTestDriver { - GetPingReceiver(associated PingReceiver& request); + GetPingReceiver(pending_associated_receiver<PingReceiver> receiver); }; interface Reflector { @@ -43,12 +43,13 @@ interface Reflector { }; interface AssociatedInterfaceVendor { - GetTestInterface(associated SimpleTestDriver& interface_reqest); + GetTestInterface(pending_associated_receiver<SimpleTestDriver> receiver); }; interface InterfacePassingTestDriver { Init() => (); - GetPingReceiver(array<PingReceiver&> request) => (); - GetAssociatedPingReceiver(array<associated PingReceiver&> request) => (); + GetPingReceiver(array<pending_receiver<PingReceiver>> receiver) => (); + GetAssociatedPingReceiver( + array<pending_associated_receiver<PingReceiver>> receiver) => (); Quit(); }; diff --git a/chromium/ipc/ipc_test_base.h b/chromium/ipc/ipc_test_base.h index 2ccc5490a7f..5727d9b8a0c 100644 --- a/chromium/ipc/ipc_test_base.h +++ b/chromium/ipc/ipc_test_base.h @@ -75,8 +75,8 @@ class IpcChannelMojoTestClient { IPC::Channel* channel() const { return channel_.get(); } private: - base::test::TaskEnvironment task_environment_{ - base::test::TaskEnvironment::MainThreadType::IO}; + base::test::SingleThreadTaskEnvironment task_environment_{ + base::test::SingleThreadTaskEnvironment::MainThreadType::IO}; mojo::ScopedMessagePipeHandle handle_; std::unique_ptr<IPC::Channel> channel_; }; |