diff options
Diffstat (limited to 'base/threading/post_task_and_reply_impl.cc')
-rw-r--r-- | base/threading/post_task_and_reply_impl.cc | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/base/threading/post_task_and_reply_impl.cc b/base/threading/post_task_and_reply_impl.cc index d16f8bd225..cddb8981ad 100644 --- a/base/threading/post_task_and_reply_impl.cc +++ b/base/threading/post_task_and_reply_impl.cc @@ -29,8 +29,8 @@ namespace { class PostTaskAndReplyRelay { public: PostTaskAndReplyRelay(const tracked_objects::Location& from_here, - Closure task, - Closure reply) + OnceClosure task, + OnceClosure reply) : sequence_checker_(), from_here_(from_here), origin_task_runner_(SequencedTaskRunnerHandle::Get()), @@ -39,12 +39,10 @@ class PostTaskAndReplyRelay { ~PostTaskAndReplyRelay() { DCHECK(sequence_checker_.CalledOnValidSequence()); - task_.Reset(); - reply_.Reset(); } void RunTaskAndPostReply() { - task_.Run(); + std::move(task_).Run(); origin_task_runner_->PostTask( from_here_, Bind(&PostTaskAndReplyRelay::RunReplyAndSelfDestruct, base::Unretained(this))); @@ -54,12 +52,12 @@ class PostTaskAndReplyRelay { void RunReplyAndSelfDestruct() { DCHECK(sequence_checker_.CalledOnValidSequence()); - // 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(); + // Ensure |task_| has already been released before |reply_| to ensure that + // no one accidentally depends on |task_| keeping one of its arguments alive + // while |reply_| is executing. + DCHECK(!task_); - reply_.Run(); + std::move(reply_).Run(); // Cue mission impossible theme. delete this; @@ -68,8 +66,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 @@ -78,8 +76,8 @@ namespace internal { bool PostTaskAndReplyImpl::PostTaskAndReply( const tracked_objects::Location& from_here, - Closure task, - Closure reply) { + OnceClosure task, + OnceClosure reply) { DCHECK(!task.is_null()) << from_here.ToString(); DCHECK(!reply.is_null()) << from_here.ToString(); PostTaskAndReplyRelay* relay = |