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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/net_internals_ui.h" 5 #include "chrome/browser/ui/webui/net_internals_ui.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/base64.h" 13 #include "base/base64.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/file_util.h" 15 #include "base/file_util.h"
16 #include "base/memory/singleton.h" 16 #include "base/memory/singleton.h"
17 #include "base/message_loop.h" 17 #include "base/message_loop.h"
18 #include "base/metrics/field_trial.h" // TODO(joi): Remove after the trial ends .
18 #include "base/path_service.h" 19 #include "base/path_service.h"
19 #include "base/string_number_conversions.h" 20 #include "base/string_number_conversions.h"
20 #include "base/string_piece.h" 21 #include "base/string_piece.h"
21 #include "base/string_split.h" 22 #include "base/string_split.h"
22 #include "base/string_util.h" 23 #include "base/string_util.h"
23 #include "base/utf_string_conversions.h" 24 #include "base/utf_string_conversions.h"
24 #include "base/values.h" 25 #include "base/values.h"
25 #include "chrome/browser/browser_process.h" 26 #include "chrome/browser/browser_process.h"
26 #include "chrome/browser/io_thread.h" 27 #include "chrome/browser/io_thread.h"
27 #include "chrome/browser/net/chrome_net_log.h" 28 #include "chrome/browser/net/chrome_net_log.h"
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 CancelableRequestConsumer consumer_; 266 CancelableRequestConsumer consumer_;
266 // Libcros request handle. 267 // Libcros request handle.
267 CancelableRequestProvider::Handle syslogs_request_id_; 268 CancelableRequestProvider::Handle syslogs_request_id_;
268 }; 269 };
269 #endif 270 #endif
270 271
271 // The pref member about whether HTTP throttling is enabled, which needs to 272 // The pref member about whether HTTP throttling is enabled, which needs to
272 // be accessed on the UI thread. 273 // be accessed on the UI thread.
273 BooleanPrefMember http_throttling_enabled_; 274 BooleanPrefMember http_throttling_enabled_;
274 275
276 // The pref member that determines whether experimentation on HTTP throttling
277 // is allowed (this becomes false once the user explicitly sets the
278 // feature to on or off).
279 BooleanPrefMember http_throttling_may_experiment_;
280
275 // OnRendererReady invokes this callback to do the part of message handling 281 // OnRendererReady invokes this callback to do the part of message handling
276 // that needs to happen on the IO thread. 282 // that needs to happen on the IO thread.
277 scoped_ptr<WebUI::MessageCallback> renderer_ready_io_callback_; 283 scoped_ptr<WebUI::MessageCallback> renderer_ready_io_callback_;
278 284
279 // This is the "real" message handler, which lives on the IO thread. 285 // This is the "real" message handler, which lives on the IO thread.
280 scoped_refptr<IOThreadImpl> proxy_; 286 scoped_refptr<IOThreadImpl> proxy_;
281 287
282 #ifdef OS_CHROMEOS 288 #ifdef OS_CHROMEOS
283 // Class that handles getting and filtering system logs. 289 // Class that handles getting and filtering system logs.
284 scoped_ptr<SystemLogsGetter> syslogs_getter_; 290 scoped_ptr<SystemLogsGetter> syslogs_getter_;
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 NewRunnableMethod(proxy_.get(), &IOThreadImpl::Detach)); 544 NewRunnableMethod(proxy_.get(), &IOThreadImpl::Detach));
539 } 545 }
540 if (select_log_file_dialog_) 546 if (select_log_file_dialog_)
541 select_log_file_dialog_->ListenerDestroyed(); 547 select_log_file_dialog_->ListenerDestroyed();
542 } 548 }
543 549
544 WebUIMessageHandler* NetInternalsMessageHandler::Attach(WebUI* web_ui) { 550 WebUIMessageHandler* NetInternalsMessageHandler::Attach(WebUI* web_ui) {
545 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 551 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
546 552
547 PrefService* pref_service = web_ui->GetProfile()->GetPrefs(); 553 PrefService* pref_service = web_ui->GetProfile()->GetPrefs();
548 http_throttling_enabled_.Init(prefs::kHttpThrottlingEnabled, pref_service, 554 http_throttling_enabled_.Init(
549 this); 555 prefs::kHttpThrottlingEnabled, pref_service, this);
556 http_throttling_may_experiment_.Init(
557 prefs::kHttpThrottlingMayExperiment, pref_service, NULL);
550 558
551 proxy_ = new IOThreadImpl(this->AsWeakPtr(), g_browser_process->io_thread(), 559 proxy_ = new IOThreadImpl(this->AsWeakPtr(), g_browser_process->io_thread(),
552 web_ui->GetProfile()->GetRequestContext()); 560 web_ui->GetProfile()->GetRequestContext());
553 #ifdef OS_CHROMEOS 561 #ifdef OS_CHROMEOS
554 syslogs_getter_.reset(new SystemLogsGetter(this, 562 syslogs_getter_.reset(new SystemLogsGetter(this,
555 chromeos::SystemAccess::GetInstance())); 563 chromeos::SystemAccess::GetInstance()));
556 #endif 564 #endif
557 renderer_ready_io_callback_.reset( 565 renderer_ready_io_callback_.reset(
558 proxy_->CreateCallback(&IOThreadImpl::OnRendererReady)); 566 proxy_->CreateCallback(&IOThreadImpl::OnRendererReady));
559 567
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 void NetInternalsMessageHandler::OnEnableHttpThrottling(const ListValue* list) { 719 void NetInternalsMessageHandler::OnEnableHttpThrottling(const ListValue* list) {
712 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 720 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
713 721
714 bool enable = false; 722 bool enable = false;
715 if (!list->GetBoolean(0, &enable)) { 723 if (!list->GetBoolean(0, &enable)) {
716 NOTREACHED(); 724 NOTREACHED();
717 return; 725 return;
718 } 726 }
719 727
720 http_throttling_enabled_.SetValue(enable); 728 http_throttling_enabled_.SetValue(enable);
729
730 // We never receive OnEnableHttpThrottling unless the user has modified
731 // the value of the checkbox on the about:net-internals page. Once the
732 // user does that, we no longer allow experiments to control its value.
733 if (http_throttling_may_experiment_.GetValue()) {
734 http_throttling_may_experiment_.SetValue(false);
735
736 // Disable the ongoing trial so that histograms after this point
737 // show as being in the "Default" group of the trial.
738 base::FieldTrial* trial = base::FieldTrialList::Find("ThrottlingEnabled");
739 if (trial)
740 trial->Disable();
741 }
721 } 742 }
722 743
723 //////////////////////////////////////////////////////////////////////////////// 744 ////////////////////////////////////////////////////////////////////////////////
724 // 745 //
725 // NetInternalsMessageHandler::ReadLogFileTask 746 // NetInternalsMessageHandler::ReadLogFileTask
726 // 747 //
727 //////////////////////////////////////////////////////////////////////////////// 748 ////////////////////////////////////////////////////////////////////////////////
728 749
729 NetInternalsMessageHandler::ReadLogFileTask::ReadLogFileTask( 750 NetInternalsMessageHandler::ReadLogFileTask::ReadLogFileTask(
730 IOThreadImpl* proxy, const FilePath& path) 751 IOThreadImpl* proxy, const FilePath& path)
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after
1632 //////////////////////////////////////////////////////////////////////////////// 1653 ////////////////////////////////////////////////////////////////////////////////
1633 1654
1634 NetInternalsUI::NetInternalsUI(TabContents* contents) : ChromeWebUI(contents) { 1655 NetInternalsUI::NetInternalsUI(TabContents* contents) : ChromeWebUI(contents) {
1635 AddMessageHandler((new NetInternalsMessageHandler())->Attach(this)); 1656 AddMessageHandler((new NetInternalsMessageHandler())->Attach(this));
1636 1657
1637 NetInternalsHTMLSource* html_source = new NetInternalsHTMLSource(); 1658 NetInternalsHTMLSource* html_source = new NetInternalsHTMLSource();
1638 1659
1639 // Set up the chrome://net-internals/ source. 1660 // Set up the chrome://net-internals/ source.
1640 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); 1661 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source);
1641 } 1662 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698