| 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> | 13 #include <stdint.h> |
| 14 | 14 |
| 15 #include <list> | 15 #include <list> |
| 16 #include <map> | 16 #include <map> |
| 17 #include <memory> | 17 #include <memory> |
| 18 #include <string> | 18 #include <string> |
| 19 #include <vector> | 19 #include <vector> |
| 20 | 20 |
| 21 #include "base/base_export.h" | 21 #include "base/base_export.h" |
| 22 #include "base/callback.h" | 22 #include "base/callback.h" |
| 23 #include "base/gtest_prod_util.h" | 23 #include "base/gtest_prod_util.h" |
| 24 #include "base/lazy_instance.h" | 24 #include "base/lazy_instance.h" |
| 25 #include "base/macros.h" | 25 #include "base/macros.h" |
| 26 #include "base/metrics/histogram_base.h" | 26 #include "base/metrics/histogram_base.h" |
| 27 #include "base/strings/string_piece.h" | 27 #include "base/strings/string_piece.h" |
| 28 | 28 |
| 29 class SubprocessMetricsProviderTest; |
| 30 |
| 29 namespace base { | 31 namespace base { |
| 30 | 32 |
| 31 class BucketRanges; | 33 class BucketRanges; |
| 32 class Lock; | 34 class Lock; |
| 33 | 35 |
| 34 class BASE_EXPORT StatisticsRecorder { | 36 class BASE_EXPORT StatisticsRecorder { |
| 35 public: | 37 public: |
| 36 // A class used as a key for the histogram map below. It always references | 38 // A class used as a key for the histogram map below. It always references |
| 37 // a string owned outside of this class, likely in the value of the map. | 39 // a string owned outside of this class, likely in the value of the map. |
| 38 class StringKey : public StringPiece { | 40 class StringKey : public StringPiece { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 // We keep a map of callbacks to histograms, so that as histograms are | 180 // We keep a map of callbacks to histograms, so that as histograms are |
| 179 // created, we can set the callback properly. | 181 // created, we can set the callback properly. |
| 180 typedef std::map<std::string, OnSampleCallback> CallbackMap; | 182 typedef std::map<std::string, OnSampleCallback> CallbackMap; |
| 181 | 183 |
| 182 // We keep all |bucket_ranges_| in a map, from checksum to a list of | 184 // We keep all |bucket_ranges_| in a map, from checksum to a list of |
| 183 // |bucket_ranges_|. Checksum is calculated from the |ranges_| in | 185 // |bucket_ranges_|. Checksum is calculated from the |ranges_| in |
| 184 // |bucket_ranges_|. | 186 // |bucket_ranges_|. |
| 185 typedef std::map<uint32_t, std::list<const BucketRanges*>*> RangesMap; | 187 typedef std::map<uint32_t, std::list<const BucketRanges*>*> RangesMap; |
| 186 | 188 |
| 187 friend struct DefaultLazyInstanceTraits<StatisticsRecorder>; | 189 friend struct DefaultLazyInstanceTraits<StatisticsRecorder>; |
| 190 friend class ::SubprocessMetricsProviderTest; |
| 188 friend class HistogramBaseTest; | 191 friend class HistogramBaseTest; |
| 189 friend class HistogramSnapshotManagerTest; | 192 friend class HistogramSnapshotManagerTest; |
| 190 friend class HistogramTest; | 193 friend class HistogramTest; |
| 191 friend class JsonPrefStoreTest; | 194 friend class JsonPrefStoreTest; |
| 195 friend class PersistentHistogramAllocatorTest; |
| 192 friend class SharedHistogramTest; | 196 friend class SharedHistogramTest; |
| 193 friend class SparseHistogramTest; | 197 friend class SparseHistogramTest; |
| 194 friend class StatisticsRecorderTest; | 198 friend class StatisticsRecorderTest; |
| 195 FRIEND_TEST_ALL_PREFIXES(HistogramDeltaSerializationTest, | 199 FRIEND_TEST_ALL_PREFIXES(HistogramDeltaSerializationTest, |
| 196 DeserializeHistogramAndAddSamples); | 200 DeserializeHistogramAndAddSamples); |
| 197 | 201 |
| 198 // Imports histograms from global persistent memory. The global lock must | 202 // Imports histograms from global persistent memory. The global lock must |
| 199 // not be held during this call. | 203 // not be held during this call. |
| 200 static void ImportGlobalPersistentHistograms(); | 204 static void ImportGlobalPersistentHistograms(); |
| 201 | 205 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 220 | 224 |
| 221 // Lock protects access to above maps. | 225 // Lock protects access to above maps. |
| 222 static base::Lock* lock_; | 226 static base::Lock* lock_; |
| 223 | 227 |
| 224 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); | 228 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); |
| 225 }; | 229 }; |
| 226 | 230 |
| 227 } // namespace base | 231 } // namespace base |
| 228 | 232 |
| 229 #endif // BASE_METRICS_STATISTICS_RECORDER_H_ | 233 #endif // BASE_METRICS_STATISTICS_RECORDER_H_ |
| OLD | NEW |