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 |