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