| 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/desktop_session_win.h" | 5 #include "remoting/host/desktop_session_win.h" |
| 6 | 6 |
| 7 #include <sddl.h> | 7 #include <sddl.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <memory> |
| 10 #include <utility> | 11 #include <utility> |
| 11 | 12 |
| 12 #include "base/base_switches.h" | 13 #include "base/base_switches.h" |
| 13 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 14 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 15 #include "base/guid.h" | 16 #include "base/guid.h" |
| 16 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/memory/ptr_util.h" |
| 17 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
| 18 #include "base/memory/scoped_ptr.h" | |
| 19 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
| 20 #include "base/strings/stringprintf.h" | 21 #include "base/strings/stringprintf.h" |
| 21 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
| 22 #include "base/threading/thread_checker.h" | 23 #include "base/threading/thread_checker.h" |
| 23 #include "base/timer/timer.h" | 24 #include "base/timer/timer.h" |
| 24 #include "base/win/scoped_bstr.h" | 25 #include "base/win/scoped_bstr.h" |
| 25 #include "base/win/scoped_comptr.h" | 26 #include "base/win/scoped_comptr.h" |
| 26 #include "base/win/scoped_handle.h" | 27 #include "base/win/scoped_handle.h" |
| 27 #include "base/win/windows_version.h" | 28 #include "base/win/windows_version.h" |
| 28 #include "ipc/ipc_message_macros.h" | 29 #include "ipc/ipc_message_macros.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 ~ConsoleSession() override; | 98 ~ConsoleSession() override; |
| 98 | 99 |
| 99 protected: | 100 protected: |
| 100 // DesktopSession overrides. | 101 // DesktopSession overrides. |
| 101 void SetScreenResolution(const ScreenResolution& resolution) override; | 102 void SetScreenResolution(const ScreenResolution& resolution) override; |
| 102 | 103 |
| 103 // DesktopSessionWin overrides. | 104 // DesktopSessionWin overrides. |
| 104 void InjectSas() override; | 105 void InjectSas() override; |
| 105 | 106 |
| 106 private: | 107 private: |
| 107 scoped_ptr<SasInjector> sas_injector_; | 108 std::unique_ptr<SasInjector> sas_injector_; |
| 108 | 109 |
| 109 DISALLOW_COPY_AND_ASSIGN(ConsoleSession); | 110 DISALLOW_COPY_AND_ASSIGN(ConsoleSession); |
| 110 }; | 111 }; |
| 111 | 112 |
| 112 // DesktopSession implementation which attaches to virtual RDP console. | 113 // DesktopSession implementation which attaches to virtual RDP console. |
| 113 // Receives IPC messages from the desktop process, running in the console | 114 // Receives IPC messages from the desktop process, running in the console |
| 114 // session, via |WorkerProcessIpcDelegate|, and monitors console session | 115 // session, via |WorkerProcessIpcDelegate|, and monitors console session |
| 115 // attach/detach events via |WtsConsoleObserer|. | 116 // attach/detach events via |WtsConsoleObserer|. |
| 116 class RdpSession : public DesktopSessionWin { | 117 class RdpSession : public DesktopSessionWin { |
| 117 public: | 118 public: |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 | 359 |
| 359 base::WeakPtr<RdpSession> desktop_session = desktop_session_; | 360 base::WeakPtr<RdpSession> desktop_session = desktop_session_; |
| 360 desktop_session_.reset(); | 361 desktop_session_.reset(); |
| 361 desktop_session->OnRdpClosed(); | 362 desktop_session->OnRdpClosed(); |
| 362 return S_OK; | 363 return S_OK; |
| 363 } | 364 } |
| 364 | 365 |
| 365 } // namespace | 366 } // namespace |
| 366 | 367 |
| 367 // static | 368 // static |
| 368 scoped_ptr<DesktopSession> DesktopSessionWin::CreateForConsole( | 369 std::unique_ptr<DesktopSession> DesktopSessionWin::CreateForConsole( |
| 369 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, | 370 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, |
| 370 scoped_refptr<AutoThreadTaskRunner> io_task_runner, | 371 scoped_refptr<AutoThreadTaskRunner> io_task_runner, |
| 371 DaemonProcess* daemon_process, | 372 DaemonProcess* daemon_process, |
| 372 int id, | 373 int id, |
| 373 const ScreenResolution& resolution) { | 374 const ScreenResolution& resolution) { |
| 374 return make_scoped_ptr(new ConsoleSession( | 375 return base::WrapUnique(new ConsoleSession(caller_task_runner, io_task_runner, |
| 375 caller_task_runner, io_task_runner, daemon_process, id, | 376 daemon_process, id, |
| 376 HostService::GetInstance())); | 377 HostService::GetInstance())); |
| 377 } | 378 } |
| 378 | 379 |
| 379 // static | 380 // static |
| 380 scoped_ptr<DesktopSession> DesktopSessionWin::CreateForVirtualTerminal( | 381 std::unique_ptr<DesktopSession> DesktopSessionWin::CreateForVirtualTerminal( |
| 381 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, | 382 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, |
| 382 scoped_refptr<AutoThreadTaskRunner> io_task_runner, | 383 scoped_refptr<AutoThreadTaskRunner> io_task_runner, |
| 383 DaemonProcess* daemon_process, | 384 DaemonProcess* daemon_process, |
| 384 int id, | 385 int id, |
| 385 const ScreenResolution& resolution) { | 386 const ScreenResolution& resolution) { |
| 386 scoped_ptr<RdpSession> session(new RdpSession( | 387 std::unique_ptr<RdpSession> session( |
| 387 caller_task_runner, io_task_runner, daemon_process, id, | 388 new RdpSession(caller_task_runner, io_task_runner, daemon_process, id, |
| 388 HostService::GetInstance())); | 389 HostService::GetInstance())); |
| 389 if (!session->Initialize(resolution)) | 390 if (!session->Initialize(resolution)) |
| 390 return nullptr; | 391 return nullptr; |
| 391 | 392 |
| 392 return std::move(session); | 393 return std::move(session); |
| 393 } | 394 } |
| 394 | 395 |
| 395 DesktopSessionWin::DesktopSessionWin( | 396 DesktopSessionWin::DesktopSessionWin( |
| 396 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, | 397 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, |
| 397 scoped_refptr<AutoThreadTaskRunner> io_task_runner, | 398 scoped_refptr<AutoThreadTaskRunner> io_task_runner, |
| 398 DaemonProcess* daemon_process, | 399 DaemonProcess* daemon_process, |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 result = GetInstalledBinaryPath(kHostBinaryName, &desktop_binary); | 524 result = GetInstalledBinaryPath(kHostBinaryName, &desktop_binary); |
| 524 } | 525 } |
| 525 | 526 |
| 526 if (!result) { | 527 if (!result) { |
| 527 TerminateSession(); | 528 TerminateSession(); |
| 528 return; | 529 return; |
| 529 } | 530 } |
| 530 | 531 |
| 531 session_attach_timer_.Stop(); | 532 session_attach_timer_.Stop(); |
| 532 | 533 |
| 533 scoped_ptr<base::CommandLine> target(new base::CommandLine(desktop_binary)); | 534 std::unique_ptr<base::CommandLine> target( |
| 535 new base::CommandLine(desktop_binary)); |
| 534 target->AppendSwitchASCII(kProcessTypeSwitchName, kProcessTypeDesktop); | 536 target->AppendSwitchASCII(kProcessTypeSwitchName, kProcessTypeDesktop); |
| 535 // Copy the command line switches enabling verbose logging. | 537 // Copy the command line switches enabling verbose logging. |
| 536 target->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(), | 538 target->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(), |
| 537 kCopiedSwitchNames, arraysize(kCopiedSwitchNames)); | 539 kCopiedSwitchNames, arraysize(kCopiedSwitchNames)); |
| 538 | 540 |
| 539 // Create a delegate capable of launching a process in a different session. | 541 // Create a delegate capable of launching a process in a different session. |
| 540 scoped_ptr<WtsSessionProcessDelegate> delegate(new WtsSessionProcessDelegate( | 542 std::unique_ptr<WtsSessionProcessDelegate> delegate( |
| 541 io_task_runner_, std::move(target), launch_elevated, | 543 new WtsSessionProcessDelegate( |
| 542 base::WideToUTF8(kDaemonIpcSecurityDescriptor))); | 544 io_task_runner_, std::move(target), launch_elevated, |
| 545 base::WideToUTF8(kDaemonIpcSecurityDescriptor))); |
| 543 if (!delegate->Initialize(session_id)) { | 546 if (!delegate->Initialize(session_id)) { |
| 544 TerminateSession(); | 547 TerminateSession(); |
| 545 return; | 548 return; |
| 546 } | 549 } |
| 547 | 550 |
| 548 // Create a launcher for the desktop process, using the per-session delegate. | 551 // Create a launcher for the desktop process, using the per-session delegate. |
| 549 launcher_.reset(new WorkerProcessLauncher(std::move(delegate), this)); | 552 launcher_.reset(new WorkerProcessLauncher(std::move(delegate), this)); |
| 550 } | 553 } |
| 551 | 554 |
| 552 void DesktopSessionWin::OnSessionDetached() { | 555 void DesktopSessionWin::OnSessionDetached() { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 exploded.hour, | 599 exploded.hour, |
| 597 exploded.minute, | 600 exploded.minute, |
| 598 exploded.second, | 601 exploded.second, |
| 599 exploded.millisecond, | 602 exploded.millisecond, |
| 600 passed.c_str()); | 603 passed.c_str()); |
| 601 | 604 |
| 602 last_timestamp_ = now; | 605 last_timestamp_ = now; |
| 603 } | 606 } |
| 604 | 607 |
| 605 } // namespace remoting | 608 } // namespace remoting |
| OLD | NEW |