| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 HistogramType GetHistogramType() const override; | 74 HistogramType GetHistogramType() const override; |
| 75 bool HasConstructionArguments(Sample expected_minimum, | 75 bool HasConstructionArguments(Sample expected_minimum, |
| 76 Sample expected_maximum, | 76 Sample expected_maximum, |
| 77 uint32_t expected_bucket_count) const override; | 77 uint32_t expected_bucket_count) const override; |
| 78 void Add(Sample value) override; | 78 void Add(Sample value) override; |
| 79 void AddCount(Sample value, int count) override; | 79 void AddCount(Sample value, int count) override; |
| 80 void AddSamples(const HistogramSamples& samples) override; | 80 void AddSamples(const HistogramSamples& samples) override; |
| 81 bool AddSamplesFromPickle(base::PickleIterator* iter) override; | 81 bool AddSamplesFromPickle(base::PickleIterator* iter) override; |
| 82 std::unique_ptr<HistogramSamples> SnapshotSamples() const override; | 82 std::unique_ptr<HistogramSamples> SnapshotSamples() const override; |
| 83 std::unique_ptr<HistogramSamples> SnapshotDelta() override; | 83 std::unique_ptr<HistogramSamples> SnapshotDelta() override; |
| 84 void WriteHTMLGraph(std::string* output) const override; | 84 void WriteHTMLGraph(const HistogramSamples* snapshot, |
| 85 void WriteAscii(std::string* output) const override; | 85 std::string* output) const override; |
| 86 void WriteAscii(const HistogramSamples* snapshot, |
| 87 std::string* output) const override; |
| 86 | 88 |
| 87 protected: | 89 protected: |
| 88 // HistogramBase implementation: | 90 // HistogramBase implementation: |
| 89 bool SerializeInfoImpl(base::Pickle* pickle) const override; | 91 bool SerializeInfoImpl(base::Pickle* pickle) const override; |
| 90 | 92 |
| 91 private: | 93 private: |
| 92 // Clients should always use FactoryGet to create SparseHistogram. | 94 // Clients should always use FactoryGet to create SparseHistogram. |
| 93 explicit SparseHistogram(const std::string& name); | 95 explicit SparseHistogram(const std::string& name); |
| 94 | 96 |
| 95 SparseHistogram(PersistentHistogramAllocator* allocator, | 97 SparseHistogram(PersistentHistogramAllocator* allocator, |
| 96 const std::string& name, | 98 const std::string& name, |
| 97 HistogramSamples::Metadata* meta, | 99 HistogramSamples::Metadata* meta, |
| 98 HistogramSamples::Metadata* logged_meta); | 100 HistogramSamples::Metadata* logged_meta); |
| 99 | 101 |
| 100 friend BASE_EXPORT HistogramBase* DeserializeHistogramInfo( | 102 friend BASE_EXPORT HistogramBase* DeserializeHistogramInfo( |
| 101 base::PickleIterator* iter); | 103 base::PickleIterator* iter); |
| 102 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); | 104 static HistogramBase* DeserializeInfoImpl(base::PickleIterator* iter); |
| 103 | 105 |
| 104 void GetParameters(DictionaryValue* params) const override; | 106 void GetParameters(DictionaryValue* params) const override; |
| 105 void GetCountAndBucketData(Count* count, | 107 void GetCountAndBucketData(Count* count, |
| 106 int64_t* sum, | 108 int64_t* sum, |
| 107 ListValue* buckets) const override; | 109 ListValue* buckets) const override; |
| 108 | 110 |
| 109 // Helpers for emitting Ascii graphic. Each method appends data to output. | 111 // Helpers for emitting Ascii graphic. Each method appends data to output. |
| 110 void WriteAsciiImpl(bool graph_it, | 112 void WriteAsciiImpl(bool graph_it, |
| 111 const std::string& newline, | 113 const std::string& newline, |
| 114 const HistogramSamples* snapshot, |
| 112 std::string* output) const; | 115 std::string* output) const; |
| 113 | 116 |
| 114 // Write a common header message describing this histogram. | 117 // Write a common header message describing this histogram. |
| 115 void WriteAsciiHeader(const Count total_count, | 118 void WriteAsciiHeader(const Count total_count, |
| 116 std::string* output) const; | 119 std::string* output) const; |
| 117 | 120 |
| 118 // For constuctor calling. | 121 // For constuctor calling. |
| 119 friend class SparseHistogramTest; | 122 friend class SparseHistogramTest; |
| 120 | 123 |
| 121 // Protects access to |samples_|. | 124 // Protects access to |samples_|. |
| 122 mutable base::Lock lock_; | 125 mutable base::Lock lock_; |
| 123 | 126 |
| 124 std::unique_ptr<HistogramSamples> samples_; | 127 std::unique_ptr<HistogramSamples> samples_; |
| 125 std::unique_ptr<HistogramSamples> logged_samples_; | 128 std::unique_ptr<HistogramSamples> logged_samples_; |
| 126 | 129 |
| 127 DISALLOW_COPY_AND_ASSIGN(SparseHistogram); | 130 DISALLOW_COPY_AND_ASSIGN(SparseHistogram); |
| 128 }; | 131 }; |
| 129 | 132 |
| 130 } // namespace base | 133 } // namespace base |
| 131 | 134 |
| 132 #endif // BASE_METRICS_SPARSE_HISTOGRAM_H_ | 135 #endif // BASE_METRICS_SPARSE_HISTOGRAM_H_ |
| OLD | NEW |