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

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

Issue 988693005: Chromium roll (https://codereview.chromium.org/976353002) (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: fixed bad android build patch Created 5 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 | « base/timer/timer.h ('k') | base/trace_event/memory_dump_manager.h » ('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 #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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 base::Bind(&BaseTimerTaskInternal::Run, base::Owned(scheduled_task_)), 156 base::Bind(&BaseTimerTaskInternal::Run, base::Owned(scheduled_task_)),
157 delay); 157 delay);
158 scheduled_run_time_ = desired_run_time_ = TimeTicks::Now() + delay; 158 scheduled_run_time_ = desired_run_time_ = TimeTicks::Now() + delay;
159 } else { 159 } else {
160 GetTaskRunner()->PostTask(posted_from_, 160 GetTaskRunner()->PostTask(posted_from_,
161 base::Bind(&BaseTimerTaskInternal::Run, base::Owned(scheduled_task_))); 161 base::Bind(&BaseTimerTaskInternal::Run, base::Owned(scheduled_task_)));
162 scheduled_run_time_ = desired_run_time_ = TimeTicks(); 162 scheduled_run_time_ = desired_run_time_ = TimeTicks();
163 } 163 }
164 // Remember the thread ID that posts the first task -- this will be verified 164 // Remember the thread ID that posts the first task -- this will be verified
165 // later when the task is abandoned to detect misuse from multiple threads. 165 // later when the task is abandoned to detect misuse from multiple threads.
166 if (!thread_id_) 166 if (!thread_id_) {
167 DCHECK(GetTaskRunner()->BelongsToCurrentThread());
167 thread_id_ = static_cast<int>(PlatformThread::CurrentId()); 168 thread_id_ = static_cast<int>(PlatformThread::CurrentId());
169 }
168 } 170 }
169 171
170 scoped_refptr<SingleThreadTaskRunner> Timer::GetTaskRunner() { 172 scoped_refptr<SingleThreadTaskRunner> Timer::GetTaskRunner() {
171 return task_runner_.get() ? task_runner_ : ThreadTaskRunnerHandle::Get(); 173 return task_runner_.get() ? task_runner_ : ThreadTaskRunnerHandle::Get();
172 } 174 }
173 175
174 void Timer::AbandonScheduledTask() { 176 void Timer::AbandonScheduledTask() {
175 DCHECK(thread_id_ == 0 || 177 DCHECK(thread_id_ == 0 ||
176 thread_id_ == static_cast<int>(PlatformThread::CurrentId())); 178 thread_id_ == static_cast<int>(PlatformThread::CurrentId()));
177 if (scheduled_task_) { 179 if (scheduled_task_) {
(...skipping 29 matching lines...) Expand all
207 PostNewScheduledTask(delay_); 209 PostNewScheduledTask(delay_);
208 else 210 else
209 Stop(); 211 Stop();
210 212
211 task.Run(); 213 task.Run();
212 214
213 // No more member accesses here: *this could be deleted at this point. 215 // No more member accesses here: *this could be deleted at this point.
214 } 216 }
215 217
216 } // namespace base 218 } // namespace base
OLDNEW
« no previous file with comments | « base/timer/timer.h ('k') | base/trace_event/memory_dump_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698