OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #include "ipc/ipc_test_base.h" | 7 #include "ipc/ipc_test_base.h" |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/process/kill.h" | 10 #include "base/process/kill.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 90 |
91 bool IPCTestBase::StartClient() { | 91 bool IPCTestBase::StartClient() { |
92 DCHECK(client_process_ == base::kNullProcessHandle); | 92 DCHECK(client_process_ == base::kNullProcessHandle); |
93 | 93 |
94 std::string test_main = test_client_name_ + "TestClientMain"; | 94 std::string test_main = test_client_name_ + "TestClientMain"; |
95 | 95 |
96 #if defined(OS_WIN) | 96 #if defined(OS_WIN) |
97 client_process_ = SpawnChild(test_main); | 97 client_process_ = SpawnChild(test_main); |
98 #elif defined(OS_POSIX) | 98 #elif defined(OS_POSIX) |
99 base::FileHandleMappingVector fds_to_map; | 99 base::FileHandleMappingVector fds_to_map; |
100 const int ipcfd = channel_.get() ? channel_->GetClientFileDescriptor() : | 100 const int ipcfd = channel_.get() |
101 channel_proxy_->GetClientFileDescriptor(); | 101 ? channel_->GetClientFileDescriptor() |
| 102 : channel_proxy_->GetClientFileDescriptor(); |
102 if (ipcfd > -1) | 103 if (ipcfd > -1) |
103 fds_to_map.push_back(std::pair<int, int>(ipcfd, | 104 fds_to_map.push_back(std::pair<int, int>(ipcfd, |
104 kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor)); | 105 kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor)); |
105 base::LaunchOptions options; | 106 base::LaunchOptions options; |
106 options.fds_to_remap = &fds_to_map; | 107 options.fds_to_remap = &fds_to_map; |
107 client_process_ = SpawnChildWithOptions(test_main, options); | 108 client_process_ = SpawnChildWithOptions(test_main, options); |
108 #endif | 109 #endif |
109 | 110 |
110 return client_process_ != base::kNullProcessHandle; | 111 return client_process_ != base::kNullProcessHandle; |
111 } | 112 } |
112 | 113 |
113 bool IPCTestBase::WaitForClientShutdown() { | 114 bool IPCTestBase::WaitForClientShutdown() { |
114 DCHECK(client_process_ != base::kNullProcessHandle); | 115 DCHECK(client_process_ != base::kNullProcessHandle); |
115 | 116 |
116 bool rv = base::WaitForSingleProcess(client_process_, | 117 bool rv = base::WaitForSingleProcess(client_process_, |
117 base::TimeDelta::FromSeconds(5)); | 118 base::TimeDelta::FromSeconds(5)); |
118 base::CloseProcessHandle(client_process_); | 119 base::CloseProcessHandle(client_process_); |
119 client_process_ = base::kNullProcessHandle; | 120 client_process_ = base::kNullProcessHandle; |
120 return rv; | 121 return rv; |
121 } | 122 } |
OLD | NEW |