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

Unified Diff: ios/web/web_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 | « ios/web/web_thread_impl.h ('k') | media/base/fake_single_thread_task_runner.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/web_thread_impl.cc
diff --git a/ios/web/web_thread_impl.cc b/ios/web/web_thread_impl.cc
index eaab3d9e3ff54132b15fa085a3400fa303df422b..d03e29dfb37d28ec6cca0b6b3ee33858aed81e85 100644
--- a/ios/web/web_thread_impl.cc
+++ b/ios/web/web_thread_impl.cc
@@ -49,15 +49,16 @@ class WebThreadTaskRunner : 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 WebThread::PostDelayedTask(id_, from_here, task, delay);
+ return WebThread::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 WebThread::PostNonNestableDelayedTask(id_, from_here, task, delay);
+ return WebThread::PostNonNestableDelayedTask(id_, from_here,
+ std::move(task), delay);
}
bool RunsTasksOnCurrentThread() const override {
@@ -290,7 +291,7 @@ WebThreadImpl::~WebThreadImpl() {
// static
bool WebThreadImpl::PostTaskHelper(WebThread::ID identifier,
const tracked_objects::Location& from_here,
- const base::Closure& task,
+ base::Closure task,
base::TimeDelta delay,
bool nestable) {
DCHECK(identifier >= 0 && identifier < ID_COUNT);
@@ -314,10 +315,11 @@ bool WebThreadImpl::PostTaskHelper(WebThread::ID identifier,
: nullptr;
if (message_loop) {
if (nestable) {
- message_loop->task_runner()->PostDelayedTask(from_here, task, delay);
+ message_loop->task_runner()->PostDelayedTask(from_here, std::move(task),
+ delay);
} else {
- message_loop->task_runner()->PostNonNestableDelayedTask(from_here, task,
- delay);
+ message_loop->task_runner()->PostNonNestableDelayedTask(
+ from_here, std::move(task), delay);
}
}
@@ -329,8 +331,9 @@ bool WebThreadImpl::PostTaskHelper(WebThread::ID identifier,
// static
bool WebThread::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
@@ -346,9 +349,9 @@ bool WebThread::PostBlockingPoolTaskAndReply(
bool WebThread::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
@@ -406,25 +409,25 @@ bool WebThread::IsMessageLoopValid(ID identifier) {
// static
bool WebThread::PostTask(ID identifier,
const tracked_objects::Location& from_here,
- const base::Closure& task) {
- return WebThreadImpl::PostTaskHelper(identifier, from_here, task,
+ base::Closure task) {
+ return WebThreadImpl::PostTaskHelper(identifier, from_here, std::move(task),
base::TimeDelta(), true);
}
// static
bool WebThread::PostDelayedTask(ID identifier,
const tracked_objects::Location& from_here,
- const base::Closure& task,
+ base::Closure task,
base::TimeDelta delay) {
- return WebThreadImpl::PostTaskHelper(identifier, from_here, task, delay,
- true);
+ return WebThreadImpl::PostTaskHelper(identifier, from_here, std::move(task),
+ delay, true);
}
// static
bool WebThread::PostNonNestableTask(ID identifier,
const tracked_objects::Location& from_here,
- const base::Closure& task) {
- return WebThreadImpl::PostTaskHelper(identifier, from_here, task,
+ base::Closure task) {
+ return WebThreadImpl::PostTaskHelper(identifier, from_here, std::move(task),
base::TimeDelta(), false);
}
@@ -432,10 +435,10 @@ bool WebThread::PostNonNestableTask(ID identifier,
bool WebThread::PostNonNestableDelayedTask(
ID identifier,
const tracked_objects::Location& from_here,
- const base::Closure& task,
+ base::Closure task,
base::TimeDelta delay) {
- return WebThreadImpl::PostTaskHelper(identifier, from_here, task, delay,
- false);
+ return WebThreadImpl::PostTaskHelper(identifier, from_here, std::move(task),
+ delay, false);
}
// static
« no previous file with comments | « ios/web/web_thread_impl.h ('k') | media/base/fake_single_thread_task_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698