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 // StatisticsRecorder holds all Histograms and BucketRanges that are used by | 5 // StatisticsRecorder holds all Histograms and BucketRanges that are used by |
6 // Histograms in the system. It provides a general place for | 6 // Histograms in the system. It provides a general place for |
7 // Histograms/BucketRanges to register, and supports a global API for accessing | 7 // Histograms/BucketRanges to register, and supports a global API for accessing |
8 // (i.e., dumping, or graphing) the data. | 8 // (i.e., dumping, or graphing) the data. |
9 | 9 |
10 #ifndef BASE_METRICS_STATISTICS_RECORDER_H_ | 10 #ifndef BASE_METRICS_STATISTICS_RECORDER_H_ |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 private: | 83 private: |
84 // We keep all registered histograms in a map, from name to histogram. | 84 // We keep all registered histograms in a map, from name to histogram. |
85 typedef std::map<std::string, Histogram*> HistogramMap; | 85 typedef std::map<std::string, Histogram*> HistogramMap; |
86 | 86 |
87 // We keep all |bucket_ranges_| in a map, from checksum to a list of | 87 // We keep all |bucket_ranges_| in a map, from checksum to a list of |
88 // |bucket_ranges_|. Checksum is calculated from the |ranges_| in | 88 // |bucket_ranges_|. Checksum is calculated from the |ranges_| in |
89 // |bucket_ranges_|. | 89 // |bucket_ranges_|. |
90 typedef std::map<uint32, std::list<const BucketRanges*>*> RangesMap; | 90 typedef std::map<uint32, std::list<const BucketRanges*>*> RangesMap; |
91 | 91 |
92 friend struct DefaultLazyInstanceTraits<StatisticsRecorder>; | 92 friend struct DefaultLazyInstanceTraits<StatisticsRecorder>; |
| 93 friend class HistogramTest; |
93 friend class StatisticsRecorderTest; | 94 friend class StatisticsRecorderTest; |
94 | 95 |
95 // The constructor just initializes static members. Usually client code should | 96 // The constructor just initializes static members. Usually client code should |
96 // use Initialize to do this. But in test code, you can friend this class and | 97 // use Initialize to do this. But in test code, you can friend this class and |
97 // call destructor/constructor to get a clean StatisticsRecorder. | 98 // call destructor/constructor to get a clean StatisticsRecorder. |
98 StatisticsRecorder(); | 99 StatisticsRecorder(); |
99 ~StatisticsRecorder(); | 100 ~StatisticsRecorder(); |
100 | 101 |
101 static HistogramMap* histograms_; | 102 static HistogramMap* histograms_; |
102 static RangesMap* ranges_; | 103 static RangesMap* ranges_; |
103 | 104 |
104 // Lock protects access to above maps. | 105 // Lock protects access to above maps. |
105 static base::Lock* lock_; | 106 static base::Lock* lock_; |
106 | 107 |
107 // Dump all known histograms to log. | 108 // Dump all known histograms to log. |
108 static bool dump_on_exit_; | 109 static bool dump_on_exit_; |
109 | 110 |
110 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); | 111 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); |
111 }; | 112 }; |
112 | 113 |
113 } // namespace base | 114 } // namespace base |
114 | 115 |
115 #endif // BASE_METRICS_STATISTICS_RECORDER_H_ | 116 #endif // BASE_METRICS_STATISTICS_RECORDER_H_ |
OLD | NEW |