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

Side by Side Diff: base/task_scheduler/test_task_factory.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
« no previous file with comments | « base/task_scheduler/task_unittest.cc ('k') | base/test/launcher/test_launcher.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 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/task_scheduler/test_task_factory.h" 5 #include "base/task_scheduler/test_task_factory.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 19 matching lines...) Expand all
30 30
31 TestTaskFactory::~TestTaskFactory() { 31 TestTaskFactory::~TestTaskFactory() {
32 WaitForAllTasksToRun(); 32 WaitForAllTasksToRun();
33 } 33 }
34 34
35 bool TestTaskFactory::PostTask(PostNestedTask post_nested_task, 35 bool TestTaskFactory::PostTask(PostNestedTask post_nested_task,
36 const Closure& after_task_closure) { 36 const Closure& after_task_closure) {
37 AutoLock auto_lock(lock_); 37 AutoLock auto_lock(lock_);
38 return task_runner_->PostTask( 38 return task_runner_->PostTask(
39 FROM_HERE, 39 FROM_HERE,
40 Bind(&TestTaskFactory::RunTaskCallback, Unretained(this), 40 BindOnce(&TestTaskFactory::RunTaskCallback, Unretained(this),
41 num_posted_tasks_++, post_nested_task, after_task_closure)); 41 num_posted_tasks_++, post_nested_task, after_task_closure));
42 } 42 }
43 43
44 void TestTaskFactory::WaitForAllTasksToRun() const { 44 void TestTaskFactory::WaitForAllTasksToRun() const {
45 AutoLock auto_lock(lock_); 45 AutoLock auto_lock(lock_);
46 while (ran_tasks_.size() < num_posted_tasks_) 46 while (ran_tasks_.size() < num_posted_tasks_)
47 cv_.Wait(); 47 cv_.Wait();
48 } 48 }
49 49
50 void TestTaskFactory::RunTaskCallback(size_t task_index, 50 void TestTaskFactory::RunTaskCallback(size_t task_index,
51 PostNestedTask post_nested_task, 51 PostNestedTask post_nested_task,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 cv_.Signal(); 97 cv_.Signal();
98 } 98 }
99 99
100 if (!after_task_closure.is_null()) 100 if (!after_task_closure.is_null())
101 after_task_closure.Run(); 101 after_task_closure.Run();
102 } 102 }
103 103
104 } // namespace test 104 } // namespace test
105 } // namespace internal 105 } // namespace internal
106 } // namespace base 106 } // namespace base
OLDNEW
« no previous file with comments | « base/task_scheduler/task_unittest.cc ('k') | base/test/launcher/test_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698