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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 private: | 210 private: |
211 // We keep a map of callbacks to histograms, so that as histograms are | 211 // We keep a map of callbacks to histograms, so that as histograms are |
212 // created, we can set the callback properly. | 212 // created, we can set the callback properly. |
213 typedef std::map<std::string, OnSampleCallback> CallbackMap; | 213 typedef std::map<std::string, OnSampleCallback> CallbackMap; |
214 | 214 |
215 // We keep all |bucket_ranges_| in a map, from checksum to a list of | 215 // We keep all |bucket_ranges_| in a map, from checksum to a list of |
216 // |bucket_ranges_|. Checksum is calculated from the |ranges_| in | 216 // |bucket_ranges_|. Checksum is calculated from the |ranges_| in |
217 // |bucket_ranges_|. | 217 // |bucket_ranges_|. |
218 typedef std::map<uint32_t, std::list<const BucketRanges*>*> RangesMap; | 218 typedef std::map<uint32_t, std::list<const BucketRanges*>*> RangesMap; |
219 | 219 |
220 friend struct DefaultLazyInstanceTraits<StatisticsRecorder>; | 220 friend struct LazyInstanceTraitsBase<StatisticsRecorder>; |
221 friend class StatisticsRecorderTest; | 221 friend class StatisticsRecorderTest; |
222 | 222 |
223 // Imports histograms from global persistent memory. The global lock must | 223 // Imports histograms from global persistent memory. The global lock must |
224 // not be held during this call. | 224 // not be held during this call. |
225 static void ImportGlobalPersistentHistograms(); | 225 static void ImportGlobalPersistentHistograms(); |
226 | 226 |
227 // The constructor just initializes static members. Usually client code should | 227 // The constructor just initializes static members. Usually client code should |
228 // use Initialize to do this. But in test code, you can friend this class and | 228 // use Initialize to do this. But in test code, you can friend this class and |
229 // call the constructor to get a clean StatisticsRecorder. | 229 // call the constructor to get a clean StatisticsRecorder. |
230 StatisticsRecorder(); | 230 StatisticsRecorder(); |
(...skipping 25 matching lines...) Expand all Loading... |
256 // would do |if (!lock_) return;| which would race with | 256 // would do |if (!lock_) return;| which would race with |
257 // |lock_ = new Lock;| in StatisticsRecorder(). http://crbug.com/672852. | 257 // |lock_ = new Lock;| in StatisticsRecorder(). http://crbug.com/672852. |
258 static base::LazyInstance<base::Lock>::Leaky lock_; | 258 static base::LazyInstance<base::Lock>::Leaky lock_; |
259 | 259 |
260 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); | 260 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); |
261 }; | 261 }; |
262 | 262 |
263 } // namespace base | 263 } // namespace base |
264 | 264 |
265 #endif // BASE_METRICS_STATISTICS_RECORDER_H_ | 265 #endif // BASE_METRICS_STATISTICS_RECORDER_H_ |
OLD | NEW |