summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-13 18:51:47 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-13 18:51:47 +0000
commitb5ce736e9dc768a1156dd33a906b3ed4bfbd2276 (patch)
tree596e448d5064142853a64646a78382398f968adc
parent96b3760243c36ed846179c18f22b91d4c996fe66 (diff)
downloadchromium_src-b5ce736e9dc768a1156dd33a906b3ed4bfbd2276.zip
chromium_src-b5ce736e9dc768a1156dd33a906b3ed4bfbd2276.tar.gz
chromium_src-b5ce736e9dc768a1156dd33a906b3ed4bfbd2276.tar.bz2
Clean up users of a deprecated base::LaunchApp API.
BUG=88990 Review URL: http://codereview.chromium.org/7346017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92393 0039d316-1c4b-4281-b951-d872f2087c98
-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/chromeos/input_method/input_method_manager.cc10
-rw-r--r--chrome/browser/chromeos/input_method/xkeyboard.cc10
-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
13 files changed, 60 insertions, 75 deletions
diff --git a/base/process_util.h b/base/process_util.h
index a7b5aa8..6820d42 100644
--- a/base/process_util.h
+++ b/base/process_util.h
@@ -347,17 +347,6 @@ 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 a1a3bbe..c691b5f 100644
--- a/base/test/multiprocess_test.cc
+++ b/base/test/multiprocess_test.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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,12 +19,8 @@ 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)
@@ -45,30 +41,20 @@ 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;
- LaunchApp(MakeCmdLine(procname, debug_on_start).argv(),
- fds_to_map, false, &handle);
+ 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);
return handle;
}
-#endif
-
} // namespace base
diff --git a/base/test/multiprocess_test.h b/base/test/multiprocess_test.h
index af7a180..bfb9e2a 100644
--- a/base/test/multiprocess_test.h
+++ b/base/test/multiprocess_test.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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,6 +58,9 @@ 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);
@@ -68,17 +71,12 @@ class MultiProcessTest : public PlatformTest {
bool debug_on_start);
private:
-#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.
+ // Shared implementation of SpawnChild.
+ // TODO: |fds_to_map| is unused on Windows; see above TODO about
+ // further refactoring.
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/chromeos/input_method/input_method_manager.cc b/chrome/browser/chromeos/input_method/input_method_manager.cc
index da81d24..6270612 100644
--- a/chrome/browser/chromeos/input_method/input_method_manager.cc
+++ b/chrome/browser/chromeos/input_method/input_method_manager.cc
@@ -757,16 +757,14 @@ class InputMethodManagerImpl : public InputMethodManager,
bool LaunchInputMethodProcess(const std::string& command_line,
base::ProcessHandle* process_handle) {
std::vector<std::string> argv;
- base::file_handle_mapping_vector fds_to_remap;
base::ProcessHandle handle = base::kNullProcessHandle;
// TODO(zork): export "LD_PRELOAD=/usr/lib/libcrash.so"
base::SplitString(command_line, ' ', &argv);
- const bool result = base::LaunchApp(argv,
- fds_to_remap, // no remapping
- false, // wait
- &handle);
- if (!result) {
+
+ base::LaunchOptions options;
+ options.process_handle = &handle;
+ if (!base::LaunchProcess(argv, options)) {
LOG(ERROR) << "Could not launch: " << command_line;
return false;
}
diff --git a/chrome/browser/chromeos/input_method/xkeyboard.cc b/chrome/browser/chromeos/input_method/xkeyboard.cc
index 6f35df2..9def5e8 100644
--- a/chrome/browser/chromeos/input_method/xkeyboard.cc
+++ b/chrome/browser/chromeos/input_method/xkeyboard.cc
@@ -279,18 +279,16 @@ class XKeyboard {
const std::string layout_to_set = execute_queue_.front();
std::vector<std::string> argv;
- base::file_handle_mapping_vector fds_to_remap;
base::ProcessHandle handle = base::kNullProcessHandle;
argv.push_back(kSetxkbmapCommand);
argv.push_back("-layout");
argv.push_back(layout_to_set);
argv.push_back("-synch");
- const bool result = base::LaunchApp(argv,
- fds_to_remap, // No remapping.
- false, // Don't wait.
- &handle);
- if (!result) {
+
+ base::LaunchOptions options;
+ options.process_handle = &handle;
+ if (!base::LaunchProcess(argv, options)) {
LOG(ERROR) << "Failed to execute setxkbmap: " << layout_to_set;
execute_queue_ = std::queue<std::string>(); // clear the queue.
return;
diff --git a/chrome/browser/mac/relauncher.cc b/chrome/browser/mac/relauncher.cc
index 9594403..07f8e79 100644
--- a/chrome/browser/mac/relauncher.cc
+++ b/chrome/browser/mac/relauncher.cc
@@ -153,8 +153,10 @@ bool RelaunchAppWithHelper(const std::string& helper,
base::file_handle_mapping_vector fd_map;
fd_map.push_back(std::make_pair(*pipe_write_fd, kRelauncherSyncFD));
- if (!base::LaunchApp(relaunch_args, fd_map, false, NULL)) {
- LOG(ERROR) << "base::LaunchApp failed";
+ base::LaunchOptions options;
+ options.fds_to_remap = &fd_map;
+ if (!base::LaunchProcess(relaunch_args, options)) {
+ LOG(ERROR) << "base::LaunchProcess failed";
return false;
}
diff --git a/chrome/browser/printing/printer_manager_dialog_linux.cc b/chrome/browser/printing/printer_manager_dialog_linux.cc
index 61cea9d..02b262c 100644
--- a/chrome/browser/printing/printer_manager_dialog_linux.cc
+++ b/chrome/browser/printing/printer_manager_dialog_linux.cc
@@ -47,9 +47,10 @@ void DetectAndOpenPrinterConfigDialog() {
std::vector<std::string> argv;
argv.push_back(command);
- base::file_handle_mapping_vector no_files;
+ base::LaunchOptions options;
base::ProcessHandle handle;
- if (!base::LaunchApp(argv, no_files, false, &handle)) {
+ options.process_handle = &handle;
+ if (!base::LaunchProcess(argv, options)) {
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 64d1c84..226aadc3 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) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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,7 +111,10 @@ TEST_F(ProcessInfoSnapshotMacTest, EffectiveVsRealUserIDTest) {
argv.push_back("0");
base::ProcessHandle process_handle;
- ASSERT_TRUE(base::LaunchApp(argv, fds_to_remap, false, &process_handle));
+ base::LaunchOptions options;
+ options.fds_to_remap = &fds_to_remap;
+ options.process_handle = &process_handle;
+ ASSERT_TRUE(base::LaunchProcess(argv, options));
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 40257a5..43d6e68 100644
--- a/chrome/browser/shell_integration_linux.cc
+++ b/chrome/browser/shell_integration_linux.cc
@@ -58,7 +58,10 @@ bool LaunchXdgUtility(const std::vector<std::string>& argv, int* exit_code) {
no_stdin.push_back(std::make_pair(devnull, STDIN_FILENO));
base::ProcessHandle handle;
- if (!base::LaunchApp(argv, no_stdin, false, &handle)) {
+ base::LaunchOptions options;
+ options.process_handle = &handle;
+ options.fds_to_remap = &no_stdin;
+ if (!base::LaunchProcess(argv, options)) {
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 b55454d..6f267a6 100644
--- a/chrome/browser/ui/webui/options/advanced_options_utils_gtk.cc
+++ b/chrome/browser/ui/webui/options/advanced_options_utils_gtk.cc
@@ -74,9 +74,10 @@ 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;
- if (!base::LaunchApp(argv, no_files, false, &handle)) {
+ base::LaunchOptions options;
+ options.process_handle = &handle;
+ if (!base::LaunchProcess(argv, options)) {
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 f7f5795..ad75064 100644
--- a/chrome/test/automation/proxy_launcher.cc
+++ b/chrome/test/automation/proxy_launcher.cc
@@ -440,9 +440,12 @@ 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)
- bool started = base::LaunchApp(command_line, wait,
- !state.show_window, process);
+ options.start_hidden = !state.show_window;
#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)
@@ -458,11 +461,10 @@ bool ProxyLauncher::LaunchBrowserHelper(const LaunchState& state, bool wait,
base::file_handle_mapping_vector fds;
if (automation_proxy_.get())
fds = automation_proxy_->fds_to_map();
-
- bool started = base::LaunchApp(command_line.argv(), fds, wait, process);
+ options.fds_to_remap = &fds;
#endif
- return started;
+ return base::LaunchProcess(command_line, options);
}
AutomationProxy* ProxyLauncher::automation() const {
diff --git a/content/browser/zygote_host_linux.cc b/content/browser/zygote_host_linux.cc
index 328c603..e4c04ae 100644
--- a/content/browser/zygote_host_linux.cc
+++ b/content/browser/zygote_host_linux.cc
@@ -149,8 +149,11 @@ void ZygoteHost::Init(const std::string& sandbox_cmd) {
fds_to_map.push_back(std::make_pair(dummy_fd, 7));
}
- base::ProcessHandle process;
- base::LaunchApp(cmd_line.argv(), fds_to_map, false, &process);
+ base::ProcessHandle process = -1;
+ base::LaunchOptions options;
+ options.process_handle = &process;
+ options.fds_to_remap = &fds_to_map;
+ base::LaunchProcess(cmd_line.argv(), options);
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 10e5b8b..a3abc69 100644
--- a/net/test/test_server_posix.cc
+++ b/net/test/test_server_posix.cc
@@ -122,10 +122,11 @@ bool TestServer::LaunchPython(const FilePath& testserver_path) {
}
// Launch a new testserver process.
- if (!base::LaunchApp(python_command.argv(), map_write_fd, false,
- &process_handle_)) {
- LOG(ERROR) << "Failed to launch " << python_command.command_line_string()
- << " ...";
+ 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();
return false;
}