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/daemon_process.h" | 5 #include "remoting/host/daemon_process.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 | 177 |
178 // Validate the supplied terminal ID. An attempt to create a desktop session | 178 // Validate the supplied terminal ID. An attempt to create a desktop session |
179 // with an ID that could possibly have been allocated already is considered | 179 // with an ID that could possibly have been allocated already is considered |
180 // a protocol error and the network process will be restarted. | 180 // a protocol error and the network process will be restarted. |
181 if (IsTerminalIdKnown(terminal_id)) { | 181 if (IsTerminalIdKnown(terminal_id)) { |
182 LOG(ERROR) << "An invalid terminal ID. terminal_id=" << terminal_id; | 182 LOG(ERROR) << "An invalid terminal ID. terminal_id=" << terminal_id; |
183 CrashNetworkProcess(FROM_HERE); | 183 CrashNetworkProcess(FROM_HERE); |
184 return; | 184 return; |
185 } | 185 } |
186 | 186 |
| 187 // Terminal IDs cannot be reused. Update the expected next terminal ID. |
| 188 next_terminal_id_ = std::max(next_terminal_id_, terminal_id + 1); |
| 189 |
187 // Validate |params|. | 190 // Validate |params|. |
188 if (params.client_dpi_.x() < 0 || params.client_dpi_.y() < 0) { | 191 if (params.client_dpi_.x() < 0 || params.client_dpi_.y() < 0) { |
189 LOG(ERROR) << "Invalid DPI of the remote screen specified: " | 192 LOG(ERROR) << "Invalid DPI of the remote screen specified: " |
190 << params.client_dpi_; | 193 << params.client_dpi_; |
191 SendToNetwork( | 194 SendToNetwork( |
192 new ChromotingDaemonNetworkMsg_TerminalDisconnected(terminal_id)); | 195 new ChromotingDaemonNetworkMsg_TerminalDisconnected(terminal_id)); |
193 return; | 196 return; |
194 } | 197 } |
195 if (params.client_size_.width() < 0 || params.client_size_.height() < 0) { | 198 if (params.client_size_.width() < 0 || params.client_size_.height() < 0) { |
196 LOG(ERROR) << "Invalid resolution of the remote screen specified: " | 199 LOG(ERROR) << "Invalid resolution of the remote screen specified: " |
197 << params.client_size_; | 200 << params.client_size_; |
198 SendToNetwork( | 201 SendToNetwork( |
199 new ChromotingDaemonNetworkMsg_TerminalDisconnected(terminal_id)); | 202 new ChromotingDaemonNetworkMsg_TerminalDisconnected(terminal_id)); |
200 return; | 203 return; |
201 } | 204 } |
202 | 205 |
203 // Create the desktop session. | 206 // Create the desktop session. |
204 scoped_ptr<DesktopSession> session = DoCreateDesktopSession( | 207 scoped_ptr<DesktopSession> session = DoCreateDesktopSession( |
205 terminal_id, params, virtual_terminal); | 208 terminal_id, params, virtual_terminal); |
206 if (session) { | 209 if (!session) { |
207 VLOG(1) << "Daemon: opened desktop session " << terminal_id; | |
208 desktop_sessions_.push_back(session.release()); | |
209 } else { | |
210 LOG(ERROR) << "Failed to create a desktop session."; | 210 LOG(ERROR) << "Failed to create a desktop session."; |
211 SendToNetwork( | 211 SendToNetwork( |
212 new ChromotingDaemonNetworkMsg_TerminalDisconnected(terminal_id)); | 212 new ChromotingDaemonNetworkMsg_TerminalDisconnected(terminal_id)); |
213 return; | 213 return; |
214 } | 214 } |
215 | 215 |
216 // Update the expected terminal ID. | 216 VLOG(1) << "Daemon: opened desktop session " << terminal_id; |
217 next_terminal_id_ = std::max(next_terminal_id_, terminal_id + 1); | 217 desktop_sessions_.push_back(session.release()); |
218 } | 218 } |
219 | 219 |
220 void DaemonProcess::CrashNetworkProcess( | 220 void DaemonProcess::CrashNetworkProcess( |
221 const tracked_objects::Location& location) { | 221 const tracked_objects::Location& location) { |
222 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 222 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
223 | 223 |
224 DoCrashNetworkProcess(location); | 224 DoCrashNetworkProcess(location); |
225 DeleteAllDesktopSessions(); | 225 DeleteAllDesktopSessions(); |
226 } | 226 } |
227 | 227 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 } | 344 } |
345 | 345 |
346 void DaemonProcess::DeleteAllDesktopSessions() { | 346 void DaemonProcess::DeleteAllDesktopSessions() { |
347 while (!desktop_sessions_.empty()) { | 347 while (!desktop_sessions_.empty()) { |
348 delete desktop_sessions_.front(); | 348 delete desktop_sessions_.front(); |
349 desktop_sessions_.pop_front(); | 349 desktop_sessions_.pop_front(); |
350 } | 350 } |
351 } | 351 } |
352 | 352 |
353 } // namespace remoting | 353 } // namespace remoting |
OLD | NEW |