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

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

Issue 11022002: Add SampleMap and use it in SparseHistogram (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address more comments 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
« no previous file with comments | « base/base.gypi ('k') | base/metrics/sample_map.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef BASE_METRICS_HISTOGRAM_SAMPLES_H_ 5 #ifndef BASE_METRICS_HISTOGRAM_SAMPLES_H_
6 #define BASE_METRICS_HISTOGRAM_SAMPLES_H_ 6 #define BASE_METRICS_HISTOGRAM_SAMPLES_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/metrics/histogram_base.h" 9 #include "base/metrics/histogram_base.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 24 matching lines...) Expand all
35 virtual void Subtract(const HistogramSamples& other); 35 virtual void Subtract(const HistogramSamples& other);
36 36
37 virtual scoped_ptr<SampleCountIterator> Iterator() const = 0; 37 virtual scoped_ptr<SampleCountIterator> Iterator() const = 0;
38 virtual bool Serialize(Pickle* pickle) const; 38 virtual bool Serialize(Pickle* pickle) const;
39 39
40 // Accessor fuctions. 40 // Accessor fuctions.
41 int64 sum() const { return sum_; } 41 int64 sum() const { return sum_; }
42 HistogramBase::Count redundant_count() const { return redundant_count_; } 42 HistogramBase::Count redundant_count() const { return redundant_count_; }
43 43
44 protected: 44 protected:
45 // Based on |instruction| type, add or subtract sample counts data from the 45 // Based on |op| type, add or subtract sample counts data from the iterator.
46 // iterator. 46 enum Operator { ADD, SUBTRACT };
47 enum Instruction { ADD, SUBTRACT }; 47 virtual bool AddSubtractImpl(SampleCountIterator* iter, Operator op) = 0;
48 virtual bool AddSubtractImpl(SampleCountIterator* iter,
49 Instruction instruction) = 0;
50 48
51 void IncreaseSum(int64 diff); 49 void IncreaseSum(int64 diff);
52 void IncreaseRedundantCount(HistogramBase::Count diff); 50 void IncreaseRedundantCount(HistogramBase::Count diff);
53 51
54 private: 52 private:
55 int64 sum_; 53 int64 sum_;
56 54
57 // |redundant_count_| helps identify memory corruption. It redundantly stores 55 // |redundant_count_| helps identify memory corruption. It redundantly stores
58 // the total number of samples accumulated in the histogram. We can compare 56 // the total number of samples accumulated in the histogram. We can compare
59 // this count to the sum of the counts (TotalCount() function), and detect 57 // this count to the sum of the counts (TotalCount() function), and detect
(...skipping 20 matching lines...) Expand all
80 78
81 // Get the index of current histogram bucket. 79 // Get the index of current histogram bucket.
82 // For histograms that don't use predefined buckets, it returns false. 80 // For histograms that don't use predefined buckets, it returns false.
83 // Requires: !Done(); 81 // Requires: !Done();
84 virtual bool GetBucketIndex(size_t* index) const; 82 virtual bool GetBucketIndex(size_t* index) const;
85 }; 83 };
86 84
87 } // namespace base 85 } // namespace base
88 86
89 #endif // BASE_METRICS_HISTOGRAM_SAMPLES_H_ 87 #endif // BASE_METRICS_HISTOGRAM_SAMPLES_H_
OLDNEW
« no previous file with comments | « base/base.gypi ('k') | base/metrics/sample_map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698