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

Unified Diff: chrome/browser/trials/http_throttling_trial.cc

Issue 7027040: Implement A/B experiment for anti-DDoS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head. Extend trial cut-off date to July 23rd. Created 9 years, 6 months 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 | « chrome/browser/trials/http_throttling_trial.h ('k') | chrome/browser/ui/webui/net_internals_ui.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+ }
+}
« no previous file with comments | « chrome/browser/trials/http_throttling_trial.h ('k') | chrome/browser/ui/webui/net_internals_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698