Removed kAshDisableTextFilteringInOverviewMode flag.
[chromium-blink-merge.git] / base / test / test_simple_task_runner.cc
blobcc39fab85ad3ecb8b1d7ee5f8d591a0f3669159b
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
3 // found in the LICENSE file.
5 #include "base/test/test_simple_task_runner.h"
7 #include "base/logging.h"
9 namespace base {
11 TestSimpleTaskRunner::TestSimpleTaskRunner() {}
13 TestSimpleTaskRunner::~TestSimpleTaskRunner() {
14 DCHECK(thread_checker_.CalledOnValidThread());
17 bool TestSimpleTaskRunner::PostDelayedTask(
18 const tracked_objects::Location& from_here,
19 const Closure& task,
20 TimeDelta delay) {
21 DCHECK(thread_checker_.CalledOnValidThread());
22 pending_tasks_.push_back(
23 TestPendingTask(from_here, task, TimeTicks(), delay,
24 TestPendingTask::NESTABLE));
25 return true;
28 bool TestSimpleTaskRunner::PostNonNestableDelayedTask(
29 const tracked_objects::Location& from_here,
30 const Closure& task,
31 TimeDelta delay) {
32 DCHECK(thread_checker_.CalledOnValidThread());
33 pending_tasks_.push_back(
34 TestPendingTask(from_here, task, TimeTicks(), delay,
35 TestPendingTask::NON_NESTABLE));
36 return true;
39 bool TestSimpleTaskRunner::RunsTasksOnCurrentThread() const {
40 DCHECK(thread_checker_.CalledOnValidThread());
41 return true;
44 const std::deque<TestPendingTask>&
45 TestSimpleTaskRunner::GetPendingTasks() const {
46 DCHECK(thread_checker_.CalledOnValidThread());
47 return pending_tasks_;
50 bool TestSimpleTaskRunner::HasPendingTask() const {
51 DCHECK(thread_checker_.CalledOnValidThread());
52 return !pending_tasks_.empty();
55 base::TimeDelta TestSimpleTaskRunner::NextPendingTaskDelay() const {
56 DCHECK(thread_checker_.CalledOnValidThread());
57 return pending_tasks_.front().GetTimeToRun() - base::TimeTicks();
60 void TestSimpleTaskRunner::ClearPendingTasks() {
61 DCHECK(thread_checker_.CalledOnValidThread());
62 pending_tasks_.clear();
65 void TestSimpleTaskRunner::RunPendingTasks() {
66 DCHECK(thread_checker_.CalledOnValidThread());
67 // Swap with a local variable to avoid re-entrancy problems.
68 std::deque<TestPendingTask> tasks_to_run;
69 tasks_to_run.swap(pending_tasks_);
70 for (std::deque<TestPendingTask>::iterator it = tasks_to_run.begin();
71 it != tasks_to_run.end(); ++it) {
72 it->task.Run();
76 void TestSimpleTaskRunner::RunUntilIdle() {
77 while (!pending_tasks_.empty()) {
78 RunPendingTasks();
82 } // namespace base