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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
Property Changes:
Name: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2010 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.
4
5 /**
6 * This view displays information on the host resolver:
7 *
8 * - Shows the current host cache contents.
9 * - Has a button to clear the host cache.
10 * - Shows the parameters used to construct the host cache (capacity, ttl).
11 *
12 * @constructor
13 */
14 function DnsView(mainBoxId,
15 cacheTbodyId,
16 clearCacheButtonId,
17 capacitySpanId,
18 ttlSuccessSpanId,
19 ttlFailureSpanId) {
20 DivView.call(this, mainBoxId);
21
22 // Hook up the UI components.
23 this.cacheTbody_ = document.getElementById(cacheTbodyId);
24 this.capacitySpan_ = document.getElementById(capacitySpanId);
25 this.ttlSuccessSpan_ = document.getElementById(ttlSuccessSpanId);
26 this.ttlFailureSpan_ = document.getElementById(ttlFailureSpanId);
27
28 var clearCacheButton = document.getElementById(clearCacheButtonId);
29 clearCacheButton.onclick =
30 g_browser.sendClearHostResolverCache.bind(g_browser);
31
32 // Register to receive changes to the host resolver cache.
33 g_browser.addHostResolverCacheObserver(this);
34 }
35
36 inherits(DnsView, DivView);
37
38 DnsView.prototype.onHostResolverCacheChanged = function(hostResolverCache) {
39 // Clear the existing values.
40 this.capacitySpan_.innerHTML = '';
41 this.ttlSuccessSpan_.innerHTML = '';
42 this.ttlFailureSpan_.innerHTML = '';
43 this.cacheTbody_.innerHTML = '';
44
45 // No cache.
46 if (!hostResolverCache)
47 return;
48
49 // Fill in the basic cache information.
50 addTextNode(this.capacitySpan_, hostResolverCache.capacity);
51 addTextNode(this.ttlSuccessSpan_, hostResolverCache.ttl_success_ms);
52 addTextNode(this.ttlFailureSpan_, hostResolverCache.ttl_failure_ms);
53
54 // Fill in the cache contents table.
55 for (var i = 0; i < hostResolverCache.entries.length; ++i) {
56 var e = hostResolverCache.entries[i];
57 var tr = addNode(this.cacheTbody_, 'tr');
58
59 var hostnameCell = addNode(tr, 'td');
60 addTextNode(hostnameCell, e.hostname);
61
62 var familyCell = addNode(tr, 'td');
63 addTextNode(familyCell, e.address_family);
64
65 var addressesCell = addNode(tr, 'td');
66
67 if (e.error != undefined) {
68 addTextNode(addressesCell, 'error: ' + e.error);
69 } else {
70 for (var j = 0; j < e.addresses.length; ++j) {
71 var address = e.addresses[j];
72 if (j != 0)
73 addNode(addressesCell, 'br');
74 addTextNode(addressesCell, address);
75 }
76 }
77
78 var expiresDate = g_browser.convertTimeTicksToDate(e.expiration);
79 var expiresCell = addNode(tr, 'td');
80 addTextNode(expiresCell, expiresDate.toLocaleString());
81 }
82 };
OLDNEW
« 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