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

Unified Diff: base/task_scheduler/scheduler_single_thread_task_runner_manager.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/task_scheduler/scheduler_single_thread_task_runner_manager.cc
diff --git a/base/task_scheduler/scheduler_single_thread_task_runner_manager.cc b/base/task_scheduler/scheduler_single_thread_task_runner_manager.cc
index 6a2676fb49b9e20bb8f06ea8b52a4839a76a8922..f0f846cddb7135ed7b7e1a558071ab10d6dca121 100644
--- a/base/task_scheduler/scheduler_single_thread_task_runner_manager.cc
+++ b/base/task_scheduler/scheduler_single_thread_task_runner_manager.cc
@@ -7,6 +7,7 @@
#include <algorithm>
#include <memory>
#include <string>
+#include <utility>
#include "base/bind.h"
#include "base/callback.h"
@@ -147,9 +148,9 @@ class SchedulerSingleThreadTaskRunnerManager::SchedulerSingleThreadTaskRunner
// SingleThreadTaskRunner:
bool PostDelayedTask(const tracked_objects::Location& from_here,
- const Closure& closure,
+ Closure closure,
TimeDelta delay) override {
- auto task = MakeUnique<Task>(from_here, closure, traits_, delay);
+ auto task = MakeUnique<Task>(from_here, std::move(closure), traits_, delay);
task->single_thread_task_runner_ref = this;
if (!outer_->task_tracker_->WillPostTask(task.get()))
@@ -166,10 +167,10 @@ class SchedulerSingleThreadTaskRunnerManager::SchedulerSingleThreadTaskRunner
}
bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
- const Closure& closure,
+ Closure closure,
base::TimeDelta delay) override {
// Tasks are never nested within the task scheduler.
- return PostDelayedTask(from_here, closure, delay);
+ return PostDelayedTask(from_here, std::move(closure), delay);
}
bool RunsTasksOnCurrentThread() const override {

Powered by Google App Engine
This is Rietveld 408576698