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

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

Issue 2434783002: Use OnceClosure in TestPendingTask (Closed)
Patch Set: +comment Created 3 years, 11 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_pending_task.cc ('k') | cc/base/delayed_unique_notifier_unittest.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 (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 #include "base/test/test_simple_task_runner.h" 5 #include "base/test/test_simple_task_runner.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace base { 9 namespace base {
10 10
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 void TestSimpleTaskRunner::RunPendingTasks() { 71 void TestSimpleTaskRunner::RunPendingTasks() {
72 DCHECK(RunsTasksOnCurrentThread()); 72 DCHECK(RunsTasksOnCurrentThread());
73 73
74 // Swap with a local variable to avoid re-entrancy problems. 74 // Swap with a local variable to avoid re-entrancy problems.
75 std::deque<TestPendingTask> tasks_to_run; 75 std::deque<TestPendingTask> tasks_to_run;
76 { 76 {
77 AutoLock auto_lock(lock_); 77 AutoLock auto_lock(lock_);
78 tasks_to_run.swap(pending_tasks_); 78 tasks_to_run.swap(pending_tasks_);
79 } 79 }
80 80
81 for (const auto& task : tasks_to_run) 81 for (auto& task : tasks_to_run)
82 task.task.Run(); 82 std::move(task.task).Run();
83 } 83 }
84 84
85 void TestSimpleTaskRunner::RunUntilIdle() { 85 void TestSimpleTaskRunner::RunUntilIdle() {
86 while (!pending_tasks_.empty()) { 86 while (!pending_tasks_.empty()) {
87 RunPendingTasks(); 87 RunPendingTasks();
88 } 88 }
89 } 89 }
90 90
91 } // namespace base 91 } // namespace base
OLDNEW
« no previous file with comments | « base/test/test_pending_task.cc ('k') | cc/base/delayed_unique_notifier_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698