Commit 6eb409ed authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Commit Bot

Convert interfaces from ipc_test.mojom to new Mojo types

This CL converts TestStructPasser, IndirectTestDriver, Reflector,
AssociatedInterfaceVendor, and InterfacePassingTestDriver to new
mojo types using PendingRemote, Remote, PendingReceiver, Receiver,
PendingAssociatedRemote, AssociatedRemote,
PendingAssociatedReceiver, and AssociatedReceiver.

Bug: 955171
Change-Id: If07e5ac24047b43dd147887f1dac03f113371b4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1827113Reviewed-by: default avatarKen Rockot <rockot@google.com>
Commit-Queue: Julie Kim <jkim@igalia.com>
Cr-Commit-Position: refs/heads/master@{#700934}
parent 924acc8f
...@@ -255,7 +255,8 @@ TEST_F(IPCChannelMojoTest, SendFailWithPendingMessages) { ...@@ -255,7 +255,8 @@ TEST_F(IPCChannelMojoTest, SendFailWithPendingMessages) {
class ListenerThatBindsATestStructPasser : public IPC::Listener, class ListenerThatBindsATestStructPasser : public IPC::Listener,
public IPC::mojom::TestStructPasser { public IPC::mojom::TestStructPasser {
public: public:
ListenerThatBindsATestStructPasser() : binding_(this) {} ListenerThatBindsATestStructPasser() = default;
~ListenerThatBindsATestStructPasser() override = default;
bool OnMessageReceived(const IPC::Message& message) override { return true; } bool OnMessageReceived(const IPC::Message& message) override { return true; }
...@@ -267,15 +268,16 @@ class ListenerThatBindsATestStructPasser : public IPC::Listener, ...@@ -267,15 +268,16 @@ class ListenerThatBindsATestStructPasser : public IPC::Listener,
const std::string& interface_name, const std::string& interface_name,
mojo::ScopedInterfaceEndpointHandle handle) override { mojo::ScopedInterfaceEndpointHandle handle) override {
CHECK_EQ(interface_name, IPC::mojom::TestStructPasser::Name_); CHECK_EQ(interface_name, IPC::mojom::TestStructPasser::Name_);
binding_.Bind( receiver_.Bind(
IPC::mojom::TestStructPasserAssociatedRequest(std::move(handle))); mojo::PendingAssociatedReceiver<IPC::mojom::TestStructPasser>(
std::move(handle)));
} }
private: private:
// IPC::mojom::TestStructPasser: // IPC::mojom::TestStructPasser:
void Pass(IPC::mojom::TestStructPtr) override { NOTREACHED(); } 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 { class ListenerThatExpectsNoError : public IPC::Listener {
...@@ -314,9 +316,9 @@ DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT( ...@@ -314,9 +316,9 @@ DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT(
Connect(&listener); Connect(&listener);
wait_to_connect_loop.Run(); wait_to_connect_loop.Run();
IPC::mojom::TestStructPasserAssociatedPtr passer; mojo::AssociatedRemote<IPC::mojom::TestStructPasser> passer;
channel()->GetAssociatedInterfaceSupport()->GetRemoteAssociatedInterface( channel()->GetAssociatedInterfaceSupport()->GetRemoteAssociatedInterface(
&passer); passer.BindNewEndpointAndPassReceiver());
// This avoids hitting DCHECKs in the serialization code meant to stop us from // 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. // making such "mistakes" as the one we're about to make below.
...@@ -1006,7 +1008,8 @@ class ListenerWithIndirectProxyAssociatedInterface ...@@ -1006,7 +1008,8 @@ class ListenerWithIndirectProxyAssociatedInterface
DCHECK(!driver_binding_.is_bound()); DCHECK(!driver_binding_.is_bound());
DCHECK_EQ(interface_name, IPC::mojom::IndirectTestDriver::Name_); DCHECK_EQ(interface_name, IPC::mojom::IndirectTestDriver::Name_);
driver_binding_.Bind( 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) { void set_ping_handler(const base::RepeatingClosure& handler) {
...@@ -1065,7 +1068,7 @@ DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT_WITH_CUSTOM_FIXTURE( ...@@ -1065,7 +1068,7 @@ DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT_WITH_CUSTOM_FIXTURE(
// message we send will still be dispatched properly even though the remote // 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 // endpoint may not have been bound yet by the time the message is initially
// processed on the IO thread. // processed on the IO thread.
IPC::mojom::IndirectTestDriverAssociatedPtr driver; mojo::AssociatedRemote<IPC::mojom::IndirectTestDriver> driver;
mojo::AssociatedRemote<IPC::mojom::PingReceiver> ping_receiver; mojo::AssociatedRemote<IPC::mojom::PingReceiver> ping_receiver;
proxy()->GetRemoteAssociatedInterface(&driver); proxy()->GetRemoteAssociatedInterface(&driver);
driver->GetPingReceiver(ping_receiver.BindNewEndpointAndPassReceiver()); driver->GetPingReceiver(ping_receiver.BindNewEndpointAndPassReceiver());
...@@ -1425,7 +1428,7 @@ TEST_F(IPCChannelProxyMojoTest, AssociatedRequestClose) { ...@@ -1425,7 +1428,7 @@ TEST_F(IPCChannelProxyMojoTest, AssociatedRequestClose) {
CreateProxy(&listener); CreateProxy(&listener);
RunProxy(); RunProxy();
IPC::mojom::AssociatedInterfaceVendorAssociatedPtr vendor; mojo::AssociatedRemote<IPC::mojom::AssociatedInterfaceVendor> vendor;
proxy()->GetRemoteAssociatedInterface(&vendor); proxy()->GetRemoteAssociatedInterface(&vendor);
mojo::AssociatedRemote<IPC::mojom::SimpleTestDriver> tester; mojo::AssociatedRemote<IPC::mojom::SimpleTestDriver> tester;
vendor->GetTestInterface(tester.BindNewEndpointAndPassReceiver()); vendor->GetTestInterface(tester.BindNewEndpointAndPassReceiver());
......
...@@ -20,7 +20,8 @@ ...@@ -20,7 +20,8 @@
#include "ipc/ipc_test_base.h" #include "ipc/ipc_test_base.h"
#include "mojo/core/test/mojo_test_base.h" #include "mojo/core/test/mojo_test_base.h"
#include "mojo/core/test/multiprocess_test_helper.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" #include "mojo/public/cpp/system/message_pipe.h"
namespace IPC { namespace IPC {
...@@ -276,7 +277,8 @@ class MojoSteadyPingPongTest : public mojo::core::test::MojoTestBase { ...@@ -276,7 +277,8 @@ class MojoSteadyPingPongTest : public mojo::core::test::MojoTestBase {
mojo::MessagePipeHandle mp_handle(mp); mojo::MessagePipeHandle mp_handle(mp);
mojo::ScopedMessagePipeHandle scoped_mp(mp_handle); 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); LockThreadAffinity thread_locker(kSharedCore);
std::vector<TestParams> params_list = GetDefaultTestParams(); std::vector<TestParams> params_list = GetDefaultTestParams();
...@@ -293,7 +295,7 @@ class MojoSteadyPingPongTest : public mojo::core::test::MojoTestBase { ...@@ -293,7 +295,7 @@ class MojoSteadyPingPongTest : public mojo::core::test::MojoTestBase {
ping_receiver_->Quit(); ping_receiver_->Quit();
ignore_result(ping_receiver_.PassInterface().PassHandle().release()); ignore_result(ping_receiver_.Unbind().PassPipe().release());
} }
void OnHello(const std::string& value) { void OnHello(const std::string& value) {
...@@ -380,7 +382,7 @@ class MojoSteadyPingPongTest : public mojo::core::test::MojoTestBase { ...@@ -380,7 +382,7 @@ class MojoSteadyPingPongTest : public mojo::core::test::MojoTestBase {
std::string label_; std::string label_;
bool sync_ = false; bool sync_ = false;
IPC::mojom::ReflectorPtr ping_receiver_; mojo::Remote<IPC::mojom::Reflector> ping_receiver_;
int count_down_ = 0; int count_down_ = 0;
int frame_count_down_ = 0; int frame_count_down_ = 0;
......
...@@ -27,9 +27,10 @@ ...@@ -27,9 +27,10 @@
#include "mojo/core/test/multiprocess_test_helper.h" #include "mojo/core/test/multiprocess_test_helper.h"
#include "mojo/public/cpp/bindings/associated_receiver_set.h" #include "mojo/public/cpp/bindings/associated_receiver_set.h"
#include "mojo/public/cpp/bindings/associated_remote.h" #include "mojo/public/cpp/bindings/associated_remote.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h" #include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_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/receiver_set.h"
#include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/system/message_pipe.h" #include "mojo/public/cpp/system/message_pipe.h"
...@@ -288,7 +289,8 @@ class MojoInterfacePerfTest : public mojo::core::test::MojoTestBase { ...@@ -288,7 +289,8 @@ class MojoInterfacePerfTest : public mojo::core::test::MojoTestBase {
mojo::MessagePipeHandle mp_handle(mp); mojo::MessagePipeHandle mp_handle(mp);
mojo::ScopedMessagePipeHandle scoped_mp(mp_handle); 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); LockThreadAffinity thread_locker(kSharedCore);
std::vector<PingPongTestParams> params = GetDefaultTestParams(); std::vector<PingPongTestParams> params = GetDefaultTestParams();
...@@ -303,7 +305,7 @@ class MojoInterfacePerfTest : public mojo::core::test::MojoTestBase { ...@@ -303,7 +305,7 @@ class MojoInterfacePerfTest : public mojo::core::test::MojoTestBase {
ping_receiver_->Quit(); ping_receiver_->Quit();
ignore_result(ping_receiver_.PassInterface().PassHandle().release()); ignore_result(ping_receiver_.Unbind().PassPipe().release());
} }
void OnPong(const std::string& value) { void OnPong(const std::string& value) {
...@@ -360,7 +362,7 @@ class MojoInterfacePerfTest : public mojo::core::test::MojoTestBase { ...@@ -360,7 +362,7 @@ class MojoInterfacePerfTest : public mojo::core::test::MojoTestBase {
int count_down_; int count_down_;
std::string label_; std::string label_;
std::string payload_; std::string payload_;
IPC::mojom::ReflectorPtr ping_receiver_; mojo::Remote<IPC::mojom::Reflector> ping_receiver_;
std::unique_ptr<base::PerfTimeLogger> perf_logger_; std::unique_ptr<base::PerfTimeLogger> perf_logger_;
DISALLOW_COPY_AND_ASSIGN(MojoInterfacePerfTest); DISALLOW_COPY_AND_ASSIGN(MojoInterfacePerfTest);
...@@ -371,11 +373,12 @@ class InterfacePassingTestDriverImpl : public mojom::InterfacePassingTestDriver, ...@@ -371,11 +373,12 @@ class InterfacePassingTestDriverImpl : public mojom::InterfacePassingTestDriver,
public: public:
InterfacePassingTestDriverImpl(mojo::ScopedMessagePipeHandle handle, InterfacePassingTestDriverImpl(mojo::ScopedMessagePipeHandle handle,
const base::Closure& quit_closure) const base::Closure& quit_closure)
: binding_(this, : receiver_(this,
mojom::InterfacePassingTestDriverRequest(std::move(handle))), mojo::PendingReceiver<mojom::InterfacePassingTestDriver>(
std::move(handle))),
quit_closure_(quit_closure) {} quit_closure_(quit_closure) {}
~InterfacePassingTestDriverImpl() override { ~InterfacePassingTestDriverImpl() override {
ignore_result(binding_.Unbind().PassMessagePipe().release()); ignore_result(receiver_.Unbind().PassPipe().release());
} }
private: private:
...@@ -412,7 +415,7 @@ class InterfacePassingTestDriverImpl : public mojom::InterfacePassingTestDriver, ...@@ -412,7 +415,7 @@ class InterfacePassingTestDriverImpl : public mojom::InterfacePassingTestDriver,
mojo::ReceiverSet<mojom::PingReceiver> ping_receiver_receivers_; mojo::ReceiverSet<mojom::PingReceiver> ping_receiver_receivers_;
mojo::AssociatedReceiverSet<mojom::PingReceiver> mojo::AssociatedReceiverSet<mojom::PingReceiver>
ping_receiver_associated_receivers_; ping_receiver_associated_receivers_;
mojo::Binding<mojom::InterfacePassingTestDriver> binding_; mojo::Receiver<mojom::InterfacePassingTestDriver> receiver_;
base::Closure quit_closure_; base::Closure quit_closure_;
}; };
...@@ -430,14 +433,14 @@ class MojoInterfacePassingPerfTest : public mojo::core::test::MojoTestBase { ...@@ -430,14 +433,14 @@ class MojoInterfacePassingPerfTest : public mojo::core::test::MojoTestBase {
mojo::MessagePipeHandle mp_handle(mp); mojo::MessagePipeHandle mp_handle(mp);
mojo::ScopedMessagePipeHandle scoped_mp(mp_handle); mojo::ScopedMessagePipeHandle scoped_mp(mp_handle);
driver_ptr_.Bind( driver_remote_.Bind(mojo::PendingRemote<mojom::InterfacePassingTestDriver>(
mojom::InterfacePassingTestDriverPtrInfo(std::move(scoped_mp), 0u)); std::move(scoped_mp), 0u));
auto params = GetDefaultInterfacePassingTestParams(); auto params = GetDefaultInterfacePassingTestParams();
LockThreadAffinity thread_locker(kSharedCore); LockThreadAffinity thread_locker(kSharedCore);
for (size_t i = 0; i < params.size(); ++i) { for (size_t i = 0; i < params.size(); ++i) {
driver_ptr_->Init( driver_remote_->Init(
base::Bind(&MojoInterfacePassingPerfTest::OnInitCallback, base::Bind(&MojoInterfacePassingPerfTest::OnInitCallback,
base::Unretained(this))); base::Unretained(this)));
rounds_ = count_down_ = params[i].rounds(); rounds_ = count_down_ = params[i].rounds();
...@@ -448,9 +451,9 @@ class MojoInterfacePassingPerfTest : public mojo::core::test::MojoTestBase { ...@@ -448,9 +451,9 @@ class MojoInterfacePassingPerfTest : public mojo::core::test::MojoTestBase {
run_loop.Run(); 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() { void OnInitCallback() {
...@@ -475,7 +478,7 @@ class MojoInterfacePassingPerfTest : public mojo::core::test::MojoTestBase { ...@@ -475,7 +478,7 @@ class MojoInterfacePassingPerfTest : public mojo::core::test::MojoTestBase {
associated_remotes[i].get(); associated_remotes[i].get();
} }
driver_ptr_->GetAssociatedPingReceiver( driver_remote_->GetAssociatedPingReceiver(
std::move(receivers), std::move(receivers),
base::Bind(&MojoInterfacePassingPerfTest::OnGetReceiverCallback, base::Bind(&MojoInterfacePassingPerfTest::OnGetReceiverCallback,
base::Unretained(this))); base::Unretained(this)));
...@@ -490,7 +493,7 @@ class MojoInterfacePassingPerfTest : public mojo::core::test::MojoTestBase { ...@@ -490,7 +493,7 @@ class MojoInterfacePassingPerfTest : public mojo::core::test::MojoTestBase {
remotes[i].get(); remotes[i].get();
} }
driver_ptr_->GetPingReceiver( driver_remote_->GetPingReceiver(
std::move(receivers), std::move(receivers),
base::Bind(&MojoInterfacePassingPerfTest::OnGetReceiverCallback, base::Bind(&MojoInterfacePassingPerfTest::OnGetReceiverCallback,
base::Unretained(this))); base::Unretained(this)));
...@@ -533,7 +536,7 @@ class MojoInterfacePassingPerfTest : public mojo::core::test::MojoTestBase { ...@@ -533,7 +536,7 @@ class MojoInterfacePassingPerfTest : public mojo::core::test::MojoTestBase {
bool associated_ = false; bool associated_ = false;
std::unique_ptr<base::PerfTimeLogger> perf_logger_; std::unique_ptr<base::PerfTimeLogger> perf_logger_;
mojom::InterfacePassingTestDriverPtr driver_ptr_; mojo::Remote<mojom::InterfacePassingTestDriver> driver_remote_;
base::Closure quit_closure_; base::Closure quit_closure_;
......
...@@ -123,10 +123,12 @@ int MojoPerfTestClient::Run(MojoHandle handle) { ...@@ -123,10 +123,12 @@ int MojoPerfTestClient::Run(MojoHandle handle) {
ReflectorImpl::ReflectorImpl(mojo::ScopedMessagePipeHandle handle, ReflectorImpl::ReflectorImpl(mojo::ScopedMessagePipeHandle handle,
const base::Closure& quit_closure) const base::Closure& quit_closure)
: quit_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() { ReflectorImpl::~ReflectorImpl() {
ignore_result(binding_.Unbind().PassMessagePipe().release()); ignore_result(receiver_.Unbind().PassPipe().release());
} }
void ReflectorImpl::Ping(const std::string& value, PingCallback callback) { void ReflectorImpl::Ping(const std::string& value, PingCallback callback) {
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "ipc/ipc_message.h" #include "ipc/ipc_message.h"
#include "ipc/ipc_sender.h" #include "ipc/ipc_sender.h"
#include "ipc/ipc_test.mojom.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" #include "mojo/public/cpp/system/core.h"
#if defined(OS_WIN) #if defined(OS_WIN)
...@@ -119,7 +119,7 @@ class ReflectorImpl : public IPC::mojom::Reflector { ...@@ -119,7 +119,7 @@ class ReflectorImpl : public IPC::mojom::Reflector {
void Quit() override; void Quit() override;
base::Closure quit_closure_; base::Closure quit_closure_;
mojo::Binding<IPC::mojom::Reflector> binding_; mojo::Receiver<IPC::mojom::Reflector> receiver_;
}; };
} // namespace IPC } // namespace IPC
......
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