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_HISTOGRAM_BASE_H_ | 5 #ifndef BASE_METRICS_HISTOGRAM_BASE_H_ |
6 #define BASE_METRICS_HISTOGRAM_BASE_H_ | 6 #define BASE_METRICS_HISTOGRAM_BASE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
(...skipping 30 matching lines...) Expand all Loading... | |
41 // Returns NULL if the pickled data has problems. | 41 // Returns NULL if the pickled data has problems. |
42 BASE_EXPORT_PRIVATE HistogramBase* DeserializeHistogramInfo( | 42 BASE_EXPORT_PRIVATE HistogramBase* DeserializeHistogramInfo( |
43 PickleIterator* iter); | 43 PickleIterator* iter); |
44 | 44 |
45 // Create or find existing histogram and add the samples from pickle. | 45 // Create or find existing histogram and add the samples from pickle. |
46 // Silently returns when seeing any data problem in the pickle. | 46 // Silently returns when seeing any data problem in the pickle. |
47 BASE_EXPORT void DeserializeHistogramAndAddSamples(PickleIterator* iter); | 47 BASE_EXPORT void DeserializeHistogramAndAddSamples(PickleIterator* iter); |
48 | 48 |
49 //////////////////////////////////////////////////////////////////////////////// | 49 //////////////////////////////////////////////////////////////////////////////// |
50 | 50 |
51 // Histogram data inconsistency types. | |
52 enum BASE_EXPORT HistogramInconsistency { | |
53 NO_INCONSISTENCIES = 0x0, | |
brettw
2013/02/28 22:56:25
This creates things named base::COUNT_LOW_ERROR, f
kaiwang
2013/03/01 00:52:12
Done.
| |
54 RANGE_CHECKSUM_ERROR = 0x1, | |
55 BUCKET_ORDER_ERROR = 0x2, | |
56 COUNT_HIGH_ERROR = 0x4, | |
57 COUNT_LOW_ERROR = 0x8, | |
58 | |
59 NEVER_EXCEEDED_VALUE = 0x10 | |
60 }; | |
61 | |
51 class BASE_EXPORT HistogramBase { | 62 class BASE_EXPORT HistogramBase { |
52 public: | 63 public: |
53 typedef int Sample; // Used for samples. | 64 typedef int Sample; // Used for samples. |
54 typedef int Count; // Used to count samples. | 65 typedef int Count; // Used to count samples. |
55 | 66 |
56 static const Sample kSampleType_MAX; // INT_MAX | 67 static const Sample kSampleType_MAX; // INT_MAX |
57 | 68 |
58 enum Flags { | 69 enum Flags { |
59 kNoFlags = 0, | 70 kNoFlags = 0, |
60 kUmaTargetedHistogramFlag = 0x1, // Histogram should be UMA uploaded. | 71 kUmaTargetedHistogramFlag = 0x1, // Histogram should be UMA uploaded. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 void AddBoolean(bool value); | 107 void AddBoolean(bool value); |
97 | 108 |
98 virtual void AddSamples(const HistogramSamples& samples) = 0; | 109 virtual void AddSamples(const HistogramSamples& samples) = 0; |
99 virtual bool AddSamplesFromPickle(PickleIterator* iter) = 0; | 110 virtual bool AddSamplesFromPickle(PickleIterator* iter) = 0; |
100 | 111 |
101 // Serialize the histogram info into |pickle|. | 112 // Serialize the histogram info into |pickle|. |
102 // Note: This only serializes the construction arguments of the histogram, but | 113 // Note: This only serializes the construction arguments of the histogram, but |
103 // does not serialize the samples. | 114 // does not serialize the samples. |
104 bool SerializeInfo(Pickle* pickle) const; | 115 bool SerializeInfo(Pickle* pickle) const; |
105 | 116 |
117 // Try to find out data corruption from histogram and the samples. | |
118 // The returned value is a combination of HistogramInconsistency enum. | |
119 virtual int FindCorruption(const HistogramSamples& samples) const; | |
120 | |
106 // Snapshot the current complete set of sample data. | 121 // Snapshot the current complete set of sample data. |
107 // Override with atomic/locked snapshot if needed. | 122 // Override with atomic/locked snapshot if needed. |
108 virtual scoped_ptr<HistogramSamples> SnapshotSamples() const = 0; | 123 virtual scoped_ptr<HistogramSamples> SnapshotSamples() const = 0; |
109 | 124 |
110 // The following methods provide graphical histogram displays. | 125 // The following methods provide graphical histogram displays. |
111 virtual void WriteHTMLGraph(std::string* output) const = 0; | 126 virtual void WriteHTMLGraph(std::string* output) const = 0; |
112 virtual void WriteAscii(std::string* output) const = 0; | 127 virtual void WriteAscii(std::string* output) const = 0; |
113 | 128 |
114 // Produce a JSON representation of the histogram. This is implemented with | 129 // Produce a JSON representation of the histogram. This is implemented with |
115 // the help of GetParameters and GetCountAndBucketData; overwrite them to | 130 // the help of GetParameters and GetCountAndBucketData; overwrite them to |
(...skipping 14 matching lines...) Expand all Loading... | |
130 private: | 145 private: |
131 const std::string histogram_name_; | 146 const std::string histogram_name_; |
132 int32 flags_; | 147 int32 flags_; |
133 | 148 |
134 DISALLOW_COPY_AND_ASSIGN(HistogramBase); | 149 DISALLOW_COPY_AND_ASSIGN(HistogramBase); |
135 }; | 150 }; |
136 | 151 |
137 } // namespace base | 152 } // namespace base |
138 | 153 |
139 #endif // BASE_METRICS_HISTOGRAM_BASE_H_ | 154 #endif // BASE_METRICS_HISTOGRAM_BASE_H_ |
OLD | NEW |