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

Unified Diff: content/browser/browser_thread_impl.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/browser/browser_thread_impl.h ('k') | content/browser/compositor/reflector_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/browser_thread_impl.cc
diff --git a/content/browser/browser_thread_impl.cc b/content/browser/browser_thread_impl.cc
index 895fba219d74d755af9da7bd47394e3e62351e4d..f4e03833b91ebea808e9695334eb4091be856967 100644
--- a/content/browser/browser_thread_impl.cc
+++ b/content/browser/browser_thread_impl.cc
@@ -62,16 +62,17 @@ class BrowserThreadTaskRunner : public base::SingleThreadTaskRunner {
// SingleThreadTaskRunner implementation.
bool PostDelayedTask(const tracked_objects::Location& from_here,
- const base::Closure& task,
+ base::Closure task,
base::TimeDelta delay) override {
- return BrowserThread::PostDelayedTask(id_, from_here, task, delay);
+ return BrowserThread::PostDelayedTask(id_, from_here, std::move(task),
+ delay);
}
bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
- const base::Closure& task,
+ base::Closure task,
base::TimeDelta delay) override {
- return BrowserThread::PostNonNestableDelayedTask(id_, from_here, task,
- delay);
+ return BrowserThread::PostNonNestableDelayedTask(id_, from_here,
+ std::move(task), delay);
}
bool RunsTasksOnCurrentThread() const override {
@@ -489,7 +490,7 @@ void BrowserThreadImpl::StopRedirectionOfThreadID(
bool BrowserThreadImpl::PostTaskHelper(
BrowserThread::ID identifier,
const tracked_objects::Location& from_here,
- const base::Closure& task,
+ base::Closure task,
base::TimeDelta delay,
bool nestable) {
DCHECK_GE(identifier, 0);
@@ -517,9 +518,10 @@ bool BrowserThreadImpl::PostTaskHelper(
globals.task_runners[identifier].get();
DCHECK(task_runner);
if (nestable) {
- task_runner->PostDelayedTask(from_here, task, delay);
+ task_runner->PostDelayedTask(from_here, std::move(task), delay);
} else {
- task_runner->PostNonNestableDelayedTask(from_here, task, delay);
+ task_runner->PostNonNestableDelayedTask(from_here, std::move(task),
+ delay);
}
}
@@ -532,8 +534,9 @@ bool BrowserThreadImpl::PostTaskHelper(
// static
bool BrowserThread::PostBlockingPoolTask(
const tracked_objects::Location& from_here,
- const base::Closure& task) {
- return g_globals.Get().blocking_pool->PostWorkerTask(from_here, task);
+ base::Closure task) {
+ return g_globals.Get().blocking_pool->PostWorkerTask(from_here,
+ std::move(task));
}
// static
@@ -549,18 +552,18 @@ bool BrowserThread::PostBlockingPoolTaskAndReply(
bool BrowserThread::PostBlockingPoolSequencedTask(
const std::string& sequence_token_name,
const tracked_objects::Location& from_here,
- const base::Closure& task) {
+ base::Closure task) {
return g_globals.Get().blocking_pool->PostNamedSequencedWorkerTask(
- sequence_token_name, from_here, task);
+ sequence_token_name, from_here, std::move(task));
}
// static
void BrowserThread::PostAfterStartupTask(
const tracked_objects::Location& from_here,
const scoped_refptr<base::TaskRunner>& task_runner,
- const base::Closure& task) {
+ base::Closure task) {
GetContentClient()->browser()->PostAfterStartupTask(from_here, task_runner,
- task);
+ std::move(task));
}
// static
@@ -620,37 +623,37 @@ bool BrowserThread::IsMessageLoopValid(ID identifier) {
// static
bool BrowserThread::PostTask(ID identifier,
const tracked_objects::Location& from_here,
- const base::Closure& task) {
+ base::Closure task) {
return BrowserThreadImpl::PostTaskHelper(
- identifier, from_here, task, base::TimeDelta(), true);
+ identifier, from_here, std::move(task), base::TimeDelta(), true);
}
// static
bool BrowserThread::PostDelayedTask(ID identifier,
const tracked_objects::Location& from_here,
- const base::Closure& task,
+ base::Closure task,
base::TimeDelta delay) {
- return BrowserThreadImpl::PostTaskHelper(
- identifier, from_here, task, delay, true);
+ return BrowserThreadImpl::PostTaskHelper(identifier, from_here,
+ std::move(task), delay, true);
}
// static
bool BrowserThread::PostNonNestableTask(
ID identifier,
const tracked_objects::Location& from_here,
- const base::Closure& task) {
+ base::Closure task) {
return BrowserThreadImpl::PostTaskHelper(
- identifier, from_here, task, base::TimeDelta(), false);
+ identifier, from_here, std::move(task), base::TimeDelta(), false);
}
// static
bool BrowserThread::PostNonNestableDelayedTask(
ID identifier,
const tracked_objects::Location& from_here,
- const base::Closure& task,
+ base::Closure task,
base::TimeDelta delay) {
- return BrowserThreadImpl::PostTaskHelper(
- identifier, from_here, task, delay, false);
+ return BrowserThreadImpl::PostTaskHelper(identifier, from_here,
+ std::move(task), delay, false);
}
// static
« no previous file with comments | « content/browser/browser_thread_impl.h ('k') | content/browser/compositor/reflector_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698