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

Side by Side Diff: net/quic/test_tools/test_task_runner.h

Issue 2726523002: Pass Callback to TaskRunner by value and consume it on invocation (1) (Closed)
Patch Set: erase Closure* Created 3 years, 8 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
OLDNEW
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>
11 11
12 #include "base/callback.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/task_runner.h" 14 #include "base/task_runner.h"
14 #include "base/test/test_pending_task.h" 15 #include "base/test/test_pending_task.h"
15 16
16 namespace net { 17 namespace net {
17 18
18 class MockClock; 19 class MockClock;
19 20
20 namespace test { 21 namespace test {
21 22
22 typedef base::TestPendingTask PostedTask; 23 typedef base::TestPendingTask PostedTask;
23 24
24 class TestTaskRunner : public base::TaskRunner { 25 class TestTaskRunner : public base::TaskRunner {
25 public: 26 public:
26 explicit TestTaskRunner(MockClock* clock); 27 explicit TestTaskRunner(MockClock* clock);
27 28
28 // base::TaskRunner implementation. 29 // base::TaskRunner implementation.
29 bool PostDelayedTask(const tracked_objects::Location& from_here, 30 bool PostDelayedTask(const tracked_objects::Location& from_here,
30 const base::Closure& task, 31 base::Closure task,
31 base::TimeDelta delay) override; 32 base::TimeDelta delay) override;
32 bool RunsTasksOnCurrentThread() const override; 33 bool RunsTasksOnCurrentThread() const override;
33 34
34 const std::vector<PostedTask>& GetPostedTasks() const; 35 const std::vector<PostedTask>& GetPostedTasks() const;
35 36
36 void RunNextTask(); 37 void RunNextTask();
37 38
38 protected: 39 protected:
39 ~TestTaskRunner() override; 40 ~TestTaskRunner() override;
40 41
41 private: 42 private:
42 std::vector<PostedTask>::iterator FindNextTask(); 43 std::vector<PostedTask>::iterator FindNextTask();
43 44
44 MockClock* const clock_; 45 MockClock* const clock_;
45 std::vector<PostedTask> tasks_; 46 std::vector<PostedTask> tasks_;
46 47
47 DISALLOW_COPY_AND_ASSIGN(TestTaskRunner); 48 DISALLOW_COPY_AND_ASSIGN(TestTaskRunner);
48 }; 49 };
49 50
50 } // namespace test 51 } // namespace test
51 52
52 } // namespace net 53 } // namespace net
53 54
54 #endif // NET_QUIC_TEST_TOOLS_TEST_TASK_RUNNER_H_ 55 #endif // NET_QUIC_TEST_TOOLS_TEST_TASK_RUNNER_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/tests/bind_task_runner_unittest.cc ('k') | net/quic/test_tools/test_task_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698