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

Unified Diff: base/task_runner_util.h

Issue 2678303002: Pass Callback by value on PostTaskAndReply family (Closed)
Patch Set: rebase Created 3 years, 10 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/task_runner.cc ('k') | base/task_scheduler/post_task.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/task_runner_util.h
diff --git a/base/task_runner_util.h b/base/task_runner_util.h
index e57d07769fa7ef66ae599490b75c4e8bcc4826a3..7fda07624da08294153279f568cecc5c0b45541d 100644
--- a/base/task_runner_util.h
+++ b/base/task_runner_util.h
@@ -5,8 +5,11 @@
#ifndef BASE_TASK_RUNNER_UTIL_H_
#define BASE_TASK_RUNNER_UTIL_H_
+#include <utility>
+
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "base/callback.h"
#include "base/logging.h"
#include "base/post_task_and_reply_with_result_internal.h"
#include "base/task_runner.h"
@@ -28,20 +31,18 @@ namespace base {
// Bind(&DoWorkAndReturn),
// Bind(&Callback));
template <typename TaskReturnType, typename ReplyArgType>
-bool PostTaskAndReplyWithResult(
- TaskRunner* task_runner,
- const tracked_objects::Location& from_here,
- const Callback<TaskReturnType(void)>& task,
- const Callback<void(ReplyArgType)>& reply) {
+bool PostTaskAndReplyWithResult(TaskRunner* task_runner,
+ const tracked_objects::Location& from_here,
+ Callback<TaskReturnType()> task,
+ Callback<void(ReplyArgType)> reply) {
DCHECK(task);
DCHECK(reply);
TaskReturnType* result = new TaskReturnType();
return task_runner->PostTaskAndReply(
- from_here,
- base::Bind(&internal::ReturnAsParamAdapter<TaskReturnType>, task,
- result),
- base::Bind(&internal::ReplyAdapter<TaskReturnType, ReplyArgType>, reply,
- base::Owned(result)));
+ from_here, base::Bind(&internal::ReturnAsParamAdapter<TaskReturnType>,
+ std::move(task), result),
+ base::Bind(&internal::ReplyAdapter<TaskReturnType, ReplyArgType>,
+ std::move(reply), base::Owned(result)));
}
} // namespace base
« no previous file with comments | « base/task_runner.cc ('k') | base/task_scheduler/post_task.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698