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

Unified Diff: content/renderer/categorized_worker_pool.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 | « content/renderer/categorized_worker_pool.h ('k') | content/renderer/render_thread_impl_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/categorized_worker_pool.cc
diff --git a/content/renderer/categorized_worker_pool.cc b/content/renderer/categorized_worker_pool.cc
index 8873ad196bab77bfbdd912d430a6d6ad73dc3258..fc89b888fa1ef71f10bb62e0f910b75c6446a342 100644
--- a/content/renderer/categorized_worker_pool.cc
+++ b/content/renderer/categorized_worker_pool.cc
@@ -53,15 +53,15 @@ class CategorizedWorkerPool::CategorizedWorkerPoolSequencedTaskRunner
// Overridden from base::TaskRunner:
bool PostDelayedTask(const tracked_objects::Location& from_here,
- const base::Closure& task,
+ base::Closure task,
base::TimeDelta delay) override {
- return PostNonNestableDelayedTask(from_here, task, delay);
+ return PostNonNestableDelayedTask(from_here, std::move(task), delay);
}
bool RunsTasksOnCurrentThread() const override { return true; }
// Overridden from base::SequencedTaskRunner:
bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
- const base::Closure& task,
+ base::Closure task,
base::TimeDelta delay) override {
base::AutoLock lock(lock_);
@@ -72,7 +72,7 @@ class CategorizedWorkerPool::CategorizedWorkerPoolSequencedTaskRunner
tasks_.erase(tasks_.begin(), tasks_.begin() + completed_tasks_.size());
- tasks_.push_back(make_scoped_refptr(new ClosureTask(task)));
+ tasks_.push_back(make_scoped_refptr(new ClosureTask(std::move(task))));
graph_.Reset();
for (const auto& graph_task : tasks_) {
int dependencies = 0;
@@ -186,7 +186,7 @@ void CategorizedWorkerPool::Shutdown() {
// Overridden from base::TaskRunner:
bool CategorizedWorkerPool::PostDelayedTask(
const tracked_objects::Location& from_here,
- const base::Closure& task,
+ base::Closure task,
base::TimeDelta delay) {
base::AutoLock lock(lock_);
@@ -202,7 +202,7 @@ bool CategorizedWorkerPool::PostDelayedTask(
});
tasks_.erase(end, tasks_.end());
- tasks_.push_back(make_scoped_refptr(new ClosureTask(task)));
+ tasks_.push_back(make_scoped_refptr(new ClosureTask(std::move(task))));
graph_.Reset();
for (const auto& graph_task : tasks_) {
// Delayed tasks are assigned FOREGROUND category, ensuring that they run as
@@ -414,13 +414,12 @@ void CategorizedWorkerPool::SignalHasReadyToRunTasksWithLockAcquired() {
}
}
-CategorizedWorkerPool::ClosureTask::ClosureTask(const base::Closure& closure)
- : closure_(closure) {}
+CategorizedWorkerPool::ClosureTask::ClosureTask(base::Closure closure)
+ : closure_(std::move(closure)) {}
// Overridden from cc::Task:
void CategorizedWorkerPool::ClosureTask::RunOnWorkerThread() {
- closure_.Run();
- closure_.Reset();
+ std::move(closure_).Run();
}
CategorizedWorkerPool::ClosureTask::~ClosureTask() {}
« no previous file with comments | « content/renderer/categorized_worker_pool.h ('k') | content/renderer/render_thread_impl_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698