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

Unified Diff: device/bluetooth/test/bluetooth_test_win.cc

Issue 2627863002: Split Closure part of TestPendingTask out of the struct (Closed)
Patch Set: rebase 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 | « device/bluetooth/test/bluetooth_test_win.h ('k') | extensions/common/one_shot_event_unittest.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..091aa2e12e2eaaf384ea28514df010a525daaebe 100644
--- a/device/bluetooth/test/bluetooth_test_win.cc
+++ b/device/bluetooth/test/bluetooth_test_win.cc
@@ -8,7 +8,7 @@
#include "base/location.h"
#include "base/run_loop.h"
#include "base/strings/sys_string_conversions.h"
-#include "base/test/test_pending_task.h"
+#include "base/test/test_pending_task_info.h"
#include "base/time/time.h"
#include "device/bluetooth/bluetooth_adapter_win.h"
#include "device/bluetooth/bluetooth_low_energy_win.h"
@@ -67,6 +67,12 @@ BTH_LE_UUID CanonicalStringToBTH_LE_UUID(std::string uuid) {
return win_uuid;
}
+// TODO(tzik): Remove this helper once TaskRunner has migrated from Clrosure to
+// OnceClosure.
+void RunOnceClosure(base::OnceClosure closure) {
+ std::move(closure).Run();
+}
+
} // namespace
namespace device {
@@ -471,25 +477,27 @@ win::GattCharacteristic* BluetoothTestWin::GetSimulatedCharacteristic(
}
void BluetoothTestWin::RunPendingTasksUntilCallback() {
- std::deque<base::TestPendingTask> tasks =
- bluetooth_task_runner_->TakePendingTasks();
+ base::TestPendingTaskQueue tasks = bluetooth_task_runner_->TakePendingTasks();
int original_callback_count = callback_count_;
int original_error_callback_count = error_callback_count_;
do {
- base::TestPendingTask task = tasks.front();
+ base::OnceClosure task = std::move(tasks.front().second);
tasks.pop_front();
- task.task.Run();
+ std::move(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) {
- if (task.delay.is_zero()) {
- bluetooth_task_runner_->PostTask(task.location, task.task);
+ for (auto& pending_task : tasks) {
+ const base::TestPendingTaskInfo& task_info = pending_task.first;
+ base::Closure task =
+ base::Bind(&RunOnceClosure, base::Passed(&pending_task.second));
+ if (task_info.delay.is_zero()) {
+ bluetooth_task_runner_->PostTask(task_info.location, task);
} else {
- bluetooth_task_runner_->PostDelayedTask(task.location, task.task,
- task.delay);
+ bluetooth_task_runner_->PostDelayedTask(task_info.location, task,
+ task_info.delay);
}
}
}
« no previous file with comments | « device/bluetooth/test/bluetooth_test_win.h ('k') | extensions/common/one_shot_event_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698