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

Unified Diff: remoting/host/continue_window.cc

Issue 13461029: The continue window is owned by the desktop environment now. (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 side-by-side diff with in-line comments
Download patch
Index: remoting/host/continue_window.cc
diff --git a/remoting/host/continue_window.cc b/remoting/host/continue_window.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a9cbf7c65ea8c687062fba597e5af4d5cdcf3aa6
--- /dev/null
+++ b/remoting/host/continue_window.cc
@@ -0,0 +1,82 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "remoting/host/continue_window.h"
+
+#include "base/location.h"
+#include "remoting/host/client_session_control.h"
+
+// Minutes before the local user should confirm that the session should go on.
+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
+
+// Minutes before the session will be disconnected (from the moment the Continue
+// window has been shown).
+const int kSessionDisconnectTimeoutMinutes = 1;
+
+namespace remoting {
+
+ContinueWindow::~ContinueWindow() {
+ 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.
+}
+
+void ContinueWindow::Start(
+ const base::WeakPtr<ClientSessionControl>& client_session_control) {
+ DCHECK(CalledOnValidThread());
+ DCHECK(!client_session_control_);
+ DCHECK(client_session_control);
+
+ client_session_control_ = client_session_control;
+
+ session_expired_timer_.Start(
+ FROM_HERE, base::TimeDelta::FromMinutes(kSessionExpirationTimeoutMinutes),
+ this, &ContinueWindow::OnSessionExpired);
+}
+
+void ContinueWindow::ContinueSession() {
+ DCHECK(CalledOnValidThread());
+
+ disconnect_timer_.Stop();
+
+ if (!client_session_control_)
+ return;
+
+ // Hide the Continue window and resume the session.
+ HideUi();
+ client_session_control_->SetDisableInputs(false);
+
+ session_expired_timer_.Start(
+ FROM_HERE, base::TimeDelta::FromMinutes(kSessionExpirationTimeoutMinutes),
+ this, &ContinueWindow::OnSessionExpired);
+}
+
+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
+ DCHECK(CalledOnValidThread());
+
+ disconnect_timer_.Stop();
+ if (client_session_control_)
+ client_session_control_->DisconnectSession();
+}
+
+ContinueWindow::ContinueWindow() {
+ disconnect_timer_.Stop();
+ session_expired_timer_.Stop();
+}
+
+void ContinueWindow::OnSessionExpired() {
+ DCHECK(CalledOnValidThread());
+
+ if (!client_session_control_)
+ return;
+
+ // Stop the remote input while the Continue window is shown.
+ client_session_control_->SetDisableInputs(true);
+
+ // Show the Continue window and wait for the local user input.
+ ShowUi();
+ disconnect_timer_.Start(
+ FROM_HERE, base::TimeDelta::FromMinutes(kSessionDisconnectTimeoutMinutes),
+ this, &ContinueWindow::DisconnectSession);
+}
+
+} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698