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

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: 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
« no previous file with comments | « chrome/browser/after_startup_task_utils.cc ('k') | chrome/browser/chrome_content_browser_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..6f3dad83f10d2112bf9a19bbdcf5b672a1459e1f 100644
--- a/chrome/browser/after_startup_task_utils_unittest.cc
+++ b/chrome/browser/after_startup_task_utils_unittest.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/after_startup_task_utils.h"
#include <memory>
+#include <utility>
#include "base/bind.h"
#include "base/bind_helpers.h"
@@ -30,11 +31,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 +58,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();
}
scoped_refptr<TaskRunner> real_task_runner_;
@@ -96,11 +98,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();
}
« no previous file with comments | « chrome/browser/after_startup_task_utils.cc ('k') | chrome/browser/chrome_content_browser_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698