Chromium Code Reviews| Index: chrome/browser/trials/throttling_trial.cc |
| diff --git a/chrome/browser/trials/throttling_trial.cc b/chrome/browser/trials/throttling_trial.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3ba26b7908b51ef603394c3d5d983b72b8db5839 |
| --- /dev/null |
| +++ b/chrome/browser/trials/throttling_trial.cc |
| @@ -0,0 +1,53 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/trials/throttling_trial.h" |
| + |
| +#include "base/metrics/field_trial.h" |
| +#include "chrome/browser/prefs/pref_service.h" |
| +#include "chrome/common/pref_names.h" |
| + |
| +namespace throttling_trial { |
| + |
| +void CreateTrial(PrefService* prefs) { |
| + DCHECK(prefs); |
| + |
| + // We only use one-time randomization, meaning each client will be put |
| + // in the same group on every startup, so that users do not have a situation |
| + // where they are intermittently in the experiment group, and have problems |
| + // because of throttling, then turn off their browser to fix the problem, |
| + // come back, and cannot figure out why they had problems (because throttling |
| + // will most likely by then be turned off). A lesser concern is that if |
| + // we didn't use one-time randomization, users might notice the preference |
| + // in about:net-internals toggling from one state to the other. |
| + if (!base::FieldTrialList::IsOneTimeRandomizationEnabled()) |
| + return; |
| + |
| + // Probability for each trial group (the experiment and the control) is 5%. |
| + const base::FieldTrial::Probability kEachGroupProbability = 5; |
| + const base::FieldTrial::Probability kTotalProbability = 100; |
| + // After June 30, 2011 builds, the trial will always be in default group. |
| + scoped_refptr<base::FieldTrial> trial(new base::FieldTrial( |
| + "ThrottlingEnabled", kTotalProbability, "Default", 2011, 6, 30)); |
|
yzshen1
2011/06/08 00:56:51
[out of curiosity]
June 30, 2011 means this will o
Jói
2011/06/08 16:44:47
Correct, this is just 5% of the dev channel for no
|
| + trial->UseOneTimeRandomization(); |
| + |
| + // If the user has touched the control for whether throttling is enabled |
| + // or not, we only allow the Default group for the trial, and we do not |
| + // modify the value of prefs::kHttpThrottlingEnabled. |
| + if (prefs->GetBoolean(prefs::kHttpThrottlingMayExperiment)) { |
| + int experiment_group = |
| + trial->AppendGroup("Experiment", kEachGroupProbability); |
| + |
| + // The behavior for the control group is the same as for the default group. |
| + // The point of having the control group is that it's the same size as |
| + // the experiment group and selected the same way, so we get an |
| + // apples-to-apples comparison of histograms. |
| + trial->AppendGroup("Control", kEachGroupProbability); |
| + |
| + prefs->SetBoolean(prefs::kHttpThrottlingEnabled, |
| + trial->group() == experiment_group); |
| + } |
| +} |
| + |
| +} // namespace throttling_trial |