Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2341)

Unified Diff: base/message_loop_proxy.h

Issue 7210053: Implementation of PostTaskAndReply() in MessageLoopProxy and BrowserThread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased and turned into methods Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/message_loop_proxy.cc » ('j') | base/task.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « no previous file | base/message_loop_proxy.cc » ('j') | base/task.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698