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

Unified Diff: chrome/browser/chrome_browser_field_trials.cc

Issue 2302043002: Adding local field trial for metrics/crash reports sampling. (Closed)
Patch Set: 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
« no previous file with comments | « chrome/browser/chrome_browser_field_trials.h ('k') | chrome/browser/chrome_browser_main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chrome_browser_field_trials.cc
diff --git a/chrome/browser/chrome_browser_field_trials.cc b/chrome/browser/chrome_browser_field_trials.cc
index 38589ebe2f83bcf8a62f6d73e3ed9a095bd31d95..c6919e6fb6bd8939d0b3b356e4df2252d43f53e0 100644
--- a/chrome/browser/chrome_browser_field_trials.cc
+++ b/chrome/browser/chrome_browser_field_trials.cc
@@ -18,11 +18,14 @@
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/browser/metrics/chrome_metrics_service_client.h"
+#include "chrome/browser/metrics/chrome_metrics_services_manager_client.h"
#include "chrome/browser/tracing/background_tracing_field_trial.h"
+#include "chrome/common/channel_info.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "components/metrics/metrics_pref_names.h"
#include "components/variations/variations_associated_data.h"
+#include "components/version_info/version_info.h"
#if defined(OS_ANDROID)
#include "chrome/browser/chrome_browser_field_trials_mobile.h"
@@ -111,6 +114,27 @@ void InstantiatePersistentHistograms() {
allocator->SetPersistentLocation(active_file);
}
+// Create a field trial to control metrics/crash sampling for Stable on
+// Windows/Android if no variations seed was applied.
+void CreateFallbackSamplingTrialIfNeeded(bool has_seed,
+ base::FeatureList* feature_list) {
+#if defined(OS_WIN) || defined(OS_ANDROID)
+ // Only create the fallback trial if there isn't already a variations seed
+ // being applied. This should occur during first run when first-run variations
+ // isn't supported. It's assumed that, if there is a seed, then it either
+ // contains the relavent study, or is intentionally omitted, so no fallback is
+ // needed.
+ if (has_seed)
+ return;
+
+ // Sampling is only supported on Stable.
+ if (chrome::GetChannel() != version_info::Channel::STABLE)
+ return;
+
+ ChromeMetricsServicesManagerClient::CreateFallbackSamplingTrial(feature_list);
+#endif // defined(OS_WIN) || defined(OS_ANDROID)
+}
+
} // namespace
ChromeBrowserFieldTrials::ChromeBrowserFieldTrials(
@@ -132,6 +156,12 @@ void ChromeBrowserFieldTrials::SetupFieldTrials() {
#endif
}
+void ChromeBrowserFieldTrials::SetupFeatureControllingFieldTrials(
+ bool has_seed,
+ base::FeatureList* feature_list) {
+ CreateFallbackSamplingTrialIfNeeded(has_seed, feature_list);
+}
+
void ChromeBrowserFieldTrials::InstantiateDynamicTrials() {
// Persistent histograms must be enabled as soon as possible.
InstantiatePersistentHistograms();
« no previous file with comments | « chrome/browser/chrome_browser_field_trials.h ('k') | chrome/browser/chrome_browser_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698