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

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: Deactivate 60s timer if the user opts to continue. 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..66a69f8cf2a1a519a67291ba984ccb05884ffb16 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 * 1000;
Sergey Ulanov 2011/08/24 01:56:45 Revert this change
Jamie 2011/08/24 17:42:03 Done.
+
+// Milliseconds before the continue window is automatically dismissed and
+// the connection is closed.
+static const int kContinueWindowHideTimeoutMs = 5 * 1000;
Sergey Ulanov 2011/08/24 01:56:45 Should be 60 * 1000 instead of 5 seconds
Jamie 2011/08/24 17:42:03 Done.
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,16 @@ 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_started_ = start;
+ continue_timer_state_ = start ? SHOW_DIALOG : INACTIVE;
Sergey Ulanov 2011/08/24 01:56:45 What if this function is called with when continue
Jamie 2011/08/24 17:42:03 Done.
}
void DesktopEnvironment::ContinueWindowTimerFunc() {
@@ -227,12 +235,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 ||
+ 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_ = HIDE_DIALOG;
+ } else {
+ continue_timer_state_ = INACTIVE;
+ ShowContinueWindow(false);
+ host_->Shutdown(NULL);
Sergey Ulanov 2011/08/24 01:56:45 I don't like the idea of calling Shutdown() from h
+ }
}
« 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