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

Unified Diff: chrome/browser/about_flags.cc

Issue 2345033002: Log base::Features in Launch.FlagsAtStartup (Closed)
Patch Set: Fix up comment Created 4 years, 3 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/about_flags.cc
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index b57dcedf7dc67ef5c5958274de5fb298a267abac..e12eec5ba586e95eef1ea2ac4d14cb7213cb7952 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -2157,6 +2157,49 @@ 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 = GetSwitchUMAId(feature);
+ 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 +2270,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 +2280,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 {

Powered by Google App Engine
This is Rietveld 408576698