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

Unified Diff: content/renderer/categorized_worker_pool.cc

Issue 2122543002: Replace Closure in TaskRunner::PostTask with OneShotCallback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@07_oneshot
Patch Set: fix Created 4 years, 3 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 47298b3b8ecd11ade943fabbcff164a0f925baf3..0927573f9589efe4178543638aba1f7fe617ab50 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::OnceClosure 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::OnceClosure 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::OnceClosure 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
@@ -415,13 +415,12 @@ void CategorizedWorkerPool::SignalHasReadyToRunTasksWithLockAcquired() {
}
}
-CategorizedWorkerPool::ClosureTask::ClosureTask(const base::Closure& closure)
- : closure_(closure) {}
+CategorizedWorkerPool::ClosureTask::ClosureTask(base::OnceClosure 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