Chromium Code Reviews| Index: shell/child_process_host.cc |
| diff --git a/shell/child_process_host.cc b/shell/child_process_host.cc |
| index 9a68ec4f1b751ad9b20e7780a2ec895396d7a6b7..c96e6ff95f3fc519898eeb10a1a4bf1800ccffde 100644 |
| --- a/shell/child_process_host.cc |
| +++ b/shell/child_process_host.cc |
| @@ -26,23 +26,21 @@ ChildProcessHost::ChildProcessHost(Context* context, |
| ChildProcess::Type type) |
| : context_(context), |
| delegate_(delegate), |
| - type_(type), |
| - child_process_handle_(base::kNullProcessHandle) { |
| + type_(type) { |
| DCHECK(delegate); |
| platform_channel_ = platform_channel_pair_.PassServerHandle(); |
| CHECK(platform_channel_.is_valid()); |
| } |
| ChildProcessHost::~ChildProcessHost() { |
| - if (child_process_handle_ != base::kNullProcessHandle) { |
| + if (child_process_.IsValid()) { |
| LOG(WARNING) << "Destroying ChildProcessHost with unjoined child"; |
| - base::CloseProcessHandle(child_process_handle_); |
| - child_process_handle_ = base::kNullProcessHandle; |
| + child_process_.Close(); |
| } |
| } |
| void ChildProcessHost::Start() { |
| - DCHECK_EQ(child_process_handle_, base::kNullProcessHandle); |
| + DCHECK(!child_process_.IsValid()); |
| delegate_->WillStart(); |
| @@ -53,12 +51,11 @@ void ChildProcessHost::Start() { |
| } |
| int ChildProcessHost::Join() { |
| - DCHECK_NE(child_process_handle_, base::kNullProcessHandle); |
| + DCHECK(child_process_.IsValid()); |
| int rv = -1; |
| - // Note: |WaitForExitCode()| closes the process handle. |
| - LOG_IF(ERROR, !base::WaitForExitCode(child_process_handle_, &rv)) |
| - << "Failed to wait for child process"; |
| - child_process_handle_ = base::kNullProcessHandle; |
| + // Note: |WaitForExit()| closes the process handle. |
|
viettrungluu
2015/01/21 22:27:04
It doesn't, so you should do |child_process_.Close
|
| + child_process_.WaitForExit(&rv); |
| + LOG_IF(ERROR, rv != 0) << "Failed to wait for child process"; |
|
viettrungluu
2015/01/21 22:27:04
You should keep the form of the original LOG_IF:
|
| return rv; |
| } |
| @@ -86,8 +83,8 @@ bool ChildProcessHost::DoLaunch() { |
| #elif defined(OS_POSIX) |
| options.fds_to_remap = &handle_passing_info; |
| #endif |
| - |
| - if (!base::LaunchProcess(child_command_line, options, &child_process_handle_)) |
| + child_process_ = base::LaunchProcess(child_command_line, options); |
| + if (!child_process_.IsValid()) |
| return false; |
| platform_channel_pair_.ChildProcessLaunched(); |