| 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 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 void OnGetSpdySessionInfo(const ListValue* list); | 471 void OnGetSpdySessionInfo(const ListValue* list); |
| 472 void OnGetSpdyStatus(const ListValue* list); | 472 void OnGetSpdyStatus(const ListValue* list); |
| 473 void OnGetSpdyAlternateProtocolMappings(const ListValue* list); | 473 void OnGetSpdyAlternateProtocolMappings(const ListValue* list); |
| 474 #ifdef OS_WIN | 474 #ifdef OS_WIN |
| 475 void OnGetServiceProviders(const ListValue* list); | 475 void OnGetServiceProviders(const ListValue* list); |
| 476 #endif | 476 #endif |
| 477 void OnGetHttpPipeliningStatus(const ListValue* list); | 477 void OnGetHttpPipeliningStatus(const ListValue* list); |
| 478 void OnSetLogLevel(const ListValue* list); | 478 void OnSetLogLevel(const ListValue* list); |
| 479 | 479 |
| 480 // ChromeNetLog::ThreadSafeObserver implementation: | 480 // ChromeNetLog::ThreadSafeObserver implementation: |
| 481 virtual void OnAddEntry(net::NetLog::EventType type, | 481 virtual void OnAddEntry(const net::NetLog::Entry& entry) OVERRIDE; |
| 482 const base::TimeTicks& time, | |
| 483 const net::NetLog::Source& source, | |
| 484 net::NetLog::EventPhase phase, | |
| 485 net::NetLog::EventParameters* params); | |
| 486 | 482 |
| 487 // ConnectionTester::Delegate implementation: | 483 // ConnectionTester::Delegate implementation: |
| 488 virtual void OnStartConnectionTestSuite(); | 484 virtual void OnStartConnectionTestSuite() OVERRIDE; |
| 489 virtual void OnStartConnectionTestExperiment( | 485 virtual void OnStartConnectionTestExperiment( |
| 490 const ConnectionTester::Experiment& experiment); | 486 const ConnectionTester::Experiment& experiment) OVERRIDE; |
| 491 virtual void OnCompletedConnectionTestExperiment( | 487 virtual void OnCompletedConnectionTestExperiment( |
| 492 const ConnectionTester::Experiment& experiment, | 488 const ConnectionTester::Experiment& experiment, |
| 493 int result); | 489 int result) OVERRIDE; |
| 494 virtual void OnCompletedConnectionTestSuite(); | 490 virtual void OnCompletedConnectionTestSuite() OVERRIDE; |
| 495 | 491 |
| 496 // Helper that calls g_browser.receive in the renderer, passing in |command| | 492 // Helper that calls g_browser.receive in the renderer, passing in |command| |
| 497 // and |arg|. Takes ownership of |arg|. If the renderer is displaying a log | 493 // and |arg|. Takes ownership of |arg|. If the renderer is displaying a log |
| 498 // file, the message will be ignored. Note that this can be called from any | 494 // file, the message will be ignored. Note that this can be called from any |
| 499 // thread. | 495 // thread. |
| 500 void SendJavascriptCommand(const std::string& command, Value* arg); | 496 void SendJavascriptCommand(const std::string& command, Value* arg); |
| 501 | 497 |
| 502 // Helper that runs |method| with |arg|, and deletes |arg| on completion. | 498 // Helper that runs |method| with |arg|, and deletes |arg| on completion. |
| 503 void DispatchToMessageHandler(ListValue* arg, MessageHandler method); | 499 void DispatchToMessageHandler(ListValue* arg, MessageHandler method); |
| 504 | 500 |
| (...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1494 | 1490 |
| 1495 DCHECK_GE(log_level, net::NetLog::LOG_ALL); | 1491 DCHECK_GE(log_level, net::NetLog::LOG_ALL); |
| 1496 DCHECK_LE(log_level, net::NetLog::LOG_BASIC); | 1492 DCHECK_LE(log_level, net::NetLog::LOG_BASIC); |
| 1497 net_log()->SetObserverLogLevel( | 1493 net_log()->SetObserverLogLevel( |
| 1498 this, static_cast<net::NetLog::LogLevel>(log_level)); | 1494 this, static_cast<net::NetLog::LogLevel>(log_level)); |
| 1499 } | 1495 } |
| 1500 | 1496 |
| 1501 // Note that unlike other methods of IOThreadImpl, this function | 1497 // Note that unlike other methods of IOThreadImpl, this function |
| 1502 // can be called from ANY THREAD. | 1498 // can be called from ANY THREAD. |
| 1503 void NetInternalsMessageHandler::IOThreadImpl::OnAddEntry( | 1499 void NetInternalsMessageHandler::IOThreadImpl::OnAddEntry( |
| 1504 net::NetLog::EventType type, | 1500 const net::NetLog::Entry& entry) { |
| 1505 const base::TimeTicks& time, | |
| 1506 const net::NetLog::Source& source, | |
| 1507 net::NetLog::EventPhase phase, | |
| 1508 net::NetLog::EventParameters* params) { | |
| 1509 BrowserThread::PostTask( | 1501 BrowserThread::PostTask( |
| 1510 BrowserThread::IO, FROM_HERE, | 1502 BrowserThread::IO, FROM_HERE, |
| 1511 base::Bind(&IOThreadImpl::AddEntryToQueue, this, | 1503 base::Bind(&IOThreadImpl::AddEntryToQueue, this, |
| 1512 net::NetLog::EntryToDictionaryValue(type, time, source, phase, | 1504 entry.ToValue())); |
| 1513 params, false))); | |
| 1514 } | 1505 } |
| 1515 | 1506 |
| 1516 void NetInternalsMessageHandler::IOThreadImpl::AddEntryToQueue(Value* entry) { | 1507 void NetInternalsMessageHandler::IOThreadImpl::AddEntryToQueue( |
| 1508 Value* entry) { |
| 1517 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1509 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 1518 if (!pending_entries_.get()) { | 1510 if (!pending_entries_.get()) { |
| 1519 pending_entries_.reset(new ListValue()); | 1511 pending_entries_.reset(new ListValue()); |
| 1520 BrowserThread::PostDelayedTask( | 1512 BrowserThread::PostDelayedTask( |
| 1521 BrowserThread::IO, FROM_HERE, | 1513 BrowserThread::IO, FROM_HERE, |
| 1522 base::Bind(&IOThreadImpl::PostPendingEntries, this), | 1514 base::Bind(&IOThreadImpl::PostPendingEntries, this), |
| 1523 base::TimeDelta::FromMilliseconds(kNetLogEventDelayMilliseconds)); | 1515 base::TimeDelta::FromMilliseconds(kNetLogEventDelayMilliseconds)); |
| 1524 } | 1516 } |
| 1525 pending_entries_->Append(entry); | 1517 pending_entries_->Append(entry); |
| 1526 } | 1518 } |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1735 } | 1727 } |
| 1736 | 1728 |
| 1737 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) | 1729 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) |
| 1738 : WebUIController(web_ui) { | 1730 : WebUIController(web_ui) { |
| 1739 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); | 1731 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); |
| 1740 | 1732 |
| 1741 // Set up the chrome://net-internals/ source. | 1733 // Set up the chrome://net-internals/ source. |
| 1742 Profile* profile = Profile::FromWebUI(web_ui); | 1734 Profile* profile = Profile::FromWebUI(web_ui); |
| 1743 ChromeURLDataManager::AddDataSource(profile, CreateNetInternalsHTMLSource()); | 1735 ChromeURLDataManager::AddDataSource(profile, CreateNetInternalsHTMLSource()); |
| 1744 } | 1736 } |
| OLD | NEW |