Index: base/metrics/histogram_base.h |
diff --git a/base/metrics/histogram_base.h b/base/metrics/histogram_base.h |
index 6817629bf8c080dd9a3fe259d96ff586c7ccebc2..23ee5254a0147a3f694906d72d4a3d4b9d4bde47 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_LOGARITHMIC, |
+ 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,7 +211,17 @@ 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 EnableActivityReportHistogram(const std::string& process_type); |
+ |
protected: |
+ enum ReportActivity { HISTOGRAM_CREATED, HISTOGRAM_LOOKUP }; |
+ |
// Subclasses should implement this function to make SerializeInfo work. |
virtual bool SerializeInfoImpl(base::Pickle* pickle) const = 0; |
@@ -210,7 +253,16 @@ class BASE_EXPORT HistogramBase { |
// passing |sample| as the parameter. |
void FindAndRunCallback(Sample sample) const; |
+ // Update report with an |activity| that occurred for |histogram|. |
+ static void ReportHistogramActivity(HistogramBase* histogram, |
+ ReportActivity activicty); |
+ |
+ // Retrieves the global histogram reporting what histograms are created. |
+ static HistogramBase* report_histogram_; |
+ |
private: |
+ friend class HistogramBaseTest; |
+ |
const std::string histogram_name_; |
AtomicCount flags_; |