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

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

Issue 10026013: Update use of TimeDelta in chrome/browser/*, ui/views/*, and other places. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase onto master. Created 8 years, 7 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
« no previous file with comments | « ui/views/mouse_watcher.h ('k') | ui/views/widget/aero_tooltip_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 bool contained = host()->Contains( 88 bool contained = host()->Contains(
89 gfx::Screen::GetCursorScreenPoint(), event_type); 89 gfx::Screen::GetCursorScreenPoint(), event_type);
90 if (!contained) { 90 if (!contained) {
91 // Mouse moved outside the host's zone, start a timer to notify the 91 // Mouse moved outside the host's zone, start a timer to notify the
92 // listener. 92 // listener.
93 if (!notify_listener_factory_.HasWeakPtrs()) { 93 if (!notify_listener_factory_.HasWeakPtrs()) {
94 MessageLoop::current()->PostDelayedTask( 94 MessageLoop::current()->PostDelayedTask(
95 FROM_HERE, 95 FROM_HERE,
96 base::Bind(&Observer::NotifyListener, 96 base::Bind(&Observer::NotifyListener,
97 notify_listener_factory_.GetWeakPtr()), 97 notify_listener_factory_.GetWeakPtr()),
98 event_type == 98 event_type == MouseWatcherHost::MOUSE_MOVE ?
99 MouseWatcherHost::MOUSE_MOVE ? kNotifyListenerTimeMs : 99 base::TimeDelta::FromMilliseconds(kNotifyListenerTimeMs) :
100 mouse_watcher_->notify_on_exit_time_ms_); 100 mouse_watcher_->notify_on_exit_time_);
101 } 101 }
102 } else { 102 } else {
103 // Mouse moved quickly out of the host and then into it again, so cancel 103 // Mouse moved quickly out of the host and then into it again, so cancel
104 // the timer. 104 // the timer.
105 notify_listener_factory_.InvalidateWeakPtrs(); 105 notify_listener_factory_.InvalidateWeakPtrs();
106 } 106 }
107 } 107 }
108 108
109 void NotifyListener() { 109 void NotifyListener() {
110 mouse_watcher_->NotifyListener(); 110 mouse_watcher_->NotifyListener();
(...skipping 12 matching lines...) Expand all
123 MouseWatcherListener::~MouseWatcherListener() { 123 MouseWatcherListener::~MouseWatcherListener() {
124 } 124 }
125 125
126 MouseWatcherHost::~MouseWatcherHost() { 126 MouseWatcherHost::~MouseWatcherHost() {
127 } 127 }
128 128
129 MouseWatcher::MouseWatcher(MouseWatcherHost* host, 129 MouseWatcher::MouseWatcher(MouseWatcherHost* host,
130 MouseWatcherListener* listener) 130 MouseWatcherListener* listener)
131 : host_(host), 131 : host_(host),
132 listener_(listener), 132 listener_(listener),
133 notify_on_exit_time_ms_(kNotifyListenerTimeMs) { 133 notify_on_exit_time_(base::TimeDelta::FromMilliseconds(
134 kNotifyListenerTimeMs)) {
134 } 135 }
135 136
136 MouseWatcher::~MouseWatcher() { 137 MouseWatcher::~MouseWatcher() {
137 } 138 }
138 139
139 void MouseWatcher::Start() { 140 void MouseWatcher::Start() {
140 if (!is_observing()) 141 if (!is_observing())
141 observer_.reset(new Observer(this)); 142 observer_.reset(new Observer(this));
142 } 143 }
143 144
144 void MouseWatcher::Stop() { 145 void MouseWatcher::Stop() {
145 observer_.reset(NULL); 146 observer_.reset(NULL);
146 } 147 }
147 148
148 void MouseWatcher::NotifyListener() { 149 void MouseWatcher::NotifyListener() {
149 observer_.reset(NULL); 150 observer_.reset(NULL);
150 listener_->MouseMovedOutOfHost(); 151 listener_->MouseMovedOutOfHost();
151 } 152 }
152 153
153 } // namespace views 154 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/mouse_watcher.h ('k') | ui/views/widget/aero_tooltip_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698