OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // This file contains functions for launching subprocesses. | 5 // This file contains functions for launching subprocesses. |
6 | 6 |
7 #ifndef BASE_PROCESS_LAUNCH_H_ | 7 #ifndef BASE_PROCESS_LAUNCH_H_ |
8 #define BASE_PROCESS_LAUNCH_H_ | 8 #define BASE_PROCESS_LAUNCH_H_ |
9 | 9 |
10 #include <string> | 10 #include <string> |
11 #include <utility> | 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/base_export.h" | 14 #include "base/base_export.h" |
15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
16 #include "base/environment.h" | 16 #include "base/environment.h" |
17 #include "base/process/process.h" | 17 #include "base/process/process.h" |
18 #include "base/process/process_handle.h" | 18 #include "base/process/process_handle.h" |
19 #include "base/strings/string_piece.h" | 19 #include "base/strings/string_piece.h" |
20 | 20 |
21 #if defined(OS_POSIX) | 21 #if defined(OS_POSIX) |
22 #include "base/posix/file_descriptor_shuffle.h" | 22 #include "base/posix/file_descriptor_shuffle.h" |
23 #elif defined(OS_WIN) | 23 #elif defined(OS_WIN) |
24 #include <windows.h> | 24 #include <windows.h> |
25 #include "base/win/scoped_handle.h" | |
26 #endif | 25 #endif |
27 | 26 |
28 namespace base { | 27 namespace base { |
29 | 28 |
30 class CommandLine; | 29 class CommandLine; |
31 | 30 |
32 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
33 typedef std::vector<HANDLE> HandlesToInheritVector; | 32 typedef std::vector<HANDLE> HandlesToInheritVector; |
34 #endif | 33 #endif |
35 // TODO(viettrungluu): Only define this on POSIX? | 34 // TODO(viettrungluu): Only define this on POSIX? |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 // Windows-specific LaunchProcess that takes the command line as a | 166 // Windows-specific LaunchProcess that takes the command line as a |
168 // string. Useful for situations where you need to control the | 167 // string. Useful for situations where you need to control the |
169 // command line arguments directly, but prefer the CommandLine version | 168 // command line arguments directly, but prefer the CommandLine version |
170 // if launching Chrome itself. | 169 // if launching Chrome itself. |
171 // | 170 // |
172 // The first command line argument should be the path to the process, | 171 // The first command line argument should be the path to the process, |
173 // and don't forget to quote it. | 172 // and don't forget to quote it. |
174 // | 173 // |
175 // Example (including literal quotes) | 174 // Example (including literal quotes) |
176 // cmdline = "c:\windows\explorer.exe" -foo "c:\bar\" | 175 // cmdline = "c:\windows\explorer.exe" -foo "c:\bar\" |
177 BASE_EXPORT bool LaunchProcess(const string16& cmdline, | 176 BASE_EXPORT Process LaunchProcess(const string16& cmdline, |
178 const LaunchOptions& options, | 177 const LaunchOptions& options); |
179 win::ScopedHandle* process_handle); | |
180 | 178 |
181 // Launches a process with elevated privileges. This does not behave exactly | 179 // Launches a process with elevated privileges. This does not behave exactly |
182 // like LaunchProcess as it uses ShellExecuteEx instead of CreateProcess to | 180 // like LaunchProcess as it uses ShellExecuteEx instead of CreateProcess to |
183 // create the process. This means the process will have elevated privileges | 181 // create the process. This means the process will have elevated privileges |
184 // and thus some common operations like OpenProcess will fail. Currently the | 182 // and thus some common operations like OpenProcess will fail. Currently the |
185 // only supported LaunchOptions are |start_hidden| and |wait|. | 183 // only supported LaunchOptions are |start_hidden| and |wait|. |
186 BASE_EXPORT Process LaunchElevatedProcess(const CommandLine& cmdline, | 184 BASE_EXPORT Process LaunchElevatedProcess(const CommandLine& cmdline, |
187 const LaunchOptions& options); | 185 const LaunchOptions& options); |
188 | 186 |
189 #elif defined(OS_POSIX) | 187 #elif defined(OS_POSIX) |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 void ReplaceBootstrapPort(const std::string& replacement_bootstrap_name); | 263 void ReplaceBootstrapPort(const std::string& replacement_bootstrap_name); |
266 #endif // defined(OS_MACOSX) | 264 #endif // defined(OS_MACOSX) |
267 | 265 |
268 // Creates a LaunchOptions object suitable for launching processes in a test | 266 // Creates a LaunchOptions object suitable for launching processes in a test |
269 // binary. This should not be called in production/released code. | 267 // binary. This should not be called in production/released code. |
270 BASE_EXPORT LaunchOptions LaunchOptionsForTest(); | 268 BASE_EXPORT LaunchOptions LaunchOptionsForTest(); |
271 | 269 |
272 } // namespace base | 270 } // namespace base |
273 | 271 |
274 #endif // BASE_PROCESS_LAUNCH_H_ | 272 #endif // BASE_PROCESS_LAUNCH_H_ |
OLD | NEW |