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

Side by Side Diff: base/timer.h

Issue 27234: DelayTimer destruction test (Closed)
Patch Set: ... Created 11 years, 9 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 | « no previous file | base/timer_unittest.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 // OneShotTimer and RepeatingTimer provide a simple timer API. As the names 5 // OneShotTimer and RepeatingTimer provide a simple timer API. As the names
6 // suggest, OneShotTimer calls you back once after a time delay expires. 6 // suggest, OneShotTimer calls you back once after a time delay expires.
7 // RepeatingTimer on the other hand calls you back periodically with the 7 // RepeatingTimer on the other hand calls you back periodically with the
8 // prescribed time interval. 8 // prescribed time interval.
9 // 9 //
10 // OneShotTimer and RepeatingTimer both cancel the timer when they go out of 10 // OneShotTimer and RepeatingTimer both cancel the timer when they go out of
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 class RepeatingTimer : public BaseTimer<Receiver, true> {}; 199 class RepeatingTimer : public BaseTimer<Receiver, true> {};
200 200
201 //----------------------------------------------------------------------------- 201 //-----------------------------------------------------------------------------
202 // A Delay timer is like The Button from Lost. Once started, you have to keep 202 // A Delay timer is like The Button from Lost. Once started, you have to keep
203 // calling Reset otherwise it will call the given method in the MessageLoop 203 // calling Reset otherwise it will call the given method in the MessageLoop
204 // thread. 204 // thread.
205 // 205 //
206 // Once created, it is inactive until Reset is called. Once |delay| seconds have 206 // Once created, it is inactive until Reset is called. Once |delay| seconds have
207 // passed since the last call to Reset, the callback is made. Once the callback 207 // passed since the last call to Reset, the callback is made. Once the callback
208 // has been made, it's inactive until Reset is called again. 208 // has been made, it's inactive until Reset is called again.
209 //
210 // If destroyed, the timeout is canceled and will not occur even if already
211 // inflight.
209 template <class Receiver> 212 template <class Receiver>
210 class DelayTimer { 213 class DelayTimer {
211 public: 214 public:
212 typedef void (Receiver::*ReceiverMethod)(); 215 typedef void (Receiver::*ReceiverMethod)();
213 216
214 DelayTimer(TimeDelta delay, Receiver* receiver, ReceiverMethod method) 217 DelayTimer(TimeDelta delay, Receiver* receiver, ReceiverMethod method)
215 : receiver_(receiver), 218 : receiver_(receiver),
216 method_(method), 219 method_(method),
217 delay_(delay) { 220 delay_(delay) {
218 } 221 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 const ReceiverMethod method_; 256 const ReceiverMethod method_;
254 const TimeDelta delay_; 257 const TimeDelta delay_;
255 258
256 OneShotTimer<DelayTimer<Receiver> > timer_; 259 OneShotTimer<DelayTimer<Receiver> > timer_;
257 Time trigger_time_; 260 Time trigger_time_;
258 }; 261 };
259 262
260 } // namespace base 263 } // namespace base
261 264
262 #endif // BASE_TIMER_H_ 265 #endif // BASE_TIMER_H_
OLDNEW
« no previous file with comments | « no previous file | base/timer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698