Index: chrome/browser/about_flags.cc |
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc |
index b57dcedf7dc67ef5c5958274de5fb298a267abac..1c31e9889c266cb78dcb6774c1d624a9198702b1 100644 |
--- a/chrome/browser/about_flags.cc |
+++ b/chrome/browser/about_flags.cc |
@@ -2157,6 +2157,51 @@ bool SkipConditionalFeatureEntry(const FeatureEntry& entry) { |
return false; |
} |
+// Records a set of feature switches (prefixed with "--"). |
+void ReportAboutFlagsHistogramSwitches(const std::string& uma_histogram_name, |
+ const std::set<std::string>& switches) { |
+ for (const std::string& flag : switches) { |
+ int uma_id = about_flags::testing::kBadSwitchFormatHistogramId; |
+ if (base::StartsWith(flag, "--", base::CompareCase::SENSITIVE)) { |
+ // Skip '--' before switch name. |
+ std::string switch_name(flag.substr(2)); |
+ |
+ // Kill value, if any. |
+ const size_t value_pos = switch_name.find('='); |
+ if (value_pos != std::string::npos) |
+ switch_name.resize(value_pos); |
+ |
+ uma_id = GetSwitchUMAId(switch_name); |
+ } else { |
+ NOTREACHED() << "ReportAboutFlagsHistogram(): flag '" << flag |
+ << "' has incorrect format."; |
+ } |
+ DVLOG(1) << "ReportAboutFlagsHistogram(): histogram='" << uma_histogram_name |
+ << "' '" << flag << "', uma_id=" << uma_id; |
+ |
+ // Sparse histogram macro does not cache the histogram, so it's safe |
+ // to use macro with non-static histogram name here. |
+ UMA_HISTOGRAM_SPARSE_SLOWLY(uma_histogram_name, uma_id); |
+ } |
+} |
+ |
+// Records a set of FEATURE_VALUE_TYPE features (suffixed with ":enabled" or |
+// "disabled", depending on their state). |
+void ReportAboutFlagsHistogramFeatures(const std::string& uma_histogram_name, |
+ const std::set<std::string>&features) { |
+ for (const std::string& feature : features) { |
+ int uma_id = about_flags::testing::kBadSwitchFormatHistogramId; |
+ |
+ uma_id = GetSwitchUMAId(feature); |
Alexei Svitkine (slow)
2016/09/16 20:50:33
Just move this initialization on line 2193 directl
lawrencewu
2016/09/16 21:20:03
Done.
|
+ DVLOG(1) << "ReportAboutFlagsHistogram(): histogram='" << uma_histogram_name |
+ << "' '" << feature << "', uma_id=" << uma_id; |
+ |
+ // Sparse histogram macro does not cache the histogram, so it's safe |
+ // to use macro with non-static histogram name here. |
+ UMA_HISTOGRAM_SPARSE_SLOWLY(uma_histogram_name, uma_id); |
+ } |
+} |
+ |
} // namespace |
void ConvertFlagsToSwitches(flags_ui::FlagsStorage* flags_storage, |
@@ -2227,7 +2272,9 @@ void ResetAllFlags(flags_ui::FlagsStorage* flags_storage) { |
void RecordUMAStatistics(flags_ui::FlagsStorage* flags_storage) { |
const std::set<std::string> switches = |
FlagsStateSingleton::GetFlagsState()->GetSwitchesFromFlags(flags_storage); |
- ReportAboutFlagsHistogram("Launch.FlagsAtStartup", switches); |
+ const std::set<std::string> features = |
+ FlagsStateSingleton::GetFlagsState()->GetFeaturesFromFlags(flags_storage); |
+ ReportAboutFlagsHistogram("Launch.FlagsAtStartup", switches, features); |
} |
base::HistogramBase::Sample GetSwitchUMAId(const std::string& switch_name) { |
@@ -2235,31 +2282,12 @@ base::HistogramBase::Sample GetSwitchUMAId(const std::string& switch_name) { |
base::HashMetricName(switch_name)); |
} |
-void ReportAboutFlagsHistogram(const std::string& uma_histogram_name, |
- const std::set<std::string>& flags) { |
- for (const std::string& flag : flags) { |
- int uma_id = about_flags::testing::kBadSwitchFormatHistogramId; |
- if (base::StartsWith(flag, "--", base::CompareCase::SENSITIVE)) { |
- // Skip '--' before switch name. |
- std::string switch_name(flag.substr(2)); |
- |
- // Kill value, if any. |
- const size_t value_pos = switch_name.find('='); |
- if (value_pos != std::string::npos) |
- switch_name.resize(value_pos); |
- |
- uma_id = GetSwitchUMAId(switch_name); |
- } else { |
- NOTREACHED() << "ReportAboutFlagsHistogram(): flag '" << flag |
- << "' has incorrect format."; |
- } |
- DVLOG(1) << "ReportAboutFlagsHistogram(): histogram='" << uma_histogram_name |
- << "' '" << flag << "', uma_id=" << uma_id; |
- |
- // Sparse histogram macro does not cache the histogram, so it's safe |
- // to use macro with non-static histogram name here. |
- UMA_HISTOGRAM_SPARSE_SLOWLY(uma_histogram_name, uma_id); |
- } |
+void ReportAboutFlagsHistogram( |
+ const std::string& uma_histogram_name, |
+ const std::set<std::string>& switches, |
+ const std::set<std::string>& features) { |
+ ReportAboutFlagsHistogramSwitches(uma_histogram_name, switches); |
+ ReportAboutFlagsHistogramFeatures(uma_histogram_name, features); |
} |
namespace testing { |