Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: remoting/host/daemon_process.cc

Issue 12678008: Reworked the plumbing required to pass the client resolution to the desktop resizer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
24 namespace remoting {
25
23 namespace { 26 namespace {
24 27
25 std::ostream& operator<<(std::ostream& os, const SkIPoint& point) { 28 // This is used for tagging system event logs.
26 return os << "(" << point.x() << ", " << point.y() << ")"; 29 const char kApplicationName[] = "chromoting";
27 }
28 30
29 std::ostream& operator<<(std::ostream& os, const SkISize& size) { 31 std::ostream& operator<<(std::ostream& os, const ScreenResolution& resolution) {
30 return os << size.width() << "x" << size.height(); 32 return os << resolution.dimensions_.width() << "x"
33 << resolution.dimensions_.height() << " at "
34 << resolution.dpi_.x() << "x" << resolution.dpi_.y() << " DPI";
31 } 35 }
32 36
33 } // namespace 37 } // namespace
34 38
35 namespace remoting {
36
37 // This is used for tagging system event logs.
38 const char kApplicationName[] = "chromoting";
39
40 DaemonProcess::~DaemonProcess() { 39 DaemonProcess::~DaemonProcess() {
41 DCHECK(!config_watcher_.get()); 40 DCHECK(!config_watcher_.get());
42 DCHECK(desktop_sessions_.empty()); 41 DCHECK(desktop_sessions_.empty());
43 } 42 }
44 43
45 void DaemonProcess::OnConfigUpdated(const std::string& serialized_config) { 44 void DaemonProcess::OnConfigUpdated(const std::string& serialized_config) {
46 DCHECK(caller_task_runner()->BelongsToCurrentThread()); 45 DCHECK(caller_task_runner()->BelongsToCurrentThread());
47 46
48 if (serialized_config_ != serialized_config) { 47 if (serialized_config_ != serialized_config) {
49 serialized_config_ = serialized_config; 48 serialized_config_ = serialized_config;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 const base::Closure& stopped_callback) 163 const base::Closure& stopped_callback)
165 : Stoppable(caller_task_runner, stopped_callback), 164 : Stoppable(caller_task_runner, stopped_callback),
166 caller_task_runner_(caller_task_runner), 165 caller_task_runner_(caller_task_runner),
167 io_task_runner_(io_task_runner), 166 io_task_runner_(io_task_runner),
168 next_terminal_id_(0), 167 next_terminal_id_(0),
169 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { 168 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
170 DCHECK(caller_task_runner->BelongsToCurrentThread()); 169 DCHECK(caller_task_runner->BelongsToCurrentThread());
171 } 170 }
172 171
173 void DaemonProcess::CreateDesktopSession(int terminal_id, 172 void DaemonProcess::CreateDesktopSession(int terminal_id,
174 const DesktopSessionParams& params, 173 const ScreenResolution& resolution,
175 bool virtual_terminal) { 174 bool virtual_terminal) {
176 DCHECK(caller_task_runner()->BelongsToCurrentThread()); 175 DCHECK(caller_task_runner()->BelongsToCurrentThread());
177 176
178 // Validate the supplied terminal ID. An attempt to create a desktop session 177 // 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 178 // with an ID that could possibly have been allocated already is considered
180 // a protocol error and the network process will be restarted. 179 // a protocol error and the network process will be restarted.
181 if (IsTerminalIdKnown(terminal_id)) { 180 if (IsTerminalIdKnown(terminal_id)) {
182 LOG(ERROR) << "An invalid terminal ID. terminal_id=" << terminal_id; 181 LOG(ERROR) << "An invalid terminal ID. terminal_id=" << terminal_id;
183 CrashNetworkProcess(FROM_HERE); 182 CrashNetworkProcess(FROM_HERE);
184 return; 183 return;
185 } 184 }
186 185
187 // Terminal IDs cannot be reused. Update the expected next terminal ID. 186 // Terminal IDs cannot be reused. Update the expected next terminal ID.
188 next_terminal_id_ = std::max(next_terminal_id_, terminal_id + 1); 187 next_terminal_id_ = std::max(next_terminal_id_, terminal_id + 1);
189 188
190 // Validate |params|. 189 // Validate |resolution|.
191 if (params.client_dpi_.x() < 0 || params.client_dpi_.y() < 0) { 190 if (!resolution.IsValid()) {
192 LOG(ERROR) << "Invalid DPI of the remote screen specified: " 191 LOG(ERROR) << "Invalid resolution specified: " << resolution;
193 << params.client_dpi_;
194 SendToNetwork( 192 SendToNetwork(
195 new ChromotingDaemonNetworkMsg_TerminalDisconnected(terminal_id)); 193 new ChromotingDaemonNetworkMsg_TerminalDisconnected(terminal_id));
196 return; 194 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 } 195 }
205 196
206 // Create the desktop session. 197 // Create the desktop session.
207 scoped_ptr<DesktopSession> session = DoCreateDesktopSession( 198 scoped_ptr<DesktopSession> session = DoCreateDesktopSession(
208 terminal_id, params, virtual_terminal); 199 terminal_id, resolution, virtual_terminal);
209 if (!session) { 200 if (!session) {
210 LOG(ERROR) << "Failed to create a desktop session."; 201 LOG(ERROR) << "Failed to create a desktop session.";
211 SendToNetwork( 202 SendToNetwork(
212 new ChromotingDaemonNetworkMsg_TerminalDisconnected(terminal_id)); 203 new ChromotingDaemonNetworkMsg_TerminalDisconnected(terminal_id));
213 return; 204 return;
214 } 205 }
215 206
216 VLOG(1) << "Daemon: opened desktop session " << terminal_id; 207 VLOG(1) << "Daemon: opened desktop session " << terminal_id;
217 desktop_sessions_.push_back(session.release()); 208 desktop_sessions_.push_back(session.release());
218 } 209 }
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 } 335 }
345 336
346 void DaemonProcess::DeleteAllDesktopSessions() { 337 void DaemonProcess::DeleteAllDesktopSessions() {
347 while (!desktop_sessions_.empty()) { 338 while (!desktop_sessions_.empty()) {
348 delete desktop_sessions_.front(); 339 delete desktop_sessions_.front();
349 desktop_sessions_.pop_front(); 340 desktop_sessions_.pop_front();
350 } 341 }
351 } 342 }
352 343
353 } // namespace remoting 344 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698