Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1083)

Unified Diff: ipc/ipc_channel_mojo_unittest.cc

Issue 2159293002: Plumb explicit IPC task runner through to IPC::Channel creation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add dcheck Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ipc/ipc_channel_mojo.cc ('k') | ipc/ipc_channel_proxy.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_channel_mojo_unittest.cc
diff --git a/ipc/ipc_channel_mojo_unittest.cc b/ipc/ipc_channel_mojo_unittest.cc
index 0e085162ca0cc81caa09796ed629b3487fad0bf1..041672023a6a84f173bc45e4c82c27d7ab6b89d2 100644
--- a/ipc/ipc_channel_mojo_unittest.cc
+++ b/ipc/ipc_channel_mojo_unittest.cc
@@ -108,8 +108,9 @@ class ChannelClient {
}
void Connect(IPC::Listener* listener) {
- channel_ = IPC::ChannelMojo::Create(std::move(handle_),
- IPC::Channel::MODE_CLIENT, listener);
+ channel_ = IPC::ChannelMojo::Create(
+ std::move(handle_), IPC::Channel::MODE_CLIENT, listener,
+ base::ThreadTaskRunnerHandle::Get());
CHECK(channel_->Connect());
}
@@ -152,7 +153,8 @@ class IPCChannelMojoTest : public IPCChannelMojoTestBase {
void CreateChannel(IPC::Listener* listener) {
channel_ = IPC::ChannelMojo::Create(
- TakeHandle(), IPC::Channel::MODE_SERVER, listener);
+ TakeHandle(), IPC::Channel::MODE_SERVER, listener,
+ base::ThreadTaskRunnerHandle::Get());
}
bool ConnectChannel() { return channel_->Connect(); }
@@ -711,8 +713,10 @@ DEFINE_IPC_CHANNEL_MOJO_TEST_CLIENT(SimpleAssociatedInterfaceClient,
class ChannelProxyRunner {
public:
- ChannelProxyRunner(std::unique_ptr<IPC::ChannelFactory> channel_factory)
- : channel_factory_(std::move(channel_factory)),
+ ChannelProxyRunner(mojo::ScopedMessagePipeHandle handle,
+ bool for_server)
+ : for_server_(for_server),
+ handle_(std::move(handle)),
io_thread_("ChannelProxyRunner IO thread") {
}
@@ -721,13 +725,25 @@ class ChannelProxyRunner {
base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
proxy_.reset(new IPC::ChannelProxy(listener, io_thread_.task_runner()));
}
- void RunProxy() { proxy_->Init(std::move(channel_factory_), true); }
+
+ void RunProxy() {
+ std::unique_ptr<IPC::ChannelFactory> factory;
+ if (for_server_) {
+ factory = IPC::ChannelMojo::CreateServerFactory(
+ std::move(handle_), io_thread_.task_runner());
+ } else {
+ factory = IPC::ChannelMojo::CreateClientFactory(
+ std::move(handle_), io_thread_.task_runner());
+ }
+ proxy_->Init(std::move(factory), true);
+ }
IPC::ChannelProxy* proxy() { return proxy_.get(); }
private:
- std::unique_ptr<IPC::ChannelFactory> channel_factory_;
+ const bool for_server_;
+ mojo::ScopedMessagePipeHandle handle_;
base::Thread io_thread_;
std::unique_ptr<IPC::ChannelProxy> proxy_;
@@ -738,8 +754,7 @@ class IPCChannelProxyMojoTest : public IPCChannelMojoTestBase {
public:
void InitWithMojo(const std::string& client_name) {
IPCChannelMojoTestBase::InitWithMojo(client_name);
- runner_.reset(new ChannelProxyRunner(
- IPC::ChannelMojo::CreateServerFactory(TakeHandle())));
+ runner_.reset(new ChannelProxyRunner(TakeHandle(), true));
}
void CreateProxy(IPC::Listener* listener) { runner_->CreateProxy(listener); }
void RunProxy() { runner_->RunProxy(); }
@@ -829,8 +844,7 @@ TEST_F(IPCChannelProxyMojoTest, ProxyThreadAssociatedInterface) {
class ChannelProxyClient {
public:
void Init(mojo::ScopedMessagePipeHandle handle) {
- runner_.reset(new ChannelProxyRunner(
- IPC::ChannelMojo::CreateClientFactory(std::move(handle))));
+ runner_.reset(new ChannelProxyRunner(std::move(handle), false));
}
void CreateProxy(IPC::Listener* listener) { runner_->CreateProxy(listener); }
void RunProxy() { runner_->RunProxy(); }
« no previous file with comments | « ipc/ipc_channel_mojo.cc ('k') | ipc/ipc_channel_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698