Chromium Code Reviews| Index: chrome/browser/instant/instant_field_trial.cc |
| diff --git a/chrome/browser/instant/instant_field_trial.cc b/chrome/browser/instant/instant_field_trial.cc |
| index 2c3e63d7e7fd65772eb47a3db1b0473b847655c3..54d4e75e46ee7e92595fd6ca1fd0d4280efbb92f 100644 |
| --- a/chrome/browser/instant/instant_field_trial.cc |
| +++ b/chrome/browser/instant/instant_field_trial.cc |
| @@ -4,24 +4,37 @@ |
| #include "chrome/browser/instant/instant_field_trial.h" |
| +#include "base/metrics/field_trial.h" |
| #include "chrome/browser/prefs/pref_service.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/common/pref_names.h" |
| namespace { |
| -bool field_trial_active_ = false; |
| + |
| +int kControlGroupId1 = 0; |
|
sky
2011/08/08 16:10:54
Add descriptions. Using kFoo implies these are con
sreeram
2011/08/08 16:30:10
Done.
|
| +int kControlGroupId2 = 0; |
| +int kExperimentGroupId1 = 0; |
| +int kExperimentGroupId2 = 0; |
| + |
| } |
| // static |
| void InstantFieldTrial::Activate() { |
| - field_trial_active_ = true; |
| + scoped_refptr<base::FieldTrial> trial( |
| + new base::FieldTrial("Instant", 10000, "InstantInactive", 2012, 1, 1)); |
| + |
| + if (!base::FieldTrialList::IsOneTimeRandomizationEnabled()) |
| + return; |
| + trial->UseOneTimeRandomization(); |
| + |
| + kControlGroupId1 = trial->AppendGroup("InstantControl1", 4500); // 45% |
| + kControlGroupId2 = trial->AppendGroup("InstantControl2", 4500); // 45% |
| + kExperimentGroupId1 = trial->AppendGroup("InstantExperiment1", 500); // 5% |
| + kExperimentGroupId2 = trial->AppendGroup("InstantExperiment2", 500); // 5% |
| } |
| // static |
| InstantFieldTrial::Group InstantFieldTrial::GetGroup(Profile* profile) { |
| - if (!field_trial_active_) |
| - return INACTIVE; |
| - |
| if (profile->IsOffTheRecord()) |
| return INACTIVE; |
| @@ -32,11 +45,24 @@ InstantFieldTrial::Group InstantFieldTrial::GetGroup(Profile* profile) { |
| return INACTIVE; |
| } |
| - const int random = prefs->GetInteger(prefs::kInstantFieldTrialRandomDraw); |
| - return random < 4500 ? CONTROL1 : // 45% |
| - random < 9000 ? CONTROL2 : // 45% |
| - random < 9500 ? EXPERIMENT1 // 5% |
| - : EXPERIMENT2; // 5% |
| + const int group = base::FieldTrialList::FindValue("Instant"); |
| + |
| + if (group == base::FieldTrial::kNotFinalized || |
| + group == base::FieldTrial::kDefaultGroupNumber) { |
| + return INACTIVE; |
| + } |
| + |
| + if (group == kControlGroupId1) { |
|
sky
2011/08/08 16:10:54
no {}
sreeram
2011/08/08 16:30:10
Done.
|
| + return CONTROL1; |
| + } else if (group == kControlGroupId2) { |
| + return CONTROL2; |
| + } else if (group == kExperimentGroupId1) { |
| + return EXPERIMENT1; |
| + } else if (group == kExperimentGroupId2) { |
| + return EXPERIMENT2; |
| + } else { |
| + return INACTIVE; |
| + } |
| } |
| // static |