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

Unified Diff: chrome/browser/after_startup_task_utils_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: chrome/browser/after_startup_task_utils_unittest.cc
diff --git a/chrome/browser/after_startup_task_utils_unittest.cc b/chrome/browser/after_startup_task_utils_unittest.cc
index c1433b7211fd2e4bc873df6568bd7d12d718ca79..ff2dfc6382dd5a2deb747f84c5e491566413d19f 100644
--- a/chrome/browser/after_startup_task_utils_unittest.cc
+++ b/chrome/browser/after_startup_task_utils_unittest.cc
@@ -5,9 +5,11 @@
#include "chrome/browser/after_startup_task_utils.h"
#include <memory>
+#include <utility>
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "base/callback_helpers.h"
#include "base/memory/ref_counted.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
@@ -30,11 +32,12 @@ class WrappedTaskRunner : public base::TaskRunner {
: real_task_runner_(real_runner) {}
bool PostDelayedTask(const tracked_objects::Location& from_here,
- const base::Closure& task,
+ base::Closure task,
base::TimeDelta delay) override {
++posted_task_count_;
return real_task_runner_->PostDelayedTask(
- from_here, base::Bind(&WrappedTaskRunner::RunWrappedTask, this, task),
+ from_here,
+ base::Bind(&WrappedTaskRunner::RunWrappedTask, this, std::move(task)),
base::TimeDelta()); // Squash all delays so our tests complete asap.
}
@@ -56,9 +59,9 @@ class WrappedTaskRunner : public base::TaskRunner {
private:
~WrappedTaskRunner() override {}
- void RunWrappedTask(const base::Closure& task) {
+ void RunWrappedTask(base::Closure task) {
++ran_task_count_;
- task.Run();
+ std::move(task).Run();
sky 2017/03/22 17:34:11 ?
}
scoped_refptr<TaskRunner> real_task_runner_;
@@ -96,11 +99,12 @@ class AfterStartupTaskTest : public testing::Test {
void PostAfterStartupTaskFromDBThread(
const tracked_objects::Location& from_here,
const scoped_refptr<base::TaskRunner>& task_runner,
- const base::Closure& task) {
+ base::Closure task) {
RunLoop run_loop;
db_thread_->real_runner()->PostTaskAndReply(
- FROM_HERE, base::Bind(&AfterStartupTaskUtils::PostTask, from_here,
- task_runner, task),
+ FROM_HERE,
+ base::Bind(&AfterStartupTaskUtils::PostTask, from_here, task_runner,
+ std::move(task)),
base::Bind(&RunLoop::Quit, base::Unretained(&run_loop)));
run_loop.Run();
}

Powered by Google App Engine
This is Rietveld 408576698