diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-13 20:04:11 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-13 20:04:11 +0000 |
commit | c5ad3e107f28390f9a822df6a7008e3c52d3c017 (patch) | |
tree | 19b1f4578e2bd11f33ce6bdded1b3a4634d18e39 /net | |
parent | d3ce6c2c6d203f9479530ac46fc5af9e8a9ccffe (diff) | |
download | chromium_src-c5ad3e107f28390f9a822df6a7008e3c52d3c017.zip chromium_src-c5ad3e107f28390f9a822df6a7008e3c52d3c017.tar.gz chromium_src-c5ad3e107f28390f9a822df6a7008e3c52d3c017.tar.bz2 |
Add more functionality to about:net-internals:
(1) Display the cached bad proxies, and how long until they will be retried (addresses an old TODO).
(2) Add a button to clear the bad proxies cache.
(3) Add a button to force refetching of the proxy configuration (this can be used to force refetch of PAC files, very convenient when testing).
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/541045
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36159 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/proxy/proxy_service.cc | 8 | ||||
-rw-r--r-- | net/proxy/proxy_service.h | 15 | ||||
-rw-r--r-- | net/url_request/url_request_view_net_internals_job.cc | 48 |
3 files changed, 69 insertions, 2 deletions
diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc index b90d781..c5bb70c 100644 --- a/net/proxy/proxy_service.cc +++ b/net/proxy/proxy_service.cc @@ -536,6 +536,14 @@ void ProxyService::PurgeMemory() { resolver_->PurgeMemory(); } +void ProxyService::ForceReloadProxyConfig() { + // Mark the current configuration as being un-initialized, then force it to + // start updating (normally this would happen lazily during the next + // call to ResolveProxy()). + config_.set_id(ProxyConfig::INVALID_ID); + UpdateConfig(NULL); +} + // static ProxyConfigService* ProxyService::CreateSystemProxyConfigService( MessageLoop* io_loop, MessageLoop* file_loop) { diff --git a/net/proxy/proxy_service.h b/net/proxy/proxy_service.h index 8cca773..9a8a1eb 100644 --- a/net/proxy/proxy_service.h +++ b/net/proxy/proxy_service.h @@ -125,6 +125,21 @@ class ProxyService : public base::RefCountedThreadSafe<ProxyService>, return config_; } + // Returns the map of proxies which have been marked as "bad". + const ProxyRetryInfoMap& proxy_retry_info() const { + return proxy_retry_info_; + } + + // Clears the list of bad proxy servers that has been cached. + void ClearBadProxiesCache() { + proxy_retry_info_.clear(); + } + + // Forces refetching the proxy configuration, and applying it. + // This re-does everything from fetching the system configuration, + // to downloading and testing the PAC files. + void ForceReloadProxyConfig(); + // Creates a proxy service that polls |proxy_config_service| to notice when // the proxy settings change. We take ownership of |proxy_config_service|. // Iff |use_v8_resolver| is true, then the V8 implementation is diff --git a/net/url_request/url_request_view_net_internals_job.cc b/net/url_request/url_request_view_net_internals_job.cc index 58aa3d7..365c92c 100644 --- a/net/url_request/url_request_view_net_internals_job.cc +++ b/net/url_request/url_request_view_net_internals_job.cc @@ -161,7 +161,8 @@ class ProxyServiceCurrentConfigSubSection : public SubSection { } virtual void OutputBody(URLRequestContext* context, std::string* out) { - // TODO(eroman): add a button to force reloading the proxy config. + DrawCommandButton("Force reload", "reload-proxy-config", out); + net::ProxyService* proxy_service = context->proxy_service(); if (proxy_service->config_has_been_initialized()) { // net::ProxyConfig defines an operator<<. @@ -198,7 +199,39 @@ class ProxyServiceBadProxiesSubSection : public SubSection { } virtual void OutputBody(URLRequestContext* context, std::string* out) { - out->append("TODO"); + net::ProxyService* proxy_service = context->proxy_service(); + const net::ProxyRetryInfoMap& bad_proxies_map = + proxy_service->proxy_retry_info(); + + DrawCommandButton("Clear", "clear-badproxies", out); + + out->append("<table border=1>"); + out->append("<tr><th>Bad proxy server</th>" + "<th>Remaining time until retry (ms)</th></tr>"); + + for (net::ProxyRetryInfoMap::const_iterator it = bad_proxies_map.begin(); + it != bad_proxies_map.end(); ++it) { + const std::string& proxy_uri = it->first; + const net::ProxyRetryInfo& retry_info = it->second; + + // Note that ttl_ms may be negative, for the cases where entries have + // expired but not been garbage collected yet. + int ttl_ms = static_cast<int>( + (retry_info.bad_until - base::TimeTicks::Now()).InMilliseconds()); + + // Color expired entries blue. + if (ttl_ms > 0) + out->append("<tr>"); + else + out->append("<tr style='color:blue'>"); + + StringAppendF(out, "<td>%s</td><td>%d</td>", + EscapeForHTML(proxy_uri).c_str(), + ttl_ms); + + out->append("</tr>"); + } + out->append("</table>"); } }; @@ -504,6 +537,16 @@ bool HandleCommand(const std::string& command, URLRequestContext* context) { return true; } + if (command == "clear-badproxies") { + context->proxy_service()->ClearBadProxiesCache(); + return true; + } + + if (command == "reload-proxy-config") { + context->proxy_service()->ForceReloadProxyConfig(); + return true; + } + return false; } @@ -544,6 +587,7 @@ void DrawControlsHeader(URLRequestContext* context, std::string* data) { DrawCommandButton("Clear all data", // Send a list of comma separated commands: + "clear-badproxies," "clear-hostcache," "clear-urlrequest-graveyard," "clear-socketstream-graveyard", |