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

Unified Diff: base/threading/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 | « base/threading/worker_pool.h ('k') | base/threading/worker_pool_posix.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/threading/worker_pool.cc
diff --git a/base/threading/worker_pool.cc b/base/threading/worker_pool.cc
index 6e07b6ef37e3d1b1c47ace828c6384a10061ddf0..a137e305739de037e09e3f1d14269250b199054d 100644
--- a/base/threading/worker_pool.cc
+++ b/base/threading/worker_pool.cc
@@ -26,8 +26,8 @@ class PostTaskAndReplyWorkerPool : public internal::PostTaskAndReplyImpl {
private:
bool PostTask(const tracked_objects::Location& from_here,
- const Closure& task) override {
- return WorkerPool::PostTask(from_here, task, task_is_slow_);
+ OnceClosure task) override {
+ return WorkerPool::PostTask(from_here, std::move(task), task_is_slow_);
}
bool task_is_slow_;
@@ -44,7 +44,7 @@ class WorkerPoolTaskRunner : public TaskRunner {
// TaskRunner implementation
bool PostDelayedTask(const tracked_objects::Location& from_here,
- const Closure& task,
+ OnceClosure task,
TimeDelta delay) override;
bool RunsTasksOnCurrentThread() const override;
@@ -55,7 +55,7 @@ class WorkerPoolTaskRunner : public TaskRunner {
// zero because non-zero delays are not supported.
bool PostDelayedTaskAssertZeroDelay(
const tracked_objects::Location& from_here,
- const Closure& task,
+ OnceClosure task,
base::TimeDelta delay);
const bool tasks_are_slow_;
@@ -72,9 +72,9 @@ WorkerPoolTaskRunner::~WorkerPoolTaskRunner() {
bool WorkerPoolTaskRunner::PostDelayedTask(
const tracked_objects::Location& from_here,
- const Closure& task,
+ OnceClosure task,
TimeDelta delay) {
- return PostDelayedTaskAssertZeroDelay(from_here, task, delay);
+ return PostDelayedTaskAssertZeroDelay(from_here, std::move(task), delay);
}
bool WorkerPoolTaskRunner::RunsTasksOnCurrentThread() const {
@@ -83,11 +83,11 @@ bool WorkerPoolTaskRunner::RunsTasksOnCurrentThread() const {
bool WorkerPoolTaskRunner::PostDelayedTaskAssertZeroDelay(
const tracked_objects::Location& from_here,
- const Closure& task,
+ OnceClosure task,
base::TimeDelta delay) {
DCHECK_EQ(delay.InMillisecondsRoundedUp(), 0)
<< "WorkerPoolTaskRunner does not support non-zero delays";
- return WorkerPool::PostTask(from_here, task, tasks_are_slow_);
+ return WorkerPool::PostTask(from_here, std::move(task), tasks_are_slow_);
}
struct TaskRunnerHolder {
@@ -104,8 +104,8 @@ base::LazyInstance<TaskRunnerHolder>::Leaky
} // namespace
bool WorkerPool::PostTaskAndReply(const tracked_objects::Location& from_here,
- const Closure& task,
- const Closure& reply,
+ OnceClosure task,
+ OnceClosure reply,
bool task_is_slow) {
// Do not report PostTaskAndReplyRelay leaks in tests. There's nothing we can
// do about them because WorkerPool doesn't have a flushing API.
@@ -113,8 +113,8 @@ bool WorkerPool::PostTaskAndReply(const tracked_objects::Location& from_here,
// http://crbug.com/290897
// Note: this annotation does not cover tasks posted through a TaskRunner.
ANNOTATE_SCOPED_MEMORY_LEAK;
- return PostTaskAndReplyWorkerPool(task_is_slow).PostTaskAndReply(
- from_here, task, reply);
+ return PostTaskAndReplyWorkerPool(task_is_slow)
+ .PostTaskAndReply(from_here, std::move(task), std::move(reply));
}
// static
« no previous file with comments | « base/threading/worker_pool.h ('k') | base/threading/worker_pool_posix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698