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 <climits> | |
9 #include <string> | 8 #include <string> |
10 | 9 |
11 #include "base/base_export.h" | 10 #include "base/base_export.h" |
| 11 #include "base/basictypes.h" |
12 | 12 |
13 namespace base { | 13 namespace base { |
14 | 14 |
15 class BASE_EXPORT HistogramBase { | 15 class BASE_EXPORT HistogramBase { |
16 public: | 16 public: |
17 typedef int Sample; // Used for samples. | 17 typedef int Sample; // Used for samples. |
18 typedef int Count; // Used to count samples. | 18 typedef int Count; // Used to count samples. |
19 | 19 |
20 static const Sample kSampleType_MAX; // INT_MAX | 20 static const Sample kSampleType_MAX; // INT_MAX |
21 | 21 |
| 22 enum Flags { |
| 23 kNoFlags = 0, |
| 24 kUmaTargetedHistogramFlag = 0x1, // Histogram should be UMA uploaded. |
| 25 |
| 26 // Indicate that the histogram was pickled to be sent across an IPC Channel. |
| 27 // If we observe this flag on a histogram being aggregated into after IPC, |
| 28 // then we are running in a single process mode, and the aggregation should |
| 29 // not take place (as we would be aggregating back into the source |
| 30 // histogram!). |
| 31 kIPCSerializationSourceFlag = 0x10, |
| 32 |
| 33 // Only for Histogram and its sub classes: fancy bucket-naming support. |
| 34 kHexRangePrintingFlag = 0x8000, |
| 35 }; |
| 36 |
| 37 |
22 HistogramBase(const std::string& name); | 38 HistogramBase(const std::string& name); |
23 virtual ~HistogramBase(); | 39 virtual ~HistogramBase(); |
24 | 40 |
25 std::string histogram_name() const { return histogram_name_; } | 41 std::string histogram_name() const { return histogram_name_; } |
26 | 42 |
| 43 // Operations with Flags enum. |
| 44 int32 flags() const { return flags_; } |
| 45 void SetFlags(int32 flags); |
| 46 void ClearFlags(int32 flags); |
| 47 |
27 virtual void Add(Sample value) = 0; | 48 virtual void Add(Sample value) = 0; |
28 | 49 |
29 // The following methods provide graphical histogram displays. | 50 // The following methods provide graphical histogram displays. |
30 virtual void WriteHTMLGraph(std::string* output) const = 0; | 51 virtual void WriteHTMLGraph(std::string* output) const = 0; |
31 virtual void WriteAscii(std::string* output) const = 0; | 52 virtual void WriteAscii(std::string* output) const = 0; |
32 | 53 |
33 private: | 54 private: |
34 const std::string histogram_name_; | 55 const std::string histogram_name_; |
| 56 int32 flags_; |
| 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(HistogramBase); |
35 }; | 59 }; |
36 | 60 |
37 } // namespace base | 61 } // namespace base |
38 | 62 |
39 #endif // BASE_METRICS_HISTOGRAM_BASE_H_ | 63 #endif // BASE_METRICS_HISTOGRAM_BASE_H_ |
OLD | NEW |