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

Unified Diff: remoting/host/desktop_environment.cc

Issue 7714026: Fixed continue window bugs and added 60s auto-shutdown timeout. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporated comments froms sergeyu@ Created 9 years, 4 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
« remoting/host/desktop_environment.h ('K') | « remoting/host/desktop_environment.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/desktop_environment.cc
diff --git a/remoting/host/desktop_environment.cc b/remoting/host/desktop_environment.cc
index 14620b0b04024e9fb7fcf9b9d902430d26c57e95..c18640e3169584313b0a394bb072202e55b57fc6 100644
--- a/remoting/host/desktop_environment.cc
+++ b/remoting/host/desktop_environment.cc
@@ -15,7 +15,12 @@
#include "remoting/host/event_executor.h"
#include "remoting/host/local_input_monitor.h"
-static const int kContinueWindowTimeoutMs = 10 * 60 * 1000;
+// Milliseconds before the continue window is shown.
+static const int kContinueWindowShowTimeoutMs = 10 * 60 * 1000;
+
+// Milliseconds before the continue window is automatically dismissed and
+// the connection is closed.
+static const int kContinueWindowHideTimeoutMs = 60 * 1000;
namespace remoting {
@@ -32,7 +37,7 @@ namespace remoting {
// MessageLoopProxy.
class UIThreadProxy : public base::RefCountedThreadSafe<UIThreadProxy> {
public:
- UIThreadProxy(base::MessageLoopProxy* message_loop)
+ explicit UIThreadProxy(base::MessageLoopProxy* message_loop)
: message_loop_(message_loop) {
}
@@ -119,7 +124,7 @@ DesktopEnvironment::DesktopEnvironment(ChromotingHostContext* context,
continue_window_(continue_window),
local_input_monitor_(local_input_monitor),
is_monitoring_local_inputs_(false),
- continue_timer_started_(false),
+ continue_timer_state_(INACTIVE),
proxy_(new UIThreadProxy(context->ui_message_loop())) {
}
@@ -170,7 +175,10 @@ void DesktopEnvironment::ProcessOnLastDisconnect() {
}
void DesktopEnvironment::ProcessOnPause(bool pause) {
- StartContinueWindowTimer(!pause);
+ if (!pause) {
+ continue_timer_state_ = INACTIVE;
+ StartContinueWindowTimer(true);
+ }
}
void DesktopEnvironment::MonitorLocalInputs(bool enable) {
@@ -210,16 +218,18 @@ void DesktopEnvironment::ShowContinueWindow(bool show) {
void DesktopEnvironment::StartContinueWindowTimer(bool start) {
DCHECK(context_->ui_message_loop()->BelongsToCurrentThread());
- if (start && !continue_timer_started_) {
+ if (start && continue_timer_state_ == INACTIVE) {
continue_timer_target_time_ = base::Time::Now() +
- base::TimeDelta::FromMilliseconds(kContinueWindowTimeoutMs);
+ base::TimeDelta::FromMilliseconds(kContinueWindowShowTimeoutMs);
proxy_->CallOnUIThreadDelayed(
FROM_HERE, base::Bind(&DesktopEnvironment::ContinueWindowTimerFunc,
base::Unretained(this)),
- kContinueWindowTimeoutMs);
+ kContinueWindowShowTimeoutMs);
+ continue_timer_state_ = SHOW_DIALOG;
+ } else if (!start) {
+ continue_timer_state_ = INACTIVE;
}
- continue_timer_started_ = start;
}
void DesktopEnvironment::ContinueWindowTimerFunc() {
@@ -227,12 +237,25 @@ void DesktopEnvironment::ContinueWindowTimerFunc() {
// This function may be called prematurely if timer was stopped and
// then started again. In that case we just ignore this call.
- if (continue_timer_target_time_ > base::Time::Now())
+ if (continue_timer_state_ == INACTIVE ||
Sergey Ulanov 2011/08/24 18:38:37 The comment above this line may be confusing now.
Jamie 2011/08/25 00:16:39 Done.
+ continue_timer_target_time_ > base::Time::Now())
return;
- continue_timer_started_ = false;
- host_->PauseSession(true);
- ShowContinueWindow(true);
+ if (continue_timer_state_ == SHOW_DIALOG) {
+ host_->PauseSession(true);
+ ShowContinueWindow(true);
+ continue_timer_target_time_ = base::Time::Now() +
+ base::TimeDelta::FromMilliseconds(kContinueWindowHideTimeoutMs);
+ proxy_->CallOnUIThreadDelayed(
+ FROM_HERE, base::Bind(&DesktopEnvironment::ContinueWindowTimerFunc,
+ base::Unretained(this)),
+ kContinueWindowHideTimeoutMs);
+ continue_timer_state_ = SHUTDOWN_HOST;
+ } else {
+ continue_timer_state_ = INACTIVE;
+ ShowContinueWindow(false);
+ host_->Shutdown(NULL);
+ }
}
« remoting/host/desktop_environment.h ('K') | « remoting/host/desktop_environment.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698