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

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

Issue 17362002: cc: Remove FakeThread, use SingleThreadTaskRunner in scheduling classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rm-fakethread: rebase Created 7 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 | Annotate | Revision Log
« no previous file with comments | « base/test/test_simple_task_runner.h ('k') | cc/base/thread.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/test/test_simple_task_runner.h" 5 #include "base/test/test_simple_task_runner.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace base { 9 namespace base {
10 10
(...skipping 29 matching lines...) Expand all
40 DCHECK(thread_checker_.CalledOnValidThread()); 40 DCHECK(thread_checker_.CalledOnValidThread());
41 return true; 41 return true;
42 } 42 }
43 43
44 const std::deque<TestPendingTask>& 44 const std::deque<TestPendingTask>&
45 TestSimpleTaskRunner::GetPendingTasks() const { 45 TestSimpleTaskRunner::GetPendingTasks() const {
46 DCHECK(thread_checker_.CalledOnValidThread()); 46 DCHECK(thread_checker_.CalledOnValidThread());
47 return pending_tasks_; 47 return pending_tasks_;
48 } 48 }
49 49
50 bool TestSimpleTaskRunner::HasPendingTask() const {
51 DCHECK(thread_checker_.CalledOnValidThread());
52 return !pending_tasks_.empty();
53 }
54
55 base::TimeDelta TestSimpleTaskRunner::NextPendingTaskDelay() const {
56 DCHECK(thread_checker_.CalledOnValidThread());
57 return pending_tasks_.front().GetTimeToRun() - base::TimeTicks();
58 }
59
50 void TestSimpleTaskRunner::ClearPendingTasks() { 60 void TestSimpleTaskRunner::ClearPendingTasks() {
51 DCHECK(thread_checker_.CalledOnValidThread()); 61 DCHECK(thread_checker_.CalledOnValidThread());
52 pending_tasks_.clear(); 62 pending_tasks_.clear();
53 } 63 }
54 64
55 void TestSimpleTaskRunner::RunPendingTasks() { 65 void TestSimpleTaskRunner::RunPendingTasks() {
56 DCHECK(thread_checker_.CalledOnValidThread()); 66 DCHECK(thread_checker_.CalledOnValidThread());
57 // Swap with a local variable to avoid re-entrancy problems. 67 // Swap with a local variable to avoid re-entrancy problems.
58 std::deque<TestPendingTask> tasks_to_run; 68 std::deque<TestPendingTask> tasks_to_run;
59 tasks_to_run.swap(pending_tasks_); 69 tasks_to_run.swap(pending_tasks_);
60 for (std::deque<TestPendingTask>::iterator it = tasks_to_run.begin(); 70 for (std::deque<TestPendingTask>::iterator it = tasks_to_run.begin();
61 it != tasks_to_run.end(); ++it) { 71 it != tasks_to_run.end(); ++it) {
62 it->task.Run(); 72 it->task.Run();
63 } 73 }
64 } 74 }
65 75
66 void TestSimpleTaskRunner::RunUntilIdle() { 76 void TestSimpleTaskRunner::RunUntilIdle() {
67 while (!pending_tasks_.empty()) { 77 while (!pending_tasks_.empty()) {
68 RunPendingTasks(); 78 RunPendingTasks();
69 } 79 }
70 } 80 }
71 81
72 } // namespace base 82 } // namespace base
OLDNEW
« no previous file with comments | « base/test/test_simple_task_runner.h ('k') | cc/base/thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698