Chromium Code Reviews| 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" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/location.h" | 12 #include "base/location.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "net/base/net_util.h" | 14 #include "net/base/net_util.h" |
| 15 #include "remoting/base/auto_thread_task_runner.h" | 15 #include "remoting/base/auto_thread_task_runner.h" |
| 16 #include "remoting/host/branding.h" | 16 #include "remoting/host/branding.h" |
| 17 #include "remoting/host/chromoting_messages.h" | 17 #include "remoting/host/chromoting_messages.h" |
| 18 #include "remoting/host/desktop_session.h" | 18 #include "remoting/host/desktop_session.h" |
| 19 #include "remoting/host/host_event_logger.h" | 19 #include "remoting/host/host_event_logger.h" |
| 20 #include "remoting/host/host_status_observer.h" | 20 #include "remoting/host/host_status_observer.h" |
| 21 #include "remoting/host/screen_resolution.h" | |
| 21 #include "remoting/protocol/transport.h" | 22 #include "remoting/protocol/transport.h" |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 std::ostream& operator<<(std::ostream& os, const SkIPoint& point) { | 26 std::ostream& operator<<(std::ostream& os, const SkIPoint& point) { |
| 26 return os << "(" << point.x() << ", " << point.y() << ")"; | 27 return os << "(" << point.x() << ", " << point.y() << ")"; |
| 27 } | 28 } |
| 28 | 29 |
| 29 std::ostream& operator<<(std::ostream& os, const SkISize& size) { | 30 std::ostream& operator<<(std::ostream& os, const SkISize& size) { |
| 30 return os << size.width() << "x" << size.height(); | 31 return os << size.width() << "x" << size.height(); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 164 const base::Closure& stopped_callback) | 165 const base::Closure& stopped_callback) |
| 165 : Stoppable(caller_task_runner, stopped_callback), | 166 : Stoppable(caller_task_runner, stopped_callback), |
| 166 caller_task_runner_(caller_task_runner), | 167 caller_task_runner_(caller_task_runner), |
| 167 io_task_runner_(io_task_runner), | 168 io_task_runner_(io_task_runner), |
| 168 next_terminal_id_(0), | 169 next_terminal_id_(0), |
| 169 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 170 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
| 170 DCHECK(caller_task_runner->BelongsToCurrentThread()); | 171 DCHECK(caller_task_runner->BelongsToCurrentThread()); |
| 171 } | 172 } |
| 172 | 173 |
| 173 void DaemonProcess::CreateDesktopSession(int terminal_id, | 174 void DaemonProcess::CreateDesktopSession(int terminal_id, |
| 174 const DesktopSessionParams& params, | 175 const ScreenResolution& resolution, |
| 175 bool virtual_terminal) { | 176 bool virtual_terminal) { |
| 176 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 177 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
| 177 | 178 |
| 178 // Validate the supplied terminal ID. An attempt to create a desktop session | 179 // 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 | 180 // with an ID that could possibly have been allocated already is considered |
| 180 // a protocol error and the network process will be restarted. | 181 // a protocol error and the network process will be restarted. |
| 181 if (IsTerminalIdKnown(terminal_id)) { | 182 if (IsTerminalIdKnown(terminal_id)) { |
| 182 LOG(ERROR) << "An invalid terminal ID. terminal_id=" << terminal_id; | 183 LOG(ERROR) << "An invalid terminal ID. terminal_id=" << terminal_id; |
| 183 CrashNetworkProcess(FROM_HERE); | 184 CrashNetworkProcess(FROM_HERE); |
| 184 return; | 185 return; |
| 185 } | 186 } |
| 186 | 187 |
| 187 // Terminal IDs cannot be reused. Update the expected next terminal ID. | 188 // Terminal IDs cannot be reused. Update the expected next terminal ID. |
| 188 next_terminal_id_ = std::max(next_terminal_id_, terminal_id + 1); | 189 next_terminal_id_ = std::max(next_terminal_id_, terminal_id + 1); |
| 189 | 190 |
| 190 // Validate |params|. | 191 // Validate |resolution|. |
| 191 if (params.client_dpi_.x() < 0 || params.client_dpi_.y() < 0) { | 192 if (!resolution.IsValid()) { |
| 192 LOG(ERROR) << "Invalid DPI of the remote screen specified: " | 193 LOG(ERROR) << "Invalid DPI of the remote screen specified: " |
|
Jamie
2013/03/15 18:33:24
"DPI/resolution" instead of "DPI"?
alexeypa (please no reviews)
2013/03/15 20:30:41
Done.
| |
| 193 << params.client_dpi_; | 194 << resolution.dimensions_ << ", " << resolution.dpi_; |
| 194 SendToNetwork( | 195 SendToNetwork( |
| 195 new ChromotingDaemonNetworkMsg_TerminalDisconnected(terminal_id)); | 196 new ChromotingDaemonNetworkMsg_TerminalDisconnected(terminal_id)); |
| 196 return; | 197 return; |
| 197 } | |
| 198 if (params.client_size_.width() < 0 || params.client_size_.height() < 0) { | |
| 199 LOG(ERROR) << "Invalid resolution of the remote screen specified: " | |
| 200 << params.client_size_; | |
| 201 SendToNetwork( | |
| 202 new ChromotingDaemonNetworkMsg_TerminalDisconnected(terminal_id)); | |
| 203 return; | |
| 204 } | 198 } |
| 205 | 199 |
| 206 // Create the desktop session. | 200 // Create the desktop session. |
| 207 scoped_ptr<DesktopSession> session = DoCreateDesktopSession( | 201 scoped_ptr<DesktopSession> session = DoCreateDesktopSession( |
| 208 terminal_id, params, virtual_terminal); | 202 terminal_id, resolution, virtual_terminal); |
| 209 if (!session) { | 203 if (!session) { |
| 210 LOG(ERROR) << "Failed to create a desktop session."; | 204 LOG(ERROR) << "Failed to create a desktop session."; |
| 211 SendToNetwork( | 205 SendToNetwork( |
| 212 new ChromotingDaemonNetworkMsg_TerminalDisconnected(terminal_id)); | 206 new ChromotingDaemonNetworkMsg_TerminalDisconnected(terminal_id)); |
| 213 return; | 207 return; |
| 214 } | 208 } |
| 215 | 209 |
| 216 VLOG(1) << "Daemon: opened desktop session " << terminal_id; | 210 VLOG(1) << "Daemon: opened desktop session " << terminal_id; |
| 217 desktop_sessions_.push_back(session.release()); | 211 desktop_sessions_.push_back(session.release()); |
| 218 } | 212 } |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 344 } | 338 } |
| 345 | 339 |
| 346 void DaemonProcess::DeleteAllDesktopSessions() { | 340 void DaemonProcess::DeleteAllDesktopSessions() { |
| 347 while (!desktop_sessions_.empty()) { | 341 while (!desktop_sessions_.empty()) { |
| 348 delete desktop_sessions_.front(); | 342 delete desktop_sessions_.front(); |
| 349 desktop_sessions_.pop_front(); | 343 desktop_sessions_.pop_front(); |
| 350 } | 344 } |
| 351 } | 345 } |
| 352 | 346 |
| 353 } // namespace remoting | 347 } // namespace remoting |
| OLD | NEW |