| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This file contains the implementation shared by | 5 // This file contains the implementation shared by |
| 6 // MessageLoopProxy::PostTaskAndReply and WorkerPool::PostTaskAndReply. | 6 // MessageLoopProxy::PostTaskAndReply and WorkerPool::PostTaskAndReply. |
| 7 | 7 |
| 8 #ifndef BASE_THREADING_POST_TASK_AND_REPLY_IMPL_H_ | 8 #ifndef BASE_THREADING_POST_TASK_AND_REPLY_IMPL_H_ |
| 9 #define BASE_THREADING_POST_TASK_AND_REPLY_IMPL_H_ | 9 #define BASE_THREADING_POST_TASK_AND_REPLY_IMPL_H_ |
| 10 | 10 |
| 11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 12 #include "base/location.h" | 12 #include "base/location.h" |
| 13 | 13 |
| 14 namespace base { | 14 namespace base { |
| 15 namespace internal { | 15 namespace internal { |
| 16 | 16 |
| 17 // Inherit from this in a class that implements PostTask appropriately | 17 // Inherit from this in a class that implements PostTask appropriately |
| 18 // for sending to a destination thread. | 18 // for sending to a destination thread. |
| 19 // | 19 // |
| 20 // Note that 'reply' will always get posted back to your current | 20 // Note that 'reply' will always get posted back to your current |
| 21 // MessageLoop. | 21 // MessageLoop. |
| 22 // | 22 // |
| 23 // If you're looking for a concrete implementation of | 23 // If you're looking for a concrete implementation of |
| 24 // PostTaskAndReply, you probably want base::MessageLoopProxy, or you | 24 // PostTaskAndReply, you probably want base::MessageLoopProxy, or you |
| 25 // may want base::WorkerPool. | 25 // may want base::WorkerPool. |
| 26 class PostTaskAndReplyImpl { | 26 class PostTaskAndReplyImpl { |
| 27 public: | 27 public: |
| 28 virtual ~PostTaskAndReplyImpl() { } | |
| 29 | |
| 30 // Implementation for MessageLoopProxy::PostTaskAndReply and | 28 // Implementation for MessageLoopProxy::PostTaskAndReply and |
| 31 // WorkerPool::PostTaskAndReply. | 29 // WorkerPool::PostTaskAndReply. |
| 32 bool PostTaskAndReply(const tracked_objects::Location& from_here, | 30 bool PostTaskAndReply(const tracked_objects::Location& from_here, |
| 33 const Closure& task, | 31 const Closure& task, |
| 34 const Closure& reply); | 32 const Closure& reply); |
| 35 | 33 |
| 36 private: | 34 private: |
| 37 virtual bool PostTask(const tracked_objects::Location& from_here, | 35 virtual bool PostTask(const tracked_objects::Location& from_here, |
| 38 const Closure& task) = 0; | 36 const Closure& task) = 0; |
| 39 }; | 37 }; |
| 40 | 38 |
| 41 } // namespace internal | 39 } // namespace internal |
| 42 } // namespace base | 40 } // namespace base |
| 43 | 41 |
| 44 #endif // BASE_THREADING_POST_TASK_AND_REPLY_IMPL_H_ | 42 #endif // BASE_THREADING_POST_TASK_AND_REPLY_IMPL_H_ |
| OLD | NEW |