Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: base/metrics/sample_map.h

Issue 11022002: Add SampleMap and use it in SparseHistogram (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Support redundant_count Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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
18 namespace base {
19
20 class BASE_EXPORT_PRIVATE SampleMap : public HistogramSamples {
21 public:
22 SampleMap();
23 virtual ~SampleMap();
24
25 // HistogramSamples implementation:
26 virtual void Accumulate(HistogramBase::Sample value,
27 HistogramBase::Count count) OVERRIDE;
28 virtual HistogramBase::Count GetCount(
29 HistogramBase::Sample value) const OVERRIDE;
30 virtual HistogramBase::Count TotalCount() const OVERRIDE;
31 virtual scoped_ptr<SampleCountIterator> Iterator() const OVERRIDE;
32
33 void ResetRedundantCount(HistogramBase::Count count);
34
35 protected:
36 virtual bool AddSubtractImpl(
37 SampleCountIterator* iter,
38 HistogramSamples::Instruction instruction) OVERRIDE;
jar (doing other things) 2012/10/05 01:27:36 The variable name and type bothered me (made me th
kaiwang 2012/10/05 03:16:17 Changed to "Operator op", because operator is C++
39
40 private:
41 std::map<HistogramBase::Sample, HistogramBase::Count> sample_counts_;
42
43 DISALLOW_COPY_AND_ASSIGN(SampleMap);
44 };
45
46 class BASE_EXPORT_PRIVATE SampleMapIterator : public SampleCountIterator {
47 public:
48 SampleMapIterator(
49 const std::map<HistogramBase::Sample, HistogramBase::Count>&
50 sample_counts);
jar (doing other things) 2012/10/05 01:27:36 This is a looong line :-/. I really think typdefs
kaiwang 2012/10/05 03:16:17 Done.
51
52 virtual ~SampleMapIterator();
53
54 // SampleCountIterator implementation:
55 virtual bool Done() const OVERRIDE;
56 virtual void Next() OVERRIDE;
57 virtual void Get(HistogramBase::Sample* min,
58 HistogramBase::Sample* max,
59 HistogramBase::Count* count) const OVERRIDE;
60 private:
61 std::map<HistogramBase::Sample, HistogramBase::Count>::const_iterator iter_;
62 const std::map<HistogramBase::Sample, HistogramBase::Count>::const_iterator
63 end_;
64 };
65
66 } // namespace base
67
68 #endif // BASE_METRICS_SAMPLE_MAP_H_
OLDNEW
« no previous file with comments | « base/base.gypi ('k') | base/metrics/sample_map.cc » ('j') | base/metrics/sample_map.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698