| 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 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1574 std::string status; | 1569 std::string status; |
| 1575 if (succeeded) | 1570 if (succeeded) |
| 1576 status = "Debug mode is changed to " + subsystem; | 1571 status = "Debug mode is changed to " + subsystem; |
| 1577 else | 1572 else |
| 1578 status = "Failed to change debug mode to " + subsystem; | 1573 status = "Failed to change debug mode to " + subsystem; |
| 1579 SendJavascriptCommand("receivedSetNetworkDebugMode", | 1574 SendJavascriptCommand("receivedSetNetworkDebugMode", |
| 1580 new base::StringValue(status)); | 1575 new base::StringValue(status)); |
| 1581 } | 1576 } |
| 1582 #endif // defined(OS_CHROMEOS) | 1577 #endif // defined(OS_CHROMEOS) |
| 1583 | 1578 |
| 1584 void NetInternalsMessageHandler::IOThreadImpl::OnGetHttpPipeliningStatus( | |
| 1585 const base::ListValue* list) { | |
| 1586 DCHECK(!list); | |
| 1587 base::DictionaryValue* status_dict = new base::DictionaryValue(); | |
| 1588 | |
| 1589 base::Value* pipelined_connection_info = NULL; | |
| 1590 net::HttpNetworkSession* http_network_session = | |
| 1591 GetHttpNetworkSession(GetMainContext()); | |
| 1592 if (http_network_session) { | |
| 1593 status_dict->Set("pipelining_enabled", base::Value::CreateBooleanValue( | |
| 1594 http_network_session->params().http_pipelining_enabled)); | |
| 1595 | |
| 1596 pipelined_connection_info = | |
| 1597 http_network_session->http_stream_factory()->PipelineInfoToValue(); | |
| 1598 } | |
| 1599 status_dict->Set("pipelined_connection_info", pipelined_connection_info); | |
| 1600 | |
| 1601 const net::HttpServerProperties& http_server_properties = | |
| 1602 *GetMainContext()->http_server_properties(); | |
| 1603 | |
| 1604 // TODO(simonjam): This call is slow. | |
| 1605 const net::PipelineCapabilityMap pipeline_capability_map = | |
| 1606 http_server_properties.GetPipelineCapabilityMap(); | |
| 1607 | |
| 1608 base::ListValue* known_hosts_list = new base::ListValue(); | |
| 1609 net::PipelineCapabilityMap::const_iterator it; | |
| 1610 for (it = pipeline_capability_map.begin(); | |
| 1611 it != pipeline_capability_map.end(); ++it) { | |
| 1612 base::DictionaryValue* host_dict = new base::DictionaryValue(); | |
| 1613 host_dict->SetString("host", it->first.ToString()); | |
| 1614 std::string capability; | |
| 1615 switch (it->second) { | |
| 1616 case net::PIPELINE_CAPABLE: | |
| 1617 capability = "capable"; | |
| 1618 break; | |
| 1619 | |
| 1620 case net::PIPELINE_PROBABLY_CAPABLE: | |
| 1621 capability = "probably capable"; | |
| 1622 break; | |
| 1623 | |
| 1624 case net::PIPELINE_INCAPABLE: | |
| 1625 capability = "incapable"; | |
| 1626 break; | |
| 1627 | |
| 1628 case net::PIPELINE_UNKNOWN: | |
| 1629 default: | |
| 1630 capability = "unknown"; | |
| 1631 break; | |
| 1632 } | |
| 1633 host_dict->SetString("capability", capability); | |
| 1634 known_hosts_list->Append(host_dict); | |
| 1635 } | |
| 1636 status_dict->Set("pipelined_host_info", known_hosts_list); | |
| 1637 | |
| 1638 SendJavascriptCommand("receivedHttpPipeliningStatus", status_dict); | |
| 1639 } | |
| 1640 | |
| 1641 void NetInternalsMessageHandler::IOThreadImpl::OnSetLogLevel( | 1579 void NetInternalsMessageHandler::IOThreadImpl::OnSetLogLevel( |
| 1642 const base::ListValue* list) { | 1580 const base::ListValue* list) { |
| 1643 int log_level; | 1581 int log_level; |
| 1644 std::string log_level_string; | 1582 std::string log_level_string; |
| 1645 if (!list->GetString(0, &log_level_string) || | 1583 if (!list->GetString(0, &log_level_string) || |
| 1646 !base::StringToInt(log_level_string, &log_level)) { | 1584 !base::StringToInt(log_level_string, &log_level)) { |
| 1647 NOTREACHED(); | 1585 NOTREACHED(); |
| 1648 return; | 1586 return; |
| 1649 } | 1587 } |
| 1650 | 1588 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1834 } | 1772 } |
| 1835 | 1773 |
| 1836 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) | 1774 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) |
| 1837 : WebUIController(web_ui) { | 1775 : WebUIController(web_ui) { |
| 1838 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); | 1776 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); |
| 1839 | 1777 |
| 1840 // Set up the chrome://net-internals/ source. | 1778 // Set up the chrome://net-internals/ source. |
| 1841 Profile* profile = Profile::FromWebUI(web_ui); | 1779 Profile* profile = Profile::FromWebUI(web_ui); |
| 1842 content::WebUIDataSource::Add(profile, CreateNetInternalsHTMLSource()); | 1780 content::WebUIDataSource::Add(profile, CreateNetInternalsHTMLSource()); |
| 1843 } | 1781 } |
| OLD | NEW |