Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Side by Side Diff: base/metrics/histogram_base.h

Issue 11342060: Histogram type support in HistogramBase and remove SetRangeDescription function (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 13
14 namespace base { 14 namespace base {
15 15
16 class DictionaryValue; 16 class DictionaryValue;
17 class HistogramSamples;
17 class ListValue; 18 class ListValue;
18 19
19 class HistogramSamples; 20 ////////////////////////////////////////////////////////////////////////////////
21 // These enums are used to facilitate deserialization of histograms from other
22 // processes into the browser. If you create another class inherits
Ilya Sherman 2012/10/31 00:35:19 nit: "class inherits" -> "class that inherits from
kaiwang 2012/10/31 01:12:56 Done.
23 // HistogramBase, add new histogram types and names below.
24
25 enum BASE_EXPORT HistogramType {
26 HISTOGRAM,
27 LINEAR_HISTOGRAM,
28 BOOLEAN_HISTOGRAM,
29 CUSTOM_HISTOGRAM,
30 SPARSE_HISTOGRAM,
31 };
32
33 std::string HistogramTypeName(HistogramType type);
Ilya Sherman 2012/10/31 00:35:19 Optional nit: Perhaps "HistogramTypeToString"?
kaiwang 2012/10/31 01:12:56 Done.
34
35 ////////////////////////////////////////////////////////////////////////////////
20 36
21 class BASE_EXPORT HistogramBase { 37 class BASE_EXPORT HistogramBase {
22 public: 38 public:
23 typedef int Sample; // Used for samples. 39 typedef int Sample; // Used for samples.
24 typedef int Count; // Used to count samples. 40 typedef int Count; // Used to count samples.
25 41
26 static const Sample kSampleType_MAX; // INT_MAX 42 static const Sample kSampleType_MAX; // INT_MAX
27 43
28 enum Flags { 44 enum Flags {
29 kNoFlags = 0, 45 kNoFlags = 0,
30 kUmaTargetedHistogramFlag = 0x1, // Histogram should be UMA uploaded. 46 kUmaTargetedHistogramFlag = 0x1, // Histogram should be UMA uploaded.
31 47
32 // Indicate that the histogram was pickled to be sent across an IPC Channel. 48 // Indicate that the histogram was pickled to be sent across an IPC Channel.
33 // If we observe this flag on a histogram being aggregated into after IPC, 49 // If we observe this flag on a histogram being aggregated into after IPC,
34 // then we are running in a single process mode, and the aggregation should 50 // then we are running in a single process mode, and the aggregation should
35 // not take place (as we would be aggregating back into the source 51 // not take place (as we would be aggregating back into the source
36 // histogram!). 52 // histogram!).
37 kIPCSerializationSourceFlag = 0x10, 53 kIPCSerializationSourceFlag = 0x10,
38 54
39 // Only for Histogram and its sub classes: fancy bucket-naming support. 55 // Only for Histogram and its sub classes: fancy bucket-naming support.
40 kHexRangePrintingFlag = 0x8000, 56 kHexRangePrintingFlag = 0x8000,
41 }; 57 };
42 58
43
44 HistogramBase(const std::string& name); 59 HistogramBase(const std::string& name);
45 virtual ~HistogramBase(); 60 virtual ~HistogramBase();
46 61
47 std::string histogram_name() const { return histogram_name_; } 62 std::string histogram_name() const { return histogram_name_; }
48 63
49 // Operations with Flags enum. 64 // Operations with Flags enum.
50 int32 flags() const { return flags_; } 65 int32 flags() const { return flags_; }
51 void SetFlags(int32 flags); 66 void SetFlags(int32 flags);
52 void ClearFlags(int32 flags); 67 void ClearFlags(int32 flags);
53 68
69 virtual HistogramType GetHistogramType() const = 0;
70
54 // Whether the histogram has construction arguments as parameters specified. 71 // Whether the histogram has construction arguments as parameters specified.
55 // For histograms that don't have the concept of minimum, maximum or 72 // For histograms that don't have the concept of minimum, maximum or
56 // bucket_count, this function always returns false. 73 // bucket_count, this function always returns false.
57 virtual bool HasConstructionArguments(Sample minimum, 74 virtual bool HasConstructionArguments(Sample minimum,
58 Sample maximum, 75 Sample maximum,
59 size_t bucket_count) const = 0; 76 size_t bucket_count) const = 0;
60 77
61 virtual void Add(Sample value) = 0; 78 virtual void Add(Sample value) = 0;
62 79
63 // Snapshot the current complete set of sample data. 80 // Snapshot the current complete set of sample data.
(...skipping 20 matching lines...) Expand all
84 private: 101 private:
85 const std::string histogram_name_; 102 const std::string histogram_name_;
86 int32 flags_; 103 int32 flags_;
87 104
88 DISALLOW_COPY_AND_ASSIGN(HistogramBase); 105 DISALLOW_COPY_AND_ASSIGN(HistogramBase);
89 }; 106 };
90 107
91 } // namespace base 108 } // namespace base
92 109
93 #endif // BASE_METRICS_HISTOGRAM_BASE_H_ 110 #endif // BASE_METRICS_HISTOGRAM_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698