Commit 682daa3b authored by rvargas's avatar rvargas Committed by Commit bot

Remove deprecated versions of LaunchProcess.

BUG=417532

Review URL: https://codereview.chromium.org/799323003

Cr-Commit-Position: refs/heads/master@{#311537}
parent 7d87d723
...@@ -159,12 +159,6 @@ struct BASE_EXPORT LaunchOptions { ...@@ -159,12 +159,6 @@ struct BASE_EXPORT LaunchOptions {
BASE_EXPORT Process LaunchProcess(const CommandLine& cmdline, BASE_EXPORT Process LaunchProcess(const CommandLine& cmdline,
const LaunchOptions& options); const LaunchOptions& options);
// Deprecated version.
// TODO(rvargas) crbug.com/417532: Remove this after migrating all consumers.
BASE_EXPORT bool LaunchProcess(const CommandLine& cmdline,
const LaunchOptions& options,
ProcessHandle* process_handle);
#if defined(OS_WIN) #if defined(OS_WIN)
// Windows-specific LaunchProcess that takes the command line as a // Windows-specific LaunchProcess that takes the command line as a
// string. Useful for situations where you need to control the // string. Useful for situations where you need to control the
...@@ -195,12 +189,6 @@ BASE_EXPORT Process LaunchElevatedProcess(const CommandLine& cmdline, ...@@ -195,12 +189,6 @@ BASE_EXPORT Process LaunchElevatedProcess(const CommandLine& cmdline,
BASE_EXPORT Process LaunchProcess(const std::vector<std::string>& argv, BASE_EXPORT Process LaunchProcess(const std::vector<std::string>& argv,
const LaunchOptions& options); const LaunchOptions& options);
// Deprecated version.
// TODO(rvargas) crbug.com/417532: Remove this after migrating all consumers.
BASE_EXPORT bool LaunchProcess(const std::vector<std::string>& argv,
const LaunchOptions& options,
ProcessHandle* process_handle);
// Close all file descriptors, except those which are a destination in the // Close all file descriptors, except those which are a destination in the
// given multimap. Only call this function in a child process where you know // given multimap. Only call this function in a child process where you know
// that there aren't any other threads. // that there aren't any other threads.
......
...@@ -277,9 +277,13 @@ void CloseSuperfluousFds(const base::InjectiveMultimap& saved_mapping) { ...@@ -277,9 +277,13 @@ void CloseSuperfluousFds(const base::InjectiveMultimap& saved_mapping) {
} }
} }
bool LaunchProcess(const std::vector<std::string>& argv, Process LaunchProcess(const CommandLine& cmdline,
const LaunchOptions& options, const LaunchOptions& options) {
ProcessHandle* process_handle) { return LaunchProcess(cmdline.argv(), options);
}
Process LaunchProcess(const std::vector<std::string>& argv,
const LaunchOptions& options) {
size_t fd_shuffle_size = 0; size_t fd_shuffle_size = 0;
if (options.fds_to_remap) { if (options.fds_to_remap) {
fd_shuffle_size = options.fds_to_remap->size(); fd_shuffle_size = options.fds_to_remap->size();
...@@ -335,7 +339,7 @@ bool LaunchProcess(const std::vector<std::string>& argv, ...@@ -335,7 +339,7 @@ bool LaunchProcess(const std::vector<std::string>& argv,
if (pid < 0) { if (pid < 0) {
DPLOG(ERROR) << "fork"; DPLOG(ERROR) << "fork";
return false; return Process();
} else if (pid == 0) { } else if (pid == 0) {
// Child process // Child process
...@@ -475,37 +479,9 @@ bool LaunchProcess(const std::vector<std::string>& argv, ...@@ -475,37 +479,9 @@ bool LaunchProcess(const std::vector<std::string>& argv,
pid_t ret = HANDLE_EINTR(waitpid(pid, 0, 0)); pid_t ret = HANDLE_EINTR(waitpid(pid, 0, 0));
DPCHECK(ret > 0); DPCHECK(ret > 0);
} }
if (process_handle)
*process_handle = pid;
} }
return true; return Process(pid);
}
Process LaunchProcess(const std::vector<std::string>& argv,
const LaunchOptions& options) {
ProcessHandle process_handle;
if (LaunchProcess(argv, options, &process_handle))
return Process(process_handle);
return Process();
}
bool LaunchProcess(const CommandLine& cmdline,
const LaunchOptions& options,
ProcessHandle* process_handle) {
return LaunchProcess(cmdline.argv(), options, process_handle);
}
Process LaunchProcess(const CommandLine& cmdline,
const LaunchOptions& options) {
ProcessHandle process_handle;
if (LaunchProcess(cmdline, options, &process_handle))
return Process(process_handle);
return Process();
} }
void RaiseProcessToHighPriority() { void RaiseProcessToHighPriority() {
......
...@@ -105,9 +105,13 @@ void RouteStdioToConsole() { ...@@ -105,9 +105,13 @@ void RouteStdioToConsole() {
std::ios::sync_with_stdio(); std::ios::sync_with_stdio();
} }
bool LaunchProcess(const string16& cmdline, Process LaunchProcess(const CommandLine& cmdline,
const LaunchOptions& options, const LaunchOptions& options) {
win::ScopedHandle* process_handle) { return LaunchProcess(cmdline.GetCommandLineString(), options);
}
Process LaunchProcess(const string16& cmdline,
const LaunchOptions& options) {
win::StartupInformation startup_info_wrapper; win::StartupInformation startup_info_wrapper;
STARTUPINFO* startup_info = startup_info_wrapper.startup_info(); STARTUPINFO* startup_info = startup_info_wrapper.startup_info();
...@@ -119,18 +123,18 @@ bool LaunchProcess(const string16& cmdline, ...@@ -119,18 +123,18 @@ bool LaunchProcess(const string16& cmdline,
} else { } else {
if (base::win::GetVersion() < base::win::VERSION_VISTA) { if (base::win::GetVersion() < base::win::VERSION_VISTA) {
DLOG(ERROR) << "Specifying handles to inherit requires Vista or later."; DLOG(ERROR) << "Specifying handles to inherit requires Vista or later.";
return false; return Process();
} }
if (options.handles_to_inherit->size() > if (options.handles_to_inherit->size() >
std::numeric_limits<DWORD>::max() / sizeof(HANDLE)) { std::numeric_limits<DWORD>::max() / sizeof(HANDLE)) {
DLOG(ERROR) << "Too many handles to inherit."; DLOG(ERROR) << "Too many handles to inherit.";
return false; return Process();
} }
if (!startup_info_wrapper.InitializeProcThreadAttributeList(1)) { if (!startup_info_wrapper.InitializeProcThreadAttributeList(1)) {
DPLOG(ERROR); DPLOG(ERROR);
return false; return Process();
} }
if (!startup_info_wrapper.UpdateProcThreadAttribute( if (!startup_info_wrapper.UpdateProcThreadAttribute(
...@@ -139,7 +143,7 @@ bool LaunchProcess(const string16& cmdline, ...@@ -139,7 +143,7 @@ bool LaunchProcess(const string16& cmdline,
static_cast<DWORD>(options.handles_to_inherit->size() * static_cast<DWORD>(options.handles_to_inherit->size() *
sizeof(HANDLE)))) { sizeof(HANDLE)))) {
DPLOG(ERROR); DPLOG(ERROR);
return false; return Process();
} }
inherit_handles = true; inherit_handles = true;
...@@ -184,7 +188,7 @@ bool LaunchProcess(const string16& cmdline, ...@@ -184,7 +188,7 @@ bool LaunchProcess(const string16& cmdline,
if (!CreateEnvironmentBlock(&enviroment_block, options.as_user, FALSE)) { if (!CreateEnvironmentBlock(&enviroment_block, options.as_user, FALSE)) {
DPLOG(ERROR); DPLOG(ERROR);
return false; return Process();
} }
BOOL launched = BOOL launched =
...@@ -197,7 +201,7 @@ bool LaunchProcess(const string16& cmdline, ...@@ -197,7 +201,7 @@ bool LaunchProcess(const string16& cmdline,
if (!launched) { if (!launched) {
DPLOG(ERROR) << "Command line:" << std::endl << UTF16ToUTF8(cmdline) DPLOG(ERROR) << "Command line:" << std::endl << UTF16ToUTF8(cmdline)
<< std::endl;; << std::endl;;
return false; return Process();
} }
} else { } else {
if (!CreateProcess(NULL, if (!CreateProcess(NULL,
...@@ -206,7 +210,7 @@ bool LaunchProcess(const string16& cmdline, ...@@ -206,7 +210,7 @@ bool LaunchProcess(const string16& cmdline,
startup_info, &temp_process_info)) { startup_info, &temp_process_info)) {
DPLOG(ERROR) << "Command line:" << std::endl << UTF16ToUTF8(cmdline) DPLOG(ERROR) << "Command line:" << std::endl << UTF16ToUTF8(cmdline)
<< std::endl;; << std::endl;;
return false; return Process();
} }
} }
base::win::ScopedProcessInformation process_info(temp_process_info); base::win::ScopedProcessInformation process_info(temp_process_info);
...@@ -216,7 +220,7 @@ bool LaunchProcess(const string16& cmdline, ...@@ -216,7 +220,7 @@ bool LaunchProcess(const string16& cmdline,
process_info.process_handle())) { process_info.process_handle())) {
DLOG(ERROR) << "Could not AssignProcessToObject."; DLOG(ERROR) << "Could not AssignProcessToObject.";
KillProcess(process_info.process_handle(), kProcessKilledExitCode, true); KillProcess(process_info.process_handle(), kProcessKilledExitCode, true);
return false; return Process();
} }
ResumeThread(process_info.thread_handle()); ResumeThread(process_info.thread_handle());
...@@ -225,43 +229,7 @@ bool LaunchProcess(const string16& cmdline, ...@@ -225,43 +229,7 @@ bool LaunchProcess(const string16& cmdline,
if (options.wait) if (options.wait)
WaitForSingleObject(process_info.process_handle(), INFINITE); WaitForSingleObject(process_info.process_handle(), INFINITE);
// If the caller wants the process handle, we won't close it. return Process(process_info.TakeProcessHandle());
if (process_handle)
process_handle->Set(process_info.TakeProcessHandle());
return true;
}
// TODO(rvargas) crbug.com/416721: Remove this stub after LaunchProcess is
// fully migrated to use Process.
Process LaunchProcess(const string16& cmdline,
const LaunchOptions& options) {
win::ScopedHandle process_handle;
if (LaunchProcess(cmdline, options, &process_handle))
return Process(process_handle.Take());
return Process();
}
bool LaunchProcess(const CommandLine& cmdline,
const LaunchOptions& options,
ProcessHandle* process_handle) {
if (!process_handle)
return LaunchProcess(cmdline.GetCommandLineString(), options, NULL);
win::ScopedHandle process;
bool rv = LaunchProcess(cmdline.GetCommandLineString(), options, &process);
*process_handle = process.Take();
return rv;
}
Process LaunchProcess(const CommandLine& cmdline,
const LaunchOptions& options) {
ProcessHandle process_handle;
if (LaunchProcess(cmdline, options, &process_handle))
return Process(process_handle);
return Process();
} }
Process LaunchElevatedProcess(const CommandLine& cmdline, Process LaunchElevatedProcess(const CommandLine& cmdline,
......
...@@ -607,7 +607,7 @@ std::string TestLaunchProcess(const std::vector<std::string>& args, ...@@ -607,7 +607,7 @@ std::string TestLaunchProcess(const std::vector<std::string>& args,
#else #else
CHECK_EQ(0, clone_flags); CHECK_EQ(0, clone_flags);
#endif // OS_LINUX #endif // OS_LINUX
EXPECT_TRUE(base::LaunchProcess(args, options, NULL)); EXPECT_TRUE(base::LaunchProcess(args, options).IsValid());
PCHECK(IGNORE_EINTR(close(fds[1])) == 0); PCHECK(IGNORE_EINTR(close(fds[1])) == 0);
char buf[512]; char buf[512];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment