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

Unified Diff: content/child/worker_thread_registry.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/child/worker_thread_registry.h ('k') | content/public/browser/browser_thread.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/worker_thread_registry.cc
diff --git a/content/child/worker_thread_registry.cc b/content/child/worker_thread_registry.cc
index cba10759f5c4fd197a323607ef095aa7b6801d0b..26d7b18b32032fb52eb89c2fcc55fa3f866f7bb0 100644
--- a/content/child/worker_thread_registry.cc
+++ b/content/child/worker_thread_registry.cc
@@ -5,8 +5,8 @@
#include "content/child/worker_thread_registry.h"
#include <memory>
+#include <utility>
-#include "base/callback.h"
#include "base/lazy_instance.h"
#include "base/location.h"
#include "base/logging.h"
@@ -38,7 +38,7 @@ class DoNothingTaskRunner : public base::TaskRunner {
~DoNothingTaskRunner() override {}
bool PostDelayedTask(const tracked_objects::Location& from_here,
- const base::Closure& task,
+ base::Closure task,
base::TimeDelta delay) override {
return false;
}
@@ -56,8 +56,8 @@ int WorkerThread::GetCurrentId() {
return base::PlatformThread::CurrentId();
}
-void WorkerThread::PostTask(int id, const base::Closure& task) {
- WorkerThreadRegistry::Instance()->PostTask(id, task);
+void WorkerThread::PostTask(int id, base::Closure task) {
+ WorkerThreadRegistry::Instance()->PostTask(id, std::move(task));
}
void WorkerThread::AddObserver(Observer* observer) {
@@ -79,10 +79,10 @@ void WorkerThread::RemoveObserver(Observer* observer) {
WorkerThreadRegistry::WorkerThreadRegistry()
: task_runner_for_dead_worker_(new DoNothingTaskRunner()) {}
-int WorkerThreadRegistry::PostTaskToAllThreads(const base::Closure& closure) {
+int WorkerThreadRegistry::PostTaskToAllThreads(base::Closure closure) {
base::AutoLock locker(task_runner_map_lock_);
for (const auto& it : task_runner_map_)
- it.second->PostTask(FROM_HERE, closure);
+ it.second->PostTask(FROM_HERE, std::move(closure));
return static_cast<int>(task_runner_map_.size());
}
@@ -125,13 +125,13 @@ base::TaskRunner* WorkerThreadRegistry::GetTaskRunnerFor(int worker_id) {
: task_runner_for_dead_worker_.get();
}
-bool WorkerThreadRegistry::PostTask(int id, const base::Closure& closure) {
+bool WorkerThreadRegistry::PostTask(int id, base::Closure closure) {
DCHECK(id > 0);
base::AutoLock locker(task_runner_map_lock_);
IDToTaskRunnerMap::iterator found = task_runner_map_.find(id);
if (found == task_runner_map_.end())
return false;
- return found->second->PostTask(FROM_HERE, closure);
+ return found->second->PostTask(FROM_HERE, std::move(closure));
}
} // namespace content
« no previous file with comments | « content/child/worker_thread_registry.h ('k') | content/public/browser/browser_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698