Index: base/message_loop.cc |
diff --git a/base/message_loop.cc b/base/message_loop.cc |
index 49d76a03bfed8c8ad9d8775b83fc4ecac67759fe..929127813338dd1aad0d0bdb84d0015f7101f610 100644 |
--- a/base/message_loop.cc |
+++ b/base/message_loop.cc |
@@ -306,6 +306,32 @@ void MessageLoop::QuitNow() { |
} |
} |
+// This is a complete hack just for the proof of concept. Really, we want |
+// to modify PendingTask to understand base::Closure. |
+class ClosureTaskAdapter : public Task { |
+ public: |
+ explicit ClosureTaskAdapter(const tracked_objects::Location& from_here, |
+ base::Closure c) |
+ : closure_(c) { |
+ closure_.tracked()->SetBirthPlace(from_here); |
+ } |
+ |
+ virtual void Run() { |
+ closure_(); |
+ } |
+ |
+ private: |
+ base::Closure closure_; |
+}; |
+ |
+void MessageLoop::PostClosure( |
+ const tracked_objects::Location& from_here, base::Closure closure) { |
+ // The wrapping of Closure in Task will screw up task tracking...that will be |
+ // fixed if we correctly refactor message loop's PendingTask. |
+ PostTask_Helper(from_here, new ClosureTaskAdapter(from_here, closure), 0, |
+ true); |
+} |
+ |
void MessageLoop::PostTask( |
const tracked_objects::Location& from_here, Task* task) { |
PostTask_Helper(from_here, task, 0, true); |
@@ -316,6 +342,15 @@ void MessageLoop::PostDelayedTask( |
PostTask_Helper(from_here, task, delay_ms, true); |
} |
+void MessageLoop::PostDelayedClosure( |
+ const tracked_objects::Location& from_here, base::Closure closure, |
+ int64 delay_ms) { |
+ // The wrapping of Closure in Task will screw up task tracking...that will be |
+ // fixed if we correctly refactor message loop's PendingTask. |
+ PostTask_Helper(from_here, new ClosureTaskAdapter(from_here, closure), |
+ delay_ms, true); |
+} |
+ |
void MessageLoop::PostNonNestableTask( |
const tracked_objects::Location& from_here, Task* task) { |
PostTask_Helper(from_here, task, 0, false); |