OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 TaskRunner, | 5 // CancelableTaskTracker posts tasks (in the form of a Closure) to a TaskRunner, |
6 // and is able to cancel the task later if it's not needed anymore. On | 6 // and is able to cancel the task later if it's not needed anymore. On |
7 // destruction, CancelableTaskTracker will cancel all tracked tasks. | 7 // destruction, CancelableTaskTracker will cancel all tracked tasks. |
8 // | 8 // |
9 // Each cancelable task can be associated with a reply (also a Closure). After | 9 // Each cancelable task can be associated with a reply (also a Closure). After |
10 // the task is run on the TaskRunner, |reply| will be posted back to originating | 10 // the task is run on the TaskRunner, |reply| will be posted back to originating |
(...skipping 18 matching lines...) Expand all Loading... |
29 // | 29 // |
30 // 2. Both task and reply are deleted on the originating thread. | 30 // 2. Both task and reply are deleted on the originating thread. |
31 // | 31 // |
32 // 3. IsCanceledCallback is thread safe and can be run or deleted on any thread. | 32 // 3. IsCanceledCallback is thread safe and can be run or deleted on any thread. |
33 | 33 |
34 #ifndef CHROME_COMMON_CANCELABLE_TASK_TRACKER_H_ | 34 #ifndef CHROME_COMMON_CANCELABLE_TASK_TRACKER_H_ |
35 #define CHROME_COMMON_CANCELABLE_TASK_TRACKER_H_ | 35 #define CHROME_COMMON_CANCELABLE_TASK_TRACKER_H_ |
36 | 36 |
37 #include "base/basictypes.h" | 37 #include "base/basictypes.h" |
38 #include "base/callback.h" | 38 #include "base/callback.h" |
39 #include "base/hash_tables.h" | 39 #include "base/containers/hash_tables.h" |
40 #include "base/memory/weak_ptr.h" | 40 #include "base/memory/weak_ptr.h" |
41 #include "base/threading/thread_checker.h" | 41 #include "base/threading/thread_checker.h" |
42 | 42 |
43 namespace base { | 43 namespace base { |
44 class CancellationFlag; | 44 class CancellationFlag; |
45 class TaskRunner; | 45 class TaskRunner; |
46 } // namespace base | 46 } // namespace base |
47 | 47 |
48 namespace tracked_objects { | 48 namespace tracked_objects { |
49 class Location; | 49 class Location; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 base::hash_map<TaskId, base::CancellationFlag*> task_flags_; | 106 base::hash_map<TaskId, base::CancellationFlag*> task_flags_; |
107 base::WeakPtrFactory<CancelableTaskTracker> weak_factory_; | 107 base::WeakPtrFactory<CancelableTaskTracker> weak_factory_; |
108 | 108 |
109 TaskId next_id_; | 109 TaskId next_id_; |
110 base::ThreadChecker thread_checker_; | 110 base::ThreadChecker thread_checker_; |
111 | 111 |
112 DISALLOW_COPY_AND_ASSIGN(CancelableTaskTracker); | 112 DISALLOW_COPY_AND_ASSIGN(CancelableTaskTracker); |
113 }; | 113 }; |
114 | 114 |
115 #endif // CHROME_COMMON_CANCELABLE_TASK_TRACKER_H_ | 115 #endif // CHROME_COMMON_CANCELABLE_TASK_TRACKER_H_ |
OLD | NEW |