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

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

Issue 2624133004: Fix use-after-free in base::Timer::StopAndAbandon() (Closed)
Patch Set: Merge branch 'master' into timer_bug Created 3 years, 11 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_unittest.cc » ('j') | base/timer/timer_unittest.cc » ('J')
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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 scoped_refptr<SingleThreadTaskRunner> GetTaskRunner(); 155 scoped_refptr<SingleThreadTaskRunner> GetTaskRunner();
156 156
157 // Disable scheduled_task_ and abandon it so that it no longer refers back to 157 // Disable scheduled_task_ and abandon it so that it no longer refers back to
158 // this object. 158 // this object.
159 void AbandonScheduledTask(); 159 void AbandonScheduledTask();
160 160
161 // Called by BaseTimerTaskInternal when the MessageLoop runs it. 161 // Called by BaseTimerTaskInternal when the MessageLoop runs it.
162 void RunScheduledTask(); 162 void RunScheduledTask();
163 163
164 // Stop running task (if any) and abandon scheduled task (if any). 164 // Stop running task (if any) and abandon scheduled task (if any).
165 void StopAndAbandon() { 165 void StopAndAbandon() {
dominickn 2017/01/12 03:27:17 Note for base/timer owners: is it worth changing t
gab 2017/01/12 19:42:54 No as I'm rewriting all of base::Timer in upcoming
166 AbandonScheduledTask();
167
166 Stop(); 168 Stop();
167 AbandonScheduledTask(); 169 // No more member accesses here: *this could be deleted at this point.
gab 2017/01/12 19:42:54 s/*this/|this|/
168 } 170 }
169 171
170 // When non-NULL, the scheduled_task_ is waiting in the MessageLoop to call 172 // When non-NULL, the scheduled_task_ is waiting in the MessageLoop to call
171 // RunScheduledTask() at scheduled_run_time_. 173 // RunScheduledTask() at scheduled_run_time_.
172 BaseTimerTaskInternal* scheduled_task_; 174 BaseTimerTaskInternal* scheduled_task_;
173 175
174 // The task runner on which the task should be scheduled. If it is null, the 176 // The task runner on which the task should be scheduled. If it is null, the
175 // task runner for the current thread should be used. 177 // task runner for the current thread should be used.
176 scoped_refptr<SingleThreadTaskRunner> task_runner_; 178 scoped_refptr<SingleThreadTaskRunner> task_runner_;
177 179
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 // 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
302 // 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
303 // to satisfy both. 305 // to satisfy both.
304 inline void DelayTimer::Reset() { 306 inline void DelayTimer::Reset() {
305 Timer::Reset(); 307 Timer::Reset();
306 } 308 }
307 309
308 } // namespace base 310 } // namespace base
309 311
310 #endif // BASE_TIMER_TIMER_H_ 312 #endif // BASE_TIMER_TIMER_H_
OLDNEW
« no previous file with comments | « no previous file | base/timer/timer_unittest.cc » ('j') | base/timer/timer_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698