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

Side by Side Diff: base/test/multiprocess_test.cc

Issue 104803007: Add a MultiProcessTest::SpawnChildWithOptions(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: better comment Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « base/test/multiprocess_test.h ('k') | base/test/multiprocess_test_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "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 namespace base { 10 namespace base {
11 11
12 MultiProcessTest::MultiProcessTest() { 12 MultiProcessTest::MultiProcessTest() {
13 } 13 }
14 14
15 ProcessHandle MultiProcessTest::SpawnChild(const std::string& procname, 15 ProcessHandle MultiProcessTest::SpawnChild(const std::string& procname,
16 bool debug_on_start) { 16 bool debug_on_start) {
17 FileHandleMappingVector empty_file_list; 17 LaunchOptions options;
18 return SpawnChildImpl(procname, empty_file_list, debug_on_start); 18 #if defined(OS_WIN)
19 options.start_hidden = true;
20 #endif
21 return SpawnChildWithOptions(procname, options, debug_on_start);
19 } 22 }
20 23
24 #if !defined(OS_ANDROID)
25 ProcessHandle MultiProcessTest::SpawnChildWithOptions(
26 const std::string& procname,
27 const LaunchOptions& options,
28 bool debug_on_start) {
29 ProcessHandle handle = kNullProcessHandle;
30 LaunchProcess(MakeCmdLine(procname, debug_on_start), options, &handle);
31 return handle;
32 }
33 #endif
34
21 #if defined(OS_POSIX) 35 #if defined(OS_POSIX)
22 ProcessHandle MultiProcessTest::SpawnChild( 36 ProcessHandle MultiProcessTest::SpawnChild(
23 const std::string& procname, 37 const std::string& procname,
24 const FileHandleMappingVector& fds_to_map, 38 const FileHandleMappingVector& fds_to_map,
25 bool debug_on_start) { 39 bool debug_on_start) {
26 return SpawnChildImpl(procname, fds_to_map, debug_on_start); 40 LaunchOptions options;
41 options.fds_to_remap = &fds_to_map;
42 return SpawnChildWithOptions(procname, options, debug_on_start);
27 } 43 }
28 #endif 44 #endif
29 45
30 CommandLine MultiProcessTest::MakeCmdLine(const std::string& procname, 46 CommandLine MultiProcessTest::MakeCmdLine(const std::string& procname,
31 bool debug_on_start) { 47 bool debug_on_start) {
32 CommandLine cl(*CommandLine::ForCurrentProcess()); 48 CommandLine cl(*CommandLine::ForCurrentProcess());
33 cl.AppendSwitchASCII(switches::kTestChildProcess, procname); 49 cl.AppendSwitchASCII(switches::kTestChildProcess, procname);
34 if (debug_on_start) 50 if (debug_on_start)
35 cl.AppendSwitch(switches::kDebugOnStart); 51 cl.AppendSwitch(switches::kDebugOnStart);
36 return cl; 52 return cl;
37 } 53 }
38 54
39 #if !defined(OS_ANDROID)
40 ProcessHandle MultiProcessTest::SpawnChildImpl(
41 const std::string& procname,
42 const FileHandleMappingVector& fds_to_map,
43 bool debug_on_start) {
44 ProcessHandle handle = kNullProcessHandle;
45 base::LaunchOptions options;
46 #if defined(OS_WIN)
47 options.start_hidden = true;
48 #else
49 options.fds_to_remap = &fds_to_map;
50 #endif
51 base::LaunchProcess(MakeCmdLine(procname, debug_on_start), options, &handle);
52 return handle;
53 }
54 #endif // !defined(OS_ANDROID)
55
56 } // namespace base 55 } // namespace base
OLDNEW
« no previous file with comments | « base/test/multiprocess_test.h ('k') | base/test/multiprocess_test_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698