Index: base/message_loop.cc |
diff --git a/base/message_loop.cc b/base/message_loop.cc |
index 49d76a03bfed8c8ad9d8775b83fc4ecac67759fe..fd1c24f62bf7408db8a31611b8c12c780d86908d 100644 |
--- a/base/message_loop.cc |
+++ b/base/message_loop.cc |
@@ -306,6 +306,30 @@ void MessageLoop::QuitNow() { |
} |
} |
+// This is a complete hack just for the proof of concept. Really, we want |
+// to modify PendingTask to understand base::Thunk. |
+class ThunkTaskAdapter : public Task { |
+ public: |
+ explicit ThunkTaskAdapter(base::Thunk<void(void)> t) |
+ : thunk_(t) { |
+ } |
+ |
+ virtual void Run() { |
+ thunk_(); |
+ } |
+ |
+ private: |
+ base::Thunk<void(void)> thunk_; |
+}; |
+ |
+void MessageLoop::PostThunk( |
+ const tracked_objects::Location& from_here, |
+ base::Thunk<void(void)> thunk) { |
+ // The wrapping of Thunk in Task will screw up task tracking...that will be |
+ // fixed if we correctly refactor message loop's PendingTask. |
+ PostTask_Helper(from_here, new ThunkTaskAdapter(thunk), 0, true); |
+} |
+ |
void MessageLoop::PostTask( |
const tracked_objects::Location& from_here, Task* task) { |
PostTask_Helper(from_here, task, 0, true); |
@@ -316,6 +340,15 @@ void MessageLoop::PostDelayedTask( |
PostTask_Helper(from_here, task, delay_ms, true); |
} |
+void MessageLoop::PostDelayedThunk( |
+ const tracked_objects::Location& from_here, |
+ base::Thunk<void(void)> thunk, |
+ 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 ThunkTaskAdapter(thunk), delay_ms, true); |
+} |
+ |
void MessageLoop::PostNonNestableTask( |
const tracked_objects::Location& from_here, Task* task) { |
PostTask_Helper(from_here, task, 0, false); |