OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "mojo/shell/child_process_host.h" | 5 #include "mojo/shell/child_process_host.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 CHECK(base::PostTaskAndReplyWithResult( | 49 CHECK(base::PostTaskAndReplyWithResult( |
50 context_->task_runners()->blocking_pool(), | 50 context_->task_runners()->blocking_pool(), |
51 FROM_HERE, | 51 FROM_HERE, |
52 base::Bind(&ChildProcessHost::DoLaunch, base::Unretained(this)), | 52 base::Bind(&ChildProcessHost::DoLaunch, base::Unretained(this)), |
53 base::Bind(&ChildProcessHost::DidLaunch, base::Unretained(this)))); | 53 base::Bind(&ChildProcessHost::DidLaunch, base::Unretained(this)))); |
54 } | 54 } |
55 | 55 |
56 int ChildProcessHost::Join() { | 56 int ChildProcessHost::Join() { |
57 DCHECK_NE(child_process_handle_, base::kNullProcessHandle); | 57 DCHECK_NE(child_process_handle_, base::kNullProcessHandle); |
58 int rv = -1; | 58 int rv = -1; |
| 59 // Note: |WaitForExitCode()| closes the process handle. |
59 LOG_IF(ERROR, !base::WaitForExitCode(child_process_handle_, &rv)) | 60 LOG_IF(ERROR, !base::WaitForExitCode(child_process_handle_, &rv)) |
60 << "Failed to wait for child process"; | 61 << "Failed to wait for child process"; |
61 base::CloseProcessHandle(child_process_handle_); | |
62 child_process_handle_ = base::kNullProcessHandle; | 62 child_process_handle_ = base::kNullProcessHandle; |
63 return rv; | 63 return rv; |
64 } | 64 } |
65 | 65 |
66 bool ChildProcessHost::DoLaunch() { | 66 bool ChildProcessHost::DoLaunch() { |
67 static const char* kForwardSwitches[] = { | 67 static const char* kForwardSwitches[] = { |
68 switches::kTraceToConsole, | 68 switches::kTraceToConsole, |
69 switches::kV, | 69 switches::kV, |
70 switches::kVModule, | 70 switches::kVModule, |
71 }; | 71 }; |
(...skipping 24 matching lines...) Expand all Loading... |
96 platform_channel_pair_.ChildProcessLaunched(); | 96 platform_channel_pair_.ChildProcessLaunched(); |
97 return true; | 97 return true; |
98 } | 98 } |
99 | 99 |
100 void ChildProcessHost::DidLaunch(bool success) { | 100 void ChildProcessHost::DidLaunch(bool success) { |
101 delegate_->DidStart(success); | 101 delegate_->DidStart(success); |
102 } | 102 } |
103 | 103 |
104 } // namespace shell | 104 } // namespace shell |
105 } // namespace mojo | 105 } // namespace mojo |
OLD | NEW |