Index: base/worker_pool.h |
diff --git a/base/worker_pool.h b/base/worker_pool.h |
index e0b75a9a753ad1169a16cea9cbb2de6c9295131e..de3ac3dc7ce0f753e22b96a9d7d214560eeee8ab 100644 |
--- a/base/worker_pool.h |
+++ b/base/worker_pool.h |
@@ -7,6 +7,8 @@ |
#pragma once |
#include "base/tracked.h" |
+#include "base/prebind.h" |
+#include "base/task.h" |
class Task; |
@@ -26,6 +28,30 @@ class WorkerPool { |
// return value, ownership of |task| is transferred to the worker pool. |
static bool PostTask(const tracked_objects::Location& from_here, |
Task* task, bool task_is_slow); |
+ static bool PostThunk(const tracked_objects::Location& from_here, |
+ base::Thunk<void(void)> thunk, bool task_is_slow) { |
+ // The wrapping of Closure in Task will screw up task tracking...that will |
+ // be fixed if we actually wave the Closure class through the API |
+ // correctly. |
+ return PostTask(from_here, new ThunkTaskAdapter(thunk), task_is_slow); |
+ } |
+ |
+private: |
+ // This is a complete hack just for the proof of concept. Really, we want |
+ // to modify PendingTask to understand base::Closure. |
+ class ThunkTaskAdapter : public Task { |
+ public: |
+ explicit ThunkTaskAdapter(base::Thunk<void(void)> t) |
+ : thunk_(t) { |
+ } |
+ |
+ virtual void Run() { |
+ thunk_(); |
+ } |
+ |
+ private: |
+ base::Thunk<void(void)> thunk_; |
+ }; |
}; |
#endif // BASE_WORKER_POOL_H_ |