| 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 HistogramBaseTest; |
| 93 friend class HistogramTest; | 94 friend class HistogramTest; |
| 94 friend class StatisticsRecorderTest; | 95 friend class StatisticsRecorderTest; |
| 95 | 96 |
| 96 // The constructor just initializes static members. Usually client code should | 97 // The constructor just initializes static members. Usually client code should |
| 97 // use Initialize to do this. But in test code, you can friend this class and | 98 // use Initialize to do this. But in test code, you can friend this class and |
| 98 // call destructor/constructor to get a clean StatisticsRecorder. | 99 // call destructor/constructor to get a clean StatisticsRecorder. |
| 99 StatisticsRecorder(); | 100 StatisticsRecorder(); |
| 100 ~StatisticsRecorder(); | 101 ~StatisticsRecorder(); |
| 101 | 102 |
| 102 static HistogramMap* histograms_; | 103 static HistogramMap* histograms_; |
| 103 static RangesMap* ranges_; | 104 static RangesMap* ranges_; |
| 104 | 105 |
| 105 // Lock protects access to above maps. | 106 // Lock protects access to above maps. |
| 106 static base::Lock* lock_; | 107 static base::Lock* lock_; |
| 107 | 108 |
| 108 // Dump all known histograms to log. | 109 // Dump all known histograms to log. |
| 109 static bool dump_on_exit_; | 110 static bool dump_on_exit_; |
| 110 | 111 |
| 111 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); | 112 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); |
| 112 }; | 113 }; |
| 113 | 114 |
| 114 } // namespace base | 115 } // namespace base |
| 115 | 116 |
| 116 #endif // BASE_METRICS_STATISTICS_RECORDER_H_ | 117 #endif // BASE_METRICS_STATISTICS_RECORDER_H_ |
| OLD | NEW |