Index: base/metrics/field_trial.cc |
diff --git a/base/metrics/field_trial.cc b/base/metrics/field_trial.cc |
index 245f2bf02a6a6e07c4ff0f625c91397f2c04a657..6d4f2eb06b2d47c28dde9c2389e68d4814551cae 100644 |
--- a/base/metrics/field_trial.cc |
+++ b/base/metrics/field_trial.cc |
@@ -170,6 +170,21 @@ void FieldTrial::EnableBenchmarking() { |
enable_benchmarking_ = true; |
} |
+void FieldTrial::SetForced() { |
+ // We might have been forced before (e.g., by CreateFieldTrial) and it's |
+ // first come first served, e.g., command line switch has precedence. |
+ if (forced_) |
+ return; |
+ // Explicit forcing should only be for cases where we want to set the group |
+ // probabilities before the hard coded field trial setup is executed. So |
+ // there must have been at least one non-default group appended at that point. |
+ DCHECK_GT(next_group_number_, kDefaultGroupNumber + 1); |
+ |
+ // And we must finalize the group choice before we mark ourselves as forced. |
+ group(); |
+ forced_ = true; |
+} |
+ |
FieldTrial::~FieldTrial() {} |
void FieldTrial::SetGroupChoice(const std::string& name, int number) { |