OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/task_runner.h" |
| 6 |
| 7 #include "base/compiler_specific.h" |
| 8 #include "base/threading/post_task_and_reply_impl.h" |
| 9 |
| 10 namespace base { |
| 11 |
| 12 namespace { |
| 13 |
| 14 // TODO(akalin): There's only one other implementation of |
| 15 // PostTaskAndReplyImpl in WorkerPool. Investigate whether it'll be |
| 16 // possible to merge the two. |
| 17 class PostTaskAndReplyTaskRunner : public internal::PostTaskAndReplyImpl { |
| 18 public: |
| 19 PostTaskAndReplyTaskRunner(TaskRunner* destination); |
| 20 |
| 21 private: |
| 22 virtual bool PostTask(const tracked_objects::Location& from_here, |
| 23 const Closure& task) OVERRIDE; |
| 24 |
| 25 // Non-owning. |
| 26 TaskRunner* destination_; |
| 27 }; |
| 28 |
| 29 PostTaskAndReplyTaskRunner::PostTaskAndReplyTaskRunner( |
| 30 TaskRunner* destination) : destination_(destination) {} |
| 31 |
| 32 bool PostTaskAndReplyTaskRunner::PostTask( |
| 33 const tracked_objects::Location& from_here, |
| 34 const Closure& task) { |
| 35 return destination_->PostTask(from_here, task); |
| 36 } |
| 37 |
| 38 } // namespace |
| 39 |
| 40 bool TaskRunner::PostTaskAndReply( |
| 41 const tracked_objects::Location& from_here, |
| 42 const Closure& task, |
| 43 const Closure& reply) { |
| 44 return PostTaskAndReplyTaskRunner(this).PostTaskAndReply( |
| 45 from_here, task, reply); |
| 46 } |
| 47 |
| 48 TaskRunner::TaskRunner() {} |
| 49 |
| 50 TaskRunner::~TaskRunner() {} |
| 51 |
| 52 void TaskRunner::OnDestruct() const { |
| 53 delete this; |
| 54 } |
| 55 |
| 56 void TaskRunnerTraits::Destruct(const TaskRunner* task_runner) { |
| 57 task_runner->OnDestruct(); |
| 58 } |
| 59 |
| 60 } // namespace base |
OLD | NEW |