diff options
Diffstat (limited to 'remoting/host/it2me_host_user_interface.cc')
| -rw-r--r-- | remoting/host/it2me_host_user_interface.cc | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/remoting/host/it2me_host_user_interface.cc b/remoting/host/it2me_host_user_interface.cc index 1b2f392..c39f6d3 100644 --- a/remoting/host/it2me_host_user_interface.cc +++ b/remoting/host/it2me_host_user_interface.cc @@ -24,15 +24,29 @@ static const int kContinueWindowHideTimeoutMs = 60 * 1000; namespace remoting { +class It2MeHostUserInterface::TimerTask { + public: + TimerTask(base::MessageLoopProxy* message_loop, + const base::Closure& task, + int delay_ms) + : thread_proxy_(message_loop) { + thread_proxy_.PostDelayedTask(FROM_HERE, task, delay_ms); + } + + private: + ScopedThreadProxy thread_proxy_; +}; + + It2MeHostUserInterface::It2MeHostUserInterface(ChromotingHostContext* context) - : HostUserInterface(context), - ALLOW_THIS_IN_INITIALIZER_LIST(timer_weak_factory_(this)) { + : HostUserInterface(context) { } It2MeHostUserInterface::~It2MeHostUserInterface() { DCHECK(ui_message_loop()->BelongsToCurrentThread()); ShowContinueWindow(false); + StartContinueWindowTimer(false); } void It2MeHostUserInterface::Start(ChromotingHost* host, @@ -89,6 +103,7 @@ void It2MeHostUserInterface::ContinueSession(bool continue_session) { if (continue_session) { get_host()->PauseSession(false); + timer_task_.reset(); StartContinueWindowTimer(true); } else { DisconnectSession(); @@ -101,13 +116,11 @@ void It2MeHostUserInterface::OnContinueWindowTimer() { get_host()->PauseSession(true); ShowContinueWindow(true); - // Cancel any pending timer and post one to hide the continue window. - timer_weak_factory_.InvalidateWeakPtrs(); - ui_message_loop()->PostDelayedTask( - FROM_HERE, + timer_task_.reset(new TimerTask( + ui_message_loop(), base::Bind(&It2MeHostUserInterface::OnShutdownHostTimer, - timer_weak_factory_.GetWeakPtr()), - kContinueWindowHideTimeoutMs); + base::Unretained(this)), + kContinueWindowHideTimeoutMs)); } void It2MeHostUserInterface::OnShutdownHostTimer() { @@ -131,14 +144,14 @@ void It2MeHostUserInterface::ShowContinueWindow(bool show) { void It2MeHostUserInterface::StartContinueWindowTimer(bool start) { DCHECK(ui_message_loop()->BelongsToCurrentThread()); - // Abandon previous timer events by invalidating their weak pointer to us. - timer_weak_factory_.InvalidateWeakPtrs(); if (start) { - ui_message_loop()->PostDelayedTask( - FROM_HERE, + timer_task_.reset(new TimerTask( + ui_message_loop(), base::Bind(&It2MeHostUserInterface::OnContinueWindowTimer, - timer_weak_factory_.GetWeakPtr()), - kContinueWindowShowTimeoutMs); + base::Unretained(this)), + kContinueWindowShowTimeoutMs)); + } else { + timer_task_.reset(); } } |
