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

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

Issue 994903002: Add ability to clear pending tasks of TestMockTimeTaskRunner without running the tasks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/test/test_mock_time_task_runner.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/time/clock.h" 9 #include "base/time/clock.h"
10 #include "base/time/tick_clock.h" 10 #include "base/time/tick_clock.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 void TestMockTimeTaskRunner::RunUntilIdle() { 93 void TestMockTimeTaskRunner::RunUntilIdle() {
94 DCHECK(thread_checker_.CalledOnValidThread()); 94 DCHECK(thread_checker_.CalledOnValidThread());
95 ProcessAllTasksNoLaterThan(TimeDelta()); 95 ProcessAllTasksNoLaterThan(TimeDelta());
96 } 96 }
97 97
98 void TestMockTimeTaskRunner::FastForwardUntilNoTasksRemain() { 98 void TestMockTimeTaskRunner::FastForwardUntilNoTasksRemain() {
99 DCHECK(thread_checker_.CalledOnValidThread()); 99 DCHECK(thread_checker_.CalledOnValidThread());
100 ProcessAllTasksNoLaterThan(TimeDelta::Max()); 100 ProcessAllTasksNoLaterThan(TimeDelta::Max());
101 } 101 }
102 102
103 void TestMockTimeTaskRunner::ClearPendingTasks() {
104 DCHECK(thread_checker_.CalledOnValidThread());
105 AutoLock scoped_lock(tasks_lock_);
106 while (!tasks_.empty())
107 tasks_.pop();
108 }
109
103 Time TestMockTimeTaskRunner::Now() const { 110 Time TestMockTimeTaskRunner::Now() const {
104 DCHECK(thread_checker_.CalledOnValidThread()); 111 DCHECK(thread_checker_.CalledOnValidThread());
105 return now_; 112 return now_;
106 } 113 }
107 114
108 TimeTicks TestMockTimeTaskRunner::NowTicks() const { 115 TimeTicks TestMockTimeTaskRunner::NowTicks() const {
109 DCHECK(thread_checker_.CalledOnValidThread()); 116 DCHECK(thread_checker_.CalledOnValidThread());
110 return now_ticks_; 117 return now_ticks_;
111 } 118 }
112 119
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 if (!tasks_.empty() && 209 if (!tasks_.empty() &&
203 (tasks_.top().GetTimeToRun() - reference) <= max_delta) { 210 (tasks_.top().GetTimeToRun() - reference) <= max_delta) {
204 *next_task = tasks_.top(); 211 *next_task = tasks_.top();
205 tasks_.pop(); 212 tasks_.pop();
206 return true; 213 return true;
207 } 214 }
208 return false; 215 return false;
209 } 216 }
210 217
211 } // namespace base 218 } // namespace base
OLDNEW
« no previous file with comments | « base/test/test_mock_time_task_runner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698