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