summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser_main.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/browser_main.cc')
-rw-r--r--chrome/browser/browser_main.cc141
1 files changed, 60 insertions, 81 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index 6224df9..8b28a2c 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -243,28 +243,16 @@ void BrowserMainParts::EarlyInitialization() {
}
// This will be called after the command-line has been mutated by about:flags
-MetricsService* BrowserMainParts::SetupMetricsAndFieldTrials(
- const CommandLine& parsed_command_line,
- PrefService* local_state) {
- // 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);
-
- // 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.
- field_trial_list_.reset(new base::FieldTrialList(metrics->GetClientId()));
-
- SetupFieldTrials();
-
- // Initialize FieldTrialSynchronizer system. This is a singleton and is used
- // for posting tasks via NewRunnableMethod. Its deleted when it goes out of
- // scope. Even though NewRunnableMethod does AddRef and Release, the object
- // will not be deleted after the Task is executed.
- field_trial_synchronizer_ = new FieldTrialSynchronizer();
-
- return metrics;
+void BrowserMainParts::SetupFieldTrials() {
+ // Note: make sure to call ConnectionFieldTrial() before
+ // ProxyConnectionsFieldTrial().
+ ConnectionFieldTrial();
+ SocketTimeoutFieldTrial();
+ ProxyConnectionsFieldTrial();
+ prerender::ConfigurePrefetchAndPrerender(parsed_command_line());
+ SpdyFieldTrial();
+ ConnectBackupJobsFieldTrial();
+ SSLFalseStartFieldTrial();
}
// This is an A/B test for the maximum number of persistent connections per
@@ -547,61 +535,6 @@ void BrowserMainParts::InitializeMainThread() {
MessageLoop::current()));
}
-// BrowserMainParts: |SetupMetricsAndFieldTrials()| related --------------------
-
-// Initializes the metrics service with the configuration for this process,
-// returning the created service (guaranteed non-NULL).
-MetricsService* BrowserMainParts::InitializeMetrics(
- const CommandLine& parsed_command_line,
- const PrefService* local_state) {
-#if defined(OS_WIN)
- if (parsed_command_line.HasSwitch(switches::kChromeFrame))
- MetricsLog::set_version_extension("-F");
-#elif defined(ARCH_CPU_64_BITS)
- MetricsLog::set_version_extension("-64");
-#endif // defined(OS_WIN)
-
- MetricsService* metrics = g_browser_process->metrics_service();
-
- if (parsed_command_line.HasSwitch(switches::kMetricsRecordingOnly) ||
- parsed_command_line.HasSwitch(switches::kEnableBenchmarking)) {
- // If we're testing then we don't care what the user preference is, we turn
- // on recording, but not reporting, otherwise tests fail.
- metrics->StartRecordingOnly();
- return metrics;
- }
-
- // If the user permits metrics reporting with the checkbox in the
- // prefs, we turn on recording. We disable metrics completely for
- // non-official builds.
-#if defined(GOOGLE_CHROME_BUILD)
-#if defined(OS_CHROMEOS)
- bool enabled = chromeos::MetricsCrosSettingsProvider::GetMetricsStatus();
-#else
- bool enabled = local_state->GetBoolean(prefs::kMetricsReportingEnabled);
-#endif // #if defined(OS_CHROMEOS)
- if (enabled) {
- metrics->Start();
- chrome_browser_net_websocket_experiment::
- WebSocketExperimentRunner::Start();
- }
-#endif // defined(GOOGLE_CHROME_BUILD)
-
- return metrics;
-}
-
-void BrowserMainParts::SetupFieldTrials() {
- // Note: make sure to call ConnectionFieldTrial() before
- // ProxyConnectionsFieldTrial().
- ConnectionFieldTrial();
- SocketTimeoutFieldTrial();
- ProxyConnectionsFieldTrial();
- prerender::ConfigurePrefetchAndPrerender(parsed_command_line());
- SpdyFieldTrial();
- ConnectBackupJobsFieldTrial();
- SSLFalseStartFieldTrial();
-}
-
// -----------------------------------------------------------------------------
// TODO(viettrungluu): move more/rest of BrowserMain() into above structure
@@ -830,6 +763,45 @@ void InitializeBrokerServices(const MainFunctionParams& parameters,
#endif
}
+// Initializes the metrics service with the configuration for this process,
+// returning the created service (guaranteed non-NULL).
+MetricsService* InitializeMetrics(const CommandLine& parsed_command_line,
+ const PrefService* local_state) {
+#if defined(OS_WIN)
+ if (parsed_command_line.HasSwitch(switches::kChromeFrame))
+ MetricsLog::set_version_extension("-F");
+#elif defined(ARCH_CPU_64_BITS)
+ MetricsLog::set_version_extension("-64");
+#endif // defined(OS_WIN)
+
+ MetricsService* metrics = g_browser_process->metrics_service();
+
+ if (parsed_command_line.HasSwitch(switches::kMetricsRecordingOnly) ||
+ parsed_command_line.HasSwitch(switches::kEnableBenchmarking)) {
+ // If we're testing then we don't care what the user preference is, we turn
+ // on recording, but not reporting, otherwise tests fail.
+ metrics->StartRecordingOnly();
+ } else {
+ // If the user permits metrics reporting with the checkbox in the
+ // prefs, we turn on recording. We disable metrics completely for
+ // non-official builds.
+#if defined(GOOGLE_CHROME_BUILD)
+#if defined(OS_CHROMEOS)
+ bool enabled = chromeos::MetricsCrosSettingsProvider::GetMetricsStatus();
+#else
+ bool enabled = local_state->GetBoolean(prefs::kMetricsReportingEnabled);
+#endif // #if defined(OS_CHROMEOS)
+ if (enabled) {
+ metrics->Start();
+ chrome_browser_net_websocket_experiment::
+ WebSocketExperimentRunner::Start();
+ }
+#endif
+ }
+
+ return metrics;
+}
+
// Initializes the profile, possibly doing some user prompting to pick a
// fallback profile. Returns the newly created profile, or NULL if startup
// should not continue.
@@ -1355,10 +1327,16 @@ 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
- // set up metrics and initialize field trials.
- MetricsService* metrics = parts->SetupMetricsAndFieldTrials(
- parsed_command_line, local_state);
+ // Now the command line has been mutated based on about:flags, we can run some
+ // field trials
+ parts->SetupFieldTrials();
+
+ // Initialize FieldTrialSynchronizer system. This is a singleton and is used
+ // for posting tasks via NewRunnableMethod. Its deleted when it goes out of
+ // scope. Even though NewRunnableMethod does AddRef and Release, the object
+ // will not be deleted after the Task is executed.
+ scoped_refptr<FieldTrialSynchronizer> field_trial_synchronizer(
+ new FieldTrialSynchronizer());
// Now that all preferences have been registered, set the install date
// for the uninstall metrics if this is our first run. This only actually
@@ -1702,6 +1680,7 @@ 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)