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 {
BASE_EXPORT Process LaunchProcess(const CommandLine& cmdline,
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)
// Windows-specific LaunchProcess that takes the command line as a
// string. Useful for situations where you need to control the
......@@ -195,12 +189,6 @@ BASE_EXPORT Process LaunchElevatedProcess(const CommandLine& cmdline,
BASE_EXPORT Process LaunchProcess(const std::vector<std::string>& argv,
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
// given multimap. Only call this function in a child process where you know
// that there aren't any other threads.
......
......@@ -277,9 +277,13 @@ void CloseSuperfluousFds(const base::InjectiveMultimap& saved_mapping) {
}
}
bool LaunchProcess(const std::vector<std::string>& argv,
const LaunchOptions& options,
ProcessHandle* process_handle) {
Process LaunchProcess(const CommandLine& cmdline,
const LaunchOptions& options) {
return LaunchProcess(cmdline.argv(), options);
}
Process LaunchProcess(const std::vector<std::string>& argv,
const LaunchOptions& options) {
size_t fd_shuffle_size = 0;
if (options.fds_to_remap) {
fd_shuffle_size = options.fds_to_remap->size();
......@@ -335,7 +339,7 @@ bool LaunchProcess(const std::vector<std::string>& argv,
if (pid < 0) {
DPLOG(ERROR) << "fork";
return false;
return Process();
} else if (pid == 0) {
// Child process
......@@ -475,37 +479,9 @@ bool LaunchProcess(const std::vector<std::string>& argv,
pid_t ret = HANDLE_EINTR(waitpid(pid, 0, 0));
DPCHECK(ret > 0);
}
if (process_handle)
*process_handle = pid;
}
return true;
}
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();
return Process(pid);
}
void RaiseProcessToHighPriority() {
......
......@@ -105,9 +105,13 @@ void RouteStdioToConsole() {
std::ios::sync_with_stdio();
}
bool LaunchProcess(const string16& cmdline,
const LaunchOptions& options,
win::ScopedHandle* process_handle) {
Process LaunchProcess(const CommandLine& cmdline,
const LaunchOptions& options) {
return LaunchProcess(cmdline.GetCommandLineString(), options);
}
Process LaunchProcess(const string16& cmdline,
const LaunchOptions& options) {
win::StartupInformation startup_info_wrapper;
STARTUPINFO* startup_info = startup_info_wrapper.startup_info();
......@@ -119,18 +123,18 @@ bool LaunchProcess(const string16& cmdline,
} else {
if (base::win::GetVersion() < base::win::VERSION_VISTA) {
DLOG(ERROR) << "Specifying handles to inherit requires Vista or later.";
return false;
return Process();
}
if (options.handles_to_inherit->size() >
std::numeric_limits<DWORD>::max() / sizeof(HANDLE)) {
DLOG(ERROR) << "Too many handles to inherit.";
return false;
return Process();
}
if (!startup_info_wrapper.InitializeProcThreadAttributeList(1)) {
DPLOG(ERROR);
return false;
return Process();
}
if (!startup_info_wrapper.UpdateProcThreadAttribute(
......@@ -139,7 +143,7 @@ bool LaunchProcess(const string16& cmdline,
static_cast<DWORD>(options.handles_to_inherit->size() *
sizeof(HANDLE)))) {
DPLOG(ERROR);
return false;
return Process();
}
inherit_handles = true;
......@@ -184,7 +188,7 @@ bool LaunchProcess(const string16& cmdline,
if (!CreateEnvironmentBlock(&enviroment_block, options.as_user, FALSE)) {
DPLOG(ERROR);
return false;
return Process();
}
BOOL launched =
......@@ -197,7 +201,7 @@ bool LaunchProcess(const string16& cmdline,
if (!launched) {
DPLOG(ERROR) << "Command line:" << std::endl << UTF16ToUTF8(cmdline)
<< std::endl;;
return false;
return Process();
}
} else {
if (!CreateProcess(NULL,
......@@ -206,7 +210,7 @@ bool LaunchProcess(const string16& cmdline,
startup_info, &temp_process_info)) {
DPLOG(ERROR) << "Command line:" << std::endl << UTF16ToUTF8(cmdline)
<< std::endl;;
return false;
return Process();
}
}
base::win::ScopedProcessInformation process_info(temp_process_info);
......@@ -216,7 +220,7 @@ bool LaunchProcess(const string16& cmdline,
process_info.process_handle())) {
DLOG(ERROR) << "Could not AssignProcessToObject.";
KillProcess(process_info.process_handle(), kProcessKilledExitCode, true);
return false;
return Process();
}
ResumeThread(process_info.thread_handle());
......@@ -225,43 +229,7 @@ bool LaunchProcess(const string16& cmdline,
if (options.wait)
WaitForSingleObject(process_info.process_handle(), INFINITE);
// If the caller wants the process handle, we won't close it.
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();
return Process(process_info.TakeProcessHandle());
}
Process LaunchElevatedProcess(const CommandLine& cmdline,
......
......@@ -607,7 +607,7 @@ std::string TestLaunchProcess(const std::vector<std::string>& args,
#else
CHECK_EQ(0, clone_flags);
#endif // OS_LINUX
EXPECT_TRUE(base::LaunchProcess(args, options, NULL));
EXPECT_TRUE(base::LaunchProcess(args, options).IsValid());
PCHECK(IGNORE_EINTR(close(fds[1])) == 0);
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