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

Side by Side Diff: net/quic/test_tools/test_task_runner.cc

Issue 2726523002: Pass Callback to TaskRunner by value and consume it on invocation (1) (Closed)
Patch Set: erase Closure* 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 | « net/quic/test_tools/test_task_runner.h ('k') | remoting/base/auto_thread_task_runner.h » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/quic/test_tools/test_task_runner.h" 5 #include "net/quic/test_tools/test_task_runner.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility>
8 9
9 #include "net/quic/test_tools/mock_clock.h" 10 #include "net/quic/test_tools/mock_clock.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 12
12 namespace net { 13 namespace net {
13 namespace test { 14 namespace test {
14 15
15 TestTaskRunner::TestTaskRunner(MockClock* clock) : clock_(clock) {} 16 TestTaskRunner::TestTaskRunner(MockClock* clock) : clock_(clock) {}
16 17
17 TestTaskRunner::~TestTaskRunner() {} 18 TestTaskRunner::~TestTaskRunner() {}
18 19
19 bool TestTaskRunner::PostDelayedTask(const tracked_objects::Location& from_here, 20 bool TestTaskRunner::PostDelayedTask(const tracked_objects::Location& from_here,
20 const base::Closure& task, 21 base::Closure task,
21 base::TimeDelta delay) { 22 base::TimeDelta delay) {
22 EXPECT_GE(delay, base::TimeDelta()); 23 EXPECT_GE(delay, base::TimeDelta());
23 tasks_.push_back(PostedTask(from_here, task, clock_->NowInTicks(), delay, 24 tasks_.push_back(PostedTask(from_here, std::move(task), clock_->NowInTicks(),
24 base::TestPendingTask::NESTABLE)); 25 delay, base::TestPendingTask::NESTABLE));
25 return false; 26 return false;
26 } 27 }
27 28
28 bool TestTaskRunner::RunsTasksOnCurrentThread() const { 29 bool TestTaskRunner::RunsTasksOnCurrentThread() const {
29 return true; 30 return true;
30 } 31 }
31 32
32 const std::vector<PostedTask>& TestTaskRunner::GetPostedTasks() const { 33 const std::vector<PostedTask>& TestTaskRunner::GetPostedTasks() const {
33 return tasks_; 34 return tasks_;
34 } 35 }
(...skipping 20 matching lines...) Expand all
55 56
56 } // namespace 57 } // namespace
57 58
58 std::vector<PostedTask>::iterator TestTaskRunner::FindNextTask() { 59 std::vector<PostedTask>::iterator TestTaskRunner::FindNextTask() {
59 return std::min_element(tasks_.begin(), tasks_.end(), 60 return std::min_element(tasks_.begin(), tasks_.end(),
60 ShouldRunBeforeLessThan()); 61 ShouldRunBeforeLessThan());
61 } 62 }
62 63
63 } // namespace test 64 } // namespace test
64 } // namespace net 65 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/test_task_runner.h ('k') | remoting/base/auto_thread_task_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698