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

Unified Diff: mojo/public/cpp/bindings/tests/bind_task_runner_unittest.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: mojo/public/cpp/bindings/tests/bind_task_runner_unittest.cc
diff --git a/mojo/public/cpp/bindings/tests/bind_task_runner_unittest.cc b/mojo/public/cpp/bindings/tests/bind_task_runner_unittest.cc
index 0c777ec410e8eccebb6f04a58a9f699177de26b4..757ed5e55be5c3be1d3ccb210bbb934815dde243 100644
--- a/mojo/public/cpp/bindings/tests/bind_task_runner_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/bind_task_runner_unittest.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <utility>
+
#include "base/bind.h"
#include "base/callback.h"
#include "base/message_loop/message_loop.h"
@@ -30,18 +32,18 @@ class TestTaskRunner : public base::SingleThreadTaskRunner {
base::WaitableEvent::InitialState::NOT_SIGNALED) {}
bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
- const base::Closure& task,
+ base::Closure task,
base::TimeDelta delay) override {
NOTREACHED();
return false;
}
bool PostDelayedTask(const tracked_objects::Location& from_here,
- const base::Closure& task,
+ base::Closure task,
base::TimeDelta delay) override {
{
base::AutoLock locker(lock_);
- tasks_.push(task);
+ tasks_.push(std::move(task));
}
task_ready_.Signal();
return true;
@@ -59,12 +61,12 @@ class TestTaskRunner : public base::SingleThreadTaskRunner {
{
base::AutoLock locker(lock_);
while (!tasks_.empty()) {
- auto task = tasks_.front();
+ auto task = std::move(tasks_.front());
tasks_.pop();
{
base::AutoUnlock unlocker(lock_);
- task.Run();
+ std::move(task).Run();
sky 2017/03/22 17:34:11 Is the std::move(task) really necessary?
if (quit_called_)
return;
}
@@ -87,12 +89,12 @@ class TestTaskRunner : public base::SingleThreadTaskRunner {
{
base::AutoLock locker(lock_);
if (!tasks_.empty()) {
- auto task = tasks_.front();
+ auto task = std::move(tasks_.front());
tasks_.pop();
{
base::AutoUnlock unlocker(lock_);
- task.Run();
+ std::move(task).Run();
sky 2017/03/22 17:34:11 Similar comment about the need for std::move(task)
return;
}
}

Powered by Google App Engine
This is Rietveld 408576698