Index: ipc/ipc_test_base.cc |
diff --git a/ipc/ipc_test_base.cc b/ipc/ipc_test_base.cc |
index 6abef0f1470b47b721dbf16ad7de8a188e9d2204..7950cb5c98830c536123d1877a24e985409afa3b 100644 |
--- a/ipc/ipc_test_base.cc |
+++ b/ipc/ipc_test_base.cc |
@@ -52,8 +52,7 @@ void IPCTestBase::InitWithCustomMessageLoop( |
} |
void IPCTestBase::CreateChannel(IPC::Listener* listener) { |
- CreateChannelFromChannelHandle( |
- GetChannelName(test_client_name_), listener); |
+ CreateChannelFromChannelHandle(GetTestChannelHandle(), listener); |
} |
bool IPCTestBase::ConnectChannel() { |
@@ -90,8 +89,7 @@ void IPCTestBase::CreateChannelProxy( |
CHECK(!channel_.get()); |
CHECK(!channel_proxy_.get()); |
channel_proxy_ = IPC::ChannelProxy::Create( |
- CreateChannelFactory(GetChannelName(test_client_name_), |
- ipc_task_runner.get()), |
+ CreateChannelFactory(GetTestChannelHandle(), ipc_task_runner.get()), |
listener, |
ipc_task_runner); |
} |
@@ -102,6 +100,27 @@ void IPCTestBase::DestroyChannelProxy() { |
} |
bool IPCTestBase::StartClient() { |
+ CHECK(channel_ || channel_proxy_); |
+#if defined(OS_WIN) |
+ return StartClientInternal(0); |
viettrungluu
2014/09/15 22:37:27
I don't know if I'm a huge fan of this.
I'd like
Hajime Morrita
2014/09/15 23:51:32
Tried this and now looks simpler. Thanks for the s
|
+#elif defined(OS_POSIX) |
+ return StartClientInternal( |
+ channel_ |
+ ? channel_->GetClientFileDescriptor() |
+ : channel_proxy_->GetClientFileDescriptor()); |
+#else |
+ NOTREACHED(); |
+ return false; |
+#endif |
+} |
+ |
+#if defined(OS_POSIX) |
+bool IPCTestBase::StartClientWithFD(int ipcfd) { |
+ return StartClientInternal(ipcfd); |
+} |
+#endif |
+ |
+bool IPCTestBase::StartClientInternal(int ipcfd) { |
DCHECK(client_process_ == base::kNullProcessHandle); |
viettrungluu
2014/09/15 22:37:27
DCHECK_EQ here too
Hajime Morrita
2014/09/15 23:51:32
Done.
|
std::string test_main = test_client_name_ + "TestClientMain"; |
@@ -110,9 +129,6 @@ bool IPCTestBase::StartClient() { |
client_process_ = SpawnChild(test_main); |
#elif defined(OS_POSIX) |
base::FileHandleMappingVector fds_to_map; |
- const int ipcfd = channel_.get() |
- ? channel_->GetClientFileDescriptor() |
- : channel_proxy_->GetClientFileDescriptor(); |
if (ipcfd > -1) |
fds_to_map.push_back(std::pair<int, int>(ipcfd, |
kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor)); |
@@ -121,6 +137,11 @@ bool IPCTestBase::StartClient() { |
client_process_ = SpawnChildWithOptions(test_main, options); |
#endif |
+ if (channel_) |
+ channel_->OnClientLaunched(client_process_); |
viettrungluu
2014/09/15 22:37:27
It seems dubious to call these even when client_pr
Hajime Morrita
2014/09/15 23:51:32
True. Added DCHECK() as there are no cases where t
|
+ if (channel_proxy_) |
+ channel_proxy_->OnClientLaunched(client_process_); |
+ |
return client_process_ != base::kNullProcessHandle; |
} |
@@ -134,6 +155,10 @@ bool IPCTestBase::WaitForClientShutdown() { |
return rv; |
} |
+IPC::ChannelHandle IPCTestBase::GetTestChannelHandle() { |
+ return GetChannelName(test_client_name_); |
+} |
+ |
scoped_refptr<base::TaskRunner> IPCTestBase::task_runner() { |
return message_loop_->message_loop_proxy(); |
} |