| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 /** | 5 /** |
| 6 * This view displays information on the HTTP cache. | 6 * This view displays information on the HTTP cache. |
| 7 * @constructor | 7 * @constructor |
| 8 */ | 8 */ |
| 9 function HttpCacheView(mainBoxId, reloadButtonId, statsDivId, | 9 function HttpCacheView(mainBoxId, statsDivId) { |
| 10 entryListingDivId) { | |
| 11 DivView.call(this, mainBoxId); | 10 DivView.call(this, mainBoxId); |
| 12 | 11 |
| 13 var reloadButton = document.getElementById(reloadButtonId); | |
| 14 reloadButton.onclick = this.reloadListing_.bind(this); | |
| 15 | |
| 16 this.statsDiv_ = document.getElementById(statsDivId); | 12 this.statsDiv_ = document.getElementById(statsDivId); |
| 17 this.entryListingDiv_ = document.getElementById(entryListingDivId); | |
| 18 | 13 |
| 19 // Register to receive http cache info. | 14 // Register to receive http cache info. |
| 20 g_browser.addHttpCacheInfoObserver(this); | 15 g_browser.addHttpCacheInfoObserver(this); |
| 21 } | 16 } |
| 22 | 17 |
| 23 inherits(HttpCacheView, DivView); | 18 inherits(HttpCacheView, DivView); |
| 24 | 19 |
| 25 HttpCacheView.prototype.onHttpCacheInfoReceived = function(info) { | 20 HttpCacheView.prototype.onHttpCacheInfoChanged = function(info) { |
| 26 this.entryListingDiv_.innerHTML = ''; | |
| 27 this.statsDiv_.innerHTML = ''; | 21 this.statsDiv_.innerHTML = ''; |
| 28 | 22 |
| 29 // Print the statistics. | 23 // Print the statistics. |
| 30 var statsUl = addNode(this.statsDiv_, 'ul'); | 24 var statsUl = addNode(this.statsDiv_, 'ul'); |
| 31 for (var statName in info.stats) { | 25 for (var statName in info.stats) { |
| 32 var li = addNode(statsUl, 'li'); | 26 var li = addNode(statsUl, 'li'); |
| 33 addTextNode(li, statName + ': ' + info.stats[statName]); | 27 addTextNode(li, statName + ': ' + info.stats[statName]); |
| 34 } | 28 } |
| 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://view-http-cache/' + key; | |
| 44 a.target = '_blank'; | |
| 45 } | |
| 46 }; | 29 }; |
| 47 | 30 |
| 48 HttpCacheView.prototype.reloadListing_ = function() { | |
| 49 this.entryListingDiv_.innerHTML = 'Loading...'; | |
| 50 this.statsDiv_.innerHTML = 'Loading...'; | |
| 51 g_browser.sendGetHttpCacheInfo(); | |
| 52 }; | |
| OLD | NEW |