summaryrefslogtreecommitdiff
path: root/chromium/components/metrics/field_trials_provider.cc
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-12 14:27:29 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-13 09:35:20 +0000
commitc30a6232df03e1efbd9f3b226777b07e087a1122 (patch)
treee992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/components/metrics/field_trials_provider.cc
parent7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff)
downloadqtwebengine-chromium-85-based.tar.gz
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/components/metrics/field_trials_provider.cc')
-rw-r--r--chromium/components/metrics/field_trials_provider.cc38
1 files changed, 34 insertions, 4 deletions
diff --git a/chromium/components/metrics/field_trials_provider.cc b/chromium/components/metrics/field_trials_provider.cc
index b13f131823e..dc202f7a39f 100644
--- a/chromium/components/metrics/field_trials_provider.cc
+++ b/chromium/components/metrics/field_trials_provider.cc
@@ -48,16 +48,46 @@ void FieldTrialsProvider::ProvideSystemProfileMetrics(
void FieldTrialsProvider::ProvideSystemProfileMetricsWithLogCreationTime(
base::TimeTicks log_creation_time,
metrics::SystemProfileProto* system_profile_proto) {
- std::vector<ActiveGroupId> field_trial_ids;
+ // TODO(crbug/1090497): Maybe call ProvideCurrentSessionData() instead from
+ // places in which ProvideSystemProfileMetricsWithLogCreationTime() is called,
+ // e.g. startup_data.cc and background_tracing_metrics_provider.cc.
+
+ log_creation_time_ = log_creation_time;
+
const std::string& version = variations::GetSeedVersion();
if (!version.empty())
system_profile_proto->set_variations_seed_version(version);
- GetFieldTrialIds(&field_trial_ids);
- WriteFieldTrials(field_trial_ids, system_profile_proto);
+
+ // TODO(crbug/1090098): Determine whether this can be deleted.
+ GetAndWriteFieldTrials(system_profile_proto);
+}
+
+void FieldTrialsProvider::ProvideCurrentSessionData(
+ metrics::ChromeUserMetricsExtension* uma_proto) {
+ // This function is called from both
+ // ProvideSystemProfileMetricsWithLogCreationTime() and
+ // ProvideCurrentSessionData() so that field trials activated in other metrics
+ // providers are captured. We need both calls because in some scenarios in
+ // which this class is used, only the former function gets called.
+ DCHECK(!log_creation_time_.is_null());
+ GetAndWriteFieldTrials(uma_proto->mutable_system_profile());
+}
+
+void FieldTrialsProvider::SetLogCreationTimeForTesting(base::TimeTicks time) {
+ log_creation_time_ = time;
+}
+
+void FieldTrialsProvider::GetAndWriteFieldTrials(
+ metrics::SystemProfileProto* system_profile_proto) const {
+ system_profile_proto->clear_field_trial();
+
+ std::vector<ActiveGroupId> field_trials;
+ GetFieldTrialIds(&field_trials);
+ WriteFieldTrials(field_trials, system_profile_proto);
if (registry_) {
std::vector<ActiveGroupId> synthetic_trials;
- registry_->GetSyntheticFieldTrialsOlderThan(log_creation_time,
+ registry_->GetSyntheticFieldTrialsOlderThan(log_creation_time_,
&synthetic_trials);
WriteFieldTrials(synthetic_trials, system_profile_proto);
}