Chromium Code Reviews| Index: base/task.h |
| diff --git a/base/task.h b/base/task.h |
| index ae47f32615b1b789db5b8a841b5908e62a9ed57d..080c150dd3e51fe61d243892b3be91a5ee773631 100644 |
| --- a/base/task.h |
| +++ b/base/task.h |
| @@ -7,6 +7,7 @@ |
| #pragma once |
| #include "base/base_api.h" |
| +#include "base/callback.h" |
| #include "base/debug/alias.h" |
| #include "base/memory/raw_scoped_refptr_mismatch_checker.h" |
| #include "base/memory/weak_ptr.h" |
| @@ -564,6 +565,38 @@ class BASE_API ScopedTaskRunner { |
| DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedTaskRunner); |
| }; |
| +namespace internal { |
| + |
| +class PostTaskAndReplyRelay { |
| + public: |
| + PostTaskAndReplyRelay(const Closure& task, const Closure& reply); |
| + |
| + ~PostTaskAndReplyRelay(); |
| + |
| + void Run(); |
| + |
| + private: |
| + void RunReplyAndSelfDestruct(); |
| + |
| + base::Closure task_; |
| + base::Closure reply_; |
| +}; |
| +} // namespace internal |
|
darin (slow to review)
2011/07/01 04:15:32
nit: add a new line above the close of the namespa
awong
2011/07/02 00:36:57
Done.
|
| + |
| +template <typename MessageLoopType, typename ResponseType> |
|
darin (slow to review)
2011/07/01 04:15:32
I guess ResponseType is just a placeholder.
awong
2011/07/02 00:36:57
No...just a mistake due to rushing this CL out. Re
|
| +void PostTaskAndReply(MessageLoopType loop, const Closure& task, |
|
willchan no longer on Chromium
2011/07/01 15:13:54
Why is MessageLoopType templated? Is this to make
awong
2011/07/02 00:36:57
Actually, I was trying bridge between MessageLoopP
|
| + const Closure& reply) { |
| + PostTaskAndReplyRelay* relay = new PostTaskAndReplyRelay(task, reply); |
| + loop.PostTask(&PostTaskAndReplyRelay::Run, base::Unretained(relay)); |
|
willchan no longer on Chromium
2011/07/01 15:13:54
Does this code actually work? Is there no need for
awong
2011/07/02 00:36:57
Nope...doesn't work yet. Will soon.
|
| +} |
| + |
| +template <typename MessageLoopType, typename ResponseType> |
| +void PostTaskAndReply<MessageLoopType, ResponseType>( |
| + MessageLoopType* loop, const Closure& task, const Closure& reply) { |
| + PostTaskAndReplyRelay* relay = new PostTaskAndReplyRelay(task, reply); |
| + loop->PostTask(&PostTaskAndReplyRelay::Run, base::Unretained(relay)); |
| +} |
| + |
| } // namespace base |
| #endif // BASE_TASK_H_ |