OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * This view displays information on the HTTP cache. |
| 7 * @constructor |
| 8 */ |
| 9 function HttpCacheView(mainBoxId, reloadButtonId, statsDivId, |
| 10 entryListingDivId) { |
| 11 DivView.call(this, mainBoxId); |
| 12 |
| 13 var reloadButton = document.getElementById(reloadButtonId); |
| 14 reloadButton.onclick = this.reloadListing_.bind(this); |
| 15 |
| 16 this.statsDiv_ = document.getElementById(statsDivId); |
| 17 this.entryListingDiv_ = document.getElementById(entryListingDivId); |
| 18 |
| 19 // Register to receive http cache info. |
| 20 g_browser.addHttpCacheInfoObserver(this); |
| 21 } |
| 22 |
| 23 inherits(HttpCacheView, DivView); |
| 24 |
| 25 HttpCacheView.prototype.onHttpCacheInfoReceived = function(info) { |
| 26 this.entryListingDiv_.innerHTML = ''; |
| 27 this.statsDiv_.innerHTML = ''; |
| 28 |
| 29 // Print the statistics. |
| 30 var statsUl = addNode(this.statsDiv_, 'ul'); |
| 31 for (var statName in info.stats) { |
| 32 var li = addNode(statsUl, 'li'); |
| 33 addTextNode(li, statName + ': ' + info.stats[statName]); |
| 34 } |
| 35 |
| 36 // Print the entries. |
| 37 var keysOl = addNode(this.entryListingDiv_, 'ol'); |
| 38 for (var i = 0; i < info.keys.length; ++i) { |
| 39 var key = info.keys[i]; |
| 40 var li = addNode(keysOl, 'li'); |
| 41 var a = addNode(li, 'a'); |
| 42 addTextNode(a, key); |
| 43 a.href = 'chrome://net-internals/view-cache/' + key; |
| 44 a.target = '_blank'; |
| 45 } |
| 46 }; |
| 47 |
| 48 HttpCacheView.prototype.reloadListing_ = function() { |
| 49 this.entryListingDiv_.innerHTML = 'Loading...'; |
| 50 this.statsDiv_.innerHTML = 'Loading...'; |
| 51 g_browser.sendGetHttpCacheInfo(); |
| 52 }; |
OLD | NEW |