OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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 */ |
| 8 var HttpCacheView = (function() { |
| 9 'use strict'; |
| 10 |
| 11 // We inherit from DivView. |
| 12 var superClass = DivView; |
| 13 |
| 14 /** |
| 15 * @constructor |
| 16 */ |
| 17 function HttpCacheView() { |
| 18 assertFirstConstructorCall(HttpCacheView); |
| 19 |
| 20 // Call superclass's constructor. |
| 21 superClass.call(this, HttpCacheView.MAIN_BOX_ID); |
| 22 |
| 23 this.statsDiv_ = $(HttpCacheView.STATS_DIV_ID); |
| 24 |
| 25 // Register to receive http cache info. |
| 26 g_browser.addHttpCacheInfoObserver(this, true); |
| 27 } |
| 28 |
| 29 HttpCacheView.TAB_ID = 'tab-handle-http-cache'; |
| 30 HttpCacheView.TAB_NAME = 'Cache'; |
| 31 HttpCacheView.TAB_HASH = '#httpCache'; |
| 32 |
| 33 // IDs for special HTML elements in http_cache_view.html |
| 34 HttpCacheView.MAIN_BOX_ID = 'http-cache-view-tab-content'; |
| 35 HttpCacheView.STATS_DIV_ID = 'http-cache-view-cache-stats'; |
| 36 |
| 37 cr.addSingletonGetter(HttpCacheView); |
| 38 |
| 39 HttpCacheView.prototype = { |
| 40 // Inherit the superclass's methods. |
| 41 __proto__: superClass.prototype, |
| 42 |
| 43 onLoadLogFinish: function(data) { |
| 44 return this.onHttpCacheInfoChanged(data.httpCacheInfo); |
| 45 }, |
| 46 |
| 47 onHttpCacheInfoChanged: function(info) { |
| 48 this.statsDiv_.innerHTML = ''; |
| 49 |
| 50 if (!info) |
| 51 return false; |
| 52 |
| 53 // Print the statistics. |
| 54 var statsUl = addNode(this.statsDiv_, 'ul'); |
| 55 for (var statName in info.stats) { |
| 56 var li = addNode(statsUl, 'li'); |
| 57 addTextNode(li, statName + ': ' + info.stats[statName]); |
| 58 } |
| 59 return true; |
| 60 } |
| 61 }; |
| 62 |
| 63 return HttpCacheView; |
| 64 })(); |
| 65 |
OLD | NEW |