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 // This is a simple struct with tracking information that is stored | 5 // This is a simple struct with tracking information that is stored |
6 // with a PendingTask (when message_loop is handling the task). | 6 // with a PendingTask (when message_loop is handling the task). |
7 // Only the information that is shared with the profiler in tracked_objects | 7 // Only the information that is shared with the profiler in tracked_objects |
8 // are included in this structure. | 8 // are included in this structure. |
9 | 9 |
10 | 10 |
11 #ifndef BASE_TRACKING_INFO_H_ | 11 #ifndef BASE_TRACKING_INFO_H_ |
12 #define BASE_TRACKING_INFO_H_ | 12 #define BASE_TRACKING_INFO_H_ |
13 | 13 |
14 #include "base/base_export.h" | 14 #include "base/base_export.h" |
15 #include "base/profiler/tracked_time.h" | |
16 #include "base/time/time.h" | 15 #include "base/time/time.h" |
17 | 16 |
18 namespace tracked_objects { | 17 namespace tracked_objects { |
19 class Location; | 18 class Location; |
20 class Births; | 19 class Births; |
21 } | 20 } |
22 | 21 |
23 namespace base { | 22 namespace base { |
24 | 23 |
25 // This structure is copied around by value. | 24 // This structure is copied around by value. |
26 struct BASE_EXPORT TrackingInfo { | 25 struct BASE_EXPORT TrackingInfo { |
27 TrackingInfo(); | 26 TrackingInfo(); |
28 TrackingInfo(const tracked_objects::Location& posted_from, | 27 TrackingInfo(const tracked_objects::Location& posted_from, |
29 base::TimeTicks delayed_run_time); | 28 base::TimeTicks delayed_run_time); |
30 ~TrackingInfo(); | 29 ~TrackingInfo(); |
31 | 30 |
32 // To avoid conflating our stats with the delay duration in a PostDelayedTask, | 31 // To avoid conflating our stats with the delay duration in a PostDelayedTask, |
33 // we identify such tasks, and replace their post_time with the time they | 32 // we identify such tasks, and replace their post_time with the time they |
34 // were scheduled (requested?) to emerge from the delayed task queue. This | 33 // were scheduled (requested?) to emerge from the delayed task queue. This |
35 // means that queuing delay for such tasks will show how long they went | 34 // means that queuing delay for such tasks will show how long they went |
36 // unserviced, after they *could* be serviced. This is the same stat as we | 35 // unserviced, after they *could* be serviced. This is the same stat as we |
37 // have for non-delayed tasks, and we consistently call it queuing delay. | 36 // have for non-delayed tasks, and we consistently call it queuing delay. |
38 tracked_objects::TrackedTime EffectiveTimePosted() const { | 37 base::TimeTicks EffectiveTimePosted() const { |
39 return delayed_run_time.is_null() | 38 return delayed_run_time.is_null() ? time_posted : delayed_run_time; |
40 ? time_posted | |
41 : tracked_objects::TrackedTime(delayed_run_time); | |
42 } | 39 } |
43 | 40 |
44 // Record of location and thread that the task came from. | 41 // Record of location and thread that the task came from. |
45 tracked_objects::Births* birth_tally; | 42 tracked_objects::Births* birth_tally; |
46 | 43 |
47 // Time when the related task was posted. Note that this value may be empty | 44 // Time when the related task was posted. Note that this value may be empty |
48 // if task profiling is disabled, and should only be used in conjunction with | 45 // if task profiling is disabled, and should only be used in conjunction with |
49 // profiling-related reporting. | 46 // profiling-related reporting. |
50 tracked_objects::TrackedTime time_posted; | 47 base::TimeTicks time_posted; |
51 | 48 |
52 // The time when the task should be run. | 49 // The time when the task should be run. |
53 base::TimeTicks delayed_run_time; | 50 base::TimeTicks delayed_run_time; |
54 }; | 51 }; |
55 | 52 |
56 } // namespace base | 53 } // namespace base |
57 | 54 |
58 #endif // BASE_TRACKING_INFO_H_ | 55 #endif // BASE_TRACKING_INFO_H_ |
OLD | NEW |