| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/net_internals_ui.h" | 5 #include "chrome/browser/ui/webui/net_internals/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> |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 void OnGetSessionNetworkStats(const base::ListValue* list); | 462 void OnGetSessionNetworkStats(const base::ListValue* list); |
| 463 void OnCloseIdleSockets(const base::ListValue* list); | 463 void OnCloseIdleSockets(const base::ListValue* list); |
| 464 void OnFlushSocketPools(const base::ListValue* list); | 464 void OnFlushSocketPools(const base::ListValue* list); |
| 465 void OnGetSpdySessionInfo(const base::ListValue* list); | 465 void OnGetSpdySessionInfo(const base::ListValue* list); |
| 466 void OnGetSpdyStatus(const base::ListValue* list); | 466 void OnGetSpdyStatus(const base::ListValue* list); |
| 467 void OnGetSpdyAlternateProtocolMappings(const base::ListValue* list); | 467 void OnGetSpdyAlternateProtocolMappings(const base::ListValue* list); |
| 468 void OnGetQuicInfo(const base::ListValue* list); | 468 void OnGetQuicInfo(const base::ListValue* list); |
| 469 #if defined(OS_WIN) | 469 #if defined(OS_WIN) |
| 470 void OnGetServiceProviders(const base::ListValue* list); | 470 void OnGetServiceProviders(const base::ListValue* list); |
| 471 #endif | 471 #endif |
| 472 void OnGetHttpPipeliningStatus(const base::ListValue* list); | |
| 473 void OnSetLogLevel(const base::ListValue* list); | 472 void OnSetLogLevel(const base::ListValue* list); |
| 474 | 473 |
| 475 // ChromeNetLog::ThreadSafeObserver implementation: | 474 // ChromeNetLog::ThreadSafeObserver implementation: |
| 476 virtual void OnAddEntry(const net::NetLog::Entry& entry) OVERRIDE; | 475 virtual void OnAddEntry(const net::NetLog::Entry& entry) OVERRIDE; |
| 477 | 476 |
| 478 // ConnectionTester::Delegate implementation: | 477 // ConnectionTester::Delegate implementation: |
| 479 virtual void OnStartConnectionTestSuite() OVERRIDE; | 478 virtual void OnStartConnectionTestSuite() OVERRIDE; |
| 480 virtual void OnStartConnectionTestExperiment( | 479 virtual void OnStartConnectionTestExperiment( |
| 481 const ConnectionTester::Experiment& experiment) OVERRIDE; | 480 const ConnectionTester::Experiment& experiment) OVERRIDE; |
| 482 virtual void OnCompletedConnectionTestExperiment( | 481 virtual void OnCompletedConnectionTestExperiment( |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 base::Bind(&IOThreadImpl::CallbackHelper, | 674 base::Bind(&IOThreadImpl::CallbackHelper, |
| 676 &IOThreadImpl::OnGetQuicInfo, proxy_)); | 675 &IOThreadImpl::OnGetQuicInfo, proxy_)); |
| 677 #if defined(OS_WIN) | 676 #if defined(OS_WIN) |
| 678 web_ui()->RegisterMessageCallback( | 677 web_ui()->RegisterMessageCallback( |
| 679 "getServiceProviders", | 678 "getServiceProviders", |
| 680 base::Bind(&IOThreadImpl::CallbackHelper, | 679 base::Bind(&IOThreadImpl::CallbackHelper, |
| 681 &IOThreadImpl::OnGetServiceProviders, proxy_)); | 680 &IOThreadImpl::OnGetServiceProviders, proxy_)); |
| 682 #endif | 681 #endif |
| 683 | 682 |
| 684 web_ui()->RegisterMessageCallback( | 683 web_ui()->RegisterMessageCallback( |
| 685 "getHttpPipeliningStatus", | |
| 686 base::Bind(&IOThreadImpl::CallbackHelper, | |
| 687 &IOThreadImpl::OnGetHttpPipeliningStatus, proxy_)); | |
| 688 web_ui()->RegisterMessageCallback( | |
| 689 "setLogLevel", | 684 "setLogLevel", |
| 690 base::Bind(&IOThreadImpl::CallbackHelper, | 685 base::Bind(&IOThreadImpl::CallbackHelper, |
| 691 &IOThreadImpl::OnSetLogLevel, proxy_)); | 686 &IOThreadImpl::OnSetLogLevel, proxy_)); |
| 692 web_ui()->RegisterMessageCallback( | 687 web_ui()->RegisterMessageCallback( |
| 693 "clearBrowserCache", | 688 "clearBrowserCache", |
| 694 base::Bind(&NetInternalsMessageHandler::OnClearBrowserCache, | 689 base::Bind(&NetInternalsMessageHandler::OnClearBrowserCache, |
| 695 base::Unretained(this))); | 690 base::Unretained(this))); |
| 696 web_ui()->RegisterMessageCallback( | 691 web_ui()->RegisterMessageCallback( |
| 697 "getPrerenderInfo", | 692 "getPrerenderInfo", |
| 698 base::Bind(&NetInternalsMessageHandler::OnGetPrerenderInfo, | 693 base::Bind(&NetInternalsMessageHandler::OnGetPrerenderInfo, |
| (...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1575 std::string status; | 1570 std::string status; |
| 1576 if (succeeded) | 1571 if (succeeded) |
| 1577 status = "Debug mode is changed to " + subsystem; | 1572 status = "Debug mode is changed to " + subsystem; |
| 1578 else | 1573 else |
| 1579 status = "Failed to change debug mode to " + subsystem; | 1574 status = "Failed to change debug mode to " + subsystem; |
| 1580 SendJavascriptCommand("receivedSetNetworkDebugMode", | 1575 SendJavascriptCommand("receivedSetNetworkDebugMode", |
| 1581 new base::StringValue(status)); | 1576 new base::StringValue(status)); |
| 1582 } | 1577 } |
| 1583 #endif // defined(OS_CHROMEOS) | 1578 #endif // defined(OS_CHROMEOS) |
| 1584 | 1579 |
| 1585 void NetInternalsMessageHandler::IOThreadImpl::OnGetHttpPipeliningStatus( | |
| 1586 const base::ListValue* list) { | |
| 1587 DCHECK(!list); | |
| 1588 base::DictionaryValue* status_dict = new base::DictionaryValue(); | |
| 1589 | |
| 1590 base::Value* pipelined_connection_info = NULL; | |
| 1591 net::HttpNetworkSession* http_network_session = | |
| 1592 GetHttpNetworkSession(GetMainContext()); | |
| 1593 if (http_network_session) { | |
| 1594 status_dict->Set("pipelining_enabled", base::Value::CreateBooleanValue( | |
| 1595 http_network_session->params().http_pipelining_enabled)); | |
| 1596 | |
| 1597 pipelined_connection_info = | |
| 1598 http_network_session->http_stream_factory()->PipelineInfoToValue(); | |
| 1599 } | |
| 1600 status_dict->Set("pipelined_connection_info", pipelined_connection_info); | |
| 1601 | |
| 1602 const net::HttpServerProperties& http_server_properties = | |
| 1603 *GetMainContext()->http_server_properties(); | |
| 1604 | |
| 1605 // TODO(simonjam): This call is slow. | |
| 1606 const net::PipelineCapabilityMap pipeline_capability_map = | |
| 1607 http_server_properties.GetPipelineCapabilityMap(); | |
| 1608 | |
| 1609 base::ListValue* known_hosts_list = new base::ListValue(); | |
| 1610 net::PipelineCapabilityMap::const_iterator it; | |
| 1611 for (it = pipeline_capability_map.begin(); | |
| 1612 it != pipeline_capability_map.end(); ++it) { | |
| 1613 base::DictionaryValue* host_dict = new base::DictionaryValue(); | |
| 1614 host_dict->SetString("host", it->first.ToString()); | |
| 1615 std::string capability; | |
| 1616 switch (it->second) { | |
| 1617 case net::PIPELINE_CAPABLE: | |
| 1618 capability = "capable"; | |
| 1619 break; | |
| 1620 | |
| 1621 case net::PIPELINE_PROBABLY_CAPABLE: | |
| 1622 capability = "probably capable"; | |
| 1623 break; | |
| 1624 | |
| 1625 case net::PIPELINE_INCAPABLE: | |
| 1626 capability = "incapable"; | |
| 1627 break; | |
| 1628 | |
| 1629 case net::PIPELINE_UNKNOWN: | |
| 1630 default: | |
| 1631 capability = "unknown"; | |
| 1632 break; | |
| 1633 } | |
| 1634 host_dict->SetString("capability", capability); | |
| 1635 known_hosts_list->Append(host_dict); | |
| 1636 } | |
| 1637 status_dict->Set("pipelined_host_info", known_hosts_list); | |
| 1638 | |
| 1639 SendJavascriptCommand("receivedHttpPipeliningStatus", status_dict); | |
| 1640 } | |
| 1641 | |
| 1642 void NetInternalsMessageHandler::IOThreadImpl::OnSetLogLevel( | 1580 void NetInternalsMessageHandler::IOThreadImpl::OnSetLogLevel( |
| 1643 const base::ListValue* list) { | 1581 const base::ListValue* list) { |
| 1644 int log_level; | 1582 int log_level; |
| 1645 std::string log_level_string; | 1583 std::string log_level_string; |
| 1646 if (!list->GetString(0, &log_level_string) || | 1584 if (!list->GetString(0, &log_level_string) || |
| 1647 !base::StringToInt(log_level_string, &log_level)) { | 1585 !base::StringToInt(log_level_string, &log_level)) { |
| 1648 NOTREACHED(); | 1586 NOTREACHED(); |
| 1649 return; | 1587 return; |
| 1650 } | 1588 } |
| 1651 | 1589 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1835 } | 1773 } |
| 1836 | 1774 |
| 1837 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) | 1775 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) |
| 1838 : WebUIController(web_ui) { | 1776 : WebUIController(web_ui) { |
| 1839 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); | 1777 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); |
| 1840 | 1778 |
| 1841 // Set up the chrome://net-internals/ source. | 1779 // Set up the chrome://net-internals/ source. |
| 1842 Profile* profile = Profile::FromWebUI(web_ui); | 1780 Profile* profile = Profile::FromWebUI(web_ui); |
| 1843 content::WebUIDataSource::Add(profile, CreateNetInternalsHTMLSource()); | 1781 content::WebUIDataSource::Add(profile, CreateNetInternalsHTMLSource()); |
| 1844 } | 1782 } |
| OLD | NEW |