| Index: chrome/browser/trials/http_throttling_trial.cc
|
| diff --git a/chrome/browser/trials/http_throttling_trial.cc b/chrome/browser/trials/http_throttling_trial.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..9fa139938d273c253c1f8a16f6f85582ed3034b2
|
| --- /dev/null
|
| +++ b/chrome/browser/trials/http_throttling_trial.cc
|
| @@ -0,0 +1,49 @@
|
| +// 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/http_throttling_trial.h"
|
| +
|
| +#include "base/metrics/field_trial.h"
|
| +#include "chrome/browser/prefs/pref_service.h"
|
| +#include "chrome/common/pref_names.h"
|
| +
|
| +void CreateHttpThrottlingTrial(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;
|
| + // Disable trial a couple of days before M14 branch point.
|
| + scoped_refptr<base::FieldTrial> trial(new base::FieldTrial(
|
| + "HttpThrottlingEnabled", kTotalProbability, "Default", 2011, 7, 23));
|
| + 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);
|
| + }
|
| +}
|
|
|