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

Side by Side Diff: ui/views/mouse_watcher.cc

Issue 2049493004: Remove use of deprecated MessageLoop methods in ui. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/mouse_watcher.h" 5 #include "ui/views/mouse_watcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/event_types.h" 9 #include "base/event_types.h"
10 #include "base/location.h"
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
12 #include "base/message_loop/message_loop.h" 13 #include "base/single_thread_task_runner.h"
14 #include "base/threading/thread_task_runner_handle.h"
13 #include "ui/events/event.h" 15 #include "ui/events/event.h"
14 #include "ui/events/event_constants.h" 16 #include "ui/events/event_constants.h"
15 #include "ui/events/event_handler.h" 17 #include "ui/events/event_handler.h"
16 #include "ui/events/event_utils.h" 18 #include "ui/events/event_utils.h"
17 #include "ui/views/event_monitor.h" 19 #include "ui/views/event_monitor.h"
18 20
19 namespace views { 21 namespace views {
20 22
21 // Amount of time between when the mouse moves outside the Host's zone and when 23 // Amount of time between when the mouse moves outside the Host's zone and when
22 // the listener is notified. 24 // the listener is notified.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // Called when a mouse event we're interested is seen. 56 // Called when a mouse event we're interested is seen.
55 void HandleMouseEvent(MouseWatcherHost::MouseEventType event_type) { 57 void HandleMouseEvent(MouseWatcherHost::MouseEventType event_type) {
56 // It's safe to use last_mouse_location() here as this function is invoked 58 // It's safe to use last_mouse_location() here as this function is invoked
57 // during event dispatching. 59 // during event dispatching.
58 if (!host()->Contains(EventMonitor::GetLastMouseLocation(), event_type)) { 60 if (!host()->Contains(EventMonitor::GetLastMouseLocation(), event_type)) {
59 if (event_type == MouseWatcherHost::MOUSE_PRESS) { 61 if (event_type == MouseWatcherHost::MOUSE_PRESS) {
60 NotifyListener(); 62 NotifyListener();
61 } else if (!notify_listener_factory_.HasWeakPtrs()) { 63 } else if (!notify_listener_factory_.HasWeakPtrs()) {
62 // Mouse moved outside the host's zone, start a timer to notify the 64 // Mouse moved outside the host's zone, start a timer to notify the
63 // listener. 65 // listener.
64 base::MessageLoop::current()->PostDelayedTask( 66 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
65 FROM_HERE, 67 FROM_HERE, base::Bind(&Observer::NotifyListener,
66 base::Bind(&Observer::NotifyListener, 68 notify_listener_factory_.GetWeakPtr()),
67 notify_listener_factory_.GetWeakPtr()),
68 event_type == MouseWatcherHost::MOUSE_MOVE 69 event_type == MouseWatcherHost::MOUSE_MOVE
69 ? base::TimeDelta::FromMilliseconds(kNotifyListenerTimeMs) 70 ? base::TimeDelta::FromMilliseconds(kNotifyListenerTimeMs)
70 : mouse_watcher_->notify_on_exit_time_); 71 : mouse_watcher_->notify_on_exit_time_);
71 } 72 }
72 } else { 73 } else {
73 // Mouse moved quickly out of the host and then into it again, so cancel 74 // Mouse moved quickly out of the host and then into it again, so cancel
74 // the timer. 75 // the timer.
75 notify_listener_factory_.InvalidateWeakPtrs(); 76 notify_listener_factory_.InvalidateWeakPtrs();
76 } 77 }
77 } 78 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 void MouseWatcher::Stop() { 117 void MouseWatcher::Stop() {
117 observer_.reset(NULL); 118 observer_.reset(NULL);
118 } 119 }
119 120
120 void MouseWatcher::NotifyListener() { 121 void MouseWatcher::NotifyListener() {
121 observer_.reset(NULL); 122 observer_.reset(NULL);
122 listener_->MouseMovedOutOfHost(); 123 listener_->MouseMovedOutOfHost();
123 } 124 }
124 125
125 } // namespace views 126 } // namespace views
OLDNEW
« no previous file with comments | « ui/shell_dialogs/select_file_dialog.cc ('k') | ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698