Skip to content

Commit

Permalink
Update net to use the new version of LaunchProcess.
Browse files Browse the repository at this point in the history
BUG=417532
R=rtenneti@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#308205}
  • Loading branch information
rvargas committed Dec 13, 2014
1 parent 304529e commit ac3c4b6
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 19 deletions.
7 changes: 3 additions & 4 deletions net/disk_cache/blockfile/stress_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}
Expand Down
10 changes: 4 additions & 6 deletions net/test/spawned_test_server/local_test_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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?";
}
Expand All @@ -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))
Expand Down
6 changes: 3 additions & 3 deletions net/test/spawned_test_server/local_test_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion net/test/spawned_test_server/local_test_server_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion net/test/spawned_test_server/local_test_server_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
7 changes: 3 additions & 4 deletions net/tools/crash_cache/crash_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit ac3c4b6

Please sign in to comment.