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_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 using internal::OnceClosure; | |
|
fdoray
2016/10/06 17:37:22
Avoid using "using" in a header file.
tzik
2016/10/13 05:58:04
Removed. This is no longer needed after I moved it
| |
| 19 | |
| 18 // Contains data about a pending task. Stored in TaskQueue and DelayedTaskQueue | 20 // Contains data about a pending task. Stored in TaskQueue and DelayedTaskQueue |
| 19 // for use by classes that queue and execute tasks. | 21 // for use by classes that queue and execute tasks. |
| 20 struct BASE_EXPORT PendingTask : public TrackingInfo { | 22 struct BASE_EXPORT PendingTask : public TrackingInfo { |
| 23 PendingTask(const tracked_objects::Location& posted_from, OnceClosure task); | |
| 21 PendingTask(const tracked_objects::Location& posted_from, | 24 PendingTask(const tracked_objects::Location& posted_from, |
| 22 Closure task); | 25 OnceClosure task, |
| 23 PendingTask(const tracked_objects::Location& posted_from, | |
| 24 Closure task, | |
| 25 TimeTicks delayed_run_time, | 26 TimeTicks delayed_run_time, |
| 26 bool nestable); | 27 bool nestable); |
| 27 PendingTask(PendingTask&& other); | 28 PendingTask(PendingTask&& other); |
| 28 ~PendingTask(); | 29 ~PendingTask(); |
| 29 | 30 |
| 30 PendingTask& operator=(PendingTask&& other); | 31 PendingTask& operator=(PendingTask&& other); |
| 31 | 32 |
| 32 // Used to support sorting. | 33 // Used to support sorting. |
| 33 bool operator<(const PendingTask& other) const; | 34 bool operator<(const PendingTask& other) const; |
| 34 | 35 |
| 35 // The task to run. | 36 // The task to run. |
| 36 Closure task; | 37 OnceClosure task; |
| 37 | 38 |
| 38 // The site this PendingTask was posted from. | 39 // The site this PendingTask was posted from. |
| 39 tracked_objects::Location posted_from; | 40 tracked_objects::Location posted_from; |
| 40 | 41 |
| 41 // Secondary sort key for run time. | 42 // Secondary sort key for run time. |
| 42 int sequence_num; | 43 int sequence_num; |
| 43 | 44 |
| 44 // OK to dispatch from a nested loop. | 45 // OK to dispatch from a nested loop. |
| 45 bool nestable; | 46 bool nestable; |
| 46 | 47 |
| 47 // Needs high resolution timers. | 48 // Needs high resolution timers. |
| 48 bool is_high_res; | 49 bool is_high_res; |
| 49 }; | 50 }; |
| 50 | 51 |
| 51 using TaskQueue = std::queue<PendingTask>; | 52 using TaskQueue = std::queue<PendingTask>; |
| 52 | 53 |
| 53 // PendingTasks are sorted by their |delayed_run_time| property. | 54 // PendingTasks are sorted by their |delayed_run_time| property. |
| 54 using DelayedTaskQueue = std::priority_queue<base::PendingTask>; | 55 using DelayedTaskQueue = std::priority_queue<base::PendingTask>; |
| 55 | 56 |
| 56 } // namespace base | 57 } // namespace base |
| 57 | 58 |
| 58 #endif // BASE_PENDING_TASK_H_ | 59 #endif // BASE_PENDING_TASK_H_ |
| OLD | NEW |