OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // CancelableTaskTracker posts tasks (in the form of a Closure) to a | 5 // CancelableTaskTracker posts tasks (in the form of a Closure) to a |
6 // TaskRunner, and is able to cancel the task later if it's not needed | 6 // TaskRunner, and is able to cancel the task later if it's not needed |
7 // anymore. On destruction, CancelableTaskTracker will cancel all | 7 // anymore. On destruction, CancelableTaskTracker will cancel all |
8 // tracked tasks. | 8 // tracked tasks. |
9 // | 9 // |
10 // Each cancelable task can be associated with a reply (also a Closure). After | 10 // Each cancelable task can be associated with a reply (also a Closure). After |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 | 119 |
120 // Returns true iff there are in-flight tasks that are still being | 120 // Returns true iff there are in-flight tasks that are still being |
121 // tracked. | 121 // tracked. |
122 bool HasTrackedTasks() const; | 122 bool HasTrackedTasks() const; |
123 | 123 |
124 private: | 124 private: |
125 void Track(TaskId id, base::CancellationFlag* flag); | 125 void Track(TaskId id, base::CancellationFlag* flag); |
126 void Untrack(TaskId id); | 126 void Untrack(TaskId id); |
127 | 127 |
128 base::hash_map<TaskId, base::CancellationFlag*> task_flags_; | 128 base::hash_map<TaskId, base::CancellationFlag*> task_flags_; |
129 base::WeakPtrFactory<CancelableTaskTracker> weak_factory_; | |
130 | 129 |
131 TaskId next_id_; | 130 TaskId next_id_; |
132 base::ThreadChecker thread_checker_; | 131 base::ThreadChecker thread_checker_; |
133 | 132 |
| 133 base::WeakPtrFactory<CancelableTaskTracker> weak_factory_; |
| 134 |
134 DISALLOW_COPY_AND_ASSIGN(CancelableTaskTracker); | 135 DISALLOW_COPY_AND_ASSIGN(CancelableTaskTracker); |
135 }; | 136 }; |
136 | 137 |
137 } // namespace base | 138 } // namespace base |
138 | 139 |
139 #endif // BASE_TASK_CANCELABLE_TASK_TRACKER_H_ | 140 #endif // BASE_TASK_CANCELABLE_TASK_TRACKER_H_ |
OLD | NEW |