// 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() {
  const mainBoxId = 'http-cache-view-tab-content';
  const statsDivId = 'http-cache-view-cache-stats';

  DivView.call(this, mainBoxId);

  this.statsDiv_ = $(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;
};


// 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.
 */

var HttpCacheView = (function() {
  // IDs for special HTML elements in http_cache_view.html
  const MAIN_BOX_ID = 'http-cache-view-tab-content';
  const STATS_DIV_ID = 'http-cache-view-cache-stats';

  // We inherit from DivView.
  var superClass = DivView;

  /**
   *  @constructor
   */
  function HttpCacheView() {
    // Call superclass's constructor.
    superClass.call(this, MAIN_BOX_ID);

    this.statsDiv_ = $(STATS_DIV_ID);

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

  cr.addSingletonGetter(HttpCacheView);

  HttpCacheView.prototype = {
    // Inherit the superclass's methods.
    __proto__: superClass.prototype,

    onLoadLogFinish: function(data) {
      return this.onHttpCacheInfoChanged(data.httpCacheInfo);
    },

    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;
    }
  };

  return HttpCacheView;
})();

Refactor HttpCacheView to be defined inside an anonymous namespace.
Refactor HttpCacheView to be defined inside an anonymous namespace. 

BUG=90857
Review URL: http://codereview.chromium.org/7544008

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@94868 0039d316-1c4b-4281-b951-d872f2087c98
