Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 5 #include "remoting/host/continue_window.h" | |
| 6 | |
| 7 #include "base/location.h" | |
| 8 #include "remoting/host/client_session_control.h" | |
| 9 | |
| 10 // Minutes before the local user should confirm that the session should go on. | |
| 11 const int kSessionExpirationTimeoutMinutes = 10; | |
|
Sergey Ulanov
2013/04/04 21:04:26
move these constants to anonymous namespace
alexeypa (please no reviews)
2013/04/06 18:07:56
Constants have local scope by default. There is no
| |
| 12 | |
| 13 // Minutes before the session will be disconnected (from the moment the Continue | |
| 14 // window has been shown). | |
| 15 const int kSessionDisconnectTimeoutMinutes = 1; | |
| 16 | |
| 17 namespace remoting { | |
| 18 | |
| 19 ContinueWindow::~ContinueWindow() { | |
| 20 DCHECK(CalledOnValidThread()); | |
|
Sergey Ulanov
2013/04/04 21:04:26
NonThreadSafe destructor has the same DCHECK, no n
alexeypa (please no reviews)
2013/04/06 18:07:56
Done.
| |
| 21 } | |
| 22 | |
| 23 void ContinueWindow::Start( | |
| 24 const base::WeakPtr<ClientSessionControl>& client_session_control) { | |
| 25 DCHECK(CalledOnValidThread()); | |
| 26 DCHECK(!client_session_control_); | |
| 27 DCHECK(client_session_control); | |
| 28 | |
| 29 client_session_control_ = client_session_control; | |
| 30 | |
| 31 session_expired_timer_.Start( | |
| 32 FROM_HERE, base::TimeDelta::FromMinutes(kSessionExpirationTimeoutMinutes), | |
| 33 this, &ContinueWindow::OnSessionExpired); | |
| 34 } | |
| 35 | |
| 36 void ContinueWindow::ContinueSession() { | |
| 37 DCHECK(CalledOnValidThread()); | |
| 38 | |
| 39 disconnect_timer_.Stop(); | |
| 40 | |
| 41 if (!client_session_control_) | |
| 42 return; | |
| 43 | |
| 44 // Hide the Continue window and resume the session. | |
| 45 HideUi(); | |
| 46 client_session_control_->SetDisableInputs(false); | |
| 47 | |
| 48 session_expired_timer_.Start( | |
| 49 FROM_HERE, base::TimeDelta::FromMinutes(kSessionExpirationTimeoutMinutes), | |
| 50 this, &ContinueWindow::OnSessionExpired); | |
| 51 } | |
| 52 | |
| 53 void ContinueWindow::DisconnectSession() { | |
|
Sergey Ulanov
2013/04/04 21:04:26
Maybe OnDisconnectTimer()?
alexeypa (please no reviews)
2013/04/06 18:07:56
The primary purpose if this API is to be called by
| |
| 54 DCHECK(CalledOnValidThread()); | |
| 55 | |
| 56 disconnect_timer_.Stop(); | |
| 57 if (client_session_control_) | |
| 58 client_session_control_->DisconnectSession(); | |
| 59 } | |
| 60 | |
| 61 ContinueWindow::ContinueWindow() { | |
| 62 disconnect_timer_.Stop(); | |
| 63 session_expired_timer_.Stop(); | |
| 64 } | |
| 65 | |
| 66 void ContinueWindow::OnSessionExpired() { | |
| 67 DCHECK(CalledOnValidThread()); | |
| 68 | |
| 69 if (!client_session_control_) | |
| 70 return; | |
| 71 | |
| 72 // Stop the remote input while the Continue window is shown. | |
| 73 client_session_control_->SetDisableInputs(true); | |
| 74 | |
| 75 // Show the Continue window and wait for the local user input. | |
| 76 ShowUi(); | |
| 77 disconnect_timer_.Start( | |
| 78 FROM_HERE, base::TimeDelta::FromMinutes(kSessionDisconnectTimeoutMinutes), | |
| 79 this, &ContinueWindow::DisconnectSession); | |
| 80 } | |
| 81 | |
| 82 } // namespace remoting | |
| OLD | NEW |