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 // SampleMap implements HistogramSamples interface. It is used by the | |
| 6 // SparseHistogram class to store samples. | |
| 7 | |
| 8 #ifndef BASE_METRICS_SAMPLE_MAP_H_ | |
| 9 #define BASE_METRICS_SAMPLE_MAP_H_ | |
| 10 | |
| 11 #include <map> | |
| 12 | |
| 13 #include "base/compiler_specific.h" | |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 #include "base/metrics/histogram_base.h" | |
| 16 #include "base/metrics/histogram_samples.h" | |
| 17 #include "base/synchronization/lock.h" | |
| 18 | |
| 19 namespace base { | |
| 20 | |
| 21 class BASE_EXPORT_PRIVATE SampleMap : public HistogramSamples { | |
| 22 public: | |
| 23 SampleMap(); | |
| 24 virtual ~SampleMap(); | |
| 25 | |
| 26 // HistogramSamples implementation: | |
| 27 virtual void Accumulate(HistogramBase::Sample value, | |
| 28 HistogramBase::Count count) OVERRIDE; | |
| 29 virtual HistogramBase::Count GetCount( | |
| 30 HistogramBase::Sample value) const OVERRIDE; | |
| 31 virtual HistogramBase::Count TotalCount() const OVERRIDE; | |
| 32 virtual scoped_ptr<SampleCountIterator> Iterator() const OVERRIDE; | |
| 33 | |
| 34 protected: | |
| 35 virtual bool AddSubtractImpl( | |
| 36 SampleCountIterator* iter, | |
| 37 HistogramSamples::Instruction instruction) OVERRIDE; | |
| 38 | |
| 39 private: | |
| 40 std::map<HistogramBase::Sample, HistogramBase::Count> sample_counts_; | |
|
jar (doing other things)
2012/10/01 23:10:38
nit: I'd prefer to see a typedef... as this map na
kaiwang
2012/10/02 02:57:56
Seems there's no way to make it a private typedef
jar (doing other things)
2012/10/02 17:41:10
Moving Sample and Count SGTM. It will surely help
| |
| 41 | |
| 42 // Protects access to above map. | |
| 43 mutable base::Lock lock_; | |
| 44 | |
| 45 DISALLOW_COPY_AND_ASSIGN(SampleMap); | |
| 46 }; | |
| 47 | |
| 48 class BASE_EXPORT_PRIVATE SampleMapIterator : public SampleCountIterator { | |
| 49 public: | |
| 50 SampleMapIterator( | |
| 51 const std::map<HistogramBase::Sample, HistogramBase::Count>& | |
| 52 sample_counts); | |
| 53 | |
| 54 virtual ~SampleMapIterator(); | |
| 55 | |
| 56 // SampleCountIterator implementation: | |
| 57 virtual bool Done() const OVERRIDE; | |
| 58 virtual void Next() OVERRIDE; | |
| 59 virtual void Get(HistogramBase::Sample* min, | |
| 60 HistogramBase::Sample* max, | |
| 61 HistogramBase::Count* count) const OVERRIDE; | |
| 62 private: | |
| 63 std::map<HistogramBase::Sample, HistogramBase::Count>::const_iterator iter_; | |
| 64 const std::map<HistogramBase::Sample, HistogramBase::Count>::const_iterator | |
| 65 end_; | |
| 66 }; | |
| 67 | |
| 68 } // namespace base | |
| 69 | |
| 70 #endif // BASE_METRICS_SAMPLE_MAP_H_ | |
| OLD | NEW |