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

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

Issue 11231025: Histogram argument related change (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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_SPARSE_HISTOGRAM_H_ 5 #ifndef BASE_METRICS_SPARSE_HISTOGRAM_H_
6 #define BASE_METRICS_SPARSE_HISTOGRAM_H_ 6 #define BASE_METRICS_SPARSE_HISTOGRAM_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/base_export.h" 11 #include "base/base_export.h"
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/metrics/histogram_base.h" 15 #include "base/metrics/histogram_base.h"
16 #include "base/synchronization/lock.h" 16 #include "base/synchronization/lock.h"
17 17
18 namespace base { 18 namespace base {
19 19
20 class HistogramSamples; 20 class HistogramSamples;
21 21
22 class BASE_EXPORT_PRIVATE SparseHistogram : public HistogramBase { 22 class BASE_EXPORT_PRIVATE SparseHistogram : public HistogramBase {
23 public: 23 public:
24 // If there's one with same name, return the existing one. If not, create a 24 // If there's one with same name, return the existing one. If not, create a
25 // new one. 25 // new one.
26 static HistogramBase* FactoryGet(const std::string& name, int32 flags); 26 static HistogramBase* FactoryGet(const std::string& name, int32 flags);
27 27
28 virtual ~SparseHistogram(); 28 virtual ~SparseHistogram();
29 29
30
Ilya Sherman 2012/10/24 00:30:08 nit: Spurious newline
kaiwang 2012/10/24 03:43:28 Done.
30 // HistogramBase implementation: 31 // HistogramBase implementation:
32 virtual bool HasConstructionArguments(Sample minimum,
33 Sample maximum,
34 size_t bucket_count) const OVERRIDE;
31 virtual void Add(Sample value) OVERRIDE; 35 virtual void Add(Sample value) OVERRIDE;
32 virtual void WriteHTMLGraph(std::string* output) const OVERRIDE; 36 virtual void WriteHTMLGraph(std::string* output) const OVERRIDE;
33 virtual void WriteAscii(std::string* output) const OVERRIDE; 37 virtual void WriteAscii(std::string* output) const OVERRIDE;
34
35 virtual scoped_ptr<HistogramSamples> SnapshotSamples() const OVERRIDE; 38 virtual scoped_ptr<HistogramSamples> SnapshotSamples() const OVERRIDE;
36 39
37 private: 40 private:
38 // Clients should always use FactoryGet to create SparseHistogram. 41 // Clients should always use FactoryGet to create SparseHistogram.
39 SparseHistogram(const std::string& name); 42 SparseHistogram(const std::string& name);
40 43
41 virtual void GetParameters(DictionaryValue* params) const OVERRIDE; 44 virtual void GetParameters(DictionaryValue* params) const OVERRIDE;
42 virtual void GetCountAndBucketData(Count* count, 45 virtual void GetCountAndBucketData(Count* count,
43 ListValue* buckets) const OVERRIDE; 46 ListValue* buckets) const OVERRIDE;
44 47
45 friend class SparseHistogramTest; // For constuctor calling. 48 friend class SparseHistogramTest; // For constuctor calling.
46 49
47 // Protects access to |sample_counts_| and |redundant_count_|. 50 // Protects access to |sample_counts_| and |redundant_count_|.
48 mutable base::Lock lock_; 51 mutable base::Lock lock_;
49 std::map<HistogramBase::Sample, HistogramBase::Count> sample_counts_; 52 std::map<HistogramBase::Sample, HistogramBase::Count> sample_counts_;
50 HistogramBase::Count redundant_count_; 53 HistogramBase::Count redundant_count_;
51 54
52 DISALLOW_COPY_AND_ASSIGN(SparseHistogram); 55 DISALLOW_COPY_AND_ASSIGN(SparseHistogram);
53 }; 56 };
54 57
55 } // namespace base 58 } // namespace base
56 59
57 #endif // BASE_METRICS_SPARSE_HISTOGRAM_H_ 60 #endif // BASE_METRICS_SPARSE_HISTOGRAM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698