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.
6 * This view displays information on the HTTP cache.
8 var HttpCacheView = (function() {
11 // We inherit from DivView.
12 var superClass = DivView;
17 function HttpCacheView() {
18 assertFirstConstructorCall(HttpCacheView);
20 // Call superclass's constructor.
21 superClass.call(this, HttpCacheView.MAIN_BOX_ID);
23 this.statsDiv_ = $(HttpCacheView.STATS_DIV_ID);
25 // Register to receive http cache info.
26 g_browser.addHttpCacheInfoObserver(this, true);
29 HttpCacheView.TAB_ID = 'tab-handle-http-cache';
30 HttpCacheView.TAB_NAME = 'Cache';
31 HttpCacheView.TAB_HASH = '#httpCache';
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';
37 cr.addSingletonGetter(HttpCacheView);
39 HttpCacheView.prototype = {
40 // Inherit the superclass's methods.
41 __proto__: superClass.prototype,
43 onLoadLogFinish: function(data) {
44 return this.onHttpCacheInfoChanged(data.httpCacheInfo);
47 onHttpCacheInfoChanged: function(info) {
48 this.statsDiv_.innerHTML = '';
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]);