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

Unified Diff: base/test/test_simple_task_runner.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 | « base/test/test_simple_task_runner.h ('k') | cc/base/delayed_unique_notifier_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/test_simple_task_runner.cc
diff --git a/base/test/test_simple_task_runner.cc b/base/test/test_simple_task_runner.cc
index 94d8e4834a3b7641296522021cbca850c6a95404..06d87381ee62419b16c4870cb1e0ddaf82421452 100644
--- a/base/test/test_simple_task_runner.cc
+++ b/base/test/test_simple_task_runner.cc
@@ -17,9 +17,9 @@ bool TestSimpleTaskRunner::PostDelayedTask(
const Closure& task,
TimeDelta delay) {
AutoLock auto_lock(lock_);
- pending_tasks_.push_back(
- TestPendingTask(from_here, task, TimeTicks(), delay,
- TestPendingTask::NESTABLE));
+ TestPendingTaskInfo task_info(from_here, TimeTicks(), delay,
+ TestPendingTaskInfo::NESTABLE);
+ pending_tasks_.push_back(std::make_pair(task_info, task));
return true;
}
@@ -28,9 +28,9 @@ bool TestSimpleTaskRunner::PostNonNestableDelayedTask(
const Closure& task,
TimeDelta delay) {
AutoLock auto_lock(lock_);
- pending_tasks_.push_back(
- TestPendingTask(from_here, task, TimeTicks(), delay,
- TestPendingTask::NON_NESTABLE));
+ TestPendingTaskInfo task_info(from_here, TimeTicks(), delay,
+ TestPendingTaskInfo::NON_NESTABLE);
+ pending_tasks_.push_back(std::make_pair(task_info, task));
return true;
}
@@ -38,7 +38,7 @@ bool TestSimpleTaskRunner::RunsTasksOnCurrentThread() const {
return thread_ref_ == PlatformThread::CurrentRef();
}
-std::deque<TestPendingTask> TestSimpleTaskRunner::TakePendingTasks() {
+TestPendingTaskQueue TestSimpleTaskRunner::TakePendingTasks() {
AutoLock auto_lock(lock_);
return std::move(pending_tasks_);
}
@@ -55,12 +55,14 @@ bool TestSimpleTaskRunner::HasPendingTask() const {
base::TimeDelta TestSimpleTaskRunner::NextPendingTaskDelay() const {
AutoLock auto_lock(lock_);
- return pending_tasks_.front().GetTimeToRun() - base::TimeTicks();
+ const TestPendingTaskInfo& task_info = pending_tasks_.front().first;
+ return task_info.GetTimeToRun() - base::TimeTicks();
}
base::TimeDelta TestSimpleTaskRunner::FinalPendingTaskDelay() const {
AutoLock auto_lock(lock_);
- return pending_tasks_.back().GetTimeToRun() - base::TimeTicks();
+ const TestPendingTaskInfo& task_info = pending_tasks_.back().first;
+ return task_info.GetTimeToRun() - base::TimeTicks();
}
void TestSimpleTaskRunner::ClearPendingTasks() {
@@ -72,14 +74,14 @@ void TestSimpleTaskRunner::RunPendingTasks() {
DCHECK(RunsTasksOnCurrentThread());
// Swap with a local variable to avoid re-entrancy problems.
- std::deque<TestPendingTask> tasks_to_run;
+ TestPendingTaskQueue tasks_to_run;
{
AutoLock auto_lock(lock_);
tasks_to_run.swap(pending_tasks_);
}
- for (const auto& task : tasks_to_run)
- task.task.Run();
+ for (auto& task : tasks_to_run)
+ std::move(task.second).Run();
}
void TestSimpleTaskRunner::RunUntilIdle() {
« no previous file with comments | « base/test/test_simple_task_runner.h ('k') | cc/base/delayed_unique_notifier_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698