| 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 <limits> | 8 #include <limits> |
| 8 #include <sddl.h> | |
| 9 | 9 |
| 10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/guid.h" | 13 #include "base/guid.h" |
| 14 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 17 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 19 #include "base/threading/thread_checker.h" | 20 #include "base/threading/thread_checker.h" |
| 20 #include "base/timer/timer.h" | 21 #include "base/timer/timer.h" |
| 21 #include "base/win/scoped_bstr.h" | 22 #include "base/win/scoped_bstr.h" |
| 22 #include "base/win/scoped_comptr.h" | 23 #include "base/win/scoped_comptr.h" |
| 23 #include "base/win/scoped_handle.h" | 24 #include "base/win/scoped_handle.h" |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 | 453 |
| 453 void DesktopSessionWin::TerminateSession() { | 454 void DesktopSessionWin::TerminateSession() { |
| 454 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 455 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 455 | 456 |
| 456 StopMonitoring(); | 457 StopMonitoring(); |
| 457 | 458 |
| 458 // This call will delete |this| so it should be at the very end of the method. | 459 // This call will delete |this| so it should be at the very end of the method. |
| 459 daemon_process()->CloseDesktopSession(id()); | 460 daemon_process()->CloseDesktopSession(id()); |
| 460 } | 461 } |
| 461 | 462 |
| 462 void DesktopSessionWin::OnChannelConnected(int32 peer_pid) { | 463 void DesktopSessionWin::OnChannelConnected(int32_t peer_pid) { |
| 463 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 464 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 464 | 465 |
| 465 ReportElapsedTime("channel connected"); | 466 ReportElapsedTime("channel connected"); |
| 466 | 467 |
| 467 // Obtain the handle of the desktop process. It will be passed to the network | 468 // Obtain the handle of the desktop process. It will be passed to the network |
| 468 // process to use to duplicate handles of shared memory objects from | 469 // process to use to duplicate handles of shared memory objects from |
| 469 // the desktop process. | 470 // the desktop process. |
| 470 desktop_process_.Set(OpenProcess(PROCESS_DUP_HANDLE, false, peer_pid)); | 471 desktop_process_.Set(OpenProcess(PROCESS_DUP_HANDLE, false, peer_pid)); |
| 471 if (!desktop_process_.IsValid()) { | 472 if (!desktop_process_.IsValid()) { |
| 472 CrashDesktopProcess(FROM_HERE); | 473 CrashDesktopProcess(FROM_HERE); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 495 | 496 |
| 496 return handled; | 497 return handled; |
| 497 } | 498 } |
| 498 | 499 |
| 499 void DesktopSessionWin::OnPermanentError(int exit_code) { | 500 void DesktopSessionWin::OnPermanentError(int exit_code) { |
| 500 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 501 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 501 | 502 |
| 502 TerminateSession(); | 503 TerminateSession(); |
| 503 } | 504 } |
| 504 | 505 |
| 505 void DesktopSessionWin::OnSessionAttached(uint32 session_id) { | 506 void DesktopSessionWin::OnSessionAttached(uint32_t session_id) { |
| 506 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 507 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
| 507 DCHECK(!launcher_); | 508 DCHECK(!launcher_); |
| 508 DCHECK(monitoring_notifications_); | 509 DCHECK(monitoring_notifications_); |
| 509 | 510 |
| 510 ReportElapsedTime("attached"); | 511 ReportElapsedTime("attached"); |
| 511 | 512 |
| 512 // Launch elevated on Win8 to be able to inject Alt+Tab. | 513 // Launch elevated on Win8 to be able to inject Alt+Tab. |
| 513 bool launch_elevated = base::win::GetVersion() >= base::win::VERSION_WIN8; | 514 bool launch_elevated = base::win::GetVersion() >= base::win::VERSION_WIN8; |
| 514 | 515 |
| 515 // Get the name of the executable to run. |kDesktopBinaryName| specifies | 516 // Get the name of the executable to run. |kDesktopBinaryName| specifies |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 exploded.hour, | 599 exploded.hour, |
| 599 exploded.minute, | 600 exploded.minute, |
| 600 exploded.second, | 601 exploded.second, |
| 601 exploded.millisecond, | 602 exploded.millisecond, |
| 602 passed.c_str()); | 603 passed.c_str()); |
| 603 | 604 |
| 604 last_timestamp_ = now; | 605 last_timestamp_ = now; |
| 605 } | 606 } |
| 606 | 607 |
| 607 } // namespace remoting | 608 } // namespace remoting |
| OLD | NEW |