| 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 10 matching lines...) Expand all Loading... |
| 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 // HistogramBase implementation: | 30 // HistogramBase implementation: |
| 31 virtual HistogramType GetHistogramType() const OVERRIDE; |
| 31 virtual bool HasConstructionArguments(Sample minimum, | 32 virtual bool HasConstructionArguments(Sample minimum, |
| 32 Sample maximum, | 33 Sample maximum, |
| 33 size_t bucket_count) const OVERRIDE; | 34 size_t bucket_count) const OVERRIDE; |
| 34 virtual void Add(Sample value) OVERRIDE; | 35 virtual void Add(Sample value) OVERRIDE; |
| 35 virtual void WriteHTMLGraph(std::string* output) const OVERRIDE; | 36 virtual void WriteHTMLGraph(std::string* output) const OVERRIDE; |
| 36 virtual void WriteAscii(std::string* output) const OVERRIDE; | 37 virtual void WriteAscii(std::string* output) const OVERRIDE; |
| 37 virtual scoped_ptr<HistogramSamples> SnapshotSamples() const OVERRIDE; | 38 virtual scoped_ptr<HistogramSamples> SnapshotSamples() const OVERRIDE; |
| 38 | 39 |
| 39 private: | 40 private: |
| 40 // Clients should always use FactoryGet to create SparseHistogram. | 41 // Clients should always use FactoryGet to create SparseHistogram. |
| 41 SparseHistogram(const std::string& name); | 42 SparseHistogram(const std::string& name); |
| 42 | 43 |
| 43 virtual void GetParameters(DictionaryValue* params) const OVERRIDE; | 44 virtual void GetParameters(DictionaryValue* params) const OVERRIDE; |
| 44 virtual void GetCountAndBucketData(Count* count, | 45 virtual void GetCountAndBucketData(Count* count, |
| 45 ListValue* buckets) const OVERRIDE; | 46 ListValue* buckets) const OVERRIDE; |
| 46 | 47 |
| 47 friend class SparseHistogramTest; // For constuctor calling. | 48 friend class SparseHistogramTest; // For constuctor calling. |
| 48 | 49 |
| 49 // Protects access to |sample_counts_| and |redundant_count_|. | 50 // Protects access to |sample_counts_| and |redundant_count_|. |
| 50 mutable base::Lock lock_; | 51 mutable base::Lock lock_; |
| 51 std::map<HistogramBase::Sample, HistogramBase::Count> sample_counts_; | 52 std::map<HistogramBase::Sample, HistogramBase::Count> sample_counts_; |
| 52 HistogramBase::Count redundant_count_; | 53 HistogramBase::Count redundant_count_; |
| 53 | 54 |
| 54 DISALLOW_COPY_AND_ASSIGN(SparseHistogram); | 55 DISALLOW_COPY_AND_ASSIGN(SparseHistogram); |
| 55 }; | 56 }; |
| 56 | 57 |
| 57 } // namespace base | 58 } // namespace base |
| 58 | 59 |
| 59 #endif // BASE_METRICS_SPARSE_HISTOGRAM_H_ | 60 #endif // BASE_METRICS_SPARSE_HISTOGRAM_H_ |
| OLD | NEW |