| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "remoting/host/win/worker_process_launcher.h" | 5 #include "remoting/host/win/worker_process_launcher.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 } | 106 } |
| 107 | 107 |
| 108 void WorkerProcessLauncher::OnProcessLaunched( | 108 void WorkerProcessLauncher::OnProcessLaunched( |
| 109 base::win::ScopedHandle worker_process) { | 109 base::win::ScopedHandle worker_process) { |
| 110 DCHECK(CalledOnValidThread()); | 110 DCHECK(CalledOnValidThread()); |
| 111 DCHECK(!ipc_enabled_); | 111 DCHECK(!ipc_enabled_); |
| 112 DCHECK(!launch_timer_.IsRunning()); | 112 DCHECK(!launch_timer_.IsRunning()); |
| 113 DCHECK(!process_watcher_.GetWatchedObject()); | 113 DCHECK(!process_watcher_.GetWatchedObject()); |
| 114 DCHECK(!worker_process_.IsValid()); | 114 DCHECK(!worker_process_.IsValid()); |
| 115 | 115 |
| 116 if (!process_watcher_.StartWatching(worker_process, this)) { | 116 if (!process_watcher_.StartWatching(worker_process.Get(), this)) { |
| 117 StopWorker(); | 117 StopWorker(); |
| 118 return; | 118 return; |
| 119 } | 119 } |
| 120 | 120 |
| 121 ipc_enabled_ = true; | 121 ipc_enabled_ = true; |
| 122 worker_process_ = worker_process.Pass(); | 122 worker_process_ = worker_process.Pass(); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void WorkerProcessLauncher::OnFatalError() { | 125 void WorkerProcessLauncher::OnFatalError() { |
| 126 DCHECK(CalledOnValidThread()); | 126 DCHECK(CalledOnValidThread()); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 if (!kill_process_timer_.IsRunning()) { | 160 if (!kill_process_timer_.IsRunning()) { |
| 161 kill_process_timer_.Start(FROM_HERE, kill_process_timeout_, this, | 161 kill_process_timer_.Start(FROM_HERE, kill_process_timeout_, this, |
| 162 &WorkerProcessLauncher::StopWorker); | 162 &WorkerProcessLauncher::StopWorker); |
| 163 } | 163 } |
| 164 } | 164 } |
| 165 | 165 |
| 166 void WorkerProcessLauncher::OnObjectSignaled(HANDLE object) { | 166 void WorkerProcessLauncher::OnObjectSignaled(HANDLE object) { |
| 167 DCHECK(CalledOnValidThread()); | 167 DCHECK(CalledOnValidThread()); |
| 168 DCHECK(!process_watcher_.GetWatchedObject()); | 168 DCHECK(!process_watcher_.GetWatchedObject()); |
| 169 DCHECK_EQ(exit_code_, CONTROL_C_EXIT); | 169 DCHECK_EQ(exit_code_, CONTROL_C_EXIT); |
| 170 DCHECK_EQ(worker_process_, object); | 170 DCHECK_EQ(worker_process_.Get(), object); |
| 171 | 171 |
| 172 // Get exit code of the worker process if it is available. | 172 // Get exit code of the worker process if it is available. |
| 173 if (!::GetExitCodeProcess(worker_process_, &exit_code_)) { | 173 if (!::GetExitCodeProcess(worker_process_.Get(), &exit_code_)) { |
| 174 PLOG(INFO) << "Failed to query the exit code of the worker process"; | 174 PLOG(INFO) << "Failed to query the exit code of the worker process"; |
| 175 exit_code_ = CONTROL_C_EXIT; | 175 exit_code_ = CONTROL_C_EXIT; |
| 176 } | 176 } |
| 177 | 177 |
| 178 worker_process_.Close(); | 178 worker_process_.Close(); |
| 179 StopWorker(); | 179 StopWorker(); |
| 180 } | 180 } |
| 181 | 181 |
| 182 void WorkerProcessLauncher::LaunchWorker() { | 182 void WorkerProcessLauncher::LaunchWorker() { |
| 183 DCHECK(CalledOnValidThread()); | 183 DCHECK(CalledOnValidThread()); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 ipc_handler_->OnPermanentError(exit_code_); | 259 ipc_handler_->OnPermanentError(exit_code_); |
| 260 return; | 260 return; |
| 261 } | 261 } |
| 262 | 262 |
| 263 // Schedule the next attempt to launch the worker process. | 263 // Schedule the next attempt to launch the worker process. |
| 264 launch_timer_.Start(FROM_HERE, launch_backoff_.GetTimeUntilRelease(), this, | 264 launch_timer_.Start(FROM_HERE, launch_backoff_.GetTimeUntilRelease(), this, |
| 265 &WorkerProcessLauncher::LaunchWorker); | 265 &WorkerProcessLauncher::LaunchWorker); |
| 266 } | 266 } |
| 267 | 267 |
| 268 } // namespace remoting | 268 } // namespace remoting |
| OLD | NEW |