Chromium Code Reviews
|
| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // HistogramSamples is a container storing all samples of a histogram. | |
|
Ilya Sherman
2012/08/23 07:50:54
Optional nit: Perhaps move this comment closer to
kaiwang
2012/08/24 04:17:58
Done.
| |
| 6 | |
| 7 #ifndef BASE_METRICS_HISTOGRAM_SAMPLES_H_ | |
| 8 #define BASE_METRICS_HISTOGRAM_SAMPLES_H_ | |
| 9 | |
| 10 #include <utility> | |
|
Ilya Sherman
2012/08/23 07:50:54
nit: What is this used for?
kaiwang
2012/08/24 04:17:58
Done.
| |
| 11 | |
| 12 #include "base/basictypes.h" | |
| 13 #include "base/metrics/histogram_base.h" | |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 | |
| 16 class Pickle; | |
| 17 class PickleIterator; | |
| 18 | |
| 19 namespace base { | |
| 20 | |
| 21 class SampleCountIterator; | |
| 22 | |
| 23 class BASE_EXPORT HistogramSamples { | |
| 24 public: | |
| 25 HistogramSamples(); | |
| 26 virtual ~HistogramSamples(); | |
| 27 | |
| 28 virtual void Accumulate(HistogramBase::Sample value, | |
| 29 HistogramBase::Count count) = 0; | |
| 30 virtual HistogramBase::Count GetCount(HistogramBase::Sample value) const = 0; | |
| 31 virtual HistogramBase::Count TotalCount() const = 0; | |
| 32 | |
| 33 virtual void Add(const HistogramSamples& other); | |
| 34 virtual bool Add(PickleIterator* iter); // Add from serialized samples. | |
|
Ilya Sherman
2012/08/23 07:50:54
Why is this method needed, rather than first readi
kaiwang
2012/08/24 04:17:58
Changed to "AddFromPickle"
| |
| 35 virtual void Subtract(const HistogramSamples& other); | |
| 36 | |
| 37 virtual scoped_ptr<SampleCountIterator> Iterator() const = 0; | |
|
Ilya Sherman
2012/08/23 07:50:54
Optional nit: Perhaps CreateIterator()?
| |
| 38 virtual bool Serialize(Pickle* pickle) const; | |
| 39 | |
| 40 // Accessor fuctions. | |
| 41 int64 sum() const { return sum_; } | |
| 42 HistogramBase::Count redundant_count() const { return redundant_count_; } | |
| 43 | |
| 44 protected: | |
| 45 // Add/subtract sample counts data from the iterator. | |
| 46 virtual bool AddSubtractHelper(SampleCountIterator* iter, bool is_add) = 0; | |
|
Ilya Sherman
2012/08/23 07:50:54
nit: Please give this a more descriptive name. I
Ilya Sherman
2012/08/23 07:50:54
nit: Interfaces like this should take an enumerate
kaiwang
2012/08/24 04:17:58
Changed to AddSubtractImpl
Ilya Sherman
2012/08/29 08:48:16
(bump)
kaiwang
2012/08/30 03:13:21
If it's not add, then it's subtract, added comment
| |
| 47 | |
| 48 int64 sum_; | |
|
Ilya Sherman
2012/08/23 07:50:54
nit: Members should be private: http://google-styl
kaiwang
2012/08/24 04:17:58
Done.
| |
| 49 | |
| 50 // |redundant_count_| helps identify memory corruption, we reduntantly save | |
| 51 // the number of samples we've accumulated. We can compare this count to the | |
|
Ilya Sherman
2012/08/23 07:50:54
nit: Split the first sentence as:
|redundant_coun
kaiwang
2012/08/24 04:17:58
Done.
| |
| 52 // sum of the counts (TotalCount() function), and detect problems. | |
| 53 // Note, depending on the implementation of different histogram types, there | |
| 54 // might be races during histogram accumulation and snapshotting that we | |
| 55 // choose to accept. In this case, the tallies might mismatch even when no | |
| 56 // memory corruption has happened. | |
| 57 HistogramBase::Count redundant_count_; | |
| 58 }; | |
| 59 | |
| 60 class BASE_EXPORT SampleCountIterator { | |
| 61 public: | |
| 62 virtual ~SampleCountIterator(); | |
| 63 | |
| 64 virtual bool Done() = 0; | |
|
Ilya Sherman
2012/08/23 07:50:54
nit: Perhaps IsDone() or IsAtEnd()?
| |
| 65 virtual void Next() = 0; | |
|
Ilya Sherman
2012/08/23 07:50:54
nit: Perhaps Advance()?
kaiwang
2012/08/24 04:17:58
Done.
kaiwang
2012/08/24 04:17:58
These 2 names are very conventional in google code
| |
| 66 virtual void Get(HistogramBase::Sample* min, | |
| 67 HistogramBase::Sample* max, | |
| 68 HistogramBase::Count* count) = 0; | |
| 69 }; | |
| 70 | |
| 71 } // namespace base | |
| 72 | |
| 73 #endif // BASE_METRICS_HISTOGRAM_SAMPLES_H_ | |
| OLD | NEW |