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

Side by Side Diff: remoting/host/desktop_session_win.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: 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/desktop_session_win.h" 5 #include "remoting/host/desktop_session_win.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <sddl.h> 8 #include <sddl.h>
9 9
10 #include "base/base_switches.h" 10 #include "base/base_switches.h"
(...skipping 13 matching lines...) Expand all
24 #include "net/base/ip_endpoint.h" 24 #include "net/base/ip_endpoint.h"
25 #include "remoting/base/auto_thread_task_runner.h" 25 #include "remoting/base/auto_thread_task_runner.h"
26 // MIDL-generated declarations and definitions. 26 // MIDL-generated declarations and definitions.
27 #include "remoting/host/chromoting_lib.h" 27 #include "remoting/host/chromoting_lib.h"
28 #include "remoting/host/chromoting_messages.h" 28 #include "remoting/host/chromoting_messages.h"
29 #include "remoting/host/daemon_process.h" 29 #include "remoting/host/daemon_process.h"
30 #include "remoting/host/desktop_session.h" 30 #include "remoting/host/desktop_session.h"
31 #include "remoting/host/host_main.h" 31 #include "remoting/host/host_main.h"
32 #include "remoting/host/ipc_constants.h" 32 #include "remoting/host/ipc_constants.h"
33 #include "remoting/host/sas_injector.h" 33 #include "remoting/host/sas_injector.h"
34 #include "remoting/host/screen_resolution.h"
34 #include "remoting/host/win/host_service.h" 35 #include "remoting/host/win/host_service.h"
35 #include "remoting/host/win/worker_process_launcher.h" 36 #include "remoting/host/win/worker_process_launcher.h"
36 #include "remoting/host/win/wts_session_process_delegate.h" 37 #include "remoting/host/win/wts_session_process_delegate.h"
37 #include "remoting/host/win/wts_terminal_monitor.h" 38 #include "remoting/host/win/wts_terminal_monitor.h"
38 #include "remoting/host/win/wts_terminal_observer.h" 39 #include "remoting/host/win/wts_terminal_observer.h"
39 #include "remoting/host/worker_process_ipc_delegate.h" 40 #include "remoting/host/worker_process_ipc_delegate.h"
40 41
41 using base::win::ScopedHandle; 42 using base::win::ScopedHandle;
42 43
43 namespace remoting { 44 namespace remoting {
(...skipping 14 matching lines...) Expand all
58 const char* kCopiedSwitchNames[] = { switches::kV, switches::kVModule }; 59 const char* kCopiedSwitchNames[] = { switches::kV, switches::kVModule };
59 60
60 // RDC 6.1 (W2K8) supports dimensions of up to 4096x2048. 61 // RDC 6.1 (W2K8) supports dimensions of up to 4096x2048.
61 const int kMaxRdpScreenWidth = 4096; 62 const int kMaxRdpScreenWidth = 4096;
62 const int kMaxRdpScreenHeight = 2048; 63 const int kMaxRdpScreenHeight = 2048;
63 64
64 // The minimum effective screen dimensions supported by Windows are 800x600. 65 // The minimum effective screen dimensions supported by Windows are 800x600.
65 const int kMinRdpScreenWidth = 800; 66 const int kMinRdpScreenWidth = 800;
66 const int kMinRdpScreenHeight = 600; 67 const int kMinRdpScreenHeight = 600;
67 68
68 // Default dots per inch is 96 DPI.
69 const int kDefaultDpiX = 96;
70 const int kDefaultDpiY = 96;
71
72 // The session attach notification should arrive within 30 seconds. 69 // The session attach notification should arrive within 30 seconds.
73 const int kSessionAttachTimeoutSeconds = 30; 70 const int kSessionAttachTimeoutSeconds = 30;
74 71
75 // DesktopSession implementation which attaches to the host's physical console. 72 // DesktopSession implementation which attaches to the host's physical console.
76 // Receives IPC messages from the desktop process, running in the console 73 // Receives IPC messages from the desktop process, running in the console
77 // session, via |WorkerProcessIpcDelegate|, and monitors console session 74 // session, via |WorkerProcessIpcDelegate|, and monitors console session
78 // attach/detach events via |WtsConsoleObserer|. 75 // attach/detach events via |WtsConsoleObserer|.
79 class ConsoleSession : public DesktopSessionWin { 76 class ConsoleSession : public DesktopSessionWin {
80 public: 77 public:
81 // Same as DesktopSessionWin(). 78 // Same as DesktopSessionWin().
(...skipping 24 matching lines...) Expand all
106 // Same as DesktopSessionWin(). 103 // Same as DesktopSessionWin().
107 RdpSession( 104 RdpSession(
108 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, 105 scoped_refptr<AutoThreadTaskRunner> caller_task_runner,
109 scoped_refptr<AutoThreadTaskRunner> io_task_runner, 106 scoped_refptr<AutoThreadTaskRunner> io_task_runner,
110 DaemonProcess* daemon_process, 107 DaemonProcess* daemon_process,
111 int id, 108 int id,
112 WtsTerminalMonitor* monitor); 109 WtsTerminalMonitor* monitor);
113 virtual ~RdpSession(); 110 virtual ~RdpSession();
114 111
115 // Performs the part of initialization that can fail. 112 // Performs the part of initialization that can fail.
116 bool Initialize(const DesktopSessionParams& params); 113 bool Initialize(const ScreenResolution& resolution);
117 114
118 // Mirrors IRdpDesktopSessionEventHandler. 115 // Mirrors IRdpDesktopSessionEventHandler.
119 void OnRdpConnected(const net::IPEndPoint& client_endpoint); 116 void OnRdpConnected(const net::IPEndPoint& client_endpoint);
120 void OnRdpClosed(); 117 void OnRdpClosed();
121 118
122 protected: 119 protected:
123 // DesktopSessionWin overrides. 120 // DesktopSessionWin overrides.
124 virtual void InjectSas() OVERRIDE; 121 virtual void InjectSas() OVERRIDE;
125 122
126 private: 123 private:
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 int id, 185 int id,
189 WtsTerminalMonitor* monitor) 186 WtsTerminalMonitor* monitor)
190 : DesktopSessionWin(caller_task_runner, io_task_runner, daemon_process, id, 187 : DesktopSessionWin(caller_task_runner, io_task_runner, daemon_process, id,
191 monitor), 188 monitor),
192 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { 189 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
193 } 190 }
194 191
195 RdpSession::~RdpSession() { 192 RdpSession::~RdpSession() {
196 } 193 }
197 194
198 bool RdpSession::Initialize(const DesktopSessionParams& params) { 195 bool RdpSession::Initialize(const ScreenResolution& resolution) {
199 DCHECK(caller_task_runner()->BelongsToCurrentThread()); 196 DCHECK(caller_task_runner()->BelongsToCurrentThread());
200 197
201 // Create the RDP wrapper object. 198 // Create the RDP wrapper object.
202 HRESULT result = rdp_desktop_session_.CreateInstance( 199 HRESULT result = rdp_desktop_session_.CreateInstance(
203 __uuidof(RdpDesktopSession)); 200 __uuidof(RdpDesktopSession));
204 if (FAILED(result)) { 201 if (FAILED(result)) {
205 LOG(ERROR) << "Failed to create RdpSession object, 0x" 202 LOG(ERROR) << "Failed to create RdpSession object, 0x"
206 << std::hex << result << std::dec << "."; 203 << std::hex << result << std::dec << ".";
207 return false; 204 return false;
208 } 205 }
209 206
210 // DaemonProcess::CreateDesktopSession() varifies that |client_dpi_| and 207 // DaemonProcess::CreateDesktopSession() verifies that the resolution is
211 // |client_size_| are positive. 208 // valid.
212 DCHECK(params.client_dpi_.x() >= 0 && params.client_dpi_.y() >= 0); 209 DCHECK(resolution.IsValid());
213 DCHECK(params.client_size_.width() >= 0 && params.client_size_.height() >= 0);
214 210
215 // Handle the default DPI. 211 // Get the screen dimensions assuming the default DPI.
216 SkIPoint client_dpi = params.client_dpi_; 212 SkISize host_size = resolution.GetLogicalDimensions();
217 if (!client_dpi.x())
218 client_dpi.setX(kDefaultDpiX);
219 if (!client_dpi.y())
220 client_dpi.setY(kDefaultDpiY);
221
222 // Make sure there will be no integer overflow while scaling the client
223 // resolution.
224 SkISize client_size = SkISize::Make(
225 std::min(params.client_size_.width(),
226 std::numeric_limits<int32_t>::max() / kDefaultDpiX),
227 std::min(params.client_size_.height(),
228 std::numeric_limits<int32_t>::max() / kDefaultDpiY));
229
230 // Scale the client resolution assiming RDP gives us the default 96 DPI.
231 SkISize host_size = SkISize::Make(
232 client_size.width() * kDefaultDpiX / client_dpi.x(),
233 client_size.height() * kDefaultDpiY / client_dpi.y());
234 213
235 // Make sure that the host resolution is within the limits supported by RDP. 214 // Make sure that the host resolution is within the limits supported by RDP.
236 host_size = SkISize::Make( 215 host_size = SkISize::Make(
237 std::min(kMaxRdpScreenWidth, 216 std::min(kMaxRdpScreenWidth,
238 std::max(kMinRdpScreenWidth, host_size.width())), 217 std::max(kMinRdpScreenWidth, host_size.width())),
239 std::min(kMaxRdpScreenHeight, 218 std::min(kMaxRdpScreenHeight,
240 std::max(kMinRdpScreenHeight, host_size.height()))); 219 std::max(kMinRdpScreenHeight, host_size.height())));
241 220
242 // Create an RDP session. 221 // Create an RDP session.
243 base::win::ScopedComPtr<IRdpDesktopSessionEventHandler> event_handler( 222 base::win::ScopedComPtr<IRdpDesktopSessionEventHandler> event_handler(
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 } 329 }
351 330
352 } // namespace 331 } // namespace
353 332
354 // static 333 // static
355 scoped_ptr<DesktopSession> DesktopSessionWin::CreateForConsole( 334 scoped_ptr<DesktopSession> DesktopSessionWin::CreateForConsole(
356 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, 335 scoped_refptr<AutoThreadTaskRunner> caller_task_runner,
357 scoped_refptr<AutoThreadTaskRunner> io_task_runner, 336 scoped_refptr<AutoThreadTaskRunner> io_task_runner,
358 DaemonProcess* daemon_process, 337 DaemonProcess* daemon_process,
359 int id, 338 int id,
360 const DesktopSessionParams& params) { 339 const ScreenResolution& resolution) {
361 scoped_ptr<ConsoleSession> session(new ConsoleSession( 340 scoped_ptr<ConsoleSession> session(new ConsoleSession(
362 caller_task_runner, io_task_runner, daemon_process, id, 341 caller_task_runner, io_task_runner, daemon_process, id,
363 HostService::GetInstance())); 342 HostService::GetInstance()));
364 343
365 return session.PassAs<DesktopSession>(); 344 return session.PassAs<DesktopSession>();
366 } 345 }
367 346
368 // static 347 // static
369 scoped_ptr<DesktopSession> DesktopSessionWin::CreateForVirtualTerminal( 348 scoped_ptr<DesktopSession> DesktopSessionWin::CreateForVirtualTerminal(
370 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, 349 scoped_refptr<AutoThreadTaskRunner> caller_task_runner,
371 scoped_refptr<AutoThreadTaskRunner> io_task_runner, 350 scoped_refptr<AutoThreadTaskRunner> io_task_runner,
372 DaemonProcess* daemon_process, 351 DaemonProcess* daemon_process,
373 int id, 352 int id,
374 const DesktopSessionParams& params) { 353 const ScreenResolution& resolution) {
375 scoped_ptr<RdpSession> session(new RdpSession( 354 scoped_ptr<RdpSession> session(new RdpSession(
376 caller_task_runner, io_task_runner, daemon_process, id, 355 caller_task_runner, io_task_runner, daemon_process, id,
377 HostService::GetInstance())); 356 HostService::GetInstance()));
378 if (!session->Initialize(params)) 357 if (!session->Initialize(resolution))
379 return scoped_ptr<DesktopSession>(); 358 return scoped_ptr<DesktopSession>();
380 359
381 return session.PassAs<DesktopSession>(); 360 return session.PassAs<DesktopSession>();
382 } 361 }
383 362
384 DesktopSessionWin::DesktopSessionWin( 363 DesktopSessionWin::DesktopSessionWin(
385 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, 364 scoped_refptr<AutoThreadTaskRunner> caller_task_runner,
386 scoped_refptr<AutoThreadTaskRunner> io_task_runner, 365 scoped_refptr<AutoThreadTaskRunner> io_task_runner,
387 DaemonProcess* daemon_process, 366 DaemonProcess* daemon_process,
388 int id, 367 int id,
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 } 512 }
534 513
535 void DesktopSessionWin::CrashDesktopProcess( 514 void DesktopSessionWin::CrashDesktopProcess(
536 const tracked_objects::Location& location) { 515 const tracked_objects::Location& location) {
537 DCHECK(caller_task_runner_->BelongsToCurrentThread()); 516 DCHECK(caller_task_runner_->BelongsToCurrentThread());
538 517
539 launcher_->Crash(location); 518 launcher_->Crash(location);
540 } 519 }
541 520
542 } // namespace remoting 521 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698