summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/metrics/field_trial.cc4
-rw-r--r--chrome/browser/browser_main.cc2
-rw-r--r--chrome/browser/net/net_pref_observer.cc8
-rw-r--r--chrome/browser/trials/http_throttling_trial.cc49
-rw-r--r--chrome/browser/trials/http_throttling_trial.h14
-rw-r--r--chrome/browser/ui/webui/net_internals_ui.cc26
-rw-r--r--chrome/chrome_browser.gypi2
-rw-r--r--chrome/common/pref_names.cc6
-rw-r--r--chrome/common/pref_names.h1
-rw-r--r--net/url_request/url_request_throttler_entry.cc19
-rw-r--r--net/url_request/url_request_throttler_manager.cc4
11 files changed, 120 insertions, 15 deletions
diff --git a/base/metrics/field_trial.cc b/base/metrics/field_trial.cc
index b86b9cc..190ebcf 100644
--- a/base/metrics/field_trial.cc
+++ b/base/metrics/field_trial.cc
@@ -369,7 +369,9 @@ size_t FieldTrialList::GetFieldTrialCount() {
// static
bool FieldTrialList::IsOneTimeRandomizationEnabled() {
- DCHECK(global_);
+ // TODO(joi): Put back a DCHECK(global_) here. First, need to make sure all
+ // unit test executables have exactly one FieldTrialList instance (currently
+ // they have 0 or 1).
if (!global_)
return false;
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index 20d2791..1315bb5 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -489,7 +489,7 @@ void BrowserMainParts::ConnectBackupJobsFieldTrial() {
const base::FieldTrial::Probability kConnectBackupJobsDivisor = 100;
// 1% probability.
const base::FieldTrial::Probability kConnectBackupJobsProbability = 1;
- // After June 30, 2011 builds, it will always be in defaut group.
+ // After June 30, 2011 builds, it will always be in default group.
scoped_refptr<base::FieldTrial> trial(
new base::FieldTrial("ConnnectBackupJobs",
kConnectBackupJobsDivisor, "ConnectBackupJobsEnabled", 2011, 6,
diff --git a/chrome/browser/net/net_pref_observer.cc b/chrome/browser/net/net_pref_observer.cc
index b125dae..8a0d08e 100644
--- a/chrome/browser/net/net_pref_observer.cc
+++ b/chrome/browser/net/net_pref_observer.cc
@@ -9,6 +9,7 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/prerender/prerender_manager.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/trials/http_throttling_trial.h"
#include "chrome/common/pref_names.h"
#include "content/browser/browser_thread.h"
#include "content/common/notification_type.h"
@@ -80,4 +81,11 @@ void NetPrefObserver::RegisterPrefs(PrefService* prefs) {
prefs->RegisterBooleanPref(prefs::kHttpThrottlingEnabled,
false,
PrefService::UNSYNCABLE_PREF);
+ prefs->RegisterBooleanPref(prefs::kHttpThrottlingMayExperiment,
+ true,
+ PrefService::UNSYNCABLE_PREF);
+
+ // This is the earliest point at which we can set up the trial, as
+ // it relies on prefs for parameterization.
+ CreateHttpThrottlingTrial(prefs);
}
diff --git a/chrome/browser/trials/http_throttling_trial.cc b/chrome/browser/trials/http_throttling_trial.cc
new file mode 100644
index 0000000..9fa1399
--- /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);
+ }
+}
diff --git a/chrome/browser/trials/http_throttling_trial.h b/chrome/browser/trials/http_throttling_trial.h
new file mode 100644
index 0000000..928779c
--- /dev/null
+++ b/chrome/browser/trials/http_throttling_trial.h
@@ -0,0 +1,14 @@
+// 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.
+
+#ifndef CHROME_BROWSER_TRIALS_HTTP_THROTTLING_TRIAL_H_
+#define CHROME_BROWSER_TRIALS_HTTP_THROTTLING_TRIAL_H_
+#pragma once
+
+class PrefService;
+
+// Creates the trial.
+void CreateHttpThrottlingTrial(PrefService* prefs);
+
+#endif // CHROME_BROWSER_TRIALS_HTTP_THROTTLING_TRIAL_H_
diff --git a/chrome/browser/ui/webui/net_internals_ui.cc b/chrome/browser/ui/webui/net_internals_ui.cc
index 2829e0d..52fe458 100644
--- a/chrome/browser/ui/webui/net_internals_ui.cc
+++ b/chrome/browser/ui/webui/net_internals_ui.cc
@@ -14,6 +14,7 @@
#include "base/command_line.h"
#include "base/memory/singleton.h"
#include "base/message_loop.h"
+#include "base/metrics/field_trial.h" // TODO(joi): Remove after the trial ends.
#include "base/path_service.h"
#include "base/string_number_conversions.h"
#include "base/string_piece.h"
@@ -242,6 +243,11 @@ class NetInternalsMessageHandler
// be accessed on the UI thread.
BooleanPrefMember http_throttling_enabled_;
+ // The pref member that determines whether experimentation on HTTP throttling
+ // is allowed (this becomes false once the user explicitly sets the
+ // feature to on or off).
+ BooleanPrefMember http_throttling_may_experiment_;
+
// OnRendererReady invokes this callback to do the part of message handling
// that needs to happen on the IO thread.
scoped_ptr<WebUI::MessageCallback> renderer_ready_io_callback_;
@@ -512,8 +518,10 @@ WebUIMessageHandler* NetInternalsMessageHandler::Attach(WebUI* web_ui) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
PrefService* pref_service = web_ui->GetProfile()->GetPrefs();
- http_throttling_enabled_.Init(prefs::kHttpThrottlingEnabled, pref_service,
- this);
+ http_throttling_enabled_.Init(
+ prefs::kHttpThrottlingEnabled, pref_service, this);
+ http_throttling_may_experiment_.Init(
+ prefs::kHttpThrottlingMayExperiment, pref_service, NULL);
proxy_ = new IOThreadImpl(this->AsWeakPtr(), g_browser_process->io_thread(),
web_ui->GetProfile()->GetRequestContext());
@@ -667,6 +675,20 @@ void NetInternalsMessageHandler::OnEnableHttpThrottling(const ListValue* list) {
}
http_throttling_enabled_.SetValue(enable);
+
+ // We never receive OnEnableHttpThrottling unless the user has modified
+ // the value of the checkbox on the about:net-internals page. Once the
+ // user does that, we no longer allow experiments to control its value.
+ if (http_throttling_may_experiment_.GetValue()) {
+ http_throttling_may_experiment_.SetValue(false);
+
+ // Disable the ongoing trial so that histograms after this point
+ // show as being in the "Default" group of the trial.
+ base::FieldTrial* trial = base::FieldTrialList::Find(
+ "HttpThrottlingEnabled");
+ if (trial)
+ trial->Disable();
+ }
}
void NetInternalsMessageHandler::OnGetPrerenderInfo(const ListValue* list) {
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index fb453ad..efe8d58 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -2145,6 +2145,8 @@
'browser/translate/translate_tab_helper.h',
'browser/transport_security_persister.cc',
'browser/transport_security_persister.h',
+ 'browser/trials/http_throttling_trial.cc',
+ 'browser/trials/http_throttling_trial.h',
'browser/ui/app_modal_dialogs/app_modal_dialog.cc',
'browser/ui/app_modal_dialogs/app_modal_dialog.h',
'browser/ui/app_modal_dialogs/app_modal_dialog_queue.cc',
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index 80a07af..297b2ad 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -691,6 +691,12 @@ const char kPinnedTabs[] = "pinned_tabs";
// Boolean that is true when HTTP throttling is enabled.
const char kHttpThrottlingEnabled[] = "http_throttling.enabled";
+// Boolean that is true until the user changes the setting of the check-box
+// that controls whether HTTP throttling is enabled. When this is false,
+// we do not allow FieldTrial experiments to modify whether the feature
+// is enabled or not.
+const char kHttpThrottlingMayExperiment[] = "http_throttling.may_experiment";
+
// Integer containing the default Geolocation content setting.
const char kGeolocationDefaultContentSetting[] =
"geolocation.default_content_setting";
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 4182c7b..5035794 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -243,6 +243,7 @@ extern const char kEnableTranslate[];
extern const char kEnableBookmarkBar[];
extern const char kPinnedTabs[];
extern const char kHttpThrottlingEnabled[];
+extern const char kHttpThrottlingMayExperiment[];
extern const char kDisable3DAPIs[];
extern const char kEnableHyperlinkAuditing[];
diff --git a/net/url_request/url_request_throttler_entry.cc b/net/url_request/url_request_throttler_entry.cc
index ca29fe0..bf831ca 100644
--- a/net/url_request/url_request_throttler_entry.cc
+++ b/net/url_request/url_request_throttler_entry.cc
@@ -199,9 +199,10 @@ bool URLRequestThrottlerEntry::IsDuringExponentialBackoff() const {
int reject_count = reject_request ? 1 : 0;
UMA_HISTOGRAM_ENUMERATION(
"Throttling.RequestThrottled", reject_count, 2);
- if (base::FieldTrialList::TrialExists("ThrottlingEnabled")) {
+ if (base::FieldTrialList::TrialExists("HttpThrottlingEnabled")) {
UMA_HISTOGRAM_ENUMERATION(base::FieldTrial::MakeName(
- "Throttling.RequestThrottled", "ThrottlingEnabled"), reject_count, 2);
+ "Throttling.RequestThrottled", "HttpThrottlingEnabled"),
+ reject_count, 2);
}
return reject_request;
@@ -367,10 +368,10 @@ void URLRequestThrottlerEntry::HandleCustomRetryAfter(
UMA_HISTOGRAM_CUSTOM_TIMES(
"Throttling.CustomRetryAfterMs", value,
base::TimeDelta::FromSeconds(1), base::TimeDelta::FromHours(12), 50);
- if (base::FieldTrialList::TrialExists("ThrottlingEnabled")) {
+ if (base::FieldTrialList::TrialExists("HttpThrottlingEnabled")) {
UMA_HISTOGRAM_CUSTOM_TIMES(
base::FieldTrial::MakeName("Throttling.CustomRetryAfterMs",
- "ThrottlingEnabled"), value,
+ "HttpThrottlingEnabled"), value,
base::TimeDelta::FromSeconds(1), base::TimeDelta::FromHours(12), 50);
}
}
@@ -393,10 +394,10 @@ void URLRequestThrottlerEntry::HandleMetricsTracking(int response_code) {
// to make sure we count only the responses seen by throttling.
// TODO(joi): Remove after experiment.
UMA_HISTOGRAM_ENUMERATION("Throttling.HttpResponseCode", response_code, 600);
- if (base::FieldTrialList::TrialExists("ThrottlingEnabled")) {
+ if (base::FieldTrialList::TrialExists("HttpThrottlingEnabled")) {
UMA_HISTOGRAM_ENUMERATION(
base::FieldTrial::MakeName("Throttling.HttpResponseCode",
- "ThrottlingEnabled"),
+ "HttpThrottlingEnabled"),
response_code, 600);
}
@@ -419,12 +420,12 @@ void URLRequestThrottlerEntry::HandleMetricsTracking(int response_code) {
base::TimeDelta::FromMilliseconds(10),
base::TimeDelta::FromHours(6), 50);
- if (base::FieldTrialList::TrialExists("ThrottlingEnabled")) {
+ if (base::FieldTrialList::TrialExists("HttpThrottlingEnabled")) {
UMA_HISTOGRAM_COUNTS(base::FieldTrial::MakeName(
- "Throttling.FailureCountAtSuccess", "ThrottlingEnabled"),
+ "Throttling.FailureCountAtSuccess", "HttpThrottlingEnabled"),
failure_count);
UMA_HISTOGRAM_CUSTOM_TIMES(base::FieldTrial::MakeName(
- "Throttling.PerceivedDowntime", "ThrottlingEnabled"), down_time,
+ "Throttling.PerceivedDowntime", "HttpThrottlingEnabled"), down_time,
base::TimeDelta::FromMilliseconds(10),
base::TimeDelta::FromHours(6), 50);
}
diff --git a/net/url_request/url_request_throttler_manager.cc b/net/url_request/url_request_throttler_manager.cc
index aaa03af..1bbad1f 100644
--- a/net/url_request/url_request_throttler_manager.cc
+++ b/net/url_request/url_request_throttler_manager.cc
@@ -89,9 +89,9 @@ void URLRequestThrottlerManager::AddToOptOutList(const std::string& host) {
// In practice, this would almost never occur.
if (opt_out_hosts_.find(host) == opt_out_hosts_.end()) {
UMA_HISTOGRAM_COUNTS("Throttling.SiteOptedOut", 1);
- if (base::FieldTrialList::TrialExists("ThrottlingEnabled")) {
+ if (base::FieldTrialList::TrialExists("HttpThrottlingEnabled")) {
UMA_HISTOGRAM_COUNTS(base::FieldTrial::MakeName(
- "Throttling.SiteOptedOut", "ThrottlingEnabled"), 1);
+ "Throttling.SiteOptedOut", "HttpThrottlingEnabled"), 1);
}
net_log_->EndEvent(