OLD | NEW |
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 |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 class BASE_EXPORT_PRIVATE SparseHistogram : public HistogramBase { | 31 class BASE_EXPORT_PRIVATE SparseHistogram : public HistogramBase { |
32 public: | 32 public: |
33 // If there's one with same name, return the existing one. If not, create a | 33 // If there's one with same name, return the existing one. If not, create a |
34 // new one. | 34 // new one. |
35 static HistogramBase* FactoryGet(const std::string& name, int32 flags); | 35 static HistogramBase* FactoryGet(const std::string& name, int32 flags); |
36 | 36 |
37 virtual ~SparseHistogram(); | 37 virtual ~SparseHistogram(); |
38 | 38 |
39 // HistogramBase implementation: | 39 // HistogramBase implementation: |
40 virtual HistogramType GetHistogramType() const OVERRIDE; | 40 virtual HistogramType GetHistogramType() const override; |
41 virtual bool HasConstructionArguments( | 41 virtual bool HasConstructionArguments( |
42 Sample expected_minimum, | 42 Sample expected_minimum, |
43 Sample expected_maximum, | 43 Sample expected_maximum, |
44 size_t expected_bucket_count) const OVERRIDE; | 44 size_t expected_bucket_count) const override; |
45 virtual void Add(Sample value) OVERRIDE; | 45 virtual void Add(Sample value) override; |
46 virtual void AddSamples(const HistogramSamples& samples) OVERRIDE; | 46 virtual void AddSamples(const HistogramSamples& samples) override; |
47 virtual bool AddSamplesFromPickle(PickleIterator* iter) OVERRIDE; | 47 virtual bool AddSamplesFromPickle(PickleIterator* iter) override; |
48 virtual scoped_ptr<HistogramSamples> SnapshotSamples() const OVERRIDE; | 48 virtual scoped_ptr<HistogramSamples> SnapshotSamples() const override; |
49 virtual void WriteHTMLGraph(std::string* output) const OVERRIDE; | 49 virtual void WriteHTMLGraph(std::string* output) const override; |
50 virtual void WriteAscii(std::string* output) const OVERRIDE; | 50 virtual void WriteAscii(std::string* output) const override; |
51 | 51 |
52 protected: | 52 protected: |
53 // HistogramBase implementation: | 53 // HistogramBase implementation: |
54 virtual bool SerializeInfoImpl(Pickle* pickle) const OVERRIDE; | 54 virtual bool SerializeInfoImpl(Pickle* pickle) const override; |
55 | 55 |
56 private: | 56 private: |
57 // Clients should always use FactoryGet to create SparseHistogram. | 57 // Clients should always use FactoryGet to create SparseHistogram. |
58 explicit SparseHistogram(const std::string& name); | 58 explicit SparseHistogram(const std::string& name); |
59 | 59 |
60 friend BASE_EXPORT_PRIVATE HistogramBase* DeserializeHistogramInfo( | 60 friend BASE_EXPORT_PRIVATE HistogramBase* DeserializeHistogramInfo( |
61 PickleIterator* iter); | 61 PickleIterator* iter); |
62 static HistogramBase* DeserializeInfoImpl(PickleIterator* iter); | 62 static HistogramBase* DeserializeInfoImpl(PickleIterator* iter); |
63 | 63 |
64 virtual void GetParameters(DictionaryValue* params) const OVERRIDE; | 64 virtual void GetParameters(DictionaryValue* params) const override; |
65 virtual void GetCountAndBucketData(Count* count, | 65 virtual void GetCountAndBucketData(Count* count, |
66 int64* sum, | 66 int64* sum, |
67 ListValue* buckets) const OVERRIDE; | 67 ListValue* buckets) const override; |
68 | 68 |
69 // Helpers for emitting Ascii graphic. Each method appends data to output. | 69 // Helpers for emitting Ascii graphic. Each method appends data to output. |
70 void WriteAsciiImpl(bool graph_it, | 70 void WriteAsciiImpl(bool graph_it, |
71 const std::string& newline, | 71 const std::string& newline, |
72 std::string* output) const; | 72 std::string* output) const; |
73 | 73 |
74 // Write a common header message describing this histogram. | 74 // Write a common header message describing this histogram. |
75 void WriteAsciiHeader(const Count total_count, | 75 void WriteAsciiHeader(const Count total_count, |
76 std::string* output) const; | 76 std::string* output) const; |
77 | 77 |
78 // For constuctor calling. | 78 // For constuctor calling. |
79 friend class SparseHistogramTest; | 79 friend class SparseHistogramTest; |
80 | 80 |
81 // Protects access to |samples_|. | 81 // Protects access to |samples_|. |
82 mutable base::Lock lock_; | 82 mutable base::Lock lock_; |
83 | 83 |
84 SampleMap samples_; | 84 SampleMap samples_; |
85 | 85 |
86 DISALLOW_COPY_AND_ASSIGN(SparseHistogram); | 86 DISALLOW_COPY_AND_ASSIGN(SparseHistogram); |
87 }; | 87 }; |
88 | 88 |
89 } // namespace base | 89 } // namespace base |
90 | 90 |
91 #endif // BASE_METRICS_SPARSE_HISTOGRAM_H_ | 91 #endif // BASE_METRICS_SPARSE_HISTOGRAM_H_ |
OLD | NEW |