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

Unified Diff: base/task_runner_util.h

Issue 2678303002: Pass Callback by value on PostTaskAndReply family (Closed)
Patch Set: #include 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
Index: base/task_runner_util.h
diff --git a/base/task_runner_util.h b/base/task_runner_util.h
index e57d07769fa7ef66ae599490b75c4e8bcc4826a3..80fedc55f15c000b7b6b7b883587a6c509fe05ae 100644
--- a/base/task_runner_util.h
+++ b/base/task_runner_util.h
@@ -7,6 +7,7 @@
#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 +29,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)));
gab 2017/02/07 15:46:08 #include <utility>
tzik 2017/02/08 01:39:32 Done.
}
} // namespace base

Powered by Google App Engine
This is Rietveld 408576698