summaryrefslogtreecommitdiffstats
path: root/remoting/host/it2me_host_user_interface.cc
diff options
context:
space:
mode:
authorwez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-30 21:09:33 +0000
committerwez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-30 21:09:33 +0000
commitb6791a77ae5c2eec843b8c9b4ad3d9fa9c11fda7 (patch)
tree608a649c16b2af968a0d250ba1c30b118e6bb3ba /remoting/host/it2me_host_user_interface.cc
parent910875d9a35955b0e51d150c40879eb892250155 (diff)
downloadchromium_src-b6791a77ae5c2eec843b8c9b4ad3d9fa9c11fda7.zip
chromium_src-b6791a77ae5c2eec843b8c9b4ad3d9fa9c11fda7.tar.gz
chromium_src-b6791a77ae5c2eec843b8c9b4ad3d9fa9c11fda7.tar.bz2
Revert 139623 - Replace ScopedThreadProxy with MessageLoopProxy & WeakPtrs.
This affects the following classes: * ChromotingClient * ChromotingInstance * HostUserInterface * It2MeHostUserInterface The MessageLoopProxy/WeakPtr combination requires that the WeakPtr is created on the thread referred to by the proxy; code in which that is hard to arrange usually has subtle race-conditions. TEST=Existing unit-tests, and manual testing. Review URL: https://chromiumcodereview.appspot.com/10454040 TBR=wez@chromium.org Review URL: https://chromiumcodereview.appspot.com/10446088 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139633 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host/it2me_host_user_interface.cc')
-rw-r--r--remoting/host/it2me_host_user_interface.cc41
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();
}
}