Index: base/message_loop_proxy.h |
diff --git a/base/message_loop_proxy.h b/base/message_loop_proxy.h |
index 646b2efcbcc86bb8559c3e2d130499a35652cbb5..4f83d0d53faff3aac13a8b193005ba9e09207a45 100644 |
--- a/base/message_loop_proxy.h |
+++ b/base/message_loop_proxy.h |
@@ -67,6 +67,24 @@ class BASE_EXPORT MessageLoopProxy |
// this proxy represents. |
virtual bool BelongsToCurrentThread() = 0; |
+ // Executes |task| on the given MessageLoopProxy. On completion, |reply| |
+ // is passed back to the MessageLoopProxy for the thread that called |
+ // PostTaskAndReply(). |
+ // |
+ // Both |task| and |reply| are guaranteed to be deleted on the thread from |
+ // which PostTaskAndReply() is invoked. |
+ // |
+ // This simplifies logic when an operation needs to be executed on another |
+ // thread, but processing of the result needs to occur on the current thread. |
+ // |
+ // Note that because of the lifetime guarantees on the |reply| Closure, it is |
+ // perfectly valid to use a WeakPtr<> in the bound parameters for |reply|. |
+ // This is useful if |reply| needs to be canceled on the originating thread |
+ // while |task| may still be executing. |
+ bool PostTaskAndReply(const tracked_objects::Location& from_here, |
+ const Closure& task, |
+ const Closure& reply); |
+ |
template <class T> |
bool DeleteSoon(const tracked_objects::Location& from_here, |
T* object) { |