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

Unified Diff: net/quic/test_tools/test_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 | « net/quic/test_tools/test_task_runner.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/test_tools/test_task_runner.cc
diff --git a/net/quic/test_tools/test_task_runner.cc b/net/quic/test_tools/test_task_runner.cc
index 5e6e647d9c7f98895cb35a41e6507f34f21c871c..3d427710e8f4ce18c7148683d4a72ef6a5f58480 100644
--- a/net/quic/test_tools/test_task_runner.cc
+++ b/net/quic/test_tools/test_task_runner.cc
@@ -20,8 +20,9 @@ bool TestTaskRunner::PostDelayedTask(const tracked_objects::Location& from_here,
const base::Closure& task,
base::TimeDelta delay) {
EXPECT_GE(delay, base::TimeDelta());
- tasks_.push_back(PostedTask(from_here, task, clock_->NowInTicks(), delay,
- base::TestPendingTask::NESTABLE));
+ base::TestPendingTaskInfo task_info(from_here, clock_->NowInTicks(), delay,
+ base::TestPendingTaskInfo::NESTABLE);
+ tasks_.push_back(std::make_pair(task_info, task));
return false;
}
@@ -38,18 +39,20 @@ void TestTaskRunner::RunNextTask() {
// and then run the task.
std::vector<PostedTask>::iterator next = FindNextTask();
DCHECK(next != tasks_.end());
+
+ const base::TestPendingTaskInfo& task_info = next->first;
clock_->AdvanceTime(QuicTime::Delta::FromMicroseconds(
- (next->GetTimeToRun() - clock_->NowInTicks()).InMicroseconds()));
- PostedTask task = *next;
+ (task_info.GetTimeToRun() - clock_->NowInTicks()).InMicroseconds()));
+ base::OnceClosure task = std::move(next->second);
tasks_.erase(next);
- task.task.Run();
+ std::move(task).Run();
}
namespace {
struct ShouldRunBeforeLessThan {
bool operator()(const PostedTask& task1, const PostedTask& task2) const {
- return task1.ShouldRunBefore(task2);
+ return task1.first.ShouldRunBefore(task2.first);
}
};
« no previous file with comments | « net/quic/test_tools/test_task_runner.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698