Chromium Code Reviews| Index: base/task.h |
| diff --git a/base/task.h b/base/task.h |
| index ae47f32615b1b789db5b8a841b5908e62a9ed57d..a651c044248faead06722b51232985aac43df17d 100644 |
| --- a/base/task.h |
| +++ b/base/task.h |
| @@ -564,6 +564,44 @@ class BASE_API ScopedTaskRunner { |
| DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedTaskRunner); |
| }; |
| +namespace subtle { |
|
willchan no longer on Chromium
2011/07/19 12:18:26
<bikeshed>I think internal is more appropriate</bi
awong
2011/07/19 21:08:20
I feel like subtle scares me people more. And this
|
| + |
| +// This class is meant for use in the implementation of MessageLoop classes |
| +// such as MessageLoop, MessageLoopProxy, BrowserThread, and WorkerPool to |
| +// implement the compatibiltiy APIs while we are transitioning from Task to |
|
willchan no longer on Chromium
2011/07/19 12:18:26
s/compatibiltiy/compatibility/
|
| +// Callback. |
| +// |
| +// It should NOT be used anywhere else! |
| +// |
| +// In particular, notice that this is RefCounted instead of |
| +// RefCountedThreadSafe. We rely on the fact that users of this class are |
| +// careful to ensure that a lock is taken during transfer of ownership for |
| +// objects from this class to ensure the refcount is not corrupted. |
| +class TaskClosureAdapter : public RefCounted<TaskClosureAdapter> { |
| + public: |
| + explicit TaskClosureAdapter(Task* task); |
| + |
| + // |should_leak_task| points to a flag variable that can be used to determine |
| + // if this class should leak the Task on destruction. This is important |
| + // at MessageLoop shutdown since not all tasks can be safely deleted without |
| + // running. See MessageLoop::DeletePendingTasks() for the exact behavior |
| + // of when a Task should be deleted. It is subtle. |
| + TaskClosureAdapter(Task* task, bool* should_leak_task); |
| + |
| + void Run(); |
| + |
| + private: |
| + friend class base::RefCounted<TaskClosureAdapter>; |
| + |
| + ~TaskClosureAdapter(); |
| + |
| + Task* task_; |
| + bool* should_leak_task_; |
| + static bool kTaskLeakingDefault; |
| +}; |
| + |
| +} // namespace subtle |
| + |
| } // namespace base |
| #endif // BASE_TASK_H_ |