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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 126 |
127 // FindCallback retrieves the callback for the histogram referred to by | 127 // FindCallback retrieves the callback for the histogram referred to by |
128 // |histogram_name|, or a null callback if no callback exists for this | 128 // |histogram_name|, or a null callback if no callback exists for this |
129 // histogram. This method is thread safe. | 129 // histogram. This method is thread safe. |
130 static OnSampleCallback FindCallback(const std::string& histogram_name); | 130 static OnSampleCallback FindCallback(const std::string& histogram_name); |
131 | 131 |
132 // Clears all of the known histograms and resets static variables to a | 132 // Clears all of the known histograms and resets static variables to a |
133 // state that allows a new initialization. | 133 // state that allows a new initialization. |
134 static void ResetForTesting(); | 134 static void ResetForTesting(); |
135 | 135 |
| 136 // Removes a histogram from the internal set of known ones. This can be |
| 137 // necessary during testing persistent histograms where the underlying |
| 138 // memory is being released. |
| 139 static void ForgetHistogramForTesting(const std::string& name); |
| 140 |
136 private: | 141 private: |
137 // We keep a map of callbacks to histograms, so that as histograms are | 142 // We keep a map of callbacks to histograms, so that as histograms are |
138 // created, we can set the callback properly. | 143 // created, we can set the callback properly. |
139 typedef std::map<std::string, OnSampleCallback> CallbackMap; | 144 typedef std::map<std::string, OnSampleCallback> CallbackMap; |
140 | 145 |
141 // We keep all |bucket_ranges_| in a map, from checksum to a list of | 146 // We keep all |bucket_ranges_| in a map, from checksum to a list of |
142 // |bucket_ranges_|. Checksum is calculated from the |ranges_| in | 147 // |bucket_ranges_|. Checksum is calculated from the |ranges_| in |
143 // |bucket_ranges_|. | 148 // |bucket_ranges_|. |
144 typedef std::map<uint32_t, std::list<const BucketRanges*>*> RangesMap; | 149 typedef std::map<uint32_t, std::list<const BucketRanges*>*> RangesMap; |
145 | 150 |
(...skipping 22 matching lines...) Expand all Loading... |
168 | 173 |
169 // Lock protects access to above maps. | 174 // Lock protects access to above maps. |
170 static base::Lock* lock_; | 175 static base::Lock* lock_; |
171 | 176 |
172 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); | 177 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); |
173 }; | 178 }; |
174 | 179 |
175 } // namespace base | 180 } // namespace base |
176 | 181 |
177 #endif // BASE_METRICS_STATISTICS_RECORDER_H_ | 182 #endif // BASE_METRICS_STATISTICS_RECORDER_H_ |
OLD | NEW |