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 // Common utilities for Quic tests | 5 // Common utilities for Quic tests |
6 | 6 |
7 #ifndef NET_QUIC_TEST_TOOLS_TEST_TASK_RUNNER_H_ | 7 #ifndef NET_QUIC_TEST_TOOLS_TEST_TASK_RUNNER_H_ |
8 #define NET_QUIC_TEST_TOOLS_TEST_TASK_RUNNER_H_ | 8 #define NET_QUIC_TEST_TOOLS_TEST_TASK_RUNNER_H_ |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
(...skipping 12 matching lines...) Expand all Loading... |
23 typedef base::TestPendingTask PostedTask; | 23 typedef base::TestPendingTask PostedTask; |
24 | 24 |
25 class TestTaskRunner : public base::TaskRunner { | 25 class TestTaskRunner : public base::TaskRunner { |
26 public: | 26 public: |
27 explicit TestTaskRunner(MockClock* clock); | 27 explicit TestTaskRunner(MockClock* clock); |
28 | 28 |
29 // base::TaskRunner implementation. | 29 // base::TaskRunner implementation. |
30 bool PostDelayedTask(const tracked_objects::Location& from_here, | 30 bool PostDelayedTask(const tracked_objects::Location& from_here, |
31 base::OnceClosure task, | 31 base::OnceClosure task, |
32 base::TimeDelta delay) override; | 32 base::TimeDelta delay) override; |
33 bool RunsTasksOnCurrentThread() const override; | 33 bool RunsTasksInCurrentSequence() const override; |
34 | 34 |
35 const std::vector<PostedTask>& GetPostedTasks() const; | 35 const std::vector<PostedTask>& GetPostedTasks() const; |
36 | 36 |
37 // Finds the next task to run, advances the time to the correct time | 37 // Finds the next task to run, advances the time to the correct time |
38 // and then runs the task. | 38 // and then runs the task. |
39 void RunNextTask(); | 39 void RunNextTask(); |
40 | 40 |
41 // While there are posted tasks, finds the next task to run, advances the | 41 // While there are posted tasks, finds the next task to run, advances the |
42 // time to the correct time and then runs the task. | 42 // time to the correct time and then runs the task. |
43 void RunUntilIdle(); | 43 void RunUntilIdle(); |
44 | 44 |
45 protected: | 45 protected: |
46 ~TestTaskRunner() override; | 46 ~TestTaskRunner() override; |
47 | 47 |
48 private: | 48 private: |
49 std::vector<PostedTask>::iterator FindNextTask(); | 49 std::vector<PostedTask>::iterator FindNextTask(); |
50 | 50 |
51 MockClock* const clock_; | 51 MockClock* const clock_; |
52 std::vector<PostedTask> tasks_; | 52 std::vector<PostedTask> tasks_; |
53 | 53 |
54 DISALLOW_COPY_AND_ASSIGN(TestTaskRunner); | 54 DISALLOW_COPY_AND_ASSIGN(TestTaskRunner); |
55 }; | 55 }; |
56 | 56 |
57 } // namespace test | 57 } // namespace test |
58 | 58 |
59 } // namespace net | 59 } // namespace net |
60 | 60 |
61 #endif // NET_QUIC_TEST_TOOLS_TEST_TASK_RUNNER_H_ | 61 #endif // NET_QUIC_TEST_TOOLS_TEST_TASK_RUNNER_H_ |
OLD | NEW |