diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-18 06:38:33 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-18 06:38:33 +0000 |
commit | e607d3266a26620aba062230d89a08b2c2705d1c (patch) | |
tree | caa5923f50cc7a6dc14899983f905551b38c9c42 /chrome/browser | |
parent | 7e3c055692e71ed5ff2afdefb400eeb92e3e70db (diff) | |
download | chromium_src-e607d3266a26620aba062230d89a08b2c2705d1c.zip chromium_src-e607d3266a26620aba062230d89a08b2c2705d1c.tar.gz chromium_src-e607d3266a26620aba062230d89a08b2c2705d1c.tar.bz2 |
Removed the "Reload" button from the HTTP cache tab of the net-internals page.
The "Reload" button was used to refresh the stats + cache listings.
With this change, I poll the statistics for updates, so the reload button is unecessary.
Note that the cache listing is too expensive to poll, so I replaced it with a link to a listings page.
Lastly, updated the text dump to include the http cache statistics.
BUG=37421
Review URL: http://codereview.chromium.org/2085005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47499 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/dom_ui/net_internals_ui.cc | 12 | ||||
-rw-r--r-- | chrome/browser/resources/net_internals/dataview.js | 10 | ||||
-rw-r--r-- | chrome/browser/resources/net_internals/httpcacheview.js | 26 | ||||
-rw-r--r-- | chrome/browser/resources/net_internals/index.html | 7 | ||||
-rw-r--r-- | chrome/browser/resources/net_internals/main.js | 14 |
5 files changed, 22 insertions, 47 deletions
diff --git a/chrome/browser/dom_ui/net_internals_ui.cc b/chrome/browser/dom_ui/net_internals_ui.cc index 9b55d0e..8d65488 100644 --- a/chrome/browser/dom_ui/net_internals_ui.cc +++ b/chrome/browser/dom_ui/net_internals_ui.cc @@ -557,6 +557,7 @@ void NetInternalsMessageHandler::IOThreadImpl::OnRendererReady( OnGetProxySettings(NULL); OnGetBadProxies(NULL); OnGetHostResolverCache(NULL); + OnGetHttpCacheInfo(NULL); } void NetInternalsMessageHandler::IOThreadImpl::OnGetProxySettings( @@ -732,22 +733,12 @@ void NetInternalsMessageHandler::IOThreadImpl::OnStartConnectionTests( void NetInternalsMessageHandler::IOThreadImpl::OnGetHttpCacheInfo( const Value* value) { DictionaryValue* info_dict = new DictionaryValue(); - ListValue* entry_keys = new ListValue(); DictionaryValue* stats_dict = new DictionaryValue(); disk_cache::Backend* disk_cache = GetDiskCacheBackend( context_getter_->GetURLRequestContext()); if (disk_cache) { - // Iterate over all the entries in the cache, to discover the keys. - // WARNING: this can be slow! (and will block the IO thread). - void* iter = NULL; - disk_cache::Entry* entry; - while (disk_cache->OpenNextEntry(&iter, &entry)) { - entry_keys->Append(Value::CreateStringValue(entry->GetKey())); - entry->Close(); - } - // Extract the statistics key/value pairs from the backend. std::vector<std::pair<std::string, std::string> > stats; disk_cache->GetStats(&stats); @@ -757,7 +748,6 @@ void NetInternalsMessageHandler::IOThreadImpl::OnGetHttpCacheInfo( } } - info_dict->Set(L"keys", entry_keys); info_dict->Set(L"stats", stats_dict); CallJavascriptFunction(L"g_browser.receivedHttpCacheInfo", info_dict); diff --git a/chrome/browser/resources/net_internals/dataview.js b/chrome/browser/resources/net_internals/dataview.js index 6810452..8032a11 100644 --- a/chrome/browser/resources/net_internals/dataview.js +++ b/chrome/browser/resources/net_internals/dataview.js @@ -116,6 +116,16 @@ DataView.prototype.onExportToText_ = function() { this.appendRequestsPrintedAsText_(text); + text.push(''); + text.push('----------------------------------------------'); + text.push(' Http cache stats'); + text.push('----------------------------------------------'); + text.push(''); + + var httpCacheStats = g_browser.httpCacheInfo_.currentData_.stats; + for (var statName in httpCacheStats) + text.push(statName + ': ' + httpCacheStats[statName]); + // Open a new window to display this text. this.setText_(text.join('\n')); }; diff --git a/chrome/browser/resources/net_internals/httpcacheview.js b/chrome/browser/resources/net_internals/httpcacheview.js index 809f66f..dd9346d 100644 --- a/chrome/browser/resources/net_internals/httpcacheview.js +++ b/chrome/browser/resources/net_internals/httpcacheview.js @@ -6,15 +6,10 @@ * This view displays information on the HTTP cache. * @constructor */ -function HttpCacheView(mainBoxId, reloadButtonId, statsDivId, - entryListingDivId) { +function HttpCacheView(mainBoxId, statsDivId) { DivView.call(this, mainBoxId); - var reloadButton = document.getElementById(reloadButtonId); - reloadButton.onclick = this.reloadListing_.bind(this); - this.statsDiv_ = document.getElementById(statsDivId); - this.entryListingDiv_ = document.getElementById(entryListingDivId); // Register to receive http cache info. g_browser.addHttpCacheInfoObserver(this); @@ -22,8 +17,7 @@ function HttpCacheView(mainBoxId, reloadButtonId, statsDivId, inherits(HttpCacheView, DivView); -HttpCacheView.prototype.onHttpCacheInfoReceived = function(info) { - this.entryListingDiv_.innerHTML = ''; +HttpCacheView.prototype.onHttpCacheInfoChanged = function(info) { this.statsDiv_.innerHTML = ''; // Print the statistics. @@ -32,21 +26,5 @@ HttpCacheView.prototype.onHttpCacheInfoReceived = function(info) { var li = addNode(statsUl, 'li'); addTextNode(li, statName + ': ' + info.stats[statName]); } - - // Print the entries. - var keysOl = addNode(this.entryListingDiv_, 'ol'); - for (var i = 0; i < info.keys.length; ++i) { - var key = info.keys[i]; - var li = addNode(keysOl, 'li'); - var a = addNode(li, 'a'); - addTextNode(a, key); - a.href = 'chrome://view-http-cache/' + key; - a.target = '_blank'; - } }; -HttpCacheView.prototype.reloadListing_ = function() { - this.entryListingDiv_.innerHTML = 'Loading...'; - this.statsDiv_.innerHTML = 'Loading...'; - g_browser.sendGetHttpCacheInfo(); -}; diff --git a/chrome/browser/resources/net_internals/index.html b/chrome/browser/resources/net_internals/index.html index 711ce35..c7c2fca 100644 --- a/chrome/browser/resources/net_internals/index.html +++ b/chrome/browser/resources/net_internals/index.html @@ -90,12 +90,11 @@ found in the LICENSE file. <!-- Sections TODO --> <div id=socketsTabContent>TODO: display socket information (outstanding connect jobs)</div> <div id=httpCacheTabContent> - <input type=button value="Reload" id=reloadHttpCacheListing /> + <h4>Entries</h4> + <a href="chrome://view-http-cache" target=_blank>Explore cache entries</a> + <h4>Statistics</h4> <div id=httpCacheStats>Nothing loaded yet.</div> - - <h4>Entries</h4> - <div id=httpCacheListing>Nothing loaded yet.</div> </div> <!-- Import/Export data --> <div id=dataTabContent> diff --git a/chrome/browser/resources/net_internals/main.js b/chrome/browser/resources/net_internals/main.js index 3078678..3815a79 100644 --- a/chrome/browser/resources/net_internals/main.js +++ b/chrome/browser/resources/net_internals/main.js @@ -68,9 +68,7 @@ function onLoaded() { "connectionTestsForm", "testSummary"); var httpCacheView = new HttpCacheView("httpCacheTabContent", - "reloadHttpCacheListing", - "httpCacheStats", - "httpCacheListing"); + "httpCacheStats"); // Create a view which lets you tab between the different sub-views. var categoryTabSwitcher = @@ -126,9 +124,9 @@ function BrowserBridge() { // List of observers for various bits of browser state. this.logObservers_ = []; this.connectionTestsObservers_ = []; - this.httpCacheInfoObservers_ = []; this.proxySettings_ = new PollableDataHelper('onProxySettingsChanged'); this.badProxies_ = new PollableDataHelper('onBadProxiesChanged'); + this.httpCacheInfo_ = new PollableDataHelper('onHttpCacheInfoChanged'); this.hostResolverCache_ = new PollableDataHelper('onHostResolverCacheChanged'); @@ -272,8 +270,7 @@ BrowserBridge.prototype.receivedCompletedConnectionTestSuite = function() { }; BrowserBridge.prototype.receivedHttpCacheInfo = function(info) { - for (var i = 0; i < this.httpCacheInfoObservers_.length; ++i) - this.httpCacheInfoObservers_[i].onHttpCacheInfoReceived(info); + this.httpCacheInfo_.update(info); }; //------------------------------------------------------------------------------ @@ -343,10 +340,10 @@ BrowserBridge.prototype.addConnectionTestsObserver = function(observer) { * Adds a listener for the http cache info results. * The observer will be called back with: * - * observer.onHttpCacheInfoReceived(info); + * observer.onHttpCacheInfoChanged(info); */ BrowserBridge.prototype.addHttpCacheInfoObserver = function(observer) { - this.httpCacheInfoObservers_.push(observer); + this.httpCacheInfo_.addObserver(observer); }; /** @@ -388,6 +385,7 @@ BrowserBridge.prototype.doPolling_ = function() { this.sendGetProxySettings(); this.sendGetBadProxies(); this.sendGetHostResolverCache(); + this.sendGetHttpCacheInfo(); }; /** |