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

Unified Diff: base/task/cancelable_task_tracker.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 | « no previous file | base/task/cancelable_task_tracker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/task/cancelable_task_tracker.h
diff --git a/base/task/cancelable_task_tracker.h b/base/task/cancelable_task_tracker.h
index 959c86f9fd67e781f9e2e19341b20c053e31da79..4f64a24060d0824654072f064dc717e33de48b73 100644
--- a/base/task/cancelable_task_tracker.h
+++ b/base/task/cancelable_task_tracker.h
@@ -37,6 +37,8 @@
#include <stdint.h>
+#include <utility>
+
#include "base/base_export.h"
#include "base/bind.h"
#include "base/callback.h"
@@ -74,25 +76,21 @@ class BASE_EXPORT CancelableTaskTracker {
TaskId PostTaskAndReply(base::TaskRunner* task_runner,
const tracked_objects::Location& from_here,
- const base::Closure& task,
- const base::Closure& reply);
+ base::Closure task,
+ base::Closure reply);
template <typename TaskReturnType, typename ReplyArgType>
- TaskId PostTaskAndReplyWithResult(
- base::TaskRunner* task_runner,
- const tracked_objects::Location& from_here,
- const base::Callback<TaskReturnType(void)>& task,
- const base::Callback<void(ReplyArgType)>& reply) {
+ TaskId PostTaskAndReplyWithResult(base::TaskRunner* task_runner,
+ const tracked_objects::Location& from_here,
+ base::Callback<TaskReturnType()> task,
+ base::Callback<void(ReplyArgType)> reply) {
TaskReturnType* result = new TaskReturnType();
return PostTaskAndReply(
- task_runner,
- from_here,
+ task_runner, from_here,
base::Bind(&base::internal::ReturnAsParamAdapter<TaskReturnType>,
- task,
- base::Unretained(result)),
+ std::move(task), base::Unretained(result)),
base::Bind(&base::internal::ReplyAdapter<TaskReturnType, ReplyArgType>,
- reply,
- base::Owned(result)));
+ std::move(reply), base::Owned(result)));
}
// Creates a tracked TaskId and an associated IsCanceledCallback. Client can
« no previous file with comments | « no previous file | base/task/cancelable_task_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698