continue_window.cc 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // Copyright 2013 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "remoting/host/continue_window.h"
  5. #include "base/location.h"
  6. #include "base/time/time.h"
  7. #include "remoting/host/client_session_control.h"
  8. // Minutes before the local user should confirm that the session should go on.
  9. constexpr base::TimeDelta kSessionExpirationTimeout = base::Minutes(30);
  10. // Minutes before the session will be disconnected (from the moment the Continue
  11. // window has been shown).
  12. constexpr base::TimeDelta kSessionDisconnectTimeout = base::Minutes(5);
  13. namespace remoting {
  14. ContinueWindow::ContinueWindow() = default;
  15. ContinueWindow::~ContinueWindow() = default;
  16. void ContinueWindow::Start(
  17. const base::WeakPtr<ClientSessionControl>& client_session_control) {
  18. DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
  19. DCHECK(!client_session_control_);
  20. DCHECK(client_session_control);
  21. client_session_control_ = client_session_control;
  22. session_expired_timer_.Start(FROM_HERE, kSessionExpirationTimeout, this,
  23. &ContinueWindow::OnSessionExpired);
  24. }
  25. void ContinueWindow::ContinueSession() {
  26. DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
  27. disconnect_timer_.Stop();
  28. if (!client_session_control_)
  29. return;
  30. // Hide the Continue window and resume the session.
  31. HideUi();
  32. client_session_control_->SetDisableInputs(false);
  33. session_expired_timer_.Start(FROM_HERE, kSessionExpirationTimeout, this,
  34. &ContinueWindow::OnSessionExpired);
  35. }
  36. void ContinueWindow::DisconnectSession() {
  37. DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
  38. disconnect_timer_.Stop();
  39. if (client_session_control_)
  40. client_session_control_->DisconnectSession(protocol::MAX_SESSION_LENGTH);
  41. }
  42. void ContinueWindow::OnSessionExpired() {
  43. DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
  44. if (!client_session_control_)
  45. return;
  46. // Stop the remote input while the Continue window is shown.
  47. client_session_control_->SetDisableInputs(true);
  48. // Show the Continue window and wait for the local user input.
  49. ShowUi();
  50. disconnect_timer_.Start(FROM_HERE, kSessionDisconnectTimeout, this,
  51. &ContinueWindow::DisconnectSession);
  52. }
  53. } // namespace remoting