Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / net / quic / test_tools / test_task_runner.h
blobe25bf2aef46b6d1a527f2958035999053bbbd46c
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
3 // found in the LICENSE file.
4 //
5 // Common utilities for Quic tests
7 #ifndef NET_QUIC_TEST_TOOLS_TEST_TASK_RUNNER_H_
8 #define NET_QUIC_TEST_TOOLS_TEST_TASK_RUNNER_H_
10 #include <vector>
12 #include "base/basictypes.h"
13 #include "base/task_runner.h"
14 #include "base/test/test_pending_task.h"
16 namespace net {
18 class MockClock;
20 namespace test {
22 typedef base::TestPendingTask PostedTask;
24 class TestTaskRunner : public base::TaskRunner {
25 public:
26 explicit TestTaskRunner(MockClock* clock);
28 // base::TaskRunner implementation.
29 virtual bool PostDelayedTask(const tracked_objects::Location& from_here,
30 const base::Closure& task,
31 base::TimeDelta delay) OVERRIDE;
32 virtual bool RunsTasksOnCurrentThread() const OVERRIDE;
34 const std::vector<PostedTask>& GetPostedTasks() const;
36 void RunNextTask();
38 protected:
39 virtual ~TestTaskRunner();
41 private:
42 std::vector<PostedTask>::iterator FindNextTask();
44 MockClock* const clock_;
45 std::vector<PostedTask> tasks_;
47 DISALLOW_COPY_AND_ASSIGN(TestTaskRunner);
50 } // namespace test
52 } // namespace net
54 #endif // NET_QUIC_TEST_TOOLS_TEST_TASK_RUNNER_H_