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

Unified Diff: base/metrics/field_trial.cc

Issue 706203003: Update from https://crrev.com/303153 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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/metrics/field_trial.h ('k') | base/metrics/field_trial_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/field_trial.cc
diff --git a/base/metrics/field_trial.cc b/base/metrics/field_trial.cc
index c82f33d6f62dd7bb715a2ee4a0ed78ca0f9c62de..7efca7a3ef53cdaa8093b880b44d7e469bebc27d 100644
--- a/base/metrics/field_trial.cc
+++ b/base/metrics/field_trial.cc
@@ -67,6 +67,7 @@ const int FieldTrial::kDefaultGroupNumber = 0;
bool FieldTrial::enable_benchmarking_ = false;
const char FieldTrialList::kPersistentStringSeparator('/');
+const char FieldTrialList::kActivationMarker('*');
int FieldTrialList::kNoExpirationYear = 0;
//------------------------------------------------------------------------------
@@ -421,7 +422,18 @@ bool FieldTrialList::CreateTrialsFromString(
return false;
if (group_name_end == trials_string.npos)
group_name_end = trials_string.length();
- std::string name(trials_string, next_item, name_end - next_item);
+
+ // Verify if the trial should be activated or not.
+ std::string name;
+ bool force_activation = false;
+ if (trials_string[next_item] == kActivationMarker) {
+ // Name cannot be only the indicator.
+ if (name_end - next_item == 1)
+ return false;
+ next_item++;
+ force_activation = true;
+ }
+ name.append(trials_string, next_item, name_end - next_item);
std::string group_name(trials_string, name_end + 1,
group_name_end - name_end - 1);
next_item = group_name_end + 1;
@@ -432,7 +444,7 @@ bool FieldTrialList::CreateTrialsFromString(
FieldTrial* trial = CreateFieldTrial(name, group_name);
if (!trial)
return false;
- if (mode == ACTIVATE_TRIALS) {
+ if (mode == ACTIVATE_TRIALS || force_activation) {
// Call |group()| to mark the trial as "used" and notify observers, if
// any. This is useful to ensure that field trials created in child
// processes are properly reported in crash reports.
« no previous file with comments | « base/metrics/field_trial.h ('k') | base/metrics/field_trial_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698