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 <utility> |
| 8 |
7 #include "base/location.h" | 9 #include "base/location.h" |
8 #include "base/logging.h" | 10 #include "base/logging.h" |
9 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
10 #include "base/time/time.h" | 12 #include "base/time/time.h" |
11 #include "base/win/windows_version.h" | 13 #include "base/win/windows_version.h" |
12 #include "ipc/ipc_message.h" | 14 #include "ipc/ipc_message.h" |
13 #include "remoting/host/chromoting_messages.h" | 15 #include "remoting/host/chromoting_messages.h" |
14 #include "remoting/host/host_exit_codes.h" | 16 #include "remoting/host/host_exit_codes.h" |
15 #include "remoting/host/worker_process_ipc_delegate.h" | 17 #include "remoting/host/worker_process_ipc_delegate.h" |
16 | 18 |
(...skipping 24 matching lines...) Expand all Loading... |
41 | 43 |
42 // Don't use initial delay unless the last request was an error. | 44 // Don't use initial delay unless the last request was an error. |
43 false, | 45 false, |
44 }; | 46 }; |
45 | 47 |
46 const int kKillProcessTimeoutSeconds = 5; | 48 const int kKillProcessTimeoutSeconds = 5; |
47 const int kLaunchResultTimeoutSeconds = 5; | 49 const int kLaunchResultTimeoutSeconds = 5; |
48 | 50 |
49 namespace remoting { | 51 namespace remoting { |
50 | 52 |
51 WorkerProcessLauncher::Delegate::~Delegate() { | 53 WorkerProcessLauncher::Delegate::~Delegate() {} |
52 } | |
53 | 54 |
54 WorkerProcessLauncher::WorkerProcessLauncher( | 55 WorkerProcessLauncher::WorkerProcessLauncher( |
55 scoped_ptr<WorkerProcessLauncher::Delegate> launcher_delegate, | 56 scoped_ptr<WorkerProcessLauncher::Delegate> launcher_delegate, |
56 WorkerProcessIpcDelegate* ipc_handler) | 57 WorkerProcessIpcDelegate* ipc_handler) |
57 : ipc_handler_(ipc_handler), | 58 : ipc_handler_(ipc_handler), |
58 launcher_delegate_(launcher_delegate.Pass()), | 59 launcher_delegate_(std::move(launcher_delegate)), |
59 exit_code_(CONTROL_C_EXIT), | 60 exit_code_(CONTROL_C_EXIT), |
60 ipc_enabled_(false), | 61 ipc_enabled_(false), |
61 kill_process_timeout_( | 62 kill_process_timeout_( |
62 base::TimeDelta::FromSeconds(kKillProcessTimeoutSeconds)), | 63 base::TimeDelta::FromSeconds(kKillProcessTimeoutSeconds)), |
63 launch_backoff_(&kDefaultBackoffPolicy) { | 64 launch_backoff_(&kDefaultBackoffPolicy) { |
64 DCHECK(ipc_handler_ != nullptr); | 65 DCHECK(ipc_handler_ != nullptr); |
65 | 66 |
66 LaunchWorker(); | 67 LaunchWorker(); |
67 } | 68 } |
68 | 69 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 DCHECK(!launch_timer_.IsRunning()); | 113 DCHECK(!launch_timer_.IsRunning()); |
113 DCHECK(!process_watcher_.GetWatchedObject()); | 114 DCHECK(!process_watcher_.GetWatchedObject()); |
114 DCHECK(!worker_process_.IsValid()); | 115 DCHECK(!worker_process_.IsValid()); |
115 | 116 |
116 if (!process_watcher_.StartWatchingOnce(worker_process.Get(), this)) { | 117 if (!process_watcher_.StartWatchingOnce(worker_process.Get(), this)) { |
117 StopWorker(); | 118 StopWorker(); |
118 return; | 119 return; |
119 } | 120 } |
120 | 121 |
121 ipc_enabled_ = true; | 122 ipc_enabled_ = true; |
122 worker_process_ = worker_process.Pass(); | 123 worker_process_ = std::move(worker_process); |
123 } | 124 } |
124 | 125 |
125 void WorkerProcessLauncher::OnFatalError() { | 126 void WorkerProcessLauncher::OnFatalError() { |
126 DCHECK(CalledOnValidThread()); | 127 DCHECK(CalledOnValidThread()); |
127 | 128 |
128 StopWorker(); | 129 StopWorker(); |
129 } | 130 } |
130 | 131 |
131 bool WorkerProcessLauncher::OnMessageReceived( | 132 bool WorkerProcessLauncher::OnMessageReceived( |
132 const IPC::Message& message) { | 133 const IPC::Message& message) { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 ipc_handler_->OnPermanentError(exit_code_); | 260 ipc_handler_->OnPermanentError(exit_code_); |
260 return; | 261 return; |
261 } | 262 } |
262 | 263 |
263 // Schedule the next attempt to launch the worker process. | 264 // Schedule the next attempt to launch the worker process. |
264 launch_timer_.Start(FROM_HERE, launch_backoff_.GetTimeUntilRelease(), this, | 265 launch_timer_.Start(FROM_HERE, launch_backoff_.GetTimeUntilRelease(), this, |
265 &WorkerProcessLauncher::LaunchWorker); | 266 &WorkerProcessLauncher::LaunchWorker); |
266 } | 267 } |
267 | 268 |
268 } // namespace remoting | 269 } // namespace remoting |
OLD | NEW |