| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/task_runner.h" | 5 #include "base/task_runner.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/threading/post_task_and_reply_impl.h" | 11 #include "base/threading/post_task_and_reply_impl.h" |
| 12 | 12 |
| 13 namespace base { | 13 namespace base { |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 // TODO(akalin): There's only one other implementation of | 17 // TODO(akalin): There's only one other implementation of |
| 18 // PostTaskAndReplyImpl in WorkerPool. Investigate whether it'll be | 18 // PostTaskAndReplyImpl in WorkerPool. Investigate whether it'll be |
| 19 // possible to merge the two. | 19 // possible to merge the two. |
| 20 class PostTaskAndReplyTaskRunner : public internal::PostTaskAndReplyImpl { | 20 class PostTaskAndReplyTaskRunner : public internal::PostTaskAndReplyImpl { |
| 21 public: | 21 public: |
| 22 explicit PostTaskAndReplyTaskRunner(TaskRunner* destination); | 22 explicit PostTaskAndReplyTaskRunner(TaskRunner* destination); |
| 23 | 23 |
| 24 private: | 24 private: |
| 25 bool PostTask(const tracked_objects::Location& from_here, | 25 bool PostTask(const tracked_objects::Location& from_here, |
| 26 const Closure& task) override; | 26 Closure task) override; |
| 27 | 27 |
| 28 // Non-owning. | 28 // Non-owning. |
| 29 TaskRunner* destination_; | 29 TaskRunner* destination_; |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 PostTaskAndReplyTaskRunner::PostTaskAndReplyTaskRunner( | 32 PostTaskAndReplyTaskRunner::PostTaskAndReplyTaskRunner( |
| 33 TaskRunner* destination) : destination_(destination) { | 33 TaskRunner* destination) : destination_(destination) { |
| 34 DCHECK(destination_); | 34 DCHECK(destination_); |
| 35 } | 35 } |
| 36 | 36 |
| 37 bool PostTaskAndReplyTaskRunner::PostTask( | 37 bool PostTaskAndReplyTaskRunner::PostTask( |
| 38 const tracked_objects::Location& from_here, | 38 const tracked_objects::Location& from_here, |
| 39 const Closure& task) { | 39 Closure task) { |
| 40 return destination_->PostTask(from_here, task); | 40 return destination_->PostTask(from_here, std::move(task)); |
| 41 } | 41 } |
| 42 | 42 |
| 43 } // namespace | 43 } // namespace |
| 44 | 44 |
| 45 bool TaskRunner::PostTask(const tracked_objects::Location& from_here, | 45 bool TaskRunner::PostTask(const tracked_objects::Location& from_here, |
| 46 const Closure& task) { | 46 Closure task) { |
| 47 return PostDelayedTask(from_here, task, base::TimeDelta()); | 47 return PostDelayedTask(from_here, std::move(task), base::TimeDelta()); |
| 48 } | 48 } |
| 49 | 49 |
| 50 bool TaskRunner::PostTaskAndReply(const tracked_objects::Location& from_here, | 50 bool TaskRunner::PostTaskAndReply(const tracked_objects::Location& from_here, |
| 51 Closure task, | 51 Closure task, |
| 52 Closure reply) { | 52 Closure reply) { |
| 53 return PostTaskAndReplyTaskRunner(this).PostTaskAndReply( | 53 return PostTaskAndReplyTaskRunner(this).PostTaskAndReply( |
| 54 from_here, std::move(task), std::move(reply)); | 54 from_here, std::move(task), std::move(reply)); |
| 55 } | 55 } |
| 56 | 56 |
| 57 TaskRunner::TaskRunner() {} | 57 TaskRunner::TaskRunner() {} |
| 58 | 58 |
| 59 TaskRunner::~TaskRunner() {} | 59 TaskRunner::~TaskRunner() {} |
| 60 | 60 |
| 61 void TaskRunner::OnDestruct() const { | 61 void TaskRunner::OnDestruct() const { |
| 62 delete this; | 62 delete this; |
| 63 } | 63 } |
| 64 | 64 |
| 65 void TaskRunnerTraits::Destruct(const TaskRunner* task_runner) { | 65 void TaskRunnerTraits::Destruct(const TaskRunner* task_runner) { |
| 66 task_runner->OnDestruct(); | 66 task_runner->OnDestruct(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 } // namespace base | 69 } // namespace base |
| OLD | NEW |