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

Unified Diff: chrome/browser/browser_main.cc

Issue 6883102: Add one-time randomization support for FieldTrial, and the ability to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Responding to review comments. Fix initialization in browser_main. Created 9 years, 8 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 | « base/rand_util.cc ('k') | chrome/browser/metrics/metrics_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/browser_main.cc
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index e8c9724b6e25e6e0dcfbe138ed8572e0603aacc5..f06f716442f332fd3be7ce998aa4b9f248b2396d 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -1324,8 +1324,20 @@ int BrowserMain(const MainFunctionParams& parameters) {
about_flags::ConvertFlagsToSwitches(local_state,
CommandLine::ForCurrentProcess());
- // Now the command line has been mutated based on about:flags, we can run some
- // field trials
+ // Must initialize metrics after labs have been converted into switches,
+ // but before field trials are set up (so that client ID is available for
+ // one-time randomized field trials).
+ MetricsService* metrics = InitializeMetrics(parsed_command_line, local_state);
jar (doing other things) 2011/04/29 00:57:11 This will probably work. I'm always nervous about
Jói 2011/05/02 18:55:03 I will watch the startup perf dash.
Jói 2011/05/05 15:07:39 Just to confirm, I looked in detail at every Start
+
+ // Initialize FieldTrialList to support FieldTrials that use one-time
+ // randomization. The client ID will be empty if the user has not opted
+ // to send metrics.
+ std::string client_id = metrics->GetClientId();
+ if (!client_id.empty())
+ base::FieldTrialList::EnableOneTimeRandomization(client_id);
+
+ // Now the command line has been mutated based on about:flags, and one-time
+ // randomization has been enabled, we can run some field trials
parts->SetupFieldTrials();
jar (doing other things) 2011/04/29 00:57:11 Wouldn't lines 1327-1337 fit nicely into SetupFiel
Jói 2011/05/02 18:55:03 Good point. I've factored it out.
// Now that all preferences have been registered, set the install date
@@ -1670,7 +1682,6 @@ int BrowserMain(const MainFunctionParams& parameters) {
sdch_manager.set_sdch_fetcher(new SdchDictionaryFetcher);
sdch_manager.EnableSdchSupport(sdch_supported_domain);
- MetricsService* metrics = InitializeMetrics(parsed_command_line, local_state);
InstallJankometer(parsed_command_line);
#if defined(OS_WIN) && !defined(GOOGLE_CHROME_BUILD)
« no previous file with comments | « base/rand_util.cc ('k') | chrome/browser/metrics/metrics_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698