OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 //------------------------------------------------------------------------------ | 5 //------------------------------------------------------------------------------ |
6 // Tracked is the base class for all tracked objects. During construction, it | 6 // Tracked is the base class for all tracked objects. During construction, it |
7 // registers the fact that an instance was created, and at destruction time, it | 7 // registers the fact that an instance was created, and at destruction time, it |
8 // records that event. The instance may be tagged with a name, which is refered | 8 // records that event. The instance may be tagged with a name, which is refered |
9 // to as its Location. The Location is a file and line number, most | 9 // to as its Location. The Location is a file and line number, most |
10 // typically indicated where the object was constructed. In some cases, as the | 10 // typically indicated where the object was constructed. In some cases, as the |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 // Used to record the FROM_HERE location of a caller. | 100 // Used to record the FROM_HERE location of a caller. |
101 void SetBirthPlace(const Location& from_here); | 101 void SetBirthPlace(const Location& from_here); |
102 | 102 |
103 // When a task sits around a long time, such as in a timer, or object watcher, | 103 // When a task sits around a long time, such as in a timer, or object watcher, |
104 // this method should be called when the task becomes active, and its | 104 // this method should be called when the task becomes active, and its |
105 // significant lifetime begins (and its waiting to be woken up has passed). | 105 // significant lifetime begins (and its waiting to be woken up has passed). |
106 void ResetBirthTime(); | 106 void ResetBirthTime(); |
107 | 107 |
108 bool MissingBirthplace() const; | 108 bool MissingBirthplace() const; |
109 | 109 |
| 110 #if defined(TRACK_ALL_TASK_OBJECTS) |
| 111 base::TimeTicks tracked_birth_time() const { return tracked_birth_time_; } |
| 112 #else |
| 113 base::TimeTicks tracked_birth_time() const { return base::TimeTicks::Now(); } |
| 114 #endif // defined(TRACK_ALL_TASK_OBJECTS) |
| 115 |
110 private: | 116 private: |
111 #ifdef TRACK_ALL_TASK_OBJECTS | 117 #if defined(TRACK_ALL_TASK_OBJECTS) |
112 | 118 |
113 // Pointer to instance were counts of objects with the same birth location | 119 // Pointer to instance were counts of objects with the same birth location |
114 // (on the same thread) are stored. | 120 // (on the same thread) are stored. |
115 Births* tracked_births_; | 121 Births* tracked_births_; |
116 // The time this object was constructed. If its life consisted of a long | 122 // The time this object was constructed. If its life consisted of a long |
117 // waiting period, and then it became active, then this value is generally | 123 // waiting period, and then it became active, then this value is generally |
118 // reset before the object begins it active life. | 124 // reset before the object begins it active life. |
119 base::TimeTicks tracked_birth_time_; | 125 base::TimeTicks tracked_birth_time_; |
120 | 126 |
121 #endif // TRACK_ALL_TASK_OBJECTS | 127 #endif // defined(TRACK_ALL_TASK_OBJECTS) |
122 | 128 |
123 DISALLOW_COPY_AND_ASSIGN(Tracked); | 129 DISALLOW_COPY_AND_ASSIGN(Tracked); |
124 }; | 130 }; |
125 | 131 |
126 } // namespace tracked_objects | 132 } // namespace tracked_objects |
127 | 133 |
128 #endif // BASE_TRACKED_H_ | 134 #endif // BASE_TRACKED_H_ |
OLD | NEW |