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

Unified Diff: base/test/test_mock_time_task_runner.cc

Issue 2726523002: Pass Callback to TaskRunner by value and consume it on invocation (1) (Closed)
Patch Set: s/base::ResetAndReturn/std::move/ Created 3 years, 9 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
Index: base/test/test_mock_time_task_runner.cc
diff --git a/base/test/test_mock_time_task_runner.cc b/base/test/test_mock_time_task_runner.cc
index f4bd7244b4decc0c2bc66661bd2369fb9c0394e5..a4311892319db29d599cc36bc45fea17aa3d02f0 100644
--- a/base/test/test_mock_time_task_runner.cc
+++ b/base/test/test_mock_time_task_runner.cc
@@ -4,6 +4,8 @@
#include "base/test/test_mock_time_task_runner.h"
+#include <utility>
+
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
@@ -79,7 +81,7 @@ struct TestMockTimeTaskRunner::TestOrderedPendingTask
: public base::TestPendingTask {
TestOrderedPendingTask();
TestOrderedPendingTask(const tracked_objects::Location& location,
- const Closure& task,
+ Closure task,
TimeTicks post_time,
TimeDelta delay,
size_t ordinal,
@@ -104,12 +106,16 @@ TestMockTimeTaskRunner::TestOrderedPendingTask::TestOrderedPendingTask(
TestMockTimeTaskRunner::TestOrderedPendingTask::TestOrderedPendingTask(
const tracked_objects::Location& location,
- const Closure& task,
+ Closure task,
TimeTicks post_time,
TimeDelta delay,
size_t ordinal,
TestNestability nestability)
- : base::TestPendingTask(location, task, post_time, delay, nestability),
+ : base::TestPendingTask(location,
+ std::move(task),
+ post_time,
+ delay,
+ nestability),
ordinal(ordinal) {}
TestMockTimeTaskRunner::TestOrderedPendingTask::~TestOrderedPendingTask() {
@@ -234,20 +240,20 @@ bool TestMockTimeTaskRunner::RunsTasksOnCurrentThread() const {
bool TestMockTimeTaskRunner::PostDelayedTask(
const tracked_objects::Location& from_here,
- const Closure& task,
+ Closure task,
TimeDelta delay) {
AutoLock scoped_lock(tasks_lock_);
- tasks_.push(TestOrderedPendingTask(from_here, task, now_ticks_, delay,
- next_task_ordinal_++,
+ tasks_.push(TestOrderedPendingTask(from_here, std::move(task), now_ticks_,
+ delay, next_task_ordinal_++,
TestPendingTask::NESTABLE));
return true;
}
bool TestMockTimeTaskRunner::PostNonNestableDelayedTask(
const tracked_objects::Location& from_here,
- const Closure& task,
+ Closure task,
TimeDelta delay) {
- return PostDelayedTask(from_here, task, delay);
+ return PostDelayedTask(from_here, std::move(task), delay);
}
bool TestMockTimeTaskRunner::IsElapsingStopped() {

Powered by Google App Engine
This is Rietveld 408576698