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_PENDING_TASK_H_ | 5 #ifndef BASE_PENDING_TASK_H_ |
6 #define BASE_PENDING_TASK_H_ | 6 #define BASE_PENDING_TASK_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 | 9 |
10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/location.h" | 12 #include "base/location.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "base/tracking_info.h" | 14 #include "base/tracking_info.h" |
15 | 15 |
16 namespace base { | 16 namespace base { |
17 | 17 |
18 // Contains data about a pending task. Stored in TaskQueue and DelayedTaskQueue | 18 // Contains data about a pending task. Stored in TaskQueue and DelayedTaskQueue |
19 // for use by classes that queue and execute tasks. | 19 // for use by classes that queue and execute tasks. |
20 struct BASE_EXPORT PendingTask : public TrackingInfo { | 20 struct BASE_EXPORT PendingTask : public TrackingInfo { |
21 PendingTask(const tracked_objects::Location& posted_from, | 21 PendingTask(const tracked_objects::Location& posted_from, |
| 22 const PendingTask* parent_task, |
22 const Closure& task); | 23 const Closure& task); |
23 PendingTask(const tracked_objects::Location& posted_from, | 24 PendingTask(const tracked_objects::Location& posted_from, |
| 25 const PendingTask* parent_task, |
24 const Closure& task, | 26 const Closure& task, |
25 TimeTicks delayed_run_time, | 27 TimeTicks delayed_run_time, |
26 bool nestable); | 28 bool nestable); |
27 ~PendingTask(); | 29 ~PendingTask(); |
28 | 30 |
29 // Used to support sorting. | 31 // Used to support sorting. |
30 bool operator<(const PendingTask& other) const; | 32 bool operator<(const PendingTask& other) const; |
31 | 33 |
32 // The task to run. | 34 // The task to run. |
33 Closure task; | 35 Closure task; |
34 | 36 |
35 // The site this PendingTask was posted from. | 37 // The site this PendingTask was posted from. |
36 tracked_objects::Location posted_from; | 38 tracked_objects::Location posted_from; |
37 | 39 |
| 40 // Task backtrace. |
| 41 const void* task_backtrace[4]; |
| 42 |
38 // Secondary sort key for run time. | 43 // Secondary sort key for run time. |
39 int sequence_num; | 44 int sequence_num; |
40 | 45 |
41 // OK to dispatch from a nested loop. | 46 // OK to dispatch from a nested loop. |
42 bool nestable; | 47 bool nestable; |
43 | 48 |
44 // Needs high resolution timers. | 49 // Needs high resolution timers. |
45 bool is_high_res; | 50 bool is_high_res; |
46 }; | 51 }; |
47 | 52 |
48 // Wrapper around std::queue specialized for PendingTask which adds a Swap | 53 // Wrapper around std::queue specialized for PendingTask which adds a Swap |
49 // helper method. | 54 // helper method. |
50 class BASE_EXPORT TaskQueue : public std::queue<PendingTask> { | 55 class BASE_EXPORT TaskQueue : public std::queue<PendingTask> { |
51 public: | 56 public: |
52 void Swap(TaskQueue* queue); | 57 void Swap(TaskQueue* queue); |
53 }; | 58 }; |
54 | 59 |
55 // PendingTasks are sorted by their |delayed_run_time| property. | 60 // PendingTasks are sorted by their |delayed_run_time| property. |
56 typedef std::priority_queue<base::PendingTask> DelayedTaskQueue; | 61 typedef std::priority_queue<base::PendingTask> DelayedTaskQueue; |
57 | 62 |
58 } // namespace base | 63 } // namespace base |
59 | 64 |
60 #endif // BASE_PENDING_TASK_H_ | 65 #endif // BASE_PENDING_TASK_H_ |
OLD | NEW |