Cleanup test files to use only one HttpUrlRequestFactory
[chromium-blink-merge.git] / base / test / multiprocess_test.cc
blob306c1090fec769167d1734ad81d00fb1b7f90a66
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
3 // found in the LICENSE file.
5 #include "base/test/multiprocess_test.h"
7 #include "base/base_switches.h"
8 #include "base/command_line.h"
10 namespace base {
12 #if !defined(OS_ANDROID)
13 ProcessHandle SpawnMultiProcessTestChild(
14 const std::string& procname,
15 const CommandLine& base_command_line,
16 const LaunchOptions& options) {
17 CommandLine command_line(base_command_line);
18 // TODO(viettrungluu): See comment above |MakeCmdLine()| in the header file.
19 // This is a temporary hack, since |MakeCmdLine()| has to provide a full
20 // command line.
21 if (!command_line.HasSwitch(switches::kTestChildProcess))
22 command_line.AppendSwitchASCII(switches::kTestChildProcess, procname);
24 ProcessHandle handle = kNullProcessHandle;
25 LaunchProcess(command_line, options, &handle);
26 return handle;
28 #endif // !defined(OS_ANDROID)
30 CommandLine GetMultiProcessTestChildBaseCommandLine() {
31 return *CommandLine::ForCurrentProcess();
34 // MultiProcessTest ------------------------------------------------------------
36 MultiProcessTest::MultiProcessTest() {
39 ProcessHandle MultiProcessTest::SpawnChild(const std::string& procname) {
40 LaunchOptions options;
41 #if defined(OS_WIN)
42 options.start_hidden = true;
43 #endif
44 return SpawnChildWithOptions(procname, options);
47 ProcessHandle MultiProcessTest::SpawnChildWithOptions(
48 const std::string& procname,
49 const LaunchOptions& options) {
50 return SpawnMultiProcessTestChild(procname, MakeCmdLine(procname), options);
53 CommandLine MultiProcessTest::MakeCmdLine(const std::string& procname) {
54 CommandLine command_line = GetMultiProcessTestChildBaseCommandLine();
55 command_line.AppendSwitchASCII(switches::kTestChildProcess, procname);
56 return command_line;
59 } // namespace base