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

Side by Side Diff: base/test/test_mock_time_task_runner.cc

Issue 2823103003: Introduce TaskRunner::RunsTasksInCurrentSequence() (Closed)
Patch Set: fixed build error and commments Created 3 years, 8 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/test/test_mock_time_task_runner.h" 5 #include "base/test/test_mock_time_task_runner.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 227
228 TimeDelta TestMockTimeTaskRunner::NextPendingTaskDelay() const { 228 TimeDelta TestMockTimeTaskRunner::NextPendingTaskDelay() const {
229 DCHECK(thread_checker_.CalledOnValidThread()); 229 DCHECK(thread_checker_.CalledOnValidThread());
230 return tasks_.empty() ? TimeDelta::Max() 230 return tasks_.empty() ? TimeDelta::Max()
231 : tasks_.top().GetTimeToRun() - now_ticks_; 231 : tasks_.top().GetTimeToRun() - now_ticks_;
232 } 232 }
233 233
234 // TODO(gab): Combine |thread_checker_| with a SequenceToken to differentiate 234 // TODO(gab): Combine |thread_checker_| with a SequenceToken to differentiate
235 // between tasks running in the scope of this TestMockTimeTaskRunner and other 235 // between tasks running in the scope of this TestMockTimeTaskRunner and other
236 // task runners sharing this thread. http://crbug.com/631186 236 // task runners sharing this thread. http://crbug.com/631186
237 bool TestMockTimeTaskRunner::RunsTasksOnCurrentThread() const { 237 bool TestMockTimeTaskRunner::RunsTasksInCurrentSequence() const {
238 return thread_checker_.CalledOnValidThread(); 238 return thread_checker_.CalledOnValidThread();
239 } 239 }
240 240
241 bool TestMockTimeTaskRunner::PostDelayedTask( 241 bool TestMockTimeTaskRunner::PostDelayedTask(
242 const tracked_objects::Location& from_here, 242 const tracked_objects::Location& from_here,
243 OnceClosure task, 243 OnceClosure task,
244 TimeDelta delay) { 244 TimeDelta delay) {
245 AutoLock scoped_lock(tasks_lock_); 245 AutoLock scoped_lock(tasks_lock_);
246 tasks_.push(TestOrderedPendingTask(from_here, std::move(task), now_ticks_, 246 tasks_.push(TestOrderedPendingTask(from_here, std::move(task), now_ticks_,
247 delay, next_task_ordinal_++, 247 delay, next_task_ordinal_++,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 // It's safe to remove const and consume |task| here, since |task| is not 318 // It's safe to remove const and consume |task| here, since |task| is not
319 // used for ordering the item. 319 // used for ordering the item.
320 *next_task = std::move(const_cast<TestOrderedPendingTask&>(tasks_.top())); 320 *next_task = std::move(const_cast<TestOrderedPendingTask&>(tasks_.top()));
321 tasks_.pop(); 321 tasks_.pop();
322 return true; 322 return true;
323 } 323 }
324 return false; 324 return false;
325 } 325 }
326 326
327 } // namespace base 327 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698