| OLD | NEW | 
|    1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2009 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 #ifndef BASE_MULTIPROCESS_TEST_H_ |    5 #ifndef BASE_MULTIPROCESS_TEST_H_ | 
|    6 #define BASE_MULTIPROCESS_TEST_H_ |    6 #define BASE_MULTIPROCESS_TEST_H_ | 
|    7  |    7  | 
|    8 #include "base/base_switches.h" |    8 #include "base/base_switches.h" | 
|    9 #include "base/command_line.h" |    9 #include "base/command_line.h" | 
|   10 #include "base/process_util.h" |   10 #include "base/process_util.h" | 
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   76  |   76  | 
|   77 #if defined(OS_POSIX) |   77 #if defined(OS_POSIX) | 
|   78   base::ProcessHandle SpawnChild( |   78   base::ProcessHandle SpawnChild( | 
|   79       const std::wstring& procname, |   79       const std::wstring& procname, | 
|   80       const base::file_handle_mapping_vector& fds_to_map, |   80       const base::file_handle_mapping_vector& fds_to_map, | 
|   81       bool debug_on_start) { |   81       bool debug_on_start) { | 
|   82     return SpawnChildImpl(procname, fds_to_map, debug_on_start); |   82     return SpawnChildImpl(procname, fds_to_map, debug_on_start); | 
|   83   } |   83   } | 
|   84 #endif |   84 #endif | 
|   85  |   85  | 
 |   86 protected: | 
 |   87   CommandLine MakeCmdLine(const std::wstring& procname, bool debug_on_start) { | 
 |   88     CommandLine cl(*CommandLine::ForCurrentProcess()); | 
 |   89     cl.AppendSwitchWithValue(kRunClientProcess, procname); | 
 |   90     if (debug_on_start) | 
 |   91       cl.AppendSwitch(switches::kDebugOnStart); | 
 |   92     return cl; | 
 |   93   } | 
 |   94  | 
|   86  private: |   95  private: | 
|   87 #if defined(OS_WIN) |   96 #if defined(OS_WIN) | 
|   88   base::ProcessHandle SpawnChildImpl( |   97   base::ProcessHandle SpawnChildImpl(const std::wstring& procname, | 
|   89       const std::wstring& procname, |   98                                      bool debug_on_start) { | 
|   90       bool debug_on_start) { |  | 
|   91     CommandLine cl(*CommandLine::ForCurrentProcess()); |  | 
|   92     base::ProcessHandle handle = static_cast<base::ProcessHandle>(NULL); |   99     base::ProcessHandle handle = static_cast<base::ProcessHandle>(NULL); | 
|   93     cl.AppendSwitchWithValue(kRunClientProcess, procname); |  100     base::LaunchApp(MakeCmdLine(procname, debug_on_start), | 
|   94  |  101                     false, true, &handle); | 
|   95     if (debug_on_start) |  | 
|   96       cl.AppendSwitch(switches::kDebugOnStart); |  | 
|   97  |  | 
|   98     base::LaunchApp(cl, false, true, &handle); |  | 
|   99     return handle; |  102     return handle; | 
|  100   } |  103   } | 
 |  104  | 
|  101 #elif defined(OS_POSIX) |  105 #elif defined(OS_POSIX) | 
|  102   // TODO(port): with the CommandLine refactoring, this code is very similar |  106   // TODO(port): with the CommandLine refactoring, this code is very similar | 
|  103   // to the Windows code.  Investigate whether this can be made shorter. |  107   // to the Windows code.  Investigate whether this can be made shorter. | 
|  104   base::ProcessHandle SpawnChildImpl( |  108   base::ProcessHandle SpawnChildImpl( | 
|  105       const std::wstring& procname, |  109       const std::wstring& procname, | 
|  106       const base::file_handle_mapping_vector& fds_to_map, |  110       const base::file_handle_mapping_vector& fds_to_map, | 
|  107       bool debug_on_start) { |  111       bool debug_on_start) { | 
|  108     CommandLine cl(*CommandLine::ForCurrentProcess()); |  | 
|  109     base::ProcessHandle handle = base::kNullProcessHandle; |  112     base::ProcessHandle handle = base::kNullProcessHandle; | 
|  110     cl.AppendSwitchWithValue(kRunClientProcess, procname); |  113     base::LaunchApp(MakeCmdLine(procname, debug_on_start).argv(), | 
|  111  |  114                     fds_to_map, false, &handle); | 
|  112     if (debug_on_start) |  | 
|  113       cl.AppendSwitch(switches::kDebugOnStart); |  | 
|  114  |  | 
|  115     base::LaunchApp(cl.argv(), fds_to_map, false, &handle); |  | 
|  116     return handle; |  115     return handle; | 
|  117   } |  116   } | 
|  118 #endif |  117 #endif | 
|  119 }; |  118 }; | 
|  120  |  119  | 
|  121 #endif  // BASE_MULTIPROCESS_TEST_H_ |  120 #endif  // BASE_MULTIPROCESS_TEST_H_ | 
| OLD | NEW |