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 // Histogram is an object that aggregates statistics, and can summarize them in | 5 // Histogram is an object that aggregates statistics, and can summarize them in |
6 // various forms, including ASCII graphical, HTML, and numerically (as a | 6 // various forms, including ASCII graphical, HTML, and numerically (as a |
7 // vector of numbers corresponding to each of the aggregating buckets). | 7 // vector of numbers corresponding to each of the aggregating buckets). |
8 | 8 |
9 // It supports calls to accumulate either time intervals (which are processed | 9 // It supports calls to accumulate either time intervals (which are processed |
10 // as integral number of milliseconds), or arbitrary integral units. | 10 // as integral number of milliseconds), or arbitrary integral units. |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 FRIEND_TEST_ALL_PREFIXES(HistogramTest, BucketPlacementTest); | 257 FRIEND_TEST_ALL_PREFIXES(HistogramTest, BucketPlacementTest); |
258 FRIEND_TEST_ALL_PREFIXES(HistogramTest, CorruptSampleCounts); | 258 FRIEND_TEST_ALL_PREFIXES(HistogramTest, CorruptSampleCounts); |
259 | 259 |
260 friend class StatisticsRecorder; // To allow it to delete duplicates. | 260 friend class StatisticsRecorder; // To allow it to delete duplicates. |
261 friend class StatisticsRecorderTest; | 261 friend class StatisticsRecorderTest; |
262 | 262 |
263 friend BASE_EXPORT HistogramBase* DeserializeHistogramInfo( | 263 friend BASE_EXPORT HistogramBase* DeserializeHistogramInfo( |
264 base::PickleIterator* iter); | 264 base::PickleIterator* iter); |
265 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); | 265 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); |
266 | 266 |
267 // Implementation of SnapshotSamples function. | 267 // Create a snapshot containing all samples (both logged and unlogged). |
268 std::unique_ptr<SampleVector> SnapshotSampleVector() const; | 268 // Implementation of SnapshotSamples method with a more specific type for |
| 269 // internal use. |
| 270 std::unique_ptr<SampleVector> SnapshotAllSamples() const; |
| 271 |
| 272 // Create a copy of unlogged samples. |
| 273 std::unique_ptr<SampleVector> SnapshotUnloggedSamples() const; |
269 | 274 |
270 //---------------------------------------------------------------------------- | 275 //---------------------------------------------------------------------------- |
271 // Helpers for emitting Ascii graphic. Each method appends data to output. | 276 // Helpers for emitting Ascii graphic. Each method appends data to output. |
272 | 277 |
273 void WriteAsciiImpl(bool graph_it, | 278 void WriteAsciiImpl(bool graph_it, |
274 const std::string& newline, | 279 const std::string& newline, |
275 std::string* output) const; | 280 std::string* output) const; |
276 | 281 |
277 // Find out how large (graphically) the largest bucket will appear to be. | 282 // Find out how large (graphically) the largest bucket will appear to be. |
278 double GetPeakBucketSize(const SampleVectorBase& samples) const; | 283 double GetPeakBucketSize(const SampleVectorBase& samples) const; |
(...skipping 17 matching lines...) Expand all Loading... |
296 void GetCountAndBucketData(Count* count, | 301 void GetCountAndBucketData(Count* count, |
297 int64_t* sum, | 302 int64_t* sum, |
298 ListValue* buckets) const override; | 303 ListValue* buckets) const override; |
299 | 304 |
300 // Does not own this object. Should get from StatisticsRecorder. | 305 // Does not own this object. Should get from StatisticsRecorder. |
301 const BucketRanges* bucket_ranges_; | 306 const BucketRanges* bucket_ranges_; |
302 | 307 |
303 Sample declared_min_; // Less than this goes into the first bucket. | 308 Sample declared_min_; // Less than this goes into the first bucket. |
304 Sample declared_max_; // Over this goes into the last bucket. | 309 Sample declared_max_; // Over this goes into the last bucket. |
305 | 310 |
306 // Finally, provide the state that changes with the addition of each new | 311 // Samples that have not yet been logged with SnapshotDelta(). |
307 // sample. | 312 std::unique_ptr<HistogramSamples> unlogged_samples_; |
308 std::unique_ptr<SampleVectorBase> samples_; | |
309 | 313 |
310 // Also keep a previous uploaded state for calculating deltas. | 314 // Accumulation of all samples that have been logged with SnapshotDelta(). |
311 std::unique_ptr<HistogramSamples> logged_samples_; | 315 std::unique_ptr<HistogramSamples> logged_samples_; |
312 | 316 |
313 // Flag to indicate if PrepareFinalDelta has been previously called. It is | 317 // Flag to indicate if PrepareFinalDelta has been previously called. It is |
314 // used to DCHECK that a final delta is not created multiple times. | 318 // used to DCHECK that a final delta is not created multiple times. |
315 mutable bool final_delta_created_ = false; | 319 mutable bool final_delta_created_ = false; |
316 | 320 |
317 DISALLOW_COPY_AND_ASSIGN(Histogram); | 321 DISALLOW_COPY_AND_ASSIGN(Histogram); |
318 }; | 322 }; |
319 | 323 |
320 //------------------------------------------------------------------------------ | 324 //------------------------------------------------------------------------------ |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); | 539 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); |
536 | 540 |
537 static bool ValidateCustomRanges(const std::vector<Sample>& custom_ranges); | 541 static bool ValidateCustomRanges(const std::vector<Sample>& custom_ranges); |
538 | 542 |
539 DISALLOW_COPY_AND_ASSIGN(CustomHistogram); | 543 DISALLOW_COPY_AND_ASSIGN(CustomHistogram); |
540 }; | 544 }; |
541 | 545 |
542 } // namespace base | 546 } // namespace base |
543 | 547 |
544 #endif // BASE_METRICS_HISTOGRAM_H_ | 548 #endif // BASE_METRICS_HISTOGRAM_H_ |
OLD | NEW |