Index: base/worker_pool.h |
diff --git a/base/worker_pool.h b/base/worker_pool.h |
index e0b75a9a753ad1169a16cea9cbb2de6c9295131e..c81ca1d50a5b383052ab1be856e100c325d7642a 100644 |
--- a/base/worker_pool.h |
+++ b/base/worker_pool.h |
@@ -7,6 +7,8 @@ |
#pragma once |
#include "base/tracked.h" |
+#include "base/closure.h" |
+#include "base/task.h" |
class Task; |
@@ -26,6 +28,33 @@ 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 PostClosure(const tracked_objects::Location& from_here, |
+ base::Closure closure, 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 ClosureTaskAdapter(from_here, closure), |
+ 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 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_; |
+ }; |
}; |
#endif // BASE_WORKER_POOL_H_ |