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

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

Issue 10829466: SampleSet -> HistogramSamples (will be reused by SparseHistogram) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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
« no previous file with comments | « base/metrics/histogram_unittest.cc ('k') | base/metrics/sample_vector.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
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 // SampleVector implements HistogramSamples interface. It is used by all
6 // Histogram based classes to store samples.
7
8 #ifndef BASE_METRICS_SAMPLE_VECTOR_H_
9 #define BASE_METRICS_SAMPLE_VECTOR_H_
10
11 #include <vector>
12
13 #include "base/compiler_specific.h"
14 #include "base/gtest_prod_util.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/metrics/histogram_base.h"
17 #include "base/metrics/histogram_samples.h"
18
19 namespace base {
20
21 class BucketRanges;
22
23 class BASE_EXPORT_PRIVATE SampleVector : public HistogramSamples {
24 public:
25 explicit SampleVector(const BucketRanges* bucket_ranges);
26 virtual ~SampleVector();
27
28 // HistogramSamples implementation:
29 virtual void Accumulate(HistogramBase::Sample value,
30 HistogramBase::Count count) OVERRIDE;
31 virtual HistogramBase::Count GetCount(
32 HistogramBase::Sample value) const OVERRIDE;
33 virtual HistogramBase::Count TotalCount() const OVERRIDE;
34 virtual scoped_ptr<SampleCountIterator> Iterator() const OVERRIDE;
35
36 // Get count of a specific bucket.
37 HistogramBase::Count GetCountAtIndex(size_t bucket_index) const;
38
39 protected:
40 virtual bool AddSubtractImpl(
41 SampleCountIterator* iter,
42 HistogramSamples::Instruction instruction) OVERRIDE;
43
44 virtual size_t GetBucketIndex(HistogramBase::Sample value) const;
45
46 private:
47 FRIEND_TEST_ALL_PREFIXES(HistogramTest, CorruptSampleCounts);
48
49 std::vector<HistogramBase::Count> counts_;
50
51 // Shares the same BucketRanges with Histogram object.
52 const BucketRanges* const bucket_ranges_;
53
54 DISALLOW_COPY_AND_ASSIGN(SampleVector);
55 };
56
57 class BASE_EXPORT_PRIVATE SampleVectorIterator : public SampleCountIterator {
58 public:
59 SampleVectorIterator(const std::vector<HistogramBase::Count>* counts,
60 const BucketRanges* bucket_ranges);
61
62 // SampleCountIterator implementation:
63 virtual bool Done() const OVERRIDE;
64 virtual void Next() OVERRIDE;
65 virtual void Get(HistogramBase::Sample* min,
66 HistogramBase::Sample* max,
67 HistogramBase::Count* count) const OVERRIDE;
68 virtual bool GetBucketIndex(size_t* index) const OVERRIDE;
69
70 private:
71 void SkipEmptyBuckets();
72
73 const std::vector<HistogramBase::Count>* counts_;
74 const BucketRanges* bucket_ranges_;
75
76 size_t index_;
77 };
78
79 } // namespace base
80
81 #endif // BASE_METRICS_SAMPLE_VECTOR_H_
OLDNEW
« no previous file with comments | « base/metrics/histogram_unittest.cc ('k') | base/metrics/sample_vector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698