OLD | NEW |
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 "net/quic/chromium/test_task_runner.h" | 5 #include "net/quic/chromium/test_task_runner.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "net/quic/test_tools/mock_clock.h" | 10 #include "net/quic/test_tools/mock_clock.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 namespace net { | 13 namespace net { |
14 namespace test { | 14 namespace test { |
15 | 15 |
16 TestTaskRunner::TestTaskRunner(MockClock* clock) : clock_(clock) {} | 16 TestTaskRunner::TestTaskRunner(MockClock* clock) : clock_(clock) {} |
17 | 17 |
18 TestTaskRunner::~TestTaskRunner() {} | 18 TestTaskRunner::~TestTaskRunner() {} |
19 | 19 |
20 bool TestTaskRunner::PostDelayedTask(const tracked_objects::Location& from_here, | 20 bool TestTaskRunner::PostDelayedTask(const tracked_objects::Location& from_here, |
21 base::OnceClosure task, | 21 base::OnceClosure task, |
22 base::TimeDelta delay) { | 22 base::TimeDelta delay) { |
23 EXPECT_GE(delay, base::TimeDelta()); | 23 EXPECT_GE(delay, base::TimeDelta()); |
24 tasks_.push_back(PostedTask(from_here, std::move(task), clock_->NowInTicks(), | 24 tasks_.push_back(PostedTask(from_here, std::move(task), clock_->NowInTicks(), |
25 delay, base::TestPendingTask::NESTABLE)); | 25 delay, base::TestPendingTask::NESTABLE)); |
26 return false; | 26 return false; |
27 } | 27 } |
28 | 28 |
29 bool TestTaskRunner::RunsTasksOnCurrentThread() const { | 29 bool TestTaskRunner::RunsTasksInCurrentSequence() const { |
30 return true; | 30 return true; |
31 } | 31 } |
32 | 32 |
33 const std::vector<PostedTask>& TestTaskRunner::GetPostedTasks() const { | 33 const std::vector<PostedTask>& TestTaskRunner::GetPostedTasks() const { |
34 return tasks_; | 34 return tasks_; |
35 } | 35 } |
36 | 36 |
37 void TestTaskRunner::RunNextTask() { | 37 void TestTaskRunner::RunNextTask() { |
38 std::vector<PostedTask>::iterator next = FindNextTask(); | 38 std::vector<PostedTask>::iterator next = FindNextTask(); |
39 DCHECK(next != tasks_.end()); | 39 DCHECK(next != tasks_.end()); |
(...skipping 18 matching lines...) Expand all Loading... |
58 | 58 |
59 } // namespace | 59 } // namespace |
60 | 60 |
61 std::vector<PostedTask>::iterator TestTaskRunner::FindNextTask() { | 61 std::vector<PostedTask>::iterator TestTaskRunner::FindNextTask() { |
62 return std::min_element(tasks_.begin(), tasks_.end(), | 62 return std::min_element(tasks_.begin(), tasks_.end(), |
63 ShouldRunBeforeLessThan()); | 63 ShouldRunBeforeLessThan()); |
64 } | 64 } |
65 | 65 |
66 } // namespace test | 66 } // namespace test |
67 } // namespace net | 67 } // namespace net |
OLD | NEW |