Chromium Code Reviews| Index: base/metrics/histogram_base.h |
| diff --git a/base/metrics/histogram_base.h b/base/metrics/histogram_base.h |
| index 6817629bf8c080dd9a3fe259d96ff586c7ccebc2..fb63935863341d80ed97da60f28bcb2b5d66576f 100644 |
| --- a/base/metrics/histogram_base.h |
| +++ b/base/metrics/histogram_base.h |
| @@ -30,7 +30,7 @@ class Pickle; |
| class PickleIterator; |
| //////////////////////////////////////////////////////////////////////////////// |
| -// These enums are used to facilitate deserialization of histograms from other |
| +// This enum is used to facilitate deserialization of histograms from other |
| // processes into the browser. If you create another class that inherits from |
| // HistogramBase, add new histogram types and names below. |
| @@ -44,6 +44,39 @@ enum HistogramType { |
| std::string HistogramTypeToString(HistogramType type); |
| +// This enum is used for reporting how many histograms and of what types and |
| +// variations are being created. It has to be in the main .h file so it is |
| +// visible to files that define the various histogram types. |
| +enum HistogramReport { |
| + // Count the number of reports created. The other counts divided by this |
| + // number will give the average per run of the program. |
| + HISTOGRAM_REPORT_CREATED, |
| + |
| + // Count the total number of histograms created. It is the limit against |
| + // which all others are compared. |
| + HISTOGRAM_REPORT_HISTOGRAM_CREATED, |
| + |
| + // Count the total number of histograms looked-up. It's better to cache |
| + // the result of a single lookup rather than do it repeatedly. |
| + HISTOGRAM_REPORT_HISTOGRAM_LOOKUP, |
| + |
| + // These count the individual histogram types. This must follow the order |
| + // of HistogramType above. |
| + HISTOGRAM_REPORT_TYPE_GENERAL, |
| + HISTOGRAM_REPORT_TYPE_LINEAR, |
| + HISTOGRAM_REPORT_TYPE_BOOLEAN, |
| + HISTOGRAM_REPORT_TYPE_CUSTOM, |
| + HISTOGRAM_REPORT_TYPE_SPARSE, |
| + |
| + // These indicate the individual flags that were set. |
| + HISTOGRAM_REPORT_FLAG_UMA_TARGETED, |
| + HISTOGRAM_REPORT_FLAG_UMA_STABILITY, |
| + HISTOGRAM_REPORT_FLAG_PERSISTENT, |
| + |
| + // This must be last. |
| + HISTOGRAM_REPORT_MAX |
| +}; |
| + |
| // Create or find existing histogram that matches the pickled info. |
| // Returns NULL if the pickled data has problems. |
| BASE_EXPORT HistogramBase* DeserializeHistogramInfo(base::PickleIterator* iter); |
| @@ -178,6 +211,14 @@ class BASE_EXPORT HistogramBase { |
| // customize the output. |
| void WriteJSON(std::string* output) const; |
| + // This enables a histogram that reports the what types of histograms are |
| + // created and their flags. It must be called while still single-threaded. |
| + // |
| + // IMPORTANT: Callers must update tools/metrics/histograms/histograms.xml |
| + // with the following histogram: |
| + // UMA.Histograms.process_type.Creations |
| + static void EnableCreationReportHistogram(StringPiece process_type); |
| + |
| protected: |
| // Subclasses should implement this function to make SerializeInfo work. |
| virtual bool SerializeInfoImpl(base::Pickle* pickle) const = 0; |
| @@ -210,7 +251,15 @@ class BASE_EXPORT HistogramBase { |
| // passing |sample| as the parameter. |
| void FindAndRunCallback(Sample sample) const; |
| + // Update the creation (or lookup) report for a histogram. |
|
Alexei Svitkine (slow)
2016/03/01 16:41:34
Document the |created| param, please. Also I think
bcwhite
2016/03/02 19:14:19
Done.
|
| + static void UpdateReportHistogram(HistogramBase* histogram, bool created); |
| + |
| + // Retrieves the global histogram reporting what histograms are created. |
| + static HistogramBase* report_histogram_; |
| + |
| private: |
| + friend class HistogramBaseTest; |
| + |
| const std::string histogram_name_; |
| AtomicCount flags_; |