OLD | NEW |
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 "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 thread_id_(0), | 78 thread_id_(0), |
79 is_repeating_(is_repeating), | 79 is_repeating_(is_repeating), |
80 retain_user_task_(true), | 80 retain_user_task_(true), |
81 is_running_(false) { | 81 is_running_(false) { |
82 } | 82 } |
83 | 83 |
84 Timer::~Timer() { | 84 Timer::~Timer() { |
85 StopAndAbandon(); | 85 StopAndAbandon(); |
86 } | 86 } |
87 | 87 |
| 88 bool Timer::IsRunning() const { |
| 89 return is_running_; |
| 90 } |
| 91 |
| 92 TimeDelta Timer::GetCurrentDelay() const { |
| 93 return delay_; |
| 94 } |
| 95 |
88 void Timer::Start(const tracked_objects::Location& posted_from, | 96 void Timer::Start(const tracked_objects::Location& posted_from, |
89 TimeDelta delay, | 97 TimeDelta delay, |
90 const base::Closure& user_task) { | 98 const base::Closure& user_task) { |
91 SetTaskInfo(posted_from, delay, user_task); | 99 SetTaskInfo(posted_from, delay, user_task); |
92 Reset(); | 100 Reset(); |
93 } | 101 } |
94 | 102 |
95 void Timer::Stop() { | 103 void Timer::Stop() { |
96 is_running_ = false; | 104 is_running_ = false; |
97 if (!retain_user_task_) | 105 if (!retain_user_task_) |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 PostNewScheduledTask(delay_); | 197 PostNewScheduledTask(delay_); |
190 else | 198 else |
191 Stop(); | 199 Stop(); |
192 | 200 |
193 task.Run(); | 201 task.Run(); |
194 | 202 |
195 // No more member accesses here: *this could be deleted at this point. | 203 // No more member accesses here: *this could be deleted at this point. |
196 } | 204 } |
197 | 205 |
198 } // namespace base | 206 } // namespace base |
OLD | NEW |