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

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: 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: 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..87041d80ad87dcfbd64eaa3c799d53c1785dd1af 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,8 +5,10 @@
#include "platform/scheduler/test/fake_web_task_runner.h"
#include <deque>
+#include <utility>
#include "base/callback.h"
+#include "base/callback_helpers.h"
#include "base/logging.h"
#include "base/single_thread_task_runner.h"
#include "wtf/RefCounted.h"
@@ -46,16 +48,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 +83,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 +111,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