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

Unified Diff: ipc/ipc_test_base.cc

Issue 2455823002: Support generic synchronization against an IPC::Channel (Closed)
Patch Set: . Created 4 years, 2 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_test_base.h ('k') | mojo/common/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_test_base.cc
diff --git a/ipc/ipc_test_base.cc b/ipc/ipc_test_base.cc
index 8bc6bfc7c81e8e6bd29ce6895a9d62e3009e35d6..84ccae53e12726f9b4c6169b538a54270b4163e5 100644
--- a/ipc/ipc_test_base.cc
+++ b/ipc/ipc_test_base.cc
@@ -170,15 +170,50 @@ std::unique_ptr<IPC::ChannelFactory> IPCTestBase::CreateChannelFactory(
base::SingleThreadTaskRunner* runner) {
return IPC::ChannelFactory::Create(handle, IPC::Channel::MODE_SERVER, runner);
}
+
+IPCChannelMojoTestBase::ClientHandle::ClientHandle() = default;
+
+IPCChannelMojoTestBase::ClientHandle::~ClientHandle() = default;
+
+void IPCChannelMojoTestBase::ClientHandle::Init(
+ const std::string& test_client_name) {
+ pipe_ = helper_.StartChild(test_client_name);
+}
+
+void IPCChannelMojoTestBase::ClientHandle::CreateChannel(
+ IPC::Listener* listener) {
+ channel_ =
+ IPC::ChannelMojo::Create(TakeHandle(), IPC::Channel::MODE_SERVER,
+ listener, base::ThreadTaskRunnerHandle::Get());
+}
+
+bool IPCChannelMojoTestBase::ClientHandle::ConnectChannel() {
+ return channel_->Connect();
+}
+
+void IPCChannelMojoTestBase::ClientHandle::DestroyChannel() {
+ channel_.reset();
+}
+
+bool IPCChannelMojoTestBase::ClientHandle::WaitForShutdown() {
+ return helper_.WaitForChildTestShutdown();
+}
+
+mojo::ScopedMessagePipeHandle
+IPCChannelMojoTestBase::ClientHandle::TakeHandle() {
+ return std::move(pipe_);
+}
+
IPCChannelMojoTestBase::IPCChannelMojoTestBase() = default;
+
IPCChannelMojoTestBase::~IPCChannelMojoTestBase() = default;
void IPCChannelMojoTestBase::Init(const std::string& test_client_name) {
- handle_ = helper_.StartChild(test_client_name);
+ primary_client_.Init(test_client_name);
}
bool IPCChannelMojoTestBase::WaitForClientShutdown() {
- return helper_.WaitForChildTestShutdown();
+ return primary_client_.WaitForShutdown();
}
void IPCChannelMojoTestBase::TearDown() {
@@ -186,21 +221,19 @@ void IPCChannelMojoTestBase::TearDown() {
}
void IPCChannelMojoTestBase::CreateChannel(IPC::Listener* listener) {
- channel_ =
- IPC::ChannelMojo::Create(TakeHandle(), IPC::Channel::MODE_SERVER,
- listener, base::ThreadTaskRunnerHandle::Get());
+ primary_client_.CreateChannel(listener);
}
bool IPCChannelMojoTestBase::ConnectChannel() {
- return channel_->Connect();
+ return primary_client_.ConnectChannel();
}
void IPCChannelMojoTestBase::DestroyChannel() {
- channel_.reset();
+ return primary_client_.DestroyChannel();
}
mojo::ScopedMessagePipeHandle IPCChannelMojoTestBase::TakeHandle() {
- return std::move(handle_);
+ return primary_client_.TakeHandle();
}
IpcChannelMojoTestClient::IpcChannelMojoTestClient() = default;
« no previous file with comments | « ipc/ipc_test_base.h ('k') | mojo/common/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698