| 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 // Since the network code we want to run lives on the IO thread, we proxy | 216 // Since the network code we want to run lives on the IO thread, we proxy |
| 217 // almost everything over to NetInternalsMessageHandler::IOThreadImpl, which | 217 // almost everything over to NetInternalsMessageHandler::IOThreadImpl, which |
| 218 // runs on the IO thread. | 218 // runs on the IO thread. |
| 219 // | 219 // |
| 220 // TODO(eroman): Can we start on the IO thread to begin with? | 220 // TODO(eroman): Can we start on the IO thread to begin with? |
| 221 class NetInternalsMessageHandler | 221 class NetInternalsMessageHandler |
| 222 : public WebUIMessageHandler, | 222 : public WebUIMessageHandler, |
| 223 public base::SupportsWeakPtr<NetInternalsMessageHandler> { | 223 public base::SupportsWeakPtr<NetInternalsMessageHandler> { |
| 224 public: | 224 public: |
| 225 NetInternalsMessageHandler(); | 225 NetInternalsMessageHandler(); |
| 226 virtual ~NetInternalsMessageHandler(); | 226 ~NetInternalsMessageHandler() override; |
| 227 | 227 |
| 228 // WebUIMessageHandler implementation. | 228 // WebUIMessageHandler implementation. |
| 229 virtual void RegisterMessages() override; | 229 void RegisterMessages() override; |
| 230 | 230 |
| 231 // Calls g_browser.receive in the renderer, passing in |command| and |arg|. | 231 // Calls g_browser.receive in the renderer, passing in |command| and |arg|. |
| 232 // Takes ownership of |arg|. If the renderer is displaying a log file, the | 232 // Takes ownership of |arg|. If the renderer is displaying a log file, the |
| 233 // message will be ignored. | 233 // message will be ignored. |
| 234 void SendJavascriptCommand(const std::string& command, base::Value* arg); | 234 void SendJavascriptCommand(const std::string& command, base::Value* arg); |
| 235 | 235 |
| 236 // Javascript message handlers. | 236 // Javascript message handlers. |
| 237 void OnRendererReady(const base::ListValue* list); | 237 void OnRendererReady(const base::ListValue* list); |
| 238 void OnClearBrowserCache(const base::ListValue* list); | 238 void OnClearBrowserCache(const base::ListValue* list); |
| 239 void OnGetPrerenderInfo(const base::ListValue* list); | 239 void OnGetPrerenderInfo(const base::ListValue* list); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 void OnGetSpdySessionInfo(const base::ListValue* list); | 403 void OnGetSpdySessionInfo(const base::ListValue* list); |
| 404 void OnGetSpdyStatus(const base::ListValue* list); | 404 void OnGetSpdyStatus(const base::ListValue* list); |
| 405 void OnGetSpdyAlternateProtocolMappings(const base::ListValue* list); | 405 void OnGetSpdyAlternateProtocolMappings(const base::ListValue* list); |
| 406 void OnGetQuicInfo(const base::ListValue* list); | 406 void OnGetQuicInfo(const base::ListValue* list); |
| 407 #if defined(OS_WIN) | 407 #if defined(OS_WIN) |
| 408 void OnGetServiceProviders(const base::ListValue* list); | 408 void OnGetServiceProviders(const base::ListValue* list); |
| 409 #endif | 409 #endif |
| 410 void OnSetLogLevel(const base::ListValue* list); | 410 void OnSetLogLevel(const base::ListValue* list); |
| 411 | 411 |
| 412 // ChromeNetLog::ThreadSafeObserver implementation: | 412 // ChromeNetLog::ThreadSafeObserver implementation: |
| 413 virtual void OnAddEntry(const net::NetLog::Entry& entry) override; | 413 void OnAddEntry(const net::NetLog::Entry& entry) override; |
| 414 | 414 |
| 415 // ConnectionTester::Delegate implementation: | 415 // ConnectionTester::Delegate implementation: |
| 416 virtual void OnStartConnectionTestSuite() override; | 416 void OnStartConnectionTestSuite() override; |
| 417 virtual void OnStartConnectionTestExperiment( | 417 void OnStartConnectionTestExperiment( |
| 418 const ConnectionTester::Experiment& experiment) override; | 418 const ConnectionTester::Experiment& experiment) override; |
| 419 virtual void OnCompletedConnectionTestExperiment( | 419 void OnCompletedConnectionTestExperiment( |
| 420 const ConnectionTester::Experiment& experiment, | 420 const ConnectionTester::Experiment& experiment, |
| 421 int result) override; | 421 int result) override; |
| 422 virtual void OnCompletedConnectionTestSuite() override; | 422 void OnCompletedConnectionTestSuite() override; |
| 423 | 423 |
| 424 // Helper that calls g_browser.receive in the renderer, passing in |command| | 424 // Helper that calls g_browser.receive in the renderer, passing in |command| |
| 425 // and |arg|. Takes ownership of |arg|. If the renderer is displaying a log | 425 // and |arg|. Takes ownership of |arg|. If the renderer is displaying a log |
| 426 // file, the message will be ignored. Note that this can be called from any | 426 // file, the message will be ignored. Note that this can be called from any |
| 427 // thread. | 427 // thread. |
| 428 void SendJavascriptCommand(const std::string& command, base::Value* arg); | 428 void SendJavascriptCommand(const std::string& command, base::Value* arg); |
| 429 | 429 |
| 430 private: | 430 private: |
| 431 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; | 431 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; |
| 432 friend class base::DeleteHelper<IOThreadImpl>; | 432 friend class base::DeleteHelper<IOThreadImpl>; |
| 433 | 433 |
| 434 typedef std::list<scoped_refptr<net::URLRequestContextGetter> > | 434 typedef std::list<scoped_refptr<net::URLRequestContextGetter> > |
| 435 ContextGetterList; | 435 ContextGetterList; |
| 436 | 436 |
| 437 virtual ~IOThreadImpl(); | 437 ~IOThreadImpl() override; |
| 438 | 438 |
| 439 // Adds |entry| to the queue of pending log entries to be sent to the page via | 439 // Adds |entry| to the queue of pending log entries to be sent to the page via |
| 440 // Javascript. Must be called on the IO Thread. Also creates a delayed task | 440 // Javascript. Must be called on the IO Thread. Also creates a delayed task |
| 441 // that will call PostPendingEntries, if there isn't one already. | 441 // that will call PostPendingEntries, if there isn't one already. |
| 442 void AddEntryToQueue(base::Value* entry); | 442 void AddEntryToQueue(base::Value* entry); |
| 443 | 443 |
| 444 // Sends all pending entries to the page via Javascript, and clears the list | 444 // Sends all pending entries to the page via Javascript, and clears the list |
| 445 // of pending entries. Sending multiple entries at once results in a | 445 // of pending entries. Sending multiple entries at once results in a |
| 446 // significant reduction of CPU usage when a lot of events are happening. | 446 // significant reduction of CPU usage when a lot of events are happening. |
| 447 // Must be called on the IO Thread. | 447 // Must be called on the IO Thread. |
| (...skipping 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1724 } | 1724 } |
| 1725 | 1725 |
| 1726 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) | 1726 NetInternalsUI::NetInternalsUI(content::WebUI* web_ui) |
| 1727 : WebUIController(web_ui) { | 1727 : WebUIController(web_ui) { |
| 1728 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); | 1728 web_ui->AddMessageHandler(new NetInternalsMessageHandler()); |
| 1729 | 1729 |
| 1730 // Set up the chrome://net-internals/ source. | 1730 // Set up the chrome://net-internals/ source. |
| 1731 Profile* profile = Profile::FromWebUI(web_ui); | 1731 Profile* profile = Profile::FromWebUI(web_ui); |
| 1732 content::WebUIDataSource::Add(profile, CreateNetInternalsHTMLSource()); | 1732 content::WebUIDataSource::Add(profile, CreateNetInternalsHTMLSource()); |
| 1733 } | 1733 } |
| OLD | NEW |