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

Unified Diff: base/task.h

Issue 7210053: Implementation of PostTaskAndReply() in MessageLoopProxy and BrowserThread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 6 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/task.cc » ('j') | base/task.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
« no previous file with comments | « no previous file | base/task.cc » ('j') | base/task.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698