| 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 "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 #if !defined(OS_ANDROID) | 12 #if !defined(OS_ANDROID) |
| 13 ProcessHandle SpawnMultiProcessTestChild( | 13 Process SpawnMultiProcessTestChild( |
| 14 const std::string& procname, | 14 const std::string& procname, |
| 15 const CommandLine& base_command_line, | 15 const CommandLine& base_command_line, |
| 16 const LaunchOptions& options) { | 16 const LaunchOptions& options) { |
| 17 CommandLine command_line(base_command_line); | 17 CommandLine command_line(base_command_line); |
| 18 // TODO(viettrungluu): See comment above |MakeCmdLine()| in the header file. | 18 // TODO(viettrungluu): See comment above |MakeCmdLine()| in the header file. |
| 19 // This is a temporary hack, since |MakeCmdLine()| has to provide a full | 19 // This is a temporary hack, since |MakeCmdLine()| has to provide a full |
| 20 // command line. | 20 // command line. |
| 21 if (!command_line.HasSwitch(switches::kTestChildProcess)) | 21 if (!command_line.HasSwitch(switches::kTestChildProcess)) |
| 22 command_line.AppendSwitchASCII(switches::kTestChildProcess, procname); | 22 command_line.AppendSwitchASCII(switches::kTestChildProcess, procname); |
| 23 | 23 |
| 24 ProcessHandle handle = kNullProcessHandle; | 24 return LaunchProcess(command_line, options); |
| 25 LaunchProcess(command_line, options, &handle); | |
| 26 return handle; | |
| 27 } | 25 } |
| 28 #endif // !defined(OS_ANDROID) | 26 #endif // !defined(OS_ANDROID) |
| 29 | 27 |
| 30 CommandLine GetMultiProcessTestChildBaseCommandLine() { | 28 CommandLine GetMultiProcessTestChildBaseCommandLine() { |
| 31 return *CommandLine::ForCurrentProcess(); | 29 return *CommandLine::ForCurrentProcess(); |
| 32 } | 30 } |
| 33 | 31 |
| 34 // MultiProcessTest ------------------------------------------------------------ | 32 // MultiProcessTest ------------------------------------------------------------ |
| 35 | 33 |
| 36 MultiProcessTest::MultiProcessTest() { | 34 MultiProcessTest::MultiProcessTest() { |
| 37 } | 35 } |
| 38 | 36 |
| 39 ProcessHandle MultiProcessTest::SpawnChild(const std::string& procname) { | 37 Process MultiProcessTest::SpawnChild(const std::string& procname) { |
| 40 LaunchOptions options; | 38 LaunchOptions options; |
| 41 #if defined(OS_WIN) | 39 #if defined(OS_WIN) |
| 42 options.start_hidden = true; | 40 options.start_hidden = true; |
| 43 #endif | 41 #endif |
| 44 return SpawnChildWithOptions(procname, options); | 42 return SpawnChildWithOptions(procname, options); |
| 45 } | 43 } |
| 46 | 44 |
| 47 ProcessHandle MultiProcessTest::SpawnChildWithOptions( | 45 Process MultiProcessTest::SpawnChildWithOptions( |
| 48 const std::string& procname, | 46 const std::string& procname, |
| 49 const LaunchOptions& options) { | 47 const LaunchOptions& options) { |
| 50 return SpawnMultiProcessTestChild(procname, MakeCmdLine(procname), options); | 48 return SpawnMultiProcessTestChild(procname, MakeCmdLine(procname), options); |
| 51 } | 49 } |
| 52 | 50 |
| 53 CommandLine MultiProcessTest::MakeCmdLine(const std::string& procname) { | 51 CommandLine MultiProcessTest::MakeCmdLine(const std::string& procname) { |
| 54 CommandLine command_line = GetMultiProcessTestChildBaseCommandLine(); | 52 CommandLine command_line = GetMultiProcessTestChildBaseCommandLine(); |
| 55 command_line.AppendSwitchASCII(switches::kTestChildProcess, procname); | 53 command_line.AppendSwitchASCII(switches::kTestChildProcess, procname); |
| 56 return command_line; | 54 return command_line; |
| 57 } | 55 } |
| 58 | 56 |
| 59 } // namespace base | 57 } // namespace base |
| OLD | NEW |