Commit ac3c4b6c authored by rvargas's avatar rvargas

Update net to use the new version of LaunchProcess.

BUG=417532
R=rtenneti@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#308205}
parent 304529e8
......@@ -27,7 +27,6 @@
#include "base/path_service.h"
#include "base/process/kill.h"
#include "base/process/launch.h"
#include "base/process/process_handle.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
......@@ -59,14 +58,14 @@ int RunSlave(int iteration) {
base::CommandLine cmdline(exe);
cmdline.AppendArg(base::IntToString(iteration));
base::ProcessHandle handle;
if (!base::LaunchProcess(cmdline, base::LaunchOptions(), &handle)) {
base::Process process = base::LaunchProcess(cmdline, base::LaunchOptions());
if (!process.IsValid()) {
printf("Unable to run test\n");
return kError;
}
int exit_code;
if (!base::WaitForExitCode(handle, &exit_code)) {
if (!process.WaitForExit(&exit_code)) {
printf("Unable to get return code\n");
return kError;
}
......
......@@ -121,18 +121,17 @@ bool LocalTestServer::BlockUntilStarted() {
bool LocalTestServer::Stop() {
CleanUpWhenStoppingServer();
if (!process_handle_)
if (!process_.IsValid())
return true;
// First check if the process has already terminated.
bool ret = base::WaitForSingleProcess(process_handle_, base::TimeDelta());
bool ret = base::WaitForSingleProcess(process_.Handle(), base::TimeDelta());
if (!ret) {
ret = base::KillProcess(process_handle_, 1, true);
ret = base::KillProcess(process_.Handle(), 1, true);
}
if (ret) {
base::CloseProcessHandle(process_handle_);
process_handle_ = base::kNullProcessHandle;
process_.Close();
} else {
VLOG(1) << "Kill failed?";
}
......@@ -149,7 +148,6 @@ bool LocalTestServer::Init(const base::FilePath& document_root) {
// number out over a pipe that this TestServer object will read from. Once
// that is complete, the host port pair will contain the actual port.
DCHECK(!GetPort());
process_handle_ = base::kNullProcessHandle;
base::FilePath src_dir;
if (!PathService::Get(base::DIR_SOURCE_ROOT, &src_dir))
......
......@@ -9,7 +9,7 @@
#include "base/files/file_util.h"
#include "base/files/scoped_file.h"
#include "base/process/process_handle.h"
#include "base/process/process.h"
#include "net/test/spawned_test_server/base_test_server.h"
#if defined(OS_WIN)
......@@ -92,8 +92,8 @@ class LocalTestServer : public BaseTestServer {
// Waits for the server to start. Returns true on success.
bool WaitToStart() WARN_UNUSED_RESULT;
// Handle of the Python process running the test server.
base::ProcessHandle process_handle_;
// The Python process running the test server.
base::Process process_;
#if defined(OS_WIN)
// The pipe file handle we read from.
......
......@@ -139,7 +139,8 @@ bool LocalTestServer::LaunchPython(const base::FilePath& testserver_path) {
base::LaunchOptions options;
options.fds_to_remap = &map_write_fd;
if (!base::LaunchProcess(python_command, options, &process_handle_)) {
process_ = base::LaunchProcess(python_command, options);
if (!process_.IsValid()) {
LOG(ERROR) << "Failed to launch " << python_command.GetCommandLineString();
return false;
}
......
......@@ -176,7 +176,8 @@ bool LocalTestServer::LaunchPython(const base::FilePath& testserver_path) {
base::LaunchOptions launch_options;
launch_options.inherit_handles = true;
if (!base::LaunchProcess(python_command, launch_options, &process_handle_)) {
process_ = base::LaunchProcess(python_command, launch_options);
if (!process_.IsValid()) {
LOG(ERROR) << "Failed to launch " << python_command.GetCommandLineString();
return false;
}
......
......@@ -17,7 +17,6 @@
#include "base/path_service.h"
#include "base/process/kill.h"
#include "base/process/launch.h"
#include "base/process/process_handle.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
......@@ -50,15 +49,15 @@ int RunSlave(RankCrashes action) {
base::CommandLine cmdline(exe);
cmdline.AppendArg(base::IntToString(action));
base::ProcessHandle handle;
if (!base::LaunchProcess(cmdline, base::LaunchOptions(), &handle)) {
base::Process process = base::LaunchProcess(cmdline, base::LaunchOptions());
if (!process.IsValid()) {
printf("Unable to run test %d\n", action);
return GENERIC;
}
int exit_code;
if (!base::WaitForExitCode(handle, &exit_code)) {
if (!process.WaitForExit(&exit_code)) {
printf("Unable to get return code, test %d\n", action);
return GENERIC;
}
......
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