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

Unified Diff: device/bluetooth/test/bluetooth_test_win.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/test/ordered_simple_task_runner_unittest.cc ('k') | net/quic/test_tools/test_task_runner.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/test/bluetooth_test_win.cc
diff --git a/device/bluetooth/test/bluetooth_test_win.cc b/device/bluetooth/test/bluetooth_test_win.cc
index 5bbdebfc4dbb43ccb46b0a48927b5ba7677c92e1..63c2ad0c3dd755fbc478e8a6257ada9c379955ae 100644
--- a/device/bluetooth/test/bluetooth_test_win.cc
+++ b/device/bluetooth/test/bluetooth_test_win.cc
@@ -18,6 +18,10 @@
namespace {
+void RunOnceClosure(base::OnceClosure closure) {
+ std::move(closure).Run();
+}
+
BLUETOOTH_ADDRESS CanonicalStringToBLUETOOTH_ADDRESS(
std::string device_address) {
BLUETOOTH_ADDRESS win_addr;
@@ -476,20 +480,24 @@ void BluetoothTestWin::RunPendingTasksUntilCallback() {
int original_callback_count = callback_count_;
int original_error_callback_count = error_callback_count_;
do {
- base::TestPendingTask task = tasks.front();
+ base::TestPendingTask task = std::move(tasks.front());
tasks.pop_front();
- task.task.Run();
+ std::move(task.task).Run();
base::RunLoop().RunUntilIdle();
} while (tasks.size() && callback_count_ == original_callback_count &&
error_callback_count_ == original_error_callback_count);
// Put the rest of pending tasks back to Bluetooth task runner.
- for (const auto& task : tasks) {
+ for (auto& task : tasks) {
+ // TODO(tzik): Remove RunOnceClosure once TaskRunner migrates from Closure
+ // to OnceClosure.
if (task.delay.is_zero()) {
- bluetooth_task_runner_->PostTask(task.location, task.task);
+ bluetooth_task_runner_->PostTask(
+ task.location, base::Bind(&RunOnceClosure, base::Passed(&task.task)));
} else {
- bluetooth_task_runner_->PostDelayedTask(task.location, task.task,
- task.delay);
+ bluetooth_task_runner_->PostDelayedTask(
+ task.location, base::Bind(&RunOnceClosure, base::Passed(&task.task)),
+ task.delay);
}
}
}
« no previous file with comments | « cc/test/ordered_simple_task_runner_unittest.cc ('k') | net/quic/test_tools/test_task_runner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698