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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // Implementation of SnapshotSamples function. |
268 std::unique_ptr<SampleVector> SnapshotSampleVector() const; | 268 std::unique_ptr<SampleVector> SnapshotSampleVector() const; |
269 | 269 |
| 270 // Create a copy of given samples. |
| 271 std::unique_ptr<SampleVector> CloneSampleVector( |
| 272 const HistogramSamples& samples) const; |
| 273 |
270 //---------------------------------------------------------------------------- | 274 //---------------------------------------------------------------------------- |
271 // Helpers for emitting Ascii graphic. Each method appends data to output. | 275 // Helpers for emitting Ascii graphic. Each method appends data to output. |
272 | 276 |
273 void WriteAsciiImpl(bool graph_it, | 277 void WriteAsciiImpl(bool graph_it, |
274 const std::string& newline, | 278 const std::string& newline, |
275 std::string* output) const; | 279 std::string* output) const; |
276 | 280 |
277 // Find out how large (graphically) the largest bucket will appear to be. | 281 // Find out how large (graphically) the largest bucket will appear to be. |
278 double GetPeakBucketSize(const SampleVectorBase& samples) const; | 282 double GetPeakBucketSize(const SampleVectorBase& samples) const; |
279 | 283 |
(...skipping 16 matching lines...) Expand all Loading... |
296 void GetCountAndBucketData(Count* count, | 300 void GetCountAndBucketData(Count* count, |
297 int64_t* sum, | 301 int64_t* sum, |
298 ListValue* buckets) const override; | 302 ListValue* buckets) const override; |
299 | 303 |
300 // Does not own this object. Should get from StatisticsRecorder. | 304 // Does not own this object. Should get from StatisticsRecorder. |
301 const BucketRanges* bucket_ranges_; | 305 const BucketRanges* bucket_ranges_; |
302 | 306 |
303 Sample declared_min_; // Less than this goes into the first bucket. | 307 Sample declared_min_; // Less than this goes into the first bucket. |
304 Sample declared_max_; // Over this goes into the last bucket. | 308 Sample declared_max_; // Over this goes into the last bucket. |
305 | 309 |
306 // Finally, provide the state that changes with the addition of each new | 310 // Samples that have not yet been logged with SnapshotDelta(). |
307 // sample. | 311 std::unique_ptr<HistogramSamples> unlogged_samples_; |
308 std::unique_ptr<SampleVectorBase> samples_; | |
309 | 312 |
310 // Also keep a previous uploaded state for calculating deltas. | 313 // Accumulation of all samples that have logged with SnapshotDelta(). |
311 std::unique_ptr<HistogramSamples> logged_samples_; | 314 std::unique_ptr<HistogramSamples> logged_samples_; |
312 | 315 |
313 // Flag to indicate if PrepareFinalDelta has been previously called. It is | 316 // Flag to indicate if PrepareFinalDelta has been previously called. It is |
314 // used to DCHECK that a final delta is not created multiple times. | 317 // used to DCHECK that a final delta is not created multiple times. |
315 mutable bool final_delta_created_ = false; | 318 mutable bool final_delta_created_ = false; |
316 | 319 |
317 DISALLOW_COPY_AND_ASSIGN(Histogram); | 320 DISALLOW_COPY_AND_ASSIGN(Histogram); |
318 }; | 321 }; |
319 | 322 |
320 //------------------------------------------------------------------------------ | 323 //------------------------------------------------------------------------------ |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); | 538 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); |
536 | 539 |
537 static bool ValidateCustomRanges(const std::vector<Sample>& custom_ranges); | 540 static bool ValidateCustomRanges(const std::vector<Sample>& custom_ranges); |
538 | 541 |
539 DISALLOW_COPY_AND_ASSIGN(CustomHistogram); | 542 DISALLOW_COPY_AND_ASSIGN(CustomHistogram); |
540 }; | 543 }; |
541 | 544 |
542 } // namespace base | 545 } // namespace base |
543 | 546 |
544 #endif // BASE_METRICS_HISTOGRAM_H_ | 547 #endif // BASE_METRICS_HISTOGRAM_H_ |
OLD | NEW |