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

Side by Side Diff: base/timer/timer.cc

Issue 2850093003: Simplify base::Timer implementation
Patch Set: . Created 3 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 | « base/timer/timer.h ('k') | no next file » | 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 "base/timer/timer.h" 5 #include "base/timer/timer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // The task remains in the MessageLoop queue, but nothing will happen when it 56 // The task remains in the MessageLoop queue, but nothing will happen when it
57 // runs. 57 // runs.
58 void Abandon() { 58 void Abandon() {
59 timer_ = NULL; 59 timer_ = NULL;
60 } 60 }
61 61
62 private: 62 private:
63 Timer* timer_; 63 Timer* timer_;
64 }; 64 };
65 65
66 Timer::Timer(bool retain_user_task, bool is_repeating)
67 : Timer(retain_user_task, is_repeating, nullptr) {}
68
69 Timer::Timer(bool retain_user_task, bool is_repeating, TickClock* tick_clock) 66 Timer::Timer(bool retain_user_task, bool is_repeating, TickClock* tick_clock)
70 : scheduled_task_(nullptr), 67 : scheduled_task_(nullptr),
71 thread_id_(0), 68 thread_id_(0),
72 is_repeating_(is_repeating), 69 is_repeating_(is_repeating),
73 retain_user_task_(retain_user_task), 70 retain_user_task_(retain_user_task),
74 tick_clock_(tick_clock), 71 tick_clock_(tick_clock),
75 is_running_(false) {} 72 is_running_(false) {}
76 73
77 Timer::Timer(const tracked_objects::Location& posted_from, 74 Timer::Timer(const tracked_objects::Location& posted_from,
78 TimeDelta delay, 75 TimeDelta delay,
79 const base::Closure& user_task, 76 const base::Closure& user_task,
80 bool is_repeating)
81 : Timer(posted_from, delay, user_task, is_repeating, nullptr) {}
82
83 Timer::Timer(const tracked_objects::Location& posted_from,
84 TimeDelta delay,
85 const base::Closure& user_task,
86 bool is_repeating, 77 bool is_repeating,
87 TickClock* tick_clock) 78 TickClock* tick_clock)
88 : scheduled_task_(nullptr), 79 : scheduled_task_(nullptr),
89 posted_from_(posted_from), 80 posted_from_(posted_from),
90 delay_(delay), 81 delay_(delay),
91 user_task_(user_task), 82 user_task_(user_task),
92 thread_id_(0), 83 thread_id_(0),
93 is_repeating_(is_repeating), 84 is_repeating_(is_repeating),
94 retain_user_task_(true), 85 retain_user_task_(true),
95 tick_clock_(tick_clock), 86 tick_clock_(tick_clock),
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 PostNewScheduledTask(delay_); 219 PostNewScheduledTask(delay_);
229 else 220 else
230 Stop(); 221 Stop();
231 222
232 task.Run(); 223 task.Run();
233 224
234 // No more member accesses here: *this could be deleted at this point. 225 // No more member accesses here: *this could be deleted at this point.
235 } 226 }
236 227
237 } // namespace base 228 } // namespace base
OLDNEW
« no previous file with comments | « base/timer/timer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698