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

Unified Diff: chrome/browser/after_startup_task_utils.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.h ('k') | chrome/browser/after_startup_task_utils_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/after_startup_task_utils.cc
diff --git a/chrome/browser/after_startup_task_utils.cc b/chrome/browser/after_startup_task_utils.cc
index c5c29e8b8cb599f7305a2df9b0a82abce8dd1e7c..e024a945968ccb901ceabca657df8747f36288c3 100644
--- a/chrome/browser/after_startup_task_utils.cc
+++ b/chrome/browser/after_startup_task_utils.cc
@@ -34,13 +34,13 @@ namespace {
struct AfterStartupTask {
AfterStartupTask(const tracked_objects::Location& from_here,
const scoped_refptr<base::TaskRunner>& task_runner,
- const base::Closure& task)
- : from_here(from_here), task_runner(task_runner), task(task) {}
+ base::Closure task)
+ : from_here(from_here), task_runner(task_runner), task(std::move(task)) {}
~AfterStartupTask() {}
const tracked_objects::Location from_here;
const scoped_refptr<base::TaskRunner> task_runner;
- const base::Closure task;
+ base::Closure task;
};
// The flag may be read on any thread, but must only be set on the UI thread.
@@ -60,7 +60,7 @@ bool IsBrowserStartupComplete() {
void RunTask(std::unique_ptr<AfterStartupTask> queued_task) {
// We're careful to delete the caller's |task| on the target runner's thread.
DCHECK(queued_task->task_runner->RunsTasksOnCurrentThread());
- queued_task->task.Run();
+ std::move(queued_task->task).Run();
}
void ScheduleTask(std::unique_ptr<AfterStartupTask> queued_task) {
@@ -202,10 +202,11 @@ AfterStartupTaskUtils::Runner::~Runner() = default;
bool AfterStartupTaskUtils::Runner::PostDelayedTask(
const tracked_objects::Location& from_here,
- const base::Closure& task,
+ base::Closure task,
base::TimeDelta delay) {
DCHECK(delay.is_zero());
- AfterStartupTaskUtils::PostTask(from_here, destination_runner_, task);
+ AfterStartupTaskUtils::PostTask(from_here, destination_runner_,
+ std::move(task));
return true;
}
@@ -221,14 +222,14 @@ void AfterStartupTaskUtils::StartMonitoringStartup() {
void AfterStartupTaskUtils::PostTask(
const tracked_objects::Location& from_here,
const scoped_refptr<base::TaskRunner>& destination_runner,
- const base::Closure& task) {
+ base::Closure task) {
if (IsBrowserStartupComplete()) {
- destination_runner->PostTask(from_here, task);
+ destination_runner->PostTask(from_here, std::move(task));
return;
}
std::unique_ptr<AfterStartupTask> queued_task(
- new AfterStartupTask(from_here, destination_runner, task));
+ new AfterStartupTask(from_here, destination_runner, std::move(task)));
QueueTask(std::move(queued_task));
}
« no previous file with comments | « chrome/browser/after_startup_task_utils.h ('k') | chrome/browser/after_startup_task_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698