Updated drag and drop thumbnails.
[chromium-blink-merge.git] / chrome / browser / resources / net_internals / http_cache_view.js
blobbdfac8cdbf3b8b19e053e59a7b362f1c9665e5bc
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.
5 /**
6 * This view displays information on the HTTP cache.
7 */
8 var HttpCacheView = (function() {
9 'use strict';
11 // We inherit from DivView.
12 var superClass = DivView;
14 /**
15 * @constructor
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 // ID for special HTML element in category_tabs.html
30 HttpCacheView.TAB_HANDLE_ID = 'tab-handle-http-cache';
32 // IDs for special HTML elements in http_cache_view.html
33 HttpCacheView.MAIN_BOX_ID = 'http-cache-view-tab-content';
34 HttpCacheView.STATS_DIV_ID = 'http-cache-view-cache-stats';
36 cr.addSingletonGetter(HttpCacheView);
38 HttpCacheView.prototype = {
39 // Inherit the superclass's methods.
40 __proto__: superClass.prototype,
42 onLoadLogFinish: function(data) {
43 return this.onHttpCacheInfoChanged(data.httpCacheInfo);
46 onHttpCacheInfoChanged: function(info) {
47 this.statsDiv_.innerHTML = '';
49 if (!info)
50 return false;
52 // Print the statistics.
53 var statsUl = addNode(this.statsDiv_, 'ul');
54 for (var statName in info.stats) {
55 var li = addNode(statsUl, 'li');
56 addTextNode(li, statName + ': ' + info.stats[statName]);
58 return true;
62 return HttpCacheView;
63 })();