diff options
author | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-30 16:31:54 +0000 |
---|---|---|
committer | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-30 16:31:54 +0000 |
commit | e695fbd6d62e9967d6256cd0667eca2fb2bb918d (patch) | |
tree | 58e196031e02447b31bd9a4182b8fb3f4d7ea81b /base/field_trial.cc | |
parent | 5c7c19d83d201fa23d5097cce108c033ece5c63b (diff) | |
download | chromium_src-e695fbd6d62e9967d6256cd0667eca2fb2bb918d.zip chromium_src-e695fbd6d62e9967d6256cd0667eca2fb2bb918d.tar.gz chromium_src-e695fbd6d62e9967d6256cd0667eca2fb2bb918d.tar.bz2 |
Create A/B test of SDCH
To do this, I needed to add the feature that ALL FieldTrials that are
established in the browser process are forwarded and established in
the corresponding renderer processes. This then allows both DNS impact,
as well as SDCH inmpact (and any other field tests) to be studied
at the same time in a single binary.
This checkin also establishes a pattern that when we're doing A/B tests
via a histogram such as RequestToFinish, that we produce names for
all groups, rather than leaving one group as the "default" or "empty postfix"
group. This is critical for naming various sub-groups when a multitude
of tests are taking place at the same time.
BUG=15479
r=mbelshe
Review URL: http://codereview.chromium.org/150087
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19595 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/field_trial.cc')
-rw-r--r-- | base/field_trial.cc | 94 |
1 files changed, 59 insertions, 35 deletions
diff --git a/base/field_trial.cc b/base/field_trial.cc index fc12f31..549822f 100644 --- a/base/field_trial.cc +++ b/base/field_trial.cc @@ -14,7 +14,10 @@ using base::Time; const int FieldTrial::kNotParticipating = -1; // static -const char FieldTrial::kPersistentStringSeparator('/'); +const int FieldTrial::kAllRemainingProbability = -2; + +// static +const char FieldTrialList::kPersistentStringSeparator('/'); //------------------------------------------------------------------------------ // FieldTrial methods and members. @@ -53,40 +56,6 @@ std::string FieldTrial::MakeName(const std::string& name_prefix, return big_string.append(FieldTrialList::FindFullName(trial_name)); } -std::string FieldTrial::MakePersistentString() const { - DCHECK_EQ(name_.find(kPersistentStringSeparator), std::string::npos); - DCHECK_EQ(group_name_.find(kPersistentStringSeparator), std::string::npos); - - std::string persistent(name_); - persistent = persistent.append(1, kPersistentStringSeparator); - persistent = persistent.append(group_name_); - return persistent; -} - -// static -FieldTrial* FieldTrial::RestorePersistentString(const std::string &persistent) { - size_t split_point = persistent.find(kPersistentStringSeparator); - if (std::string::npos == split_point) - return NULL; // Bogus string. - std::string new_name(persistent, 0, split_point); - std::string new_group_name(persistent, split_point + 1); - if (new_name.empty() || new_group_name.empty()) - return NULL; // Incomplete string. - - FieldTrial *field_trial; - field_trial = FieldTrialList::Find(new_name); - if (field_trial) { - // In single process mode, we may have already created the field trial. - if (field_trial->group_name_ != new_group_name) - return NULL; // Conflicting group name :-(. - } else { - const int kTotalProbability = 100; - field_trial = new FieldTrial(new_name, kTotalProbability); - field_trial->AppendGroup(new_group_name, kTotalProbability); - } - return field_trial; -} - //------------------------------------------------------------------------------ // FieldTrialList methods and members. @@ -151,3 +120,58 @@ FieldTrial* FieldTrialList::PreLockedFind(const std::string& name) { return NULL; return it->second; } + +// static +void FieldTrialList::StatesToString(std::string* output) { + if (!global_) + return; + DCHECK(output->empty()); + for (RegistrationList::iterator it = global_->registered_.begin(); + it != global_->registered_.end(); ++it) { + const std::string name = it->first; + const std::string group_name = it->second->group_name(); + if (group_name.empty()) + continue; // No definitive winner in this trial. + DCHECK_EQ(name.find(kPersistentStringSeparator), std::string::npos); + DCHECK_EQ(group_name.find(kPersistentStringSeparator), std::string::npos); + output->append(name); + output->append(1, kPersistentStringSeparator); + output->append(group_name); + output->append(1, kPersistentStringSeparator); + } +} + +// static +bool FieldTrialList::StringAugmentsState(const std::string& prior_state) { + DCHECK(global_); + if (prior_state.empty() || !global_) + return true; + + size_t next_item = 0; + while (next_item < prior_state.length()) { + size_t name_end = prior_state.find(kPersistentStringSeparator, next_item); + if (name_end == prior_state.npos || next_item == name_end) + return false; + size_t group_name_end = prior_state.find(kPersistentStringSeparator, + name_end + 1); + if (group_name_end == prior_state.npos || name_end + 1 == group_name_end) + return false; + std::string name(prior_state, next_item, name_end - next_item); + std::string group_name(prior_state, name_end + 1, + group_name_end - name_end - 1); + next_item = group_name_end + 1; + + FieldTrial *field_trial(FieldTrialList::Find(name)); + if (field_trial) { + // In single process mode, we may have already created the field trial. + if (field_trial->group_name() != group_name) + return false; + continue; + } + const int kTotalProbability = 100; + field_trial = new FieldTrial(name, kTotalProbability); + field_trial->AppendGroup(group_name, kTotalProbability); + } + return true; +} + |