| 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 Sample* minimum, | 174 Sample* minimum, |
| 175 Sample* maximum, | 175 Sample* maximum, |
| 176 size_t* bucket_count); | 176 size_t* bucket_count); |
| 177 | 177 |
| 178 // HistogramBase implementation: | 178 // HistogramBase implementation: |
| 179 HistogramType GetHistogramType() const override; | 179 HistogramType GetHistogramType() const override; |
| 180 bool HasConstructionArguments(Sample expected_minimum, | 180 bool HasConstructionArguments(Sample expected_minimum, |
| 181 Sample expected_maximum, | 181 Sample expected_maximum, |
| 182 size_t expected_bucket_count) const override; | 182 size_t expected_bucket_count) const override; |
| 183 void Add(Sample value) override; | 183 void Add(Sample value) override; |
| 184 void AddCount(Sample value, int count) override; |
| 184 scoped_ptr<HistogramSamples> SnapshotSamples() const override; | 185 scoped_ptr<HistogramSamples> SnapshotSamples() const override; |
| 185 void AddSamples(const HistogramSamples& samples) override; | 186 void AddSamples(const HistogramSamples& samples) override; |
| 186 bool AddSamplesFromPickle(base::PickleIterator* iter) override; | 187 bool AddSamplesFromPickle(base::PickleIterator* iter) override; |
| 187 void WriteHTMLGraph(std::string* output) const override; | 188 void WriteHTMLGraph(std::string* output) const override; |
| 188 void WriteAscii(std::string* output) const override; | 189 void WriteAscii(std::string* output) const override; |
| 189 | 190 |
| 190 protected: | 191 protected: |
| 191 // |ranges| should contain the underflow and overflow buckets. See top | 192 // |ranges| should contain the underflow and overflow buckets. See top |
| 192 // comments for example. | 193 // comments for example. |
| 193 Histogram(const std::string& name, | 194 Histogram(const std::string& name, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 211 // be a name (or string description) given to the bucket. | 212 // be a name (or string description) given to the bucket. |
| 212 virtual const std::string GetAsciiBucketRange(size_t it) const; | 213 virtual const std::string GetAsciiBucketRange(size_t it) const; |
| 213 | 214 |
| 214 private: | 215 private: |
| 215 // Allow tests to corrupt our innards for testing purposes. | 216 // Allow tests to corrupt our innards for testing purposes. |
| 216 FRIEND_TEST_ALL_PREFIXES(HistogramTest, BoundsTest); | 217 FRIEND_TEST_ALL_PREFIXES(HistogramTest, BoundsTest); |
| 217 FRIEND_TEST_ALL_PREFIXES(HistogramTest, BucketPlacementTest); | 218 FRIEND_TEST_ALL_PREFIXES(HistogramTest, BucketPlacementTest); |
| 218 FRIEND_TEST_ALL_PREFIXES(HistogramTest, CorruptBucketBounds); | 219 FRIEND_TEST_ALL_PREFIXES(HistogramTest, CorruptBucketBounds); |
| 219 FRIEND_TEST_ALL_PREFIXES(HistogramTest, CorruptSampleCounts); | 220 FRIEND_TEST_ALL_PREFIXES(HistogramTest, CorruptSampleCounts); |
| 220 FRIEND_TEST_ALL_PREFIXES(HistogramTest, NameMatchTest); | 221 FRIEND_TEST_ALL_PREFIXES(HistogramTest, NameMatchTest); |
| 222 FRIEND_TEST_ALL_PREFIXES(HistogramTest, AddCountTest); |
| 221 | 223 |
| 222 friend class StatisticsRecorder; // To allow it to delete duplicates. | 224 friend class StatisticsRecorder; // To allow it to delete duplicates. |
| 223 friend class StatisticsRecorderTest; | 225 friend class StatisticsRecorderTest; |
| 224 | 226 |
| 225 friend BASE_EXPORT_PRIVATE HistogramBase* DeserializeHistogramInfo( | 227 friend BASE_EXPORT_PRIVATE HistogramBase* DeserializeHistogramInfo( |
| 226 base::PickleIterator* iter); | 228 base::PickleIterator* iter); |
| 227 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); | 229 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); |
| 228 | 230 |
| 229 // Implementation of SnapshotSamples function. | 231 // Implementation of SnapshotSamples function. |
| 230 scoped_ptr<SampleVector> SnapshotSampleVector() const; | 232 scoped_ptr<SampleVector> SnapshotSampleVector() const; |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 static bool ValidateCustomRanges(const std::vector<Sample>& custom_ranges); | 434 static bool ValidateCustomRanges(const std::vector<Sample>& custom_ranges); |
| 433 static BucketRanges* CreateBucketRangesFromCustomRanges( | 435 static BucketRanges* CreateBucketRangesFromCustomRanges( |
| 434 const std::vector<Sample>& custom_ranges); | 436 const std::vector<Sample>& custom_ranges); |
| 435 | 437 |
| 436 DISALLOW_COPY_AND_ASSIGN(CustomHistogram); | 438 DISALLOW_COPY_AND_ASSIGN(CustomHistogram); |
| 437 }; | 439 }; |
| 438 | 440 |
| 439 } // namespace base | 441 } // namespace base |
| 440 | 442 |
| 441 #endif // BASE_METRICS_HISTOGRAM_H_ | 443 #endif // BASE_METRICS_HISTOGRAM_H_ |
| OLD | NEW |