| 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_ |
| 11 #define BASE_METRICS_STATISTICS_RECORDER_H_ | 11 #define BASE_METRICS_STATISTICS_RECORDER_H_ |
| 12 | 12 |
| 13 #include <stdint.h> |
| 14 |
| 13 #include <list> | 15 #include <list> |
| 14 #include <map> | 16 #include <map> |
| 15 #include <string> | 17 #include <string> |
| 16 #include <vector> | 18 #include <vector> |
| 17 | 19 |
| 18 #include "base/base_export.h" | 20 #include "base/base_export.h" |
| 19 #include "base/basictypes.h" | |
| 20 #include "base/callback.h" | 21 #include "base/callback.h" |
| 21 #include "base/gtest_prod_util.h" | 22 #include "base/gtest_prod_util.h" |
| 22 #include "base/lazy_instance.h" | 23 #include "base/lazy_instance.h" |
| 24 #include "base/macros.h" |
| 23 #include "base/metrics/histogram_base.h" | 25 #include "base/metrics/histogram_base.h" |
| 24 | 26 |
| 25 namespace base { | 27 namespace base { |
| 26 | 28 |
| 27 class BucketRanges; | 29 class BucketRanges; |
| 28 class Lock; | 30 class Lock; |
| 29 | 31 |
| 30 class BASE_EXPORT StatisticsRecorder { | 32 class BASE_EXPORT StatisticsRecorder { |
| 31 public: | 33 public: |
| 32 typedef std::vector<HistogramBase*> Histograms; | 34 typedef std::vector<HistogramBase*> Histograms; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // name of the histogram. | 101 // name of the histogram. |
| 100 typedef std::map<uint64_t, HistogramBase*> HistogramMap; | 102 typedef std::map<uint64_t, HistogramBase*> HistogramMap; |
| 101 | 103 |
| 102 // We keep a map of callbacks to histograms, so that as histograms are | 104 // We keep a map of callbacks to histograms, so that as histograms are |
| 103 // created, we can set the callback properly. | 105 // created, we can set the callback properly. |
| 104 typedef std::map<std::string, OnSampleCallback> CallbackMap; | 106 typedef std::map<std::string, OnSampleCallback> CallbackMap; |
| 105 | 107 |
| 106 // We keep all |bucket_ranges_| in a map, from checksum to a list of | 108 // We keep all |bucket_ranges_| in a map, from checksum to a list of |
| 107 // |bucket_ranges_|. Checksum is calculated from the |ranges_| in | 109 // |bucket_ranges_|. Checksum is calculated from the |ranges_| in |
| 108 // |bucket_ranges_|. | 110 // |bucket_ranges_|. |
| 109 typedef std::map<uint32, std::list<const BucketRanges*>*> RangesMap; | 111 typedef std::map<uint32_t, std::list<const BucketRanges*>*> RangesMap; |
| 110 | 112 |
| 111 friend struct DefaultLazyInstanceTraits<StatisticsRecorder>; | 113 friend struct DefaultLazyInstanceTraits<StatisticsRecorder>; |
| 112 friend class HistogramBaseTest; | 114 friend class HistogramBaseTest; |
| 113 friend class HistogramSnapshotManagerTest; | 115 friend class HistogramSnapshotManagerTest; |
| 114 friend class HistogramTest; | 116 friend class HistogramTest; |
| 115 friend class JsonPrefStoreTest; | 117 friend class JsonPrefStoreTest; |
| 116 friend class SparseHistogramTest; | 118 friend class SparseHistogramTest; |
| 117 friend class StatisticsRecorderTest; | 119 friend class StatisticsRecorderTest; |
| 118 FRIEND_TEST_ALL_PREFIXES(HistogramDeltaSerializationTest, | 120 FRIEND_TEST_ALL_PREFIXES(HistogramDeltaSerializationTest, |
| 119 DeserializeHistogramAndAddSamples); | 121 DeserializeHistogramAndAddSamples); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 132 | 134 |
| 133 // Lock protects access to above maps. | 135 // Lock protects access to above maps. |
| 134 static base::Lock* lock_; | 136 static base::Lock* lock_; |
| 135 | 137 |
| 136 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); | 138 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); |
| 137 }; | 139 }; |
| 138 | 140 |
| 139 } // namespace base | 141 } // namespace base |
| 140 | 142 |
| 141 #endif // BASE_METRICS_STATISTICS_RECORDER_H_ | 143 #endif // BASE_METRICS_STATISTICS_RECORDER_H_ |
| OLD | NEW |