| 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 // HistogramBase implementation: | 197 // HistogramBase implementation: |
| 198 uint64_t name_hash() const override; | 198 uint64_t name_hash() const override; |
| 199 HistogramType GetHistogramType() const override; | 199 HistogramType GetHistogramType() const override; |
| 200 bool HasConstructionArguments(Sample expected_minimum, | 200 bool HasConstructionArguments(Sample expected_minimum, |
| 201 Sample expected_maximum, | 201 Sample expected_maximum, |
| 202 uint32_t expected_bucket_count) const override; | 202 uint32_t expected_bucket_count) const override; |
| 203 void Add(Sample value) override; | 203 void Add(Sample value) override; |
| 204 void AddCount(Sample value, int count) override; | 204 void AddCount(Sample value, int count) override; |
| 205 std::unique_ptr<HistogramSamples> SnapshotSamples() const override; | 205 std::unique_ptr<HistogramSamples> SnapshotSamples() const override; |
| 206 std::unique_ptr<HistogramSamples> SnapshotDelta() override; | 206 std::unique_ptr<HistogramSamples> SnapshotDelta() override; |
| 207 std::unique_ptr<HistogramSamples> SnapshotFinalDelta() const override; |
| 207 void AddSamples(const HistogramSamples& samples) override; | 208 void AddSamples(const HistogramSamples& samples) override; |
| 208 bool AddSamplesFromPickle(base::PickleIterator* iter) override; | 209 bool AddSamplesFromPickle(base::PickleIterator* iter) override; |
| 209 void WriteHTMLGraph(std::string* output) const override; | 210 void WriteHTMLGraph(std::string* output) const override; |
| 210 void WriteAscii(std::string* output) const override; | 211 void WriteAscii(std::string* output) const override; |
| 211 | 212 |
| 212 protected: | 213 protected: |
| 213 // This class, defined entirely within the .cc file, contains all the | 214 // This class, defined entirely within the .cc file, contains all the |
| 214 // common logic for building a Histogram and can be overridden by more | 215 // common logic for building a Histogram and can be overridden by more |
| 215 // specific types to alter details of how the creation is done. It is | 216 // specific types to alter details of how the creation is done. It is |
| 216 // defined as an embedded class (rather than an anonymous one) so it | 217 // defined as an embedded class (rather than an anonymous one) so it |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 Sample declared_min_; // Less than this goes into the first bucket. | 307 Sample declared_min_; // Less than this goes into the first bucket. |
| 307 Sample declared_max_; // Over this goes into the last bucket. | 308 Sample declared_max_; // Over this goes into the last bucket. |
| 308 | 309 |
| 309 // Finally, provide the state that changes with the addition of each new | 310 // Finally, provide the state that changes with the addition of each new |
| 310 // sample. | 311 // sample. |
| 311 std::unique_ptr<SampleVector> samples_; | 312 std::unique_ptr<SampleVector> samples_; |
| 312 | 313 |
| 313 // Also keep a previous uploaded state for calculating deltas. | 314 // Also keep a previous uploaded state for calculating deltas. |
| 314 std::unique_ptr<HistogramSamples> logged_samples_; | 315 std::unique_ptr<HistogramSamples> logged_samples_; |
| 315 | 316 |
| 317 // Flag to indicate if PrepareFinalDelta has been previously called. It is |
| 318 // used to DCHECK that a final delta is not created multiple times. |
| 319 mutable bool final_delta_created_ = false; |
| 320 |
| 316 DISALLOW_COPY_AND_ASSIGN(Histogram); | 321 DISALLOW_COPY_AND_ASSIGN(Histogram); |
| 317 }; | 322 }; |
| 318 | 323 |
| 319 //------------------------------------------------------------------------------ | 324 //------------------------------------------------------------------------------ |
| 320 | 325 |
| 321 // LinearHistogram is a more traditional histogram, with evenly spaced | 326 // LinearHistogram is a more traditional histogram, with evenly spaced |
| 322 // buckets. | 327 // buckets. |
| 323 class BASE_EXPORT LinearHistogram : public Histogram { | 328 class BASE_EXPORT LinearHistogram : public Histogram { |
| 324 public: | 329 public: |
| 325 ~LinearHistogram() override; | 330 ~LinearHistogram() override; |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); | 543 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); |
| 539 | 544 |
| 540 static bool ValidateCustomRanges(const std::vector<Sample>& custom_ranges); | 545 static bool ValidateCustomRanges(const std::vector<Sample>& custom_ranges); |
| 541 | 546 |
| 542 DISALLOW_COPY_AND_ASSIGN(CustomHistogram); | 547 DISALLOW_COPY_AND_ASSIGN(CustomHistogram); |
| 543 }; | 548 }; |
| 544 | 549 |
| 545 } // namespace base | 550 } // namespace base |
| 546 | 551 |
| 547 #endif // BASE_METRICS_HISTOGRAM_H_ | 552 #endif // BASE_METRICS_HISTOGRAM_H_ |
| OLD | NEW |