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

Side by Side Diff: base/win/wait_chain_unittest.cc

Issue 2950153002: Improve process launch handle sharing API. (Closed)
Patch Set: Fix Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/win/wait_chain.h" 5 #include "base/win/wait_chain.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 183
184 // Start a child process and passes the |mutex| and the |sync_event| to the 184 // Start a child process and passes the |mutex| and the |sync_event| to the
185 // command line. 185 // command line.
186 Process StartChildProcess(HANDLE mutex, HANDLE sync_event) { 186 Process StartChildProcess(HANDLE mutex, HANDLE sync_event) {
187 CommandLine command_line = GetMultiProcessTestChildBaseCommandLine(); 187 CommandLine command_line = GetMultiProcessTestChildBaseCommandLine();
188 188
189 AppendSwitchHandle(&command_line, "mutex", mutex); 189 AppendSwitchHandle(&command_line, "mutex", mutex);
190 AppendSwitchHandle(&command_line, "sync_event", sync_event); 190 AppendSwitchHandle(&command_line, "sync_event", sync_event);
191 191
192 LaunchOptions options; 192 LaunchOptions options;
193 HandlesToInheritVector handle_vector; 193 options.handles_to_inherit.push_back(mutex);
194 handle_vector.push_back(mutex); 194 options.handles_to_inherit.push_back(sync_event);
195 handle_vector.push_back(sync_event);
196 options.handles_to_inherit = &handle_vector;
197 base::SpawnChildResult spawn_result = 195 base::SpawnChildResult spawn_result =
198 SpawnMultiProcessTestChild("WaitChainTestProc", command_line, options); 196 SpawnMultiProcessTestChild("WaitChainTestProc", command_line, options);
199 return std::move(spawn_result.process); 197 return std::move(spawn_result.process);
200 } 198 }
201 199
202 // Returns true if the |wait_chain| is an alternating sequence of thread objects 200 // Returns true if the |wait_chain| is an alternating sequence of thread objects
203 // and synchronization objects. 201 // and synchronization objects.
204 bool WaitChainStructureIsCorrect(const WaitChainNodeVector& wait_chain) { 202 bool WaitChainStructureIsCorrect(const WaitChainNodeVector& wait_chain) {
205 // Checks thread objects. 203 // Checks thread objects.
206 for (size_t i = 0; i < wait_chain.size(); i += 2) { 204 for (size_t i = 0; i < wait_chain.size(); i += 2) {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 // Unblock child process and wait for it to terminate. 309 // Unblock child process and wait for it to terminate.
312 ASSERT_TRUE(::SetEvent(sync_event.Get())); 310 ASSERT_TRUE(::SetEvent(sync_event.Get()));
313 ASSERT_TRUE(child_process.WaitForExit(nullptr)); 311 ASSERT_TRUE(child_process.WaitForExit(nullptr));
314 312
315 // The SimpleThread API expect Join() to be called before destruction. 313 // The SimpleThread API expect Join() to be called before destruction.
316 waiting_thread_3->Join(); 314 waiting_thread_3->Join();
317 } 315 }
318 316
319 } // namespace win 317 } // namespace win
320 } // namespace base 318 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698