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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 friend class HistogramBaseTest; | 188 friend class HistogramBaseTest; |
189 friend class HistogramSnapshotManagerTest; | 189 friend class HistogramSnapshotManagerTest; |
190 friend class HistogramTest; | 190 friend class HistogramTest; |
191 friend class JsonPrefStoreTest; | 191 friend class JsonPrefStoreTest; |
192 friend class SharedHistogramTest; | 192 friend class SharedHistogramTest; |
193 friend class SparseHistogramTest; | 193 friend class SparseHistogramTest; |
194 friend class StatisticsRecorderTest; | 194 friend class StatisticsRecorderTest; |
195 FRIEND_TEST_ALL_PREFIXES(HistogramDeltaSerializationTest, | 195 FRIEND_TEST_ALL_PREFIXES(HistogramDeltaSerializationTest, |
196 DeserializeHistogramAndAddSamples); | 196 DeserializeHistogramAndAddSamples); |
197 | 197 |
| 198 // Imports histograms from global persistent memory. The global lock must |
| 199 // not be held during this call. |
| 200 static void ImportGlobalPersistentHistograms(); |
| 201 |
198 // The constructor just initializes static members. Usually client code should | 202 // The constructor just initializes static members. Usually client code should |
199 // use Initialize to do this. But in test code, you can friend this class and | 203 // use Initialize to do this. But in test code, you can friend this class and |
200 // call the constructor to get a clean StatisticsRecorder. | 204 // call the constructor to get a clean StatisticsRecorder. |
201 StatisticsRecorder(); | 205 StatisticsRecorder(); |
202 | 206 |
203 // These are copies of everything that existed when the (test) Statistics- | 207 // These are copies of everything that existed when the (test) Statistics- |
204 // Recorder was created. The global ones have to be moved aside to create a | 208 // Recorder was created. The global ones have to be moved aside to create a |
205 // clean environment. | 209 // clean environment. |
206 std::unique_ptr<HistogramMap> existing_histograms_; | 210 std::unique_ptr<HistogramMap> existing_histograms_; |
207 std::unique_ptr<CallbackMap> existing_callbacks_; | 211 std::unique_ptr<CallbackMap> existing_callbacks_; |
208 std::unique_ptr<RangesMap> existing_ranges_; | 212 std::unique_ptr<RangesMap> existing_ranges_; |
209 | 213 |
210 static void Reset(); | 214 static void Reset(); |
211 static void DumpHistogramsToVlog(void* instance); | 215 static void DumpHistogramsToVlog(void* instance); |
212 | 216 |
213 static HistogramMap* histograms_; | 217 static HistogramMap* histograms_; |
214 static CallbackMap* callbacks_; | 218 static CallbackMap* callbacks_; |
215 static RangesMap* ranges_; | 219 static RangesMap* ranges_; |
216 | 220 |
217 // Lock protects access to above maps. | 221 // Lock protects access to above maps. |
218 static base::Lock* lock_; | 222 static base::Lock* lock_; |
219 | 223 |
220 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); | 224 DISALLOW_COPY_AND_ASSIGN(StatisticsRecorder); |
221 }; | 225 }; |
222 | 226 |
223 } // namespace base | 227 } // namespace base |
224 | 228 |
225 #endif // BASE_METRICS_STATISTICS_RECORDER_H_ | 229 #endif // BASE_METRICS_STATISTICS_RECORDER_H_ |
OLD | NEW |