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..1b2d3788e881fbf390d9e5dcc197291c5459ef0a 100644 |
--- a/base/threading/post_task_and_reply_impl.cc |
+++ b/base/threading/post_task_and_reply_impl.cc |
@@ -28,13 +28,13 @@ namespace { |
class PostTaskAndReplyRelay { |
public: |
PostTaskAndReplyRelay(const tracked_objects::Location& from_here, |
- const Closure& task, |
- const Closure& reply) |
+ OnceClosure task, |
+ OnceClosure 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()); |
@@ -43,7 +43,7 @@ class PostTaskAndReplyRelay { |
} |
void RunTaskAndPostReply() { |
- task_.Run(); |
+ std::move(task_).Run(); |
origin_task_runner_->PostTask( |
from_here_, Bind(&PostTaskAndReplyRelay::RunReplyAndSelfDestruct, |
base::Unretained(this))); |
@@ -56,9 +56,9 @@ class PostTaskAndReplyRelay { |
// Force |task_| to be released before |reply_| is to ensure that no one |
// accidentally depends on |task_| keeping one of its arguments alive while |
// |reply_| is executing. |
- task_.Reset(); |
+ std::move(task_).Reset(); |
- reply_.Run(); |
+ std::move(reply_).Run(); |
// Cue mission impossible theme. |
delete this; |
@@ -67,8 +67,8 @@ class PostTaskAndReplyRelay { |
const SequenceChecker sequence_checker_; |
const tracked_objects::Location from_here_; |
const scoped_refptr<SequencedTaskRunner> origin_task_runner_; |
- Closure reply_; |
- Closure task_; |
+ OnceClosure reply_; |
+ OnceClosure task_; |
}; |
} // namespace |
@@ -77,12 +77,12 @@ namespace internal { |
bool PostTaskAndReplyImpl::PostTaskAndReply( |
const tracked_objects::Location& from_here, |
- const Closure& task, |
- const Closure& reply) { |
+ OnceClosure task, |
+ OnceClosure 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 |