summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources/net_internals/httpcacheview.js
blob: 2e0e624ed03dbe1f464eb99386948c6ed8600894 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/**
 * This view displays information on the HTTP cache.
 *  @constructor
 */
function HttpCacheView(mainBoxId, statsDivId) {
  DivView.call(this, mainBoxId);

  this.statsDiv_ = document.getElementById(statsDivId);

  // Register to receive http cache info.
  g_browser.addHttpCacheInfoObserver(this);
}

inherits(HttpCacheView, DivView);

HttpCacheView.prototype.onLoadLogFinish = function(data) {
  return this.onHttpCacheInfoChanged(data.httpCacheInfo);
};

HttpCacheView.prototype.onHttpCacheInfoChanged = function(info) {
  this.statsDiv_.innerHTML = '';

  if (!info)
    return false;

  // Print the statistics.
  var statsUl = addNode(this.statsDiv_, 'ul');
  for (var statName in info.stats) {
    var li = addNode(statsUl, 'li');
    addTextNode(li, statName + ': ' + info.stats[statName]);
  }
  return true;
};