Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3454)

Unified Diff: chrome/browser/resources/net_internals/dnsview.js

Issue 1558027: Add the host resolver cache to the new net internals page. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync with fragment changes Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/dom_ui/net_internals_ui.cc ('k') | chrome/browser/resources/net_internals/index.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/net_internals/dnsview.js
===================================================================
--- chrome/browser/resources/net_internals/dnsview.js (revision 0)
+++ chrome/browser/resources/net_internals/dnsview.js (revision 0)
@@ -0,0 +1,82 @@
+// Copyright (c) 2010 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 host resolver:
+ *
+ * - Shows the current host cache contents.
+ * - Has a button to clear the host cache.
+ * - Shows the parameters used to construct the host cache (capacity, ttl).
+ *
+ * @constructor
+ */
+function DnsView(mainBoxId,
+ cacheTbodyId,
+ clearCacheButtonId,
+ capacitySpanId,
+ ttlSuccessSpanId,
+ ttlFailureSpanId) {
+ DivView.call(this, mainBoxId);
+
+ // Hook up the UI components.
+ this.cacheTbody_ = document.getElementById(cacheTbodyId);
+ this.capacitySpan_ = document.getElementById(capacitySpanId);
+ this.ttlSuccessSpan_ = document.getElementById(ttlSuccessSpanId);
+ this.ttlFailureSpan_ = document.getElementById(ttlFailureSpanId);
+
+ var clearCacheButton = document.getElementById(clearCacheButtonId);
+ clearCacheButton.onclick =
+ g_browser.sendClearHostResolverCache.bind(g_browser);
+
+ // Register to receive changes to the host resolver cache.
+ g_browser.addHostResolverCacheObserver(this);
+}
+
+inherits(DnsView, DivView);
+
+DnsView.prototype.onHostResolverCacheChanged = function(hostResolverCache) {
+ // Clear the existing values.
+ this.capacitySpan_.innerHTML = '';
+ this.ttlSuccessSpan_.innerHTML = '';
+ this.ttlFailureSpan_.innerHTML = '';
+ this.cacheTbody_.innerHTML = '';
+
+ // No cache.
+ if (!hostResolverCache)
+ return;
+
+ // Fill in the basic cache information.
+ addTextNode(this.capacitySpan_, hostResolverCache.capacity);
+ addTextNode(this.ttlSuccessSpan_, hostResolverCache.ttl_success_ms);
+ addTextNode(this.ttlFailureSpan_, hostResolverCache.ttl_failure_ms);
+
+ // Fill in the cache contents table.
+ for (var i = 0; i < hostResolverCache.entries.length; ++i) {
+ var e = hostResolverCache.entries[i];
+ var tr = addNode(this.cacheTbody_, 'tr');
+
+ var hostnameCell = addNode(tr, 'td');
+ addTextNode(hostnameCell, e.hostname);
+
+ var familyCell = addNode(tr, 'td');
+ addTextNode(familyCell, e.address_family);
+
+ var addressesCell = addNode(tr, 'td');
+
+ if (e.error != undefined) {
+ addTextNode(addressesCell, 'error: ' + e.error);
+ } else {
+ for (var j = 0; j < e.addresses.length; ++j) {
+ var address = e.addresses[j];
+ if (j != 0)
+ addNode(addressesCell, 'br');
+ addTextNode(addressesCell, address);
+ }
+ }
+
+ var expiresDate = g_browser.convertTimeTicksToDate(e.expiration);
+ var expiresCell = addNode(tr, 'td');
+ addTextNode(expiresCell, expiresDate.toLocaleString());
+ }
+};
Property changes on: chrome/browser/resources/net_internals/dnsview.js
___________________________________________________________________
Name: svn:eol-style
+ LF
« no previous file with comments | « chrome/browser/dom_ui/net_internals_ui.cc ('k') | chrome/browser/resources/net_internals/index.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698