Commit d38f6b0a authored by robliao's avatar robliao Committed by Commit bot

Rearrange iOS SetupMetricsAndFieldTrials to SetupFieldTrials and SetupMetrics

This allows for the Browser Task Scheduler to setup and redirect after
SetupFieldTrials to get variations data but before SetupMetrics, which
posts tasks to the blocking pool.

This harmonizes iOS with
https://codereview.chromium.org/2342993002/

BUG=636518

Review-Url: https://codereview.chromium.org/2376123004
Cr-Commit-Position: refs/heads/master@{#422890}
parent 9976d47e
......@@ -6,8 +6,7 @@
#include "base/metrics/field_trial.h"
void SetupFieldTrials(const base::CommandLine& command_line,
const base::Time& install_time) {
void SetupIOSFieldTrials() {
// Activate the iOS tab eviction dynamic field trials.
base::FieldTrialList::FindValue("TabEviction");
}
......@@ -11,7 +11,6 @@ class Time;
}
// Sets up iOS-specific field trials.
void SetupFieldTrials(const base::CommandLine& command_line,
const base::Time& install_time);
void SetupIOSFieldTrials();
#endif // IOS_CHROME_BROWSER_IOS_CHROME_FIELD_TRIALS_H_
......@@ -36,10 +36,12 @@ class IOSChromeMainParts : public web::WebMainParts {
void PostMainMessageLoopRun() override;
void PostDestroyThreads() override;
// Constructs metrics service and does related initialization, including
// creation of field trials. Call only after labs have been converted to
// switches.
void SetUpMetricsAndFieldTrials();
// Sets up the field trials and related initialization. Call only after
// about:flags have been converted to switches.
void SetupFieldTrials();
// Constructs the metrics service and initializes metrics recording.
void SetupMetrics();
// Starts recording of metrics. This can only be called after we have a file
// thread.
......
......@@ -114,7 +114,8 @@ void IOSChromeMainParts::PreCreateThreads() {
// Now the command line has been mutated based on about:flags, we can setup
// metrics and initialize field trials that are needed by IOSChromeIOThread's
// initialization which happens in ApplicationContext:PreCreateThreads.
SetUpMetricsAndFieldTrials();
SetupFieldTrials();
SetupMetrics();
// Initialize FieldTrialSynchronizer system.
field_trial_synchronizer_.reset(new ios::FieldTrialSynchronizer);
......@@ -192,7 +193,7 @@ void IOSChromeMainParts::PostDestroyThreads() {
}
// This will be called after the command-line has been mutated by about:flags
void IOSChromeMainParts::SetUpMetricsAndFieldTrials() {
void IOSChromeMainParts::SetupFieldTrials() {
base::SetRecordActionTaskRunner(
web::WebThread::GetTaskRunnerForThread(web::WebThread::UI));
......@@ -225,11 +226,6 @@ void IOSChromeMainParts::SetUpMetricsAndFieldTrials() {
std::vector<std::string> variation_ids =
RegisterAllFeatureVariationParameters(&flags_storage, feature_list.get());
// Must initialize metrics after about:flags have been converted into
// switches, but before field trials are set up (so that client ID is
// available for one-time randomized field trials).
metrics::MetricsService* metrics = application_context_->GetMetricsService();
variations::VariationsHttpHeaderProvider* http_header_provider =
variations::VariationsHttpHeaderProvider::GetInstance();
// Force the variation ids selected in chrome://flags and/or specified using
......@@ -239,7 +235,6 @@ void IOSChromeMainParts::SetUpMetricsAndFieldTrials() {
&variation_ids);
CHECK(result) << "Invalid list of variation ids specified (either in --"
<< switches::kIOSForceVariationIds << " or in chrome://flags)";
metrics->AddSyntheticTrialObserver(http_header_provider);
feature_list->InitializeFromCommandLine(
command_line->GetSwitchValueASCII(switches::kEnableIOSFeatures),
......@@ -252,9 +247,13 @@ void IOSChromeMainParts::SetUpMetricsAndFieldTrials() {
base::FeatureList::SetInstance(std::move(feature_list));
SetupFieldTrials(parsed_command_line_,
base::Time::FromTimeT(metrics->GetInstallDate()));
SetupIOSFieldTrials();
}
void IOSChromeMainParts::SetupMetrics() {
metrics::MetricsService* metrics = application_context_->GetMetricsService();
metrics->AddSyntheticTrialObserver(
variations::VariationsHttpHeaderProvider::GetInstance());
// Now that field trials have been created, initializes metrics recording.
metrics->InitializeMetricsRecordingState();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment