diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-05 17:47:14 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-05 17:47:14 +0000 |
commit | 56f38f4aee4a6fb282d20bd6f0f506661e00d81f (patch) | |
tree | 2675d58f56f137b0ec18481b39a0134eb0ad2d91 /views/mouse_watcher.cc | |
parent | 1ead2c0901c083ceb667798328dfe8cdca700e4c (diff) | |
download | chromium_src-56f38f4aee4a6fb282d20bd6f0f506661e00d81f.zip chromium_src-56f38f4aee4a6fb282d20bd6f0f506661e00d81f.tar.gz chromium_src-56f38f4aee4a6fb282d20bd6f0f506661e00d81f.tar.bz2 |
views: Migrate more NewRunnableMethod instances to base::Bind()
R=sky@chromium.org,ajwong@chromium.org
Review URL: http://codereview.chromium.org/8133012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104128 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/mouse_watcher.cc')
-rw-r--r-- | views/mouse_watcher.cc | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/views/mouse_watcher.cc b/views/mouse_watcher.cc index 5daab25..3166f90 100644 --- a/views/mouse_watcher.cc +++ b/views/mouse_watcher.cc @@ -4,7 +4,9 @@ #include "views/mouse_watcher.h" +#include "base/bind.h" #include "base/compiler_specific.h" +#include "base/memory/weak_ptr.h" #include "base/message_loop.h" #include "base/task.h" #include "ui/gfx/screen.h" @@ -140,18 +142,18 @@ class MouseWatcher::Observer : public MessageLoopForUI::Observer { if (!in_view || (check_window && !IsMouseOverWindow())) { // Mouse moved outside the view's zone, start a timer to notify the // listener. - if (notify_listener_factory_.empty()) { + if (!notify_listener_factory_.HasWeakPtrs()) { MessageLoop::current()->PostDelayedTask( FROM_HERE, - notify_listener_factory_.NewRunnableMethod( - &Observer::NotifyListener), + base::Bind(&Observer::NotifyListener, + notify_listener_factory_.GetWeakPtr()), !in_view ? kNotifyListenerTimeMs : mouse_watcher_->notify_on_exit_time_ms_); } } else { // Mouse moved quickly out of the view and then into it again, so cancel // the timer. - notify_listener_factory_.RevokeAll(); + notify_listener_factory_.InvalidateWeakPtrs(); } } @@ -164,7 +166,7 @@ class MouseWatcher::Observer : public MessageLoopForUI::Observer { MouseWatcher* mouse_watcher_; // A factory that is used to construct a delayed callback to the listener. - ScopedRunnableMethodFactory<Observer> notify_listener_factory_; + base::WeakPtrFactory<Observer> notify_listener_factory_; DISALLOW_COPY_AND_ASSIGN(Observer); }; |