| OLD | NEW |
| 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/memory/singleton.h" | 15 #include "base/memory/singleton.h" |
| 16 #include "base/message_loop.h" | 16 #include "base/message_loop.h" |
| 17 #include "base/metrics/field_trial.h" // TODO(joi): Remove after the trial ends
. |
| 17 #include "base/path_service.h" | 18 #include "base/path_service.h" |
| 18 #include "base/string_number_conversions.h" | 19 #include "base/string_number_conversions.h" |
| 19 #include "base/string_piece.h" | 20 #include "base/string_piece.h" |
| 20 #include "base/string_split.h" | 21 #include "base/string_split.h" |
| 21 #include "base/string_util.h" | 22 #include "base/string_util.h" |
| 22 #include "base/utf_string_conversions.h" | 23 #include "base/utf_string_conversions.h" |
| 23 #include "base/values.h" | 24 #include "base/values.h" |
| 24 #include "chrome/browser/browser_process.h" | 25 #include "chrome/browser/browser_process.h" |
| 25 #include "chrome/browser/io_thread.h" | 26 #include "chrome/browser/io_thread.h" |
| 26 #include "chrome/browser/net/chrome_net_log.h" | 27 #include "chrome/browser/net/chrome_net_log.h" |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 CancelableRequestConsumer consumer_; | 236 CancelableRequestConsumer consumer_; |
| 236 // Libcros request handle. | 237 // Libcros request handle. |
| 237 CancelableRequestProvider::Handle syslogs_request_id_; | 238 CancelableRequestProvider::Handle syslogs_request_id_; |
| 238 }; | 239 }; |
| 239 #endif | 240 #endif |
| 240 | 241 |
| 241 // The pref member about whether HTTP throttling is enabled, which needs to | 242 // The pref member about whether HTTP throttling is enabled, which needs to |
| 242 // be accessed on the UI thread. | 243 // be accessed on the UI thread. |
| 243 BooleanPrefMember http_throttling_enabled_; | 244 BooleanPrefMember http_throttling_enabled_; |
| 244 | 245 |
| 246 // The pref member that determines whether experimentation on HTTP throttling |
| 247 // is allowed (this becomes false once the user explicitly sets the |
| 248 // feature to on or off). |
| 249 BooleanPrefMember http_throttling_may_experiment_; |
| 250 |
| 245 // OnRendererReady invokes this callback to do the part of message handling | 251 // OnRendererReady invokes this callback to do the part of message handling |
| 246 // that needs to happen on the IO thread. | 252 // that needs to happen on the IO thread. |
| 247 scoped_ptr<WebUI::MessageCallback> renderer_ready_io_callback_; | 253 scoped_ptr<WebUI::MessageCallback> renderer_ready_io_callback_; |
| 248 | 254 |
| 249 // This is the "real" message handler, which lives on the IO thread. | 255 // This is the "real" message handler, which lives on the IO thread. |
| 250 scoped_refptr<IOThreadImpl> proxy_; | 256 scoped_refptr<IOThreadImpl> proxy_; |
| 251 | 257 |
| 252 base::WeakPtr<prerender::PrerenderManager> prerender_manager_; | 258 base::WeakPtr<prerender::PrerenderManager> prerender_manager_; |
| 253 | 259 |
| 254 #ifdef OS_CHROMEOS | 260 #ifdef OS_CHROMEOS |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 // Notify the handler on the IO thread that the renderer is gone. | 511 // Notify the handler on the IO thread that the renderer is gone. |
| 506 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 512 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 507 NewRunnableMethod(proxy_.get(), &IOThreadImpl::Detach)); | 513 NewRunnableMethod(proxy_.get(), &IOThreadImpl::Detach)); |
| 508 } | 514 } |
| 509 } | 515 } |
| 510 | 516 |
| 511 WebUIMessageHandler* NetInternalsMessageHandler::Attach(WebUI* web_ui) { | 517 WebUIMessageHandler* NetInternalsMessageHandler::Attach(WebUI* web_ui) { |
| 512 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 518 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 513 | 519 |
| 514 PrefService* pref_service = web_ui->GetProfile()->GetPrefs(); | 520 PrefService* pref_service = web_ui->GetProfile()->GetPrefs(); |
| 515 http_throttling_enabled_.Init(prefs::kHttpThrottlingEnabled, pref_service, | 521 http_throttling_enabled_.Init( |
| 516 this); | 522 prefs::kHttpThrottlingEnabled, pref_service, this); |
| 523 http_throttling_may_experiment_.Init( |
| 524 prefs::kHttpThrottlingMayExperiment, pref_service, NULL); |
| 517 | 525 |
| 518 proxy_ = new IOThreadImpl(this->AsWeakPtr(), g_browser_process->io_thread(), | 526 proxy_ = new IOThreadImpl(this->AsWeakPtr(), g_browser_process->io_thread(), |
| 519 web_ui->GetProfile()->GetRequestContext()); | 527 web_ui->GetProfile()->GetRequestContext()); |
| 520 #ifdef OS_CHROMEOS | 528 #ifdef OS_CHROMEOS |
| 521 syslogs_getter_.reset(new SystemLogsGetter(this, | 529 syslogs_getter_.reset(new SystemLogsGetter(this, |
| 522 chromeos::SystemAccess::GetInstance())); | 530 chromeos::SystemAccess::GetInstance())); |
| 523 #endif | 531 #endif |
| 524 renderer_ready_io_callback_.reset( | 532 renderer_ready_io_callback_.reset( |
| 525 proxy_->CreateCallback(&IOThreadImpl::OnRendererReady)); | 533 proxy_->CreateCallback(&IOThreadImpl::OnRendererReady)); |
| 526 | 534 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 void NetInternalsMessageHandler::OnEnableHttpThrottling(const ListValue* list) { | 668 void NetInternalsMessageHandler::OnEnableHttpThrottling(const ListValue* list) { |
| 661 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 669 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 662 | 670 |
| 663 bool enable = false; | 671 bool enable = false; |
| 664 if (!list->GetBoolean(0, &enable)) { | 672 if (!list->GetBoolean(0, &enable)) { |
| 665 NOTREACHED(); | 673 NOTREACHED(); |
| 666 return; | 674 return; |
| 667 } | 675 } |
| 668 | 676 |
| 669 http_throttling_enabled_.SetValue(enable); | 677 http_throttling_enabled_.SetValue(enable); |
| 678 |
| 679 // We never receive OnEnableHttpThrottling unless the user has modified |
| 680 // the value of the checkbox on the about:net-internals page. Once the |
| 681 // user does that, we no longer allow experiments to control its value. |
| 682 if (http_throttling_may_experiment_.GetValue()) { |
| 683 http_throttling_may_experiment_.SetValue(false); |
| 684 |
| 685 // Disable the ongoing trial so that histograms after this point |
| 686 // show as being in the "Default" group of the trial. |
| 687 base::FieldTrial* trial = base::FieldTrialList::Find( |
| 688 "HttpThrottlingEnabled"); |
| 689 if (trial) |
| 690 trial->Disable(); |
| 691 } |
| 670 } | 692 } |
| 671 | 693 |
| 672 void NetInternalsMessageHandler::OnGetPrerenderInfo(const ListValue* list) { | 694 void NetInternalsMessageHandler::OnGetPrerenderInfo(const ListValue* list) { |
| 673 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 695 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 674 | 696 |
| 675 Value* value = NULL; | 697 Value* value = NULL; |
| 676 prerender::PrerenderManager* prerender_manager = prerender_manager_.get(); | 698 prerender::PrerenderManager* prerender_manager = prerender_manager_.get(); |
| 677 if (!prerender_manager) { | 699 if (!prerender_manager) { |
| 678 value = new ListValue(); | 700 value = new ListValue(); |
| 679 } else { | 701 } else { |
| (...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1576 //////////////////////////////////////////////////////////////////////////////// | 1598 //////////////////////////////////////////////////////////////////////////////// |
| 1577 | 1599 |
| 1578 NetInternalsUI::NetInternalsUI(TabContents* contents) : ChromeWebUI(contents) { | 1600 NetInternalsUI::NetInternalsUI(TabContents* contents) : ChromeWebUI(contents) { |
| 1579 AddMessageHandler((new NetInternalsMessageHandler())->Attach(this)); | 1601 AddMessageHandler((new NetInternalsMessageHandler())->Attach(this)); |
| 1580 | 1602 |
| 1581 NetInternalsHTMLSource* html_source = new NetInternalsHTMLSource(); | 1603 NetInternalsHTMLSource* html_source = new NetInternalsHTMLSource(); |
| 1582 | 1604 |
| 1583 // Set up the chrome://net-internals/ source. | 1605 // Set up the chrome://net-internals/ source. |
| 1584 GetProfile()->GetChromeURLDataManager()->AddDataSource(html_source); | 1606 GetProfile()->GetChromeURLDataManager()->AddDataSource(html_source); |
| 1585 } | 1607 } |
| OLD | NEW |