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

Unified Diff: base/task.cc

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
« base/task.h ('K') | « base/task.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/task.cc
diff --git a/base/task.cc b/base/task.cc
index e4da5474a0098d852963c1ca5c1b350ffa306d37..3085d3465faaae0d2a3a68d7a89851e99d718f17 100644
--- a/base/task.cc
+++ b/base/task.cc
@@ -4,6 +4,8 @@
#include "base/task.h"
+#include "base/bind.h"
+
Task::Task() {
}
@@ -34,4 +36,31 @@ Task* ScopedTaskRunner::Release() {
return tmp;
}
+namespace internal {
+
+PostTaskAndReplyRelay::PostTaskAndReplyRelay(const Closure& task,
+ const Closure& reply)
+ : task_(task),
+ reply_(reply),
+ origin_loop_(MessageLoop::Current()) {
+}
+
+PostTaskAndReplyRelay::~PostTaskAndReplyRelay() {
+ DCHECK(origin_loop_ == MessageLoop::Current());
+}
+
+void PostTaskAndReplyRelay::Run() {
+ task_.Run();
+ origin_loop_->PostTask(
darin (slow to review) 2011/07/01 04:15:32 what if the origin thread is already gone? i susp
willchan no longer on Chromium 2011/07/01 15:13:54 Yes, MessageLoopProxy FTW.
awong 2011/07/02 00:36:57 Done.
+ base::Bind(&PostTaskAndReplyRelay::RunReplyAndSelfDestruct,
willchan no longer on Chromium 2011/07/01 15:13:54 We're already in base::, so the prefix probably is
awong 2011/07/02 00:36:57 Done.
+ base::Unretained(this)));
+}
+
+void PostTaskAndReplyRelay::RunReplyAndSelfDestruct() {
+ reply_.Run();
+ delete this;
+}
+} // 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.
+
+
} // namespace base
« base/task.h ('K') | « base/task.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698