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

Unified Diff: base/threading/post_task_and_reply_impl.cc

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/threading/post_task_and_reply_impl.h ('k') | base/threading/worker_pool.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/threading/post_task_and_reply_impl.cc
diff --git a/base/threading/post_task_and_reply_impl.cc b/base/threading/post_task_and_reply_impl.cc
index 7899f65f94bd792e3f9bd2f277a9e11595e590b7..d16f8bd22590e857cb65c9b3cd5d9d7db4f3132e 100644
--- a/base/threading/post_task_and_reply_impl.cc
+++ b/base/threading/post_task_and_reply_impl.cc
@@ -4,8 +4,9 @@
#include "base/threading/post_task_and_reply_impl.h"
+#include <utility>
+
#include "base/bind.h"
-#include "base/callback.h"
#include "base/debug/leak_annotations.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
@@ -28,13 +29,13 @@ namespace {
class PostTaskAndReplyRelay {
public:
PostTaskAndReplyRelay(const tracked_objects::Location& from_here,
- const Closure& task,
- const Closure& reply)
+ Closure task,
+ Closure reply)
: sequence_checker_(),
from_here_(from_here),
origin_task_runner_(SequencedTaskRunnerHandle::Get()),
- reply_(reply),
- task_(task) {}
+ reply_(std::move(reply)),
+ task_(std::move(task)) {}
~PostTaskAndReplyRelay() {
DCHECK(sequence_checker_.CalledOnValidSequence());
@@ -77,12 +78,12 @@ namespace internal {
bool PostTaskAndReplyImpl::PostTaskAndReply(
const tracked_objects::Location& from_here,
- const Closure& task,
- const Closure& reply) {
+ Closure task,
+ Closure reply) {
DCHECK(!task.is_null()) << from_here.ToString();
DCHECK(!reply.is_null()) << from_here.ToString();
PostTaskAndReplyRelay* relay =
- new PostTaskAndReplyRelay(from_here, task, reply);
+ new PostTaskAndReplyRelay(from_here, std::move(task), std::move(reply));
// PostTaskAndReplyRelay self-destructs after executing |reply|. On the flip
// side though, it is intentionally leaked if the |task| doesn't complete
// before the origin sequence stops executing tasks. Annotate |relay| as leaky
« no previous file with comments | « base/threading/post_task_and_reply_impl.h ('k') | base/threading/worker_pool.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698