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

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

Issue 2912433002: Fix race in base::Timer when SetTaskRunner() is used
Patch Set: rebase Created 3 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
« no previous file with comments | « no previous file | base/timer/timer.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 // 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 bool is_running() const { return is_running_; } 147 bool is_running() const { return is_running_; }
148 148
149 private: 149 private:
150 friend class BaseTimerTaskInternal; 150 friend class BaseTimerTaskInternal;
151 151
152 // Allocates a new |scheduled_task_| and posts it on the current sequence with 152 // Allocates a new |scheduled_task_| and posts it on the current sequence with
153 // the given |delay|. |scheduled_task_| must be null. |scheduled_run_time_| 153 // the given |delay|. |scheduled_task_| must be null. |scheduled_run_time_|
154 // and |desired_run_time_| are reset to Now() + delay. 154 // and |desired_run_time_| are reset to Now() + delay.
155 void PostNewScheduledTask(TimeDelta delay); 155 void PostNewScheduledTask(TimeDelta delay);
156 156
157 // Returns the task runner on which the task should be scheduled. If the
158 // corresponding |task_runner_| field is null, the task runner for the current
159 // sequence is returned.
160 scoped_refptr<SequencedTaskRunner> GetTaskRunner();
161
162 // Disable |scheduled_task_| and abandon it so that it no longer refers back 157 // Disable |scheduled_task_| and abandon it so that it no longer refers back
163 // to this object. 158 // to this object.
164 void AbandonScheduledTask(); 159 void AbandonScheduledTask();
165 160
166 // Called by BaseTimerTaskInternal when the delayed task fires. 161 // Called by BaseTimerTaskInternal when the delayed task fires.
167 void RunScheduledTask(); 162 void RunScheduledTask();
168 163
169 // Stop running task (if any) and abandon scheduled task (if any). 164 // Stop running task (if any) and abandon scheduled task (if any).
170 void AbandonAndStop() { 165 void AbandonAndStop() {
171 AbandonScheduledTask(); 166 AbandonScheduledTask();
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 // to link in MSVC. But clang-plugin does not allow inline definitions of 303 // to link in MSVC. But clang-plugin does not allow inline definitions of
309 // virtual methods, so the inline definition lives in the header file here 304 // virtual methods, so the inline definition lives in the header file here
310 // to satisfy both. 305 // to satisfy both.
311 inline void DelayTimer::Reset() { 306 inline void DelayTimer::Reset() {
312 Timer::Reset(); 307 Timer::Reset();
313 } 308 }
314 309
315 } // namespace base 310 } // namespace base
316 311
317 #endif // BASE_TIMER_TIMER_H_ 312 #endif // BASE_TIMER_TIMER_H_
OLDNEW
« no previous file with comments | « no previous file | base/timer/timer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698