Commit bef18568 authored by engedy's avatar engedy Committed by Commit bot

Add ability to clear pending tasks of TestMockTimeTaskRunner without running the tasks.

BUG=None

Review URL: https://codereview.chromium.org/994903002

Cr-Commit-Position: refs/heads/master@{#319896}
parent eb2372fa
...@@ -100,6 +100,13 @@ void TestMockTimeTaskRunner::FastForwardUntilNoTasksRemain() { ...@@ -100,6 +100,13 @@ void TestMockTimeTaskRunner::FastForwardUntilNoTasksRemain() {
ProcessAllTasksNoLaterThan(TimeDelta::Max()); ProcessAllTasksNoLaterThan(TimeDelta::Max());
} }
void TestMockTimeTaskRunner::ClearPendingTasks() {
DCHECK(thread_checker_.CalledOnValidThread());
AutoLock scoped_lock(tasks_lock_);
while (!tasks_.empty())
tasks_.pop();
}
Time TestMockTimeTaskRunner::Now() const { Time TestMockTimeTaskRunner::Now() const {
DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(thread_checker_.CalledOnValidThread());
return now_; return now_;
......
...@@ -61,6 +61,9 @@ class TestMockTimeTaskRunner : public SingleThreadTaskRunner { ...@@ -61,6 +61,9 @@ class TestMockTimeTaskRunner : public SingleThreadTaskRunner {
// elapse. // elapse.
void RunUntilIdle(); void RunUntilIdle();
// Clears the queue of pending tasks without running them.
void ClearPendingTasks();
// Returns the current virtual time (initially starting at the Unix epoch). // Returns the current virtual time (initially starting at the Unix epoch).
Time Now() const; Time Now() const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment