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

Unified Diff: ipc/mojo/ipc_channel_mojo_unittest.cc

Issue 553283002: IPC::ChannelMojo: Introduce IPC::MojoBootstrap for Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed build error Created 6 years, 3 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/mojo/ipc_channel_mojo_host.cc ('k') | ipc/mojo/ipc_mojo.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/mojo/ipc_channel_mojo_unittest.cc
diff --git a/ipc/mojo/ipc_channel_mojo_unittest.cc b/ipc/mojo/ipc_channel_mojo_unittest.cc
index 2b9a954567fc32eb6d43149c6fa996794450253d..076353302fc4671d70a81ba6d81ccde5659bd401 100644
--- a/ipc/mojo/ipc_channel_mojo_unittest.cc
+++ b/ipc/mojo/ipc_channel_mojo_unittest.cc
@@ -13,6 +13,7 @@
#include "ipc/ipc_message.h"
#include "ipc/ipc_test_base.h"
#include "ipc/ipc_test_channel_listener.h"
+#include "ipc/mojo/ipc_channel_mojo_host.h"
#include "ipc/mojo/ipc_channel_mojo_readers.h"
#if defined(OS_POSIX)
@@ -59,9 +60,10 @@ class ListenerThatExpectsOK : public IPC::Listener {
class ChannelClient {
public:
explicit ChannelClient(IPC::Listener* listener, const char* name) {
- channel_ = IPC::ChannelMojo::Create(
- IPCTestBase::GetChannelName(name), IPC::Channel::MODE_CLIENT, listener,
- main_message_loop_.message_loop_proxy());
+ channel_ = IPC::ChannelMojo::Create(NULL,
+ IPCTestBase::GetChannelName(name),
+ IPC::Channel::MODE_CLIENT,
+ listener);
}
void Connect() {
@@ -71,8 +73,8 @@ class ChannelClient {
IPC::ChannelMojo* channel() const { return channel_.get(); }
private:
- scoped_ptr<IPC::ChannelMojo> channel_;
base::MessageLoopForIO main_message_loop_;
+ scoped_ptr<IPC::ChannelMojo> channel_;
};
class IPCChannelMojoTest : public IPCTestBase {
@@ -80,9 +82,19 @@ class IPCChannelMojoTest : public IPCTestBase {
virtual scoped_ptr<IPC::ChannelFactory> CreateChannelFactory(
const IPC::ChannelHandle& handle,
base::TaskRunner* runner) OVERRIDE {
- return IPC::ChannelMojo::CreateFactory(
- handle, IPC::Channel::MODE_SERVER, runner);
+ host_.reset(new IPC::ChannelMojoHost(task_runner()));
+ return IPC::ChannelMojo::CreateServerFactory(host_.get(), handle);
+ }
+
+ virtual bool DidStartClient() OVERRIDE {
+ bool ok = IPCTestBase::DidStartClient();
+ DCHECK(ok);
+ host_->OnClientLaunched(client_process());
+ return ok;
}
+
+ private:
+ scoped_ptr<IPC::ChannelMojoHost> host_;
};
@@ -149,13 +161,12 @@ MULTIPROCESS_IPC_TEST_CLIENT_MAIN(IPCChannelMojoTestClient) {
// Close given handle before use to simulate an error.
class ErraticChannelMojo : public IPC::ChannelMojo {
public:
- ErraticChannelMojo(
- const IPC::ChannelHandle& channel_handle,
- IPC::Channel::Mode mode,
- IPC::Listener* listener,
- scoped_refptr<base::TaskRunner> runner)
- : ChannelMojo(channel_handle, mode, listener, runner) {
- }
+ ErraticChannelMojo(IPC::ChannelMojoHost* host,
+ const IPC::ChannelHandle& channel_handle,
+ IPC::Channel::Mode mode,
+ IPC::Listener* listener,
+ scoped_refptr<base::TaskRunner> runner)
+ : ChannelMojo(host, channel_handle, mode, listener) {}
virtual void OnConnected(mojo::ScopedMessagePipeHandle pipe) {
MojoClose(pipe.get().value());
@@ -166,11 +177,10 @@ class ErraticChannelMojo : public IPC::ChannelMojo {
// Exists to create ErraticChannelMojo.
class ErraticChannelFactory : public IPC::ChannelFactory {
public:
- explicit ErraticChannelFactory(
- const IPC::ChannelHandle& handle,
- base::TaskRunner* runner)
- : handle_(handle), runner_(runner) {
- }
+ explicit ErraticChannelFactory(IPC::ChannelMojoHost* host,
+ const IPC::ChannelHandle& handle,
+ base::TaskRunner* runner)
+ : host_(host), handle_(handle), runner_(runner) {}
virtual std::string GetName() const OVERRIDE {
return "";
@@ -178,12 +188,12 @@ class ErraticChannelFactory : public IPC::ChannelFactory {
virtual scoped_ptr<IPC::Channel> BuildChannel(
IPC::Listener* listener) OVERRIDE {
- return scoped_ptr<IPC::Channel>(
- new ErraticChannelMojo(
- handle_, IPC::Channel::MODE_SERVER, listener, runner_));
+ return scoped_ptr<IPC::Channel>(new ErraticChannelMojo(
+ host_, handle_, IPC::Channel::MODE_SERVER, listener, runner_));
}
private:
+ IPC::ChannelMojoHost* host_;
IPC::ChannelHandle handle_;
scoped_refptr<base::TaskRunner> runner_;
};
@@ -215,9 +225,20 @@ class IPCChannelMojoErrorTest : public IPCTestBase {
virtual scoped_ptr<IPC::ChannelFactory> CreateChannelFactory(
const IPC::ChannelHandle& handle,
base::TaskRunner* runner) OVERRIDE {
+ host_.reset(new IPC::ChannelMojoHost(task_runner()));
return scoped_ptr<IPC::ChannelFactory>(
- new ErraticChannelFactory(handle, runner));
+ new ErraticChannelFactory(host_.get(), handle, runner));
+ }
+
+ virtual bool DidStartClient() OVERRIDE {
+ bool ok = IPCTestBase::DidStartClient();
+ DCHECK(ok);
+ host_->OnClientLaunched(client_process());
+ return ok;
}
+
+ private:
+ scoped_ptr<IPC::ChannelMojoHost> host_;
};
class ListenerThatQuits : public IPC::Listener {
« no previous file with comments | « ipc/mojo/ipc_channel_mojo_host.cc ('k') | ipc/mojo/ipc_mojo.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698