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