summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/process_util.h11
-rw-r--r--base/test/multiprocess_test.cc32
-rw-r--r--base/test/multiprocess_test.h16
-rw-r--r--chrome/browser/mac/relauncher.cc6
-rw-r--r--chrome/browser/printing/printer_manager_dialog_linux.cc5
-rw-r--r--chrome/browser/process_info_snapshot_mac_unittest.cc7
-rw-r--r--chrome/browser/shell_integration_linux.cc5
-rw-r--r--chrome/browser/ui/webui/options/advanced_options_utils_gtk.cc5
-rw-r--r--chrome/test/automation/proxy_launcher.cc12
-rw-r--r--content/browser/zygote_host_linux.cc7
-rw-r--r--net/test/test_server_posix.cc9
11 files changed, 63 insertions, 52 deletions
diff --git a/base/process_util.h b/base/process_util.h
index 6820d42..a7b5aa8 100644
--- a/base/process_util.h
+++ b/base/process_util.h
@@ -347,6 +347,17 @@ inline bool LaunchAppAsUser(UserTokenHandle token,
BASE_API bool LaunchProcess(const std::vector<std::string>& argv,
const LaunchOptions& options);
+// TODO(evan): deprecated; change callers to use LaunchProcess, remove.
+inline bool LaunchApp(const std::vector<std::string>& argv,
+ const file_handle_mapping_vector& fds_to_remap,
+ bool wait, ProcessHandle* process_handle) {
+ LaunchOptions options;
+ options.fds_to_remap = &fds_to_remap;
+ options.wait = wait;
+ options.process_handle = process_handle;
+ return LaunchProcess(argv, options);
+}
+
// AlterEnvironment returns a modified environment vector, constructed from the
// given environment and the list of changes given in |changes|. Each key in
// the environment is matched against the first element of the pairs. In the
diff --git a/base/test/multiprocess_test.cc b/base/test/multiprocess_test.cc
index c691b5f..a1a3bbe 100644
--- a/base/test/multiprocess_test.cc
+++ b/base/test/multiprocess_test.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -19,8 +19,12 @@ MultiProcessTest::MultiProcessTest() {
ProcessHandle MultiProcessTest::SpawnChild(const std::string& procname,
bool debug_on_start) {
+#if defined(OS_WIN)
+ return SpawnChildImpl(procname, debug_on_start);
+#elif defined(OS_POSIX)
file_handle_mapping_vector empty_file_list;
return SpawnChildImpl(procname, empty_file_list, debug_on_start);
+#endif
}
#if defined(OS_POSIX)
@@ -41,20 +45,30 @@ CommandLine MultiProcessTest::MakeCmdLine(const std::string& procname,
return cl;
}
+#if defined(OS_WIN)
+
+ProcessHandle MultiProcessTest::SpawnChildImpl(const std::string& procname,
+ bool debug_on_start) {
+ ProcessHandle handle = static_cast<ProcessHandle>(NULL);
+ LaunchApp(MakeCmdLine(procname, debug_on_start),
+ false, true, &handle);
+ return handle;
+}
+
+#elif defined(OS_POSIX)
+
+// TODO(port): with the CommandLine refactoring, this code is very similar
+// to the Windows code. Investigate whether this can be made shorter.
ProcessHandle MultiProcessTest::SpawnChildImpl(
const std::string& procname,
const file_handle_mapping_vector& fds_to_map,
bool debug_on_start) {
ProcessHandle handle = kNullProcessHandle;
- base::LaunchOptions options;
- options.process_handle = &handle;
-#if defined(OS_WIN)
- options.start_hidden = true;
-#else
- options.fds_to_remap = &fds_to_map;
-#endif
- base::LaunchProcess(MakeCmdLine(procname, debug_on_start), options);
+ LaunchApp(MakeCmdLine(procname, debug_on_start).argv(),
+ fds_to_map, false, &handle);
return handle;
}
+#endif
+
} // namespace base
diff --git a/base/test/multiprocess_test.h b/base/test/multiprocess_test.h
index bfb9e2a..af7a180 100644
--- a/base/test/multiprocess_test.h
+++ b/base/test/multiprocess_test.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -58,9 +58,6 @@ class MultiProcessTest : public PlatformTest {
ProcessHandle SpawnChild(const std::string& procname, bool debug_on_start);
#if defined(OS_POSIX)
- // TODO(evan): see if we can delete this via more refactoring.
- // SpawnChild() should just take a base::LaunchOptions so that we don't
- // need multiple versions of it.
ProcessHandle SpawnChild(const std::string& procname,
const file_handle_mapping_vector& fds_to_map,
bool debug_on_start);
@@ -71,12 +68,17 @@ class MultiProcessTest : public PlatformTest {
bool debug_on_start);
private:
- // Shared implementation of SpawnChild.
- // TODO: |fds_to_map| is unused on Windows; see above TODO about
- // further refactoring.
+#if defined(OS_WIN)
+ ProcessHandle SpawnChildImpl(const std::string& procname,
+ bool debug_on_start);
+
+#elif defined(OS_POSIX)
+ // TODO(port): with the CommandLine refactoring, this code is very similar
+ // to the Windows code. Investigate whether this can be made shorter.
ProcessHandle SpawnChildImpl(const std::string& procname,
const file_handle_mapping_vector& fds_to_map,
bool debug_on_start);
+#endif
DISALLOW_COPY_AND_ASSIGN(MultiProcessTest);
};
diff --git a/chrome/browser/mac/relauncher.cc b/chrome/browser/mac/relauncher.cc
index 07f8e79..9594403 100644
--- a/chrome/browser/mac/relauncher.cc
+++ b/chrome/browser/mac/relauncher.cc
@@ -153,10 +153,8 @@ bool RelaunchAppWithHelper(const std::string& helper,
base::file_handle_mapping_vector fd_map;
fd_map.push_back(std::make_pair(*pipe_write_fd, kRelauncherSyncFD));
- base::LaunchOptions options;
- options.fds_to_remap = &fd_map;
- if (!base::LaunchProcess(relaunch_args, options)) {
- LOG(ERROR) << "base::LaunchProcess failed";
+ if (!base::LaunchApp(relaunch_args, fd_map, false, NULL)) {
+ LOG(ERROR) << "base::LaunchApp failed";
return false;
}
diff --git a/chrome/browser/printing/printer_manager_dialog_linux.cc b/chrome/browser/printing/printer_manager_dialog_linux.cc
index 02b262c..61cea9d 100644
--- a/chrome/browser/printing/printer_manager_dialog_linux.cc
+++ b/chrome/browser/printing/printer_manager_dialog_linux.cc
@@ -47,10 +47,9 @@ void DetectAndOpenPrinterConfigDialog() {
std::vector<std::string> argv;
argv.push_back(command);
- base::LaunchOptions options;
+ base::file_handle_mapping_vector no_files;
base::ProcessHandle handle;
- options.process_handle = &handle;
- if (!base::LaunchProcess(argv, options)) {
+ if (!base::LaunchApp(argv, no_files, false, &handle)) {
LOG(ERROR) << "Failed to open printer manager dialog ";
return;
}
diff --git a/chrome/browser/process_info_snapshot_mac_unittest.cc b/chrome/browser/process_info_snapshot_mac_unittest.cc
index 226aadc3..64d1c84 100644
--- a/chrome/browser/process_info_snapshot_mac_unittest.cc
+++ b/chrome/browser/process_info_snapshot_mac_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -111,10 +111,7 @@ TEST_F(ProcessInfoSnapshotMacTest, EffectiveVsRealUserIDTest) {
argv.push_back("0");
base::ProcessHandle process_handle;
- base::LaunchOptions options;
- options.fds_to_remap = &fds_to_remap;
- options.process_handle = &process_handle;
- ASSERT_TRUE(base::LaunchProcess(argv, options));
+ ASSERT_TRUE(base::LaunchApp(argv, fds_to_remap, false, &process_handle));
PCHECK(HANDLE_EINTR(close(fds[1])) == 0);
// Wait until there's some output form top. This is an easy way to tell that
diff --git a/chrome/browser/shell_integration_linux.cc b/chrome/browser/shell_integration_linux.cc
index 43d6e68..40257a5 100644
--- a/chrome/browser/shell_integration_linux.cc
+++ b/chrome/browser/shell_integration_linux.cc
@@ -58,10 +58,7 @@ bool LaunchXdgUtility(const std::vector<std::string>& argv, int* exit_code) {
no_stdin.push_back(std::make_pair(devnull, STDIN_FILENO));
base::ProcessHandle handle;
- base::LaunchOptions options;
- options.process_handle = &handle;
- options.fds_to_remap = &no_stdin;
- if (!base::LaunchProcess(argv, options)) {
+ if (!base::LaunchApp(argv, no_stdin, false, &handle)) {
close(devnull);
return false;
}
diff --git a/chrome/browser/ui/webui/options/advanced_options_utils_gtk.cc b/chrome/browser/ui/webui/options/advanced_options_utils_gtk.cc
index 6f267a6..b55454d 100644
--- a/chrome/browser/ui/webui/options/advanced_options_utils_gtk.cc
+++ b/chrome/browser/ui/webui/options/advanced_options_utils_gtk.cc
@@ -74,10 +74,9 @@ bool StartProxyConfigUtil(TabContents* tab_contents, const char* command[]) {
std::vector<std::string> argv;
for (size_t i = 0; command[i]; ++i)
argv.push_back(command[i]);
+ base::file_handle_mapping_vector no_files;
base::ProcessHandle handle;
- base::LaunchOptions options;
- options.process_handle = &handle;
- if (!base::LaunchProcess(argv, options)) {
+ if (!base::LaunchApp(argv, no_files, false, &handle)) {
LOG(ERROR) << "StartProxyConfigUtil failed to start " << command[0];
return false;
}
diff --git a/chrome/test/automation/proxy_launcher.cc b/chrome/test/automation/proxy_launcher.cc
index ad75064..f7f5795 100644
--- a/chrome/test/automation/proxy_launcher.cc
+++ b/chrome/test/automation/proxy_launcher.cc
@@ -440,12 +440,9 @@ bool ProxyLauncher::LaunchBrowserHelper(const LaunchState& state, bool wait,
// TODO(phajdan.jr): Only run it for "main" browser launch.
browser_launch_time_ = base::TimeTicks::Now();
- base::LaunchOptions options;
- options.wait = wait;
- options.process_handle = process;
-
#if defined(OS_WIN)
- options.start_hidden = !state.show_window;
+ bool started = base::LaunchApp(command_line, wait,
+ !state.show_window, process);
#elif defined(OS_POSIX)
// Sometimes one needs to run the browser under a special environment
// (e.g. valgrind) without also running the test harness (e.g. python)
@@ -461,10 +458,11 @@ bool ProxyLauncher::LaunchBrowserHelper(const LaunchState& state, bool wait,
base::file_handle_mapping_vector fds;
if (automation_proxy_.get())
fds = automation_proxy_->fds_to_map();
- options.fds_to_remap = &fds;
+
+ bool started = base::LaunchApp(command_line.argv(), fds, wait, process);
#endif
- return base::LaunchProcess(command_line, options);
+ return started;
}
AutomationProxy* ProxyLauncher::automation() const {
diff --git a/content/browser/zygote_host_linux.cc b/content/browser/zygote_host_linux.cc
index e4c04ae..328c603 100644
--- a/content/browser/zygote_host_linux.cc
+++ b/content/browser/zygote_host_linux.cc
@@ -149,11 +149,8 @@ void ZygoteHost::Init(const std::string& sandbox_cmd) {
fds_to_map.push_back(std::make_pair(dummy_fd, 7));
}
- base::ProcessHandle process = -1;
- base::LaunchOptions options;
- options.process_handle = &process;
- options.fds_to_remap = &fds_to_map;
- base::LaunchProcess(cmd_line.argv(), options);
+ base::ProcessHandle process;
+ base::LaunchApp(cmd_line.argv(), fds_to_map, false, &process);
CHECK(process != -1) << "Failed to launch zygote process";
if (using_suid_sandbox_) {
diff --git a/net/test/test_server_posix.cc b/net/test/test_server_posix.cc
index a3abc69..10e5b8b 100644
--- a/net/test/test_server_posix.cc
+++ b/net/test/test_server_posix.cc
@@ -122,11 +122,10 @@ bool TestServer::LaunchPython(const FilePath& testserver_path) {
}
// Launch a new testserver process.
- base::LaunchOptions options;
- options.fds_to_remap = &map_write_fd;
- options.process_handle = &process_handle_;
- if (!base::LaunchProcess(python_command, options)) {
- LOG(ERROR) << "Failed to launch " << python_command.command_line_string();
+ if (!base::LaunchApp(python_command.argv(), map_write_fd, false,
+ &process_handle_)) {
+ LOG(ERROR) << "Failed to launch " << python_command.command_line_string()
+ << " ...";
return false;
}