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

Side by Side Diff: base/test/test_mock_time_task_runner.cc

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/test/test_mock_time_task_runner.h ('k') | base/test/test_pending_task.h » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/test/test_mock_time_task_runner.h" 5 #include "base/test/test_mock_time_task_runner.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 // TestMockTimeTaskRunner::TestOrderedPendingTask ----------------------------- 75 // TestMockTimeTaskRunner::TestOrderedPendingTask -----------------------------
76 76
77 // Subclass of TestPendingTask which has a strictly monotonically increasing ID 77 // Subclass of TestPendingTask which has a strictly monotonically increasing ID
78 // for every task, so that tasks posted with the same 'time to run' can be run 78 // for every task, so that tasks posted with the same 'time to run' can be run
79 // in the order of being posted. 79 // in the order of being posted.
80 struct TestMockTimeTaskRunner::TestOrderedPendingTask 80 struct TestMockTimeTaskRunner::TestOrderedPendingTask
81 : public base::TestPendingTask { 81 : public base::TestPendingTask {
82 TestOrderedPendingTask(); 82 TestOrderedPendingTask();
83 TestOrderedPendingTask(const tracked_objects::Location& location, 83 TestOrderedPendingTask(const tracked_objects::Location& location,
84 Closure task, 84 OnceClosure task,
85 TimeTicks post_time, 85 TimeTicks post_time,
86 TimeDelta delay, 86 TimeDelta delay,
87 size_t ordinal, 87 size_t ordinal,
88 TestNestability nestability); 88 TestNestability nestability);
89 TestOrderedPendingTask(TestOrderedPendingTask&&); 89 TestOrderedPendingTask(TestOrderedPendingTask&&);
90 ~TestOrderedPendingTask(); 90 ~TestOrderedPendingTask();
91 91
92 TestOrderedPendingTask& operator=(TestOrderedPendingTask&&); 92 TestOrderedPendingTask& operator=(TestOrderedPendingTask&&);
93 93
94 size_t ordinal; 94 size_t ordinal;
95 95
96 private: 96 private:
97 DISALLOW_COPY_AND_ASSIGN(TestOrderedPendingTask); 97 DISALLOW_COPY_AND_ASSIGN(TestOrderedPendingTask);
98 }; 98 };
99 99
100 TestMockTimeTaskRunner::TestOrderedPendingTask::TestOrderedPendingTask() 100 TestMockTimeTaskRunner::TestOrderedPendingTask::TestOrderedPendingTask()
101 : ordinal(0) { 101 : ordinal(0) {
102 } 102 }
103 103
104 TestMockTimeTaskRunner::TestOrderedPendingTask::TestOrderedPendingTask( 104 TestMockTimeTaskRunner::TestOrderedPendingTask::TestOrderedPendingTask(
105 TestOrderedPendingTask&&) = default; 105 TestOrderedPendingTask&&) = default;
106 106
107 TestMockTimeTaskRunner::TestOrderedPendingTask::TestOrderedPendingTask( 107 TestMockTimeTaskRunner::TestOrderedPendingTask::TestOrderedPendingTask(
108 const tracked_objects::Location& location, 108 const tracked_objects::Location& location,
109 Closure task, 109 OnceClosure task,
110 TimeTicks post_time, 110 TimeTicks post_time,
111 TimeDelta delay, 111 TimeDelta delay,
112 size_t ordinal, 112 size_t ordinal,
113 TestNestability nestability) 113 TestNestability nestability)
114 : base::TestPendingTask(location, 114 : base::TestPendingTask(location,
115 std::move(task), 115 std::move(task),
116 post_time, 116 post_time,
117 delay, 117 delay,
118 nestability), 118 nestability),
119 ordinal(ordinal) {} 119 ordinal(ordinal) {}
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 233
234 // TODO(gab): Combine |thread_checker_| with a SequenceToken to differentiate 234 // TODO(gab): Combine |thread_checker_| with a SequenceToken to differentiate
235 // between tasks running in the scope of this TestMockTimeTaskRunner and other 235 // between tasks running in the scope of this TestMockTimeTaskRunner and other
236 // task runners sharing this thread. http://crbug.com/631186 236 // task runners sharing this thread. http://crbug.com/631186
237 bool TestMockTimeTaskRunner::RunsTasksOnCurrentThread() const { 237 bool TestMockTimeTaskRunner::RunsTasksOnCurrentThread() const {
238 return thread_checker_.CalledOnValidThread(); 238 return thread_checker_.CalledOnValidThread();
239 } 239 }
240 240
241 bool TestMockTimeTaskRunner::PostDelayedTask( 241 bool TestMockTimeTaskRunner::PostDelayedTask(
242 const tracked_objects::Location& from_here, 242 const tracked_objects::Location& from_here,
243 Closure task, 243 OnceClosure task,
244 TimeDelta delay) { 244 TimeDelta delay) {
245 AutoLock scoped_lock(tasks_lock_); 245 AutoLock scoped_lock(tasks_lock_);
246 tasks_.push(TestOrderedPendingTask(from_here, std::move(task), now_ticks_, 246 tasks_.push(TestOrderedPendingTask(from_here, std::move(task), now_ticks_,
247 delay, next_task_ordinal_++, 247 delay, next_task_ordinal_++,
248 TestPendingTask::NESTABLE)); 248 TestPendingTask::NESTABLE));
249 return true; 249 return true;
250 } 250 }
251 251
252 bool TestMockTimeTaskRunner::PostNonNestableDelayedTask( 252 bool TestMockTimeTaskRunner::PostNonNestableDelayedTask(
253 const tracked_objects::Location& from_here, 253 const tracked_objects::Location& from_here,
254 Closure task, 254 OnceClosure task,
255 TimeDelta delay) { 255 TimeDelta delay) {
256 return PostDelayedTask(from_here, std::move(task), delay); 256 return PostDelayedTask(from_here, std::move(task), delay);
257 } 257 }
258 258
259 bool TestMockTimeTaskRunner::IsElapsingStopped() { 259 bool TestMockTimeTaskRunner::IsElapsingStopped() {
260 return false; 260 return false;
261 } 261 }
262 262
263 void TestMockTimeTaskRunner::OnBeforeSelectingTask() { 263 void TestMockTimeTaskRunner::OnBeforeSelectingTask() {
264 // Empty default implementation. 264 // Empty default implementation.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 // It's safe to remove const and consume |task| here, since |task| is not 318 // It's safe to remove const and consume |task| here, since |task| is not
319 // used for ordering the item. 319 // used for ordering the item.
320 *next_task = std::move(const_cast<TestOrderedPendingTask&>(tasks_.top())); 320 *next_task = std::move(const_cast<TestOrderedPendingTask&>(tasks_.top()));
321 tasks_.pop(); 321 tasks_.pop();
322 return true; 322 return true;
323 } 323 }
324 return false; 324 return false;
325 } 325 }
326 326
327 } // namespace base 327 } // namespace base
OLDNEW
« no previous file with comments | « base/test/test_mock_time_task_runner.h ('k') | base/test/test_pending_task.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698