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

Unified Diff: chrome/browser/ui/webui/net_internals_ui.cc

Issue 7027040: Implement A/B experiment for anti-DDoS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments. 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
Index: chrome/browser/ui/webui/net_internals_ui.cc
diff --git a/chrome/browser/ui/webui/net_internals_ui.cc b/chrome/browser/ui/webui/net_internals_ui.cc
index cd8d09d9fb9e1398292236575f8ad2058ca8a189..17faee1aa8055774e92b3236f32ab8694d431ae6 100644
--- a/chrome/browser/ui/webui/net_internals_ui.cc
+++ b/chrome/browser/ui/webui/net_internals_ui.cc
@@ -15,6 +15,7 @@
#include "base/file_util.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"
@@ -272,6 +273,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_;
@@ -545,8 +551,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());
@@ -718,6 +726,19 @@ 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("ThrottlingEnabled");
+ if (trial)
+ trial->Disable();
+ }
}
////////////////////////////////////////////////////////////////////////////////

Powered by Google App Engine
This is Rietveld 408576698