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

Unified Diff: third_party/WebKit/Source/platform/scheduler/test/fake_web_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, 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: third_party/WebKit/Source/platform/scheduler/test/fake_web_task_runner.cc
diff --git a/third_party/WebKit/Source/platform/scheduler/test/fake_web_task_runner.cc b/third_party/WebKit/Source/platform/scheduler/test/fake_web_task_runner.cc
index 2358c40f098143fa80ad12185dd7f5539849ca51..57f06bec214e4a49fac78e2f823ed7520aa73df5 100644
--- a/third_party/WebKit/Source/platform/scheduler/test/fake_web_task_runner.cc
+++ b/third_party/WebKit/Source/platform/scheduler/test/fake_web_task_runner.cc
@@ -5,6 +5,7 @@
#include "platform/scheduler/test/fake_web_task_runner.h"
#include <deque>
+#include <utility>
#include "base/callback.h"
#include "base/logging.h"
@@ -46,16 +47,16 @@ class FakeWebTaskRunner::BaseTaskRunner : public base::SingleThreadTaskRunner {
explicit BaseTaskRunner(PassRefPtr<Data> data) : data_(std::move(data)) {}
bool PostDelayedTask(const tracked_objects::Location& from_here,
- const base::Closure& task,
+ base::Closure task,
base::TimeDelta delay) override {
- data_->PostTask(task, delay);
+ data_->PostTask(std::move(task), delay);
return true;
}
bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
- const base::Closure& task,
+ base::Closure task,
base::TimeDelta delay) override {
- data_->PostTask(task, delay);
+ data_->PostTask(std::move(task), delay);
return true;
}
@@ -81,9 +82,10 @@ void FakeWebTaskRunner::setTime(double new_time) {
}
void FakeWebTaskRunner::postDelayedTask(const WebTraceLocation&,
- const base::Closure& closure,
+ base::Closure closure,
double delay_ms) {
- data_->PostTask(closure, base::TimeDelta::FromMillisecondsD(delay_ms));
+ data_->PostTask(std::move(closure),
+ base::TimeDelta::FromMillisecondsD(delay_ms));
}
bool FakeWebTaskRunner::runsTasksOnCurrentThread() {
@@ -108,7 +110,7 @@ void FakeWebTaskRunner::runUntilIdle() {
// task queue by posting a new task.
base::Closure task = std::move(data_->task_queue_.front()).first;
data_->task_queue_.pop_front();
- task.Run();
+ std::move(task).Run();
}
}

Powered by Google App Engine
This is Rietveld 408576698