OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/test/multiprocess_test.h" | 5 #include "base/test/multiprocess_test.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 | 9 |
10 #if defined(OS_POSIX) | |
11 #include <sys/types.h> | |
12 #include <unistd.h> | |
13 #endif | |
14 | |
15 namespace base { | 10 namespace base { |
16 | 11 |
17 MultiProcessTest::MultiProcessTest() { | 12 MultiProcessTest::MultiProcessTest() { |
18 } | 13 } |
19 | 14 |
20 ProcessHandle MultiProcessTest::SpawnChild(const std::string& procname, | 15 ProcessHandle MultiProcessTest::SpawnChild(const std::string& procname, |
21 bool debug_on_start) { | 16 bool debug_on_start) { |
22 file_handle_mapping_vector empty_file_list; | 17 FileHandleMappingVector empty_file_list; |
23 return SpawnChildImpl(procname, empty_file_list, debug_on_start); | 18 return SpawnChildImpl(procname, empty_file_list, debug_on_start); |
24 } | 19 } |
25 | 20 |
26 #if defined(OS_POSIX) | 21 #if defined(OS_POSIX) |
27 ProcessHandle MultiProcessTest::SpawnChild( | 22 ProcessHandle MultiProcessTest::SpawnChild( |
28 const std::string& procname, | 23 const std::string& procname, |
29 const file_handle_mapping_vector& fds_to_map, | 24 const FileHandleMappingVector& fds_to_map, |
30 bool debug_on_start) { | 25 bool debug_on_start) { |
31 return SpawnChildImpl(procname, fds_to_map, debug_on_start); | 26 return SpawnChildImpl(procname, fds_to_map, debug_on_start); |
32 } | 27 } |
33 #endif | 28 #endif |
34 | 29 |
35 CommandLine MultiProcessTest::MakeCmdLine(const std::string& procname, | 30 CommandLine MultiProcessTest::MakeCmdLine(const std::string& procname, |
36 bool debug_on_start) { | 31 bool debug_on_start) { |
37 CommandLine cl(*CommandLine::ForCurrentProcess()); | 32 CommandLine cl(*CommandLine::ForCurrentProcess()); |
38 cl.AppendSwitchASCII(switches::kTestChildProcess, procname); | 33 cl.AppendSwitchASCII(switches::kTestChildProcess, procname); |
39 if (debug_on_start) | 34 if (debug_on_start) |
40 cl.AppendSwitch(switches::kDebugOnStart); | 35 cl.AppendSwitch(switches::kDebugOnStart); |
41 return cl; | 36 return cl; |
42 } | 37 } |
43 | 38 |
44 ProcessHandle MultiProcessTest::SpawnChildImpl( | 39 ProcessHandle MultiProcessTest::SpawnChildImpl( |
45 const std::string& procname, | 40 const std::string& procname, |
46 const file_handle_mapping_vector& fds_to_map, | 41 const FileHandleMappingVector& fds_to_map, |
47 bool debug_on_start) { | 42 bool debug_on_start) { |
48 ProcessHandle handle = kNullProcessHandle; | 43 ProcessHandle handle = kNullProcessHandle; |
49 base::LaunchOptions options; | 44 base::LaunchOptions options; |
50 #if defined(OS_WIN) | 45 #if defined(OS_WIN) |
51 options.start_hidden = true; | 46 options.start_hidden = true; |
52 #else | 47 #else |
53 options.fds_to_remap = &fds_to_map; | 48 options.fds_to_remap = &fds_to_map; |
54 #endif | 49 #endif |
55 base::LaunchProcess(MakeCmdLine(procname, debug_on_start), options, &handle); | 50 base::LaunchProcess(MakeCmdLine(procname, debug_on_start), options, &handle); |
56 return handle; | 51 return handle; |
57 } | 52 } |
58 | 53 |
59 } // namespace base | 54 } // namespace base |
OLD | NEW |