diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-03 20:19:23 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-03 20:19:23 +0000 |
commit | cb5fb563c6b182cd40441736bf049cc6b5c9b8d2 (patch) | |
tree | a8e646136efe15a3dea1074f20987b450a6f6bf0 | |
parent | 16199ee1a44b90f0d3e2f80b1b3ee40ac46d0198 (diff) | |
download | chromium_src-cb5fb563c6b182cd40441736bf049cc6b5c9b8d2.zip chromium_src-cb5fb563c6b182cd40441736bf049cc6b5c9b8d2.tar.gz chromium_src-cb5fb563c6b182cd40441736bf049cc6b5c9b8d2.tar.bz2 |
Display the LoadLogs for recent and in-progress URLRequests on the net-internals page.
BUG=http://crbug.com/14478
Review URL: http://codereview.chromium.org/184008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25358 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | net/http/http_network_transaction.cc | 3 | ||||
-rw-r--r-- | net/url_request/url_request_view_net_internal_job.cc | 68 |
2 files changed, 66 insertions, 5 deletions
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc index 4af1fa3..f81b9e2 100644 --- a/net/http/http_network_transaction.cc +++ b/net/http/http_network_transaction.cc @@ -625,7 +625,8 @@ int HttpNetworkTransaction::DoInitConnection() { } int rv = connection_.Init(connection_group, resolve_info, request_->priority, - &io_callback_, session_->tcp_socket_pool(), NULL); + &io_callback_, session_->tcp_socket_pool(), + load_log_); return rv; } diff --git a/net/url_request/url_request_view_net_internal_job.cc b/net/url_request/url_request_view_net_internal_job.cc index d2185c4..a18d378 100644 --- a/net/url_request/url_request_view_net_internal_job.cc +++ b/net/url_request/url_request_view_net_internal_job.cc @@ -14,6 +14,7 @@ #include "net/base/net_errors.h" #include "net/base/net_util.h" #include "net/proxy/proxy_service.h" +#include "net/url_request/url_request.h" #include "net/url_request/url_request_context.h" namespace { @@ -262,14 +263,73 @@ class HostResolverSubSection : public SubSection { } }; +// Helper for the URLRequest "outstanding" and "live" sections. +void OutputURLAndLoadLog(const GURL& url, + const net::LoadLog* log, + std::string* out) { + out->append("<li>"); + out->append("<nobr>"); + out->append(EscapeForHTML(url.spec())); + out->append("</nobr>"); + if (log) + OutputTextInPre(net::LoadLogUtil::PrettyPrintAsEventTree(log), out); + out->append("</li>"); +} + +class URLRequestLiveSubSection : public SubSection { + public: + URLRequestLiveSubSection(SubSection* parent) + : SubSection(parent, "outstanding", "Outstanding requests") { + } + + virtual void OutputBody(URLRequestContext* /*context*/, std::string* out) { + URLRequest::InstanceTracker* tracker = URLRequest::InstanceTracker::Get(); + + // Note that these are the requests across ALL contexts. + std::vector<URLRequest*> requests = tracker->GetLiveRequests(); + + out->append("<ol>"); + for (size_t i = 0; i < requests.size(); ++i) { + // Reverse the list order, so we dispay from most recent to oldest. + size_t index = requests.size() - i - 1; + OutputURLAndLoadLog(requests[index]->original_url(), + requests[index]->load_log(), + out); + } + out->append("</ol>"); + } +}; + +class URLRequestRecentSubSection : public SubSection { + public: + URLRequestRecentSubSection(SubSection* parent) + : SubSection(parent, "recent", "Recently completed requests") { + } + + virtual void OutputBody(URLRequestContext* /*context*/, std::string* out) { + URLRequest::InstanceTracker* tracker = URLRequest::InstanceTracker::Get(); + + // Note that these are the recently completed requests across ALL contexts. + URLRequest::InstanceTracker::RecentRequestInfoList recent = + tracker->GetRecentlyDeceased(); + + out->append("<ol>"); + for (size_t i = 0; i < recent.size(); ++i) { + // Reverse the list order, so we dispay from most recent to oldest. + size_t index = recent.size() - i - 1; + OutputURLAndLoadLog(recent[index].original_url, + recent[index].load_log, out); + } + out->append("</ol>"); + } +}; + class URLRequestSubSection : public SubSection { public: URLRequestSubSection(SubSection* parent) : SubSection(parent, "urlrequest", "URLRequest") { - } - - virtual void OutputBody(URLRequestContext* context, std::string* out) { - out->append("TODO"); + AddSubSection(new URLRequestLiveSubSection(this)); + AddSubSection(new URLRequestRecentSubSection(this)); } }; |