Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_TASK_H_ | 5 #ifndef BASE_TASK_H_ |
| 6 #define BASE_TASK_H_ | 6 #define BASE_TASK_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/base_api.h" | 9 #include "base/base_api.h" |
| 10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 557 ~ScopedTaskRunner(); | 557 ~ScopedTaskRunner(); |
| 558 | 558 |
| 559 Task* Release(); | 559 Task* Release(); |
| 560 | 560 |
| 561 private: | 561 private: |
| 562 Task* task_; | 562 Task* task_; |
| 563 | 563 |
| 564 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedTaskRunner); | 564 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedTaskRunner); |
| 565 }; | 565 }; |
| 566 | 566 |
| 567 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
| |
| 568 | |
| 569 // This class is meant for use in the implementation of MessageLoop classes | |
| 570 // such as MessageLoop, MessageLoopProxy, BrowserThread, and WorkerPool to | |
| 571 // 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/
| |
| 572 // Callback. | |
| 573 // | |
| 574 // It should NOT be used anywhere else! | |
| 575 // | |
| 576 // In particular, notice that this is RefCounted instead of | |
| 577 // RefCountedThreadSafe. We rely on the fact that users of this class are | |
| 578 // careful to ensure that a lock is taken during transfer of ownership for | |
| 579 // objects from this class to ensure the refcount is not corrupted. | |
| 580 class TaskClosureAdapter : public RefCounted<TaskClosureAdapter> { | |
| 581 public: | |
| 582 explicit TaskClosureAdapter(Task* task); | |
| 583 | |
| 584 // |should_leak_task| points to a flag variable that can be used to determine | |
| 585 // if this class should leak the Task on destruction. This is important | |
| 586 // at MessageLoop shutdown since not all tasks can be safely deleted without | |
| 587 // running. See MessageLoop::DeletePendingTasks() for the exact behavior | |
| 588 // of when a Task should be deleted. It is subtle. | |
| 589 TaskClosureAdapter(Task* task, bool* should_leak_task); | |
| 590 | |
| 591 void Run(); | |
| 592 | |
| 593 private: | |
| 594 friend class base::RefCounted<TaskClosureAdapter>; | |
| 595 | |
| 596 ~TaskClosureAdapter(); | |
| 597 | |
| 598 Task* task_; | |
| 599 bool* should_leak_task_; | |
| 600 static bool kTaskLeakingDefault; | |
| 601 }; | |
| 602 | |
| 603 } // namespace subtle | |
| 604 | |
| 567 } // namespace base | 605 } // namespace base |
| 568 | 606 |
| 569 #endif // BASE_TASK_H_ | 607 #endif // BASE_TASK_H_ |
| OLD | NEW |