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

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

Issue 2791243002: Rewrite base::Bind into base::BindOnce on trivial cases in base (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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/scoped_task_scheduler.h" 5 #include "base/test/scoped_task_scheduler.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 // TestTaskScheduler doesn't create threads so this does nothing. 229 // TestTaskScheduler doesn't create threads so this does nothing.
230 } 230 }
231 231
232 bool TestTaskScheduler::PostTask(std::unique_ptr<internal::Task> task, 232 bool TestTaskScheduler::PostTask(std::unique_ptr<internal::Task> task,
233 const SequenceToken& sequence_token) { 233 const SequenceToken& sequence_token) {
234 DCHECK(task); 234 DCHECK(task);
235 if (!task_tracker_.WillPostTask(task.get())) 235 if (!task_tracker_.WillPostTask(task.get()))
236 return false; 236 return false;
237 internal::Task* const task_ptr = task.get(); 237 internal::Task* const task_ptr = task.get();
238 return MessageLoopTaskRunner()->PostDelayedTask( 238 return MessageLoopTaskRunner()->PostDelayedTask(
239 task_ptr->posted_from, Bind(&TestTaskScheduler::RunTask, Unretained(this), 239 task_ptr->posted_from,
240 Passed(&task), sequence_token), 240 BindOnce(&TestTaskScheduler::RunTask, Unretained(this), Passed(&task),
241 sequence_token),
241 task_ptr->delay); 242 task_ptr->delay);
242 } 243 }
243 244
244 void TestTaskScheduler::RunTask(std::unique_ptr<internal::Task> task, 245 void TestTaskScheduler::RunTask(std::unique_ptr<internal::Task> task,
245 const SequenceToken& sequence_token) { 246 const SequenceToken& sequence_token) {
246 DCHECK(!saved_task_runner_); 247 DCHECK(!saved_task_runner_);
247 saved_task_runner_ = MessageLoop::current()->task_runner(); 248 saved_task_runner_ = MessageLoop::current()->task_runner();
248 249
249 // Clear the MessageLoop TaskRunner to allow TaskTracker to register its own 250 // Clear the MessageLoop TaskRunner to allow TaskTracker to register its own
250 // Thread/SequencedTaskRunnerHandle as appropriate. 251 // Thread/SequencedTaskRunnerHandle as appropriate.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 DCHECK_EQ(task_scheduler_, TaskScheduler::GetInstance()); 323 DCHECK_EQ(task_scheduler_, TaskScheduler::GetInstance());
323 324
324 // Per contract, call JoinForTesting() before deleting the TaskScheduler. 325 // Per contract, call JoinForTesting() before deleting the TaskScheduler.
325 TaskScheduler::GetInstance()->JoinForTesting(); 326 TaskScheduler::GetInstance()->JoinForTesting();
326 327
327 TaskScheduler::SetInstance(nullptr); 328 TaskScheduler::SetInstance(nullptr);
328 } 329 }
329 330
330 } // namespace test 331 } // namespace test
331 } // namespace base 332 } // namespace base
OLDNEW
« no previous file with comments | « base/test/scoped_mock_time_message_loop_task_runner.cc ('k') | base/test/scoped_task_scheduler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698