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 // SampleVector implements HistogramSamples interface. It is used by all | 5 // SampleVector implements HistogramSamples interface. It is used by all |
6 // Histogram based classes to store samples. | 6 // Histogram based classes to store samples. |
7 | 7 |
8 #ifndef BASE_METRICS_SAMPLE_VECTOR_H_ | 8 #ifndef BASE_METRICS_SAMPLE_VECTOR_H_ |
9 #define BASE_METRICS_SAMPLE_VECTOR_H_ | 9 #define BASE_METRICS_SAMPLE_VECTOR_H_ |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... |
39 protected: | 39 protected: |
40 virtual bool AddSubtractImpl( | 40 virtual bool AddSubtractImpl( |
41 SampleCountIterator* iter, | 41 SampleCountIterator* iter, |
42 HistogramSamples::Operator op) OVERRIDE; // |op| is ADD or SUBTRACT. | 42 HistogramSamples::Operator op) OVERRIDE; // |op| is ADD or SUBTRACT. |
43 | 43 |
44 virtual size_t GetBucketIndex(HistogramBase::Sample value) const; | 44 virtual size_t GetBucketIndex(HistogramBase::Sample value) const; |
45 | 45 |
46 private: | 46 private: |
47 FRIEND_TEST_ALL_PREFIXES(HistogramTest, CorruptSampleCounts); | 47 FRIEND_TEST_ALL_PREFIXES(HistogramTest, CorruptSampleCounts); |
48 | 48 |
49 std::vector<HistogramBase::Count> counts_; | 49 std::vector<HistogramBase::AtomicCount> counts_; |
50 | 50 |
51 // Shares the same BucketRanges with Histogram object. | 51 // Shares the same BucketRanges with Histogram object. |
52 const BucketRanges* const bucket_ranges_; | 52 const BucketRanges* const bucket_ranges_; |
53 | 53 |
54 DISALLOW_COPY_AND_ASSIGN(SampleVector); | 54 DISALLOW_COPY_AND_ASSIGN(SampleVector); |
55 }; | 55 }; |
56 | 56 |
57 class BASE_EXPORT_PRIVATE SampleVectorIterator : public SampleCountIterator { | 57 class BASE_EXPORT_PRIVATE SampleVectorIterator : public SampleCountIterator { |
58 public: | 58 public: |
59 SampleVectorIterator(const std::vector<HistogramBase::Count>* counts, | 59 SampleVectorIterator(const std::vector<HistogramBase::AtomicCount>* counts, |
60 const BucketRanges* bucket_ranges); | 60 const BucketRanges* bucket_ranges); |
61 virtual ~SampleVectorIterator(); | 61 virtual ~SampleVectorIterator(); |
62 | 62 |
63 // SampleCountIterator implementation: | 63 // SampleCountIterator implementation: |
64 virtual bool Done() const OVERRIDE; | 64 virtual bool Done() const OVERRIDE; |
65 virtual void Next() OVERRIDE; | 65 virtual void Next() OVERRIDE; |
66 virtual void Get(HistogramBase::Sample* min, | 66 virtual void Get(HistogramBase::Sample* min, |
67 HistogramBase::Sample* max, | 67 HistogramBase::Sample* max, |
68 HistogramBase::Count* count) const OVERRIDE; | 68 HistogramBase::Count* count) const OVERRIDE; |
69 | 69 |
70 // SampleVector uses predefined buckets, so iterator can return bucket index. | 70 // SampleVector uses predefined buckets, so iterator can return bucket index. |
71 virtual bool GetBucketIndex(size_t* index) const OVERRIDE; | 71 virtual bool GetBucketIndex(size_t* index) const OVERRIDE; |
72 | 72 |
73 private: | 73 private: |
74 void SkipEmptyBuckets(); | 74 void SkipEmptyBuckets(); |
75 | 75 |
76 const std::vector<HistogramBase::Count>* counts_; | 76 const std::vector<HistogramBase::AtomicCount>* counts_; |
77 const BucketRanges* bucket_ranges_; | 77 const BucketRanges* bucket_ranges_; |
78 | 78 |
79 size_t index_; | 79 size_t index_; |
80 }; | 80 }; |
81 | 81 |
82 } // namespace base | 82 } // namespace base |
83 | 83 |
84 #endif // BASE_METRICS_SAMPLE_VECTOR_H_ | 84 #endif // BASE_METRICS_SAMPLE_VECTOR_H_ |
OLD | NEW |