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 <stdint.h> |
| 9 |
8 #include <string> | 10 #include <string> |
9 #include <vector> | 11 #include <vector> |
10 | 12 |
11 #include "base/atomicops.h" | 13 #include "base/atomicops.h" |
12 #include "base/base_export.h" | 14 #include "base/base_export.h" |
13 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
14 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
15 #include "base/strings/string_piece.h" | 17 #include "base/strings/string_piece.h" |
16 #include "base/time/time.h" | 18 #include "base/time/time.h" |
17 | 19 |
(...skipping 24 matching lines...) Expand all Loading... |
42 | 44 |
43 // Create or find existing histogram that matches the pickled info. | 45 // Create or find existing histogram that matches the pickled info. |
44 // Returns NULL if the pickled data has problems. | 46 // Returns NULL if the pickled data has problems. |
45 BASE_EXPORT_PRIVATE HistogramBase* DeserializeHistogramInfo( | 47 BASE_EXPORT_PRIVATE HistogramBase* DeserializeHistogramInfo( |
46 PickleIterator* iter); | 48 PickleIterator* iter); |
47 | 49 |
48 //////////////////////////////////////////////////////////////////////////////// | 50 //////////////////////////////////////////////////////////////////////////////// |
49 | 51 |
50 class BASE_EXPORT HistogramBase { | 52 class BASE_EXPORT HistogramBase { |
51 public: | 53 public: |
52 typedef int Sample; // Used for samples. | 54 typedef int32_t Sample; // Used for samples. |
53 typedef subtle::Atomic32 AtomicCount; // Used to count samples. | 55 typedef subtle::Atomic32 AtomicCount; // Used to count samples. |
54 typedef int32 Count; // Used to manipulate counts in temporaries. | 56 typedef int32_t Count; // Used to manipulate counts in temporaries. |
55 | 57 |
56 static const Sample kSampleType_MAX; // INT_MAX | 58 static const Sample kSampleType_MAX; // INT_MAX |
57 | 59 |
58 enum Flags { | 60 enum Flags { |
59 kNoFlags = 0, | 61 kNoFlags = 0, |
60 | 62 |
61 // Histogram should be UMA uploaded. | 63 // Histogram should be UMA uploaded. |
62 kUmaTargetedHistogramFlag = 0x1, | 64 kUmaTargetedHistogramFlag = 0x1, |
63 | 65 |
64 // Indicates that this is a stability histogram. This flag exists to specify | 66 // Indicates that this is a stability histogram. This flag exists to specify |
(...skipping 27 matching lines...) Expand all Loading... |
92 virtual ~HistogramBase(); | 94 virtual ~HistogramBase(); |
93 | 95 |
94 std::string histogram_name() const { return histogram_name_; } | 96 std::string histogram_name() const { return histogram_name_; } |
95 | 97 |
96 // Comapres |name| to the histogram name and triggers a DCHECK if they do not | 98 // Comapres |name| to the histogram name and triggers a DCHECK if they do not |
97 // match. This is a helper function used by histogram macros, which results in | 99 // match. This is a helper function used by histogram macros, which results in |
98 // in more compact machine code being generated by the macros. | 100 // in more compact machine code being generated by the macros. |
99 void CheckName(const StringPiece& name) const; | 101 void CheckName(const StringPiece& name) const; |
100 | 102 |
101 // Operations with Flags enum. | 103 // Operations with Flags enum. |
102 int32 flags() const { return flags_; } | 104 int32_t flags() const { return flags_; } |
103 void SetFlags(int32 flags); | 105 void SetFlags(int32_t flags); |
104 void ClearFlags(int32 flags); | 106 void ClearFlags(int32_t flags); |
105 | 107 |
106 virtual HistogramType GetHistogramType() const = 0; | 108 virtual HistogramType GetHistogramType() const = 0; |
107 | 109 |
108 // Whether the histogram has construction arguments as parameters specified. | 110 // Whether the histogram has construction arguments as parameters specified. |
109 // For histograms that don't have the concept of minimum, maximum or | 111 // For histograms that don't have the concept of minimum, maximum or |
110 // bucket_count, this function always returns false. | 112 // bucket_count, this function always returns false. |
111 virtual bool HasConstructionArguments(Sample expected_minimum, | 113 virtual bool HasConstructionArguments(Sample expected_minimum, |
112 Sample expected_maximum, | 114 Sample expected_maximum, |
113 size_t expected_bucket_count) const = 0; | 115 size_t expected_bucket_count) const = 0; |
114 | 116 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 const std::string GetSimpleAsciiBucketRange(Sample sample) const; | 168 const std::string GetSimpleAsciiBucketRange(Sample sample) const; |
167 | 169 |
168 // Write textual description of the bucket contents (relative to histogram). | 170 // Write textual description of the bucket contents (relative to histogram). |
169 // Output is the count in the buckets, as well as the percentage. | 171 // Output is the count in the buckets, as well as the percentage. |
170 void WriteAsciiBucketValue(Count current, | 172 void WriteAsciiBucketValue(Count current, |
171 double scaled_sum, | 173 double scaled_sum, |
172 std::string* output) const; | 174 std::string* output) const; |
173 | 175 |
174 private: | 176 private: |
175 const std::string histogram_name_; | 177 const std::string histogram_name_; |
176 int32 flags_; | 178 int32_t flags_; |
177 | 179 |
178 DISALLOW_COPY_AND_ASSIGN(HistogramBase); | 180 DISALLOW_COPY_AND_ASSIGN(HistogramBase); |
179 }; | 181 }; |
180 | 182 |
181 } // namespace base | 183 } // namespace base |
182 | 184 |
183 #endif // BASE_METRICS_HISTOGRAM_BASE_H_ | 185 #endif // BASE_METRICS_HISTOGRAM_BASE_H_ |
OLD | NEW |