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

Side by Side Diff: cc/test/ordered_simple_task_runner.h

Issue 2637843002: Migrate base::TaskRunner from Closure to OnceClosure (Closed)
Patch Set: rebase 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
« no previous file with comments | « base/trace_event/memory_dump_manager_unittest.cc ('k') | cc/test/ordered_simple_task_runner.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_ 5 #ifndef CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_
6 #define CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_ 6 #define CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <limits> 10 #include <limits>
(...skipping 11 matching lines...) Expand all
22 #include "base/trace_event/trace_event.h" 22 #include "base/trace_event/trace_event.h"
23 23
24 namespace cc { 24 namespace cc {
25 25
26 // Subclass of TestPendingTask which has a unique ID for every task, supports 26 // Subclass of TestPendingTask which has a unique ID for every task, supports
27 // being used inside a std::set and has debug tracing support. 27 // being used inside a std::set and has debug tracing support.
28 class TestOrderablePendingTask : public base::TestPendingTask { 28 class TestOrderablePendingTask : public base::TestPendingTask {
29 public: 29 public:
30 TestOrderablePendingTask(); 30 TestOrderablePendingTask();
31 TestOrderablePendingTask(const tracked_objects::Location& location, 31 TestOrderablePendingTask(const tracked_objects::Location& location,
32 base::Closure task, 32 base::OnceClosure task,
33 base::TimeTicks post_time, 33 base::TimeTicks post_time,
34 base::TimeDelta delay, 34 base::TimeDelta delay,
35 TestNestability nestability); 35 TestNestability nestability);
36 TestOrderablePendingTask(TestOrderablePendingTask&&); 36 TestOrderablePendingTask(TestOrderablePendingTask&&);
37 ~TestOrderablePendingTask(); 37 ~TestOrderablePendingTask();
38 38
39 TestOrderablePendingTask& operator=(TestOrderablePendingTask&&); 39 TestOrderablePendingTask& operator=(TestOrderablePendingTask&&);
40 40
41 // operators needed by std::set and comparison 41 // operators needed by std::set and comparison
42 bool operator==(const TestOrderablePendingTask& other) const; 42 bool operator==(const TestOrderablePendingTask& other) const;
(...skipping 14 matching lines...) Expand all
57 57
58 // This runs pending tasks based on task's post_time + delay. 58 // This runs pending tasks based on task's post_time + delay.
59 // We should not execute a delayed task sooner than some of the queued tasks 59 // We should not execute a delayed task sooner than some of the queued tasks
60 // which don't have a delay even though it is queued early. 60 // which don't have a delay even though it is queued early.
61 class OrderedSimpleTaskRunner : public base::SingleThreadTaskRunner { 61 class OrderedSimpleTaskRunner : public base::SingleThreadTaskRunner {
62 public: 62 public:
63 OrderedSimpleTaskRunner(base::SimpleTestTickClock* now_src, bool advance_now); 63 OrderedSimpleTaskRunner(base::SimpleTestTickClock* now_src, bool advance_now);
64 64
65 // base::TestSimpleTaskRunner implementation: 65 // base::TestSimpleTaskRunner implementation:
66 bool PostDelayedTask(const tracked_objects::Location& from_here, 66 bool PostDelayedTask(const tracked_objects::Location& from_here,
67 base::Closure task, 67 base::OnceClosure task,
68 base::TimeDelta delay) override; 68 base::TimeDelta delay) override;
69 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, 69 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
70 base::Closure task, 70 base::OnceClosure task,
71 base::TimeDelta delay) override; 71 base::TimeDelta delay) override;
72 72
73 bool RunsTasksOnCurrentThread() const override; 73 bool RunsTasksOnCurrentThread() const override;
74 74
75 static base::TimeTicks AbsoluteMaxNow(); 75 static base::TimeTicks AbsoluteMaxNow();
76 76
77 // Set a maximum number of tasks to run at once. Useful as a timeout to 77 // Set a maximum number of tasks to run at once. Useful as a timeout to
78 // prevent infinite task loops. 78 // prevent infinite task loops.
79 static const size_t kAbsoluteMaxTasks; 79 static const size_t kAbsoluteMaxTasks;
80 void SetRunTaskLimit(size_t max_tasks) { max_tasks_ = max_tasks; } 80 void SetRunTaskLimit(size_t max_tasks) { max_tasks_ = max_tasks; }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 bool inside_run_tasks_until_; 160 bool inside_run_tasks_until_;
161 std::set<TestOrderablePendingTask> pending_tasks_; 161 std::set<TestOrderablePendingTask> pending_tasks_;
162 162
163 private: 163 private:
164 DISALLOW_COPY_AND_ASSIGN(OrderedSimpleTaskRunner); 164 DISALLOW_COPY_AND_ASSIGN(OrderedSimpleTaskRunner);
165 }; 165 };
166 166
167 } // namespace cc 167 } // namespace cc
168 168
169 #endif // CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_ 169 #endif // CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_
OLDNEW
« no previous file with comments | « base/trace_event/memory_dump_manager_unittest.cc ('k') | cc/test/ordered_simple_task_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698