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_TRACKED_OBJECTS_H_ | 5 #ifndef BASE_TRACKED_OBJECTS_H_ |
| 6 #define BASE_TRACKED_OBJECTS_H_ | 6 #define BASE_TRACKED_OBJECTS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/base_export.h" | 13 #include "base/base_export.h" |
| 14 #include "base/location.h" | |
| 15 #include "base/time.h" | |
| 14 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
| 15 #include "base/tracked.h" | |
| 16 #include "base/threading/thread_local_storage.h" | 17 #include "base/threading/thread_local_storage.h" |
| 17 | 18 |
| 19 // TODO(ajwong): Fix this comment to remove references to Tracked. | |
|
willchan no longer on Chromium
2011/09/13 05:06:56
You gonna do this?
awong
2011/09/13 19:39:04
Yep...sorry...apparently uploaded a stale CL. :(
| |
| 18 // TrackedObjects provides a database of stats about objects (generally Tasks) | 20 // TrackedObjects provides a database of stats about objects (generally Tasks) |
| 19 // that are tracked. Tracking means their birth, death, duration, birth thread, | 21 // that are tracked. Tracking means their birth, death, duration, birth thread, |
| 20 // death thread, and birth place are recorded. This data is carefully spread | 22 // death thread, and birth place are recorded. This data is carefully spread |
| 21 // across a series of objects so that the counts and times can be rapidly | 23 // across a series of objects so that the counts and times can be rapidly |
| 22 // updated without (usually) having to lock the data, and hence there is usually | 24 // updated without (usually) having to lock the data, and hence there is usually |
| 23 // very little contention caused by the tracking. The data can be viewed via | 25 // very little contention caused by the tracking. The data can be viewed via |
| 24 // the about:tasks URL, with a variety of sorting and filtering choices. | 26 // the about:tasks URL, with a variety of sorting and filtering choices. |
| 25 // | 27 // |
| 26 // These classes serve as the basis of a profiler of sorts for the Tasks system. | 28 // These classes serve as the basis of a profiler of sorts for the Tasks system. |
| 27 // As a result, design decisions were made to maximize speed, by minimizing | 29 // As a result, design decisions were made to maximize speed, by minimizing |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 // snapshot instances, and are used to print sub-totals in an about:tasks page. | 142 // snapshot instances, and are used to print sub-totals in an about:tasks page. |
| 141 // | 143 // |
| 142 // TODO(jar): I need to store DataCollections, and provide facilities for taking | 144 // TODO(jar): I need to store DataCollections, and provide facilities for taking |
| 143 // the difference between two gathered DataCollections. For now, I'm just | 145 // the difference between two gathered DataCollections. For now, I'm just |
| 144 // adding a hack that Reset()'s to zero all counts and stats. This is also | 146 // adding a hack that Reset()'s to zero all counts and stats. This is also |
| 145 // done in a slighly thread-unsafe fashion, as the reseting is done | 147 // done in a slighly thread-unsafe fashion, as the reseting is done |
| 146 // asynchronously relative to ongoing updates, and worse yet, some data fields | 148 // asynchronously relative to ongoing updates, and worse yet, some data fields |
| 147 // are 64bit quantities, and are not atomicly accessed (reset or incremented | 149 // are 64bit quantities, and are not atomicly accessed (reset or incremented |
| 148 // etc.). For basic profiling, this will work "most of the time," and should be | 150 // etc.). For basic profiling, this will work "most of the time," and should be |
| 149 // sufficient... but storing away DataCollections is the "right way" to do this. | 151 // sufficient... but storing away DataCollections is the "right way" to do this. |
| 150 // | 152 |
| 151 class MessageLoop; | 153 class MessageLoop; |
| 152 | 154 |
| 153 | |
| 154 namespace tracked_objects { | 155 namespace tracked_objects { |
| 155 | 156 |
| 156 //------------------------------------------------------------------------------ | 157 //------------------------------------------------------------------------------ |
| 157 // For a specific thread, and a specific birth place, the collection of all | 158 // For a specific thread, and a specific birth place, the collection of all |
| 158 // death info (with tallies for each death thread, to prevent access conflicts). | 159 // death info (with tallies for each death thread, to prevent access conflicts). |
| 159 class ThreadData; | 160 class ThreadData; |
| 160 class BASE_EXPORT BirthOnThread { | 161 class BASE_EXPORT BirthOnThread { |
| 161 public: | 162 public: |
| 162 explicit BirthOnThread(const Location& location); | 163 explicit BirthOnThread(const Location& location); |
| 163 | 164 |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 666 }; | 667 }; |
| 667 static State state_; | 668 static State state_; |
| 668 | 669 |
| 669 DISALLOW_COPY_AND_ASSIGN(AutoTracking); | 670 DISALLOW_COPY_AND_ASSIGN(AutoTracking); |
| 670 }; | 671 }; |
| 671 | 672 |
| 672 | 673 |
| 673 } // namespace tracked_objects | 674 } // namespace tracked_objects |
| 674 | 675 |
| 675 #endif // BASE_TRACKED_OBJECTS_H_ | 676 #endif // BASE_TRACKED_OBJECTS_H_ |
| OLD | NEW |