Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * This view displays information on the host resolver: | 6 * This view displays information on the host resolver: |
| 7 * | 7 * |
| 8 * - Shows the default address family. | 8 * - Shows the default address family. |
| 9 * - Shows the current host cache contents. | 9 * - Shows the current host cache contents. |
| 10 * - Has a button to clear the host cache. | 10 * - Has a button to clear the host cache. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 DnsView.INTERNAL_DNS_ENABLED_SPAN_ID = 'dns-view-internal-dns-enabled'; | 48 DnsView.INTERNAL_DNS_ENABLED_SPAN_ID = 'dns-view-internal-dns-enabled'; |
| 49 DnsView.INTERNAL_DNS_INVALID_CONFIG_SPAN_ID = | 49 DnsView.INTERNAL_DNS_INVALID_CONFIG_SPAN_ID = |
| 50 'dns-view-internal-dns-invalid-config'; | 50 'dns-view-internal-dns-invalid-config'; |
| 51 DnsView.INTERNAL_DNS_CONFIG_TBODY_ID = 'dns-view-internal-dns-config-tbody'; | 51 DnsView.INTERNAL_DNS_CONFIG_TBODY_ID = 'dns-view-internal-dns-config-tbody'; |
| 52 | 52 |
| 53 DnsView.CLEAR_CACHE_BUTTON_ID = 'dns-view-clear-cache'; | 53 DnsView.CLEAR_CACHE_BUTTON_ID = 'dns-view-clear-cache'; |
| 54 DnsView.CAPACITY_SPAN_ID = 'dns-view-cache-capacity'; | 54 DnsView.CAPACITY_SPAN_ID = 'dns-view-cache-capacity'; |
| 55 | 55 |
| 56 DnsView.ACTIVE_SPAN_ID = 'dns-view-cache-active'; | 56 DnsView.ACTIVE_SPAN_ID = 'dns-view-cache-active'; |
| 57 DnsView.EXPIRED_SPAN_ID = 'dns-view-cache-expired'; | 57 DnsView.EXPIRED_SPAN_ID = 'dns-view-cache-expired'; |
| 58 DnsView.NETWORK_SPAN_ID = 'dns-view-network-changes'; | |
| 58 DnsView.CACHE_TBODY_ID = 'dns-view-cache-tbody'; | 59 DnsView.CACHE_TBODY_ID = 'dns-view-cache-tbody'; |
| 59 | 60 |
| 60 cr.addSingletonGetter(DnsView); | 61 cr.addSingletonGetter(DnsView); |
| 61 | 62 |
| 62 DnsView.prototype = { | 63 DnsView.prototype = { |
| 63 // Inherit the superclass's methods. | 64 // Inherit the superclass's methods. |
| 64 __proto__: superClass.prototype, | 65 __proto__: superClass.prototype, |
| 65 | 66 |
| 66 onLoadLogFinish: function(data) { | 67 onLoadLogFinish: function(data) { |
| 67 return this.onHostResolverInfoChanged(data.hostResolverInfo); | 68 return this.onHostResolverInfoChanged(data.hostResolverInfo); |
| 68 }, | 69 }, |
| 69 | 70 |
| 70 onHostResolverInfoChanged: function(hostResolverInfo) { | 71 onHostResolverInfoChanged: function(hostResolverInfo) { |
| 71 // Clear the existing values. | 72 // Clear the existing values. |
| 72 $(DnsView.CAPACITY_SPAN_ID).innerHTML = ''; | 73 $(DnsView.CAPACITY_SPAN_ID).innerHTML = ''; |
| 73 $(DnsView.CACHE_TBODY_ID).innerHTML = ''; | 74 $(DnsView.CACHE_TBODY_ID).innerHTML = ''; |
| 74 $(DnsView.ACTIVE_SPAN_ID).innerHTML = '0'; | 75 $(DnsView.ACTIVE_SPAN_ID).innerHTML = '0'; |
| 75 $(DnsView.EXPIRED_SPAN_ID).innerHTML = '0'; | 76 $(DnsView.EXPIRED_SPAN_ID).innerHTML = '0'; |
| 77 $(DnsView.NETWORK_SPAN_ID).innerHTML = '0'; | |
| 76 | 78 |
| 77 // Update fields containing async DNS configuration information. | 79 // Update fields containing async DNS configuration information. |
| 78 displayAsyncDnsConfig_(hostResolverInfo); | 80 displayAsyncDnsConfig_(hostResolverInfo); |
| 79 | 81 |
| 80 // No info. | 82 // No info. |
| 81 if (!hostResolverInfo || !hostResolverInfo.cache) | 83 if (!hostResolverInfo || !hostResolverInfo.cache) |
| 82 return false; | 84 return false; |
| 83 | 85 |
| 84 // Fill in the basic cache information. | 86 // Fill in the basic cache information. |
| 85 var hostResolverCache = hostResolverInfo.cache; | 87 var hostResolverCache = hostResolverInfo.cache; |
| 86 $(DnsView.CAPACITY_SPAN_ID).innerText = hostResolverCache.capacity; | 88 $(DnsView.CAPACITY_SPAN_ID).innerText = hostResolverCache.capacity; |
| 89 $(DnsView.NETWORK_SPAN_ID).innerText = hostResolverCache.network_changes; | |
|
eroman
2017/03/28 22:41:59
When loading older log files, network_changes will
mgersh
2017/03/29 18:15:25
Ah yeah. I thought to check old Chrome loading new
eroman
2017/03/29 18:36:11
Yes I think it is worth it.
In general not doing
mgersh
2017/03/29 20:20:53
I still don't entirely understand why it's importa
| |
| 87 | 90 |
| 88 var expiredEntries = 0; | 91 var expiredEntries = 0; |
| 89 // Date the cache was logged. This will be either now, when actively | 92 // Date the cache was logged. This will be either now, when actively |
| 90 // logging data, or the date the log dump was created. | 93 // logging data, or the date the log dump was created. |
| 91 var logDate; | 94 var logDate; |
| 92 if (MainView.isViewingLoadedLog()) { | 95 if (MainView.isViewingLoadedLog()) { |
| 93 logDate = new Date(ClientInfo.numericDate); | 96 logDate = new Date(ClientInfo.numericDate); |
| 94 } else { | 97 } else { |
| 95 logDate = new Date(); | 98 logDate = new Date(); |
| 96 } | 99 } |
| 97 | 100 |
| 98 // Fill in the cache contents table. | 101 // Fill in the cache contents table. |
| 99 for (var i = 0; i < hostResolverCache.entries.length; ++i) { | 102 for (var i = 0; i < hostResolverCache.entries.length; ++i) { |
| 100 var e = hostResolverCache.entries[i]; | 103 var e = hostResolverCache.entries[i]; |
| 101 var tr = addNode($(DnsView.CACHE_TBODY_ID), 'tr'); | 104 var tr = addNode($(DnsView.CACHE_TBODY_ID), 'tr'); |
| 105 var expired = false; | |
| 102 | 106 |
| 103 var hostnameCell = addNode(tr, 'td'); | 107 var hostnameCell = addNode(tr, 'td'); |
| 104 addTextNode(hostnameCell, e.hostname); | 108 addTextNode(hostnameCell, e.hostname); |
| 105 | 109 |
| 106 var familyCell = addNode(tr, 'td'); | 110 var familyCell = addNode(tr, 'td'); |
| 107 addTextNode(familyCell, addressFamilyToString(e.address_family)); | 111 addTextNode(familyCell, addressFamilyToString(e.address_family)); |
| 108 | 112 |
| 109 var addressesCell = addNode(tr, 'td'); | 113 var addressesCell = addNode(tr, 'td'); |
| 110 | 114 |
| 111 if (e.error != undefined) { | 115 if (e.error != undefined) { |
| 112 var errorText = e.error + ' (' + netErrorToString(e.error) + ')'; | 116 var errorText = e.error + ' (' + netErrorToString(e.error) + ')'; |
| 113 var errorNode = addTextNode(addressesCell, 'error: ' + errorText); | 117 var errorNode = addTextNode(addressesCell, 'error: ' + errorText); |
| 114 addressesCell.classList.add('warning-text'); | 118 addressesCell.classList.add('warning-text'); |
| 115 } else { | 119 } else { |
| 116 addListToNode_(addNode(addressesCell, 'div'), e.addresses); | 120 addListToNode_(addNode(addressesCell, 'div'), e.addresses); |
| 117 } | 121 } |
| 118 | 122 |
| 123 var ttlCell = addNode(tr, 'td'); | |
| 124 addTextNode(ttlCell, e.ttl); | |
| 125 | |
| 119 var expiresDate = timeutil.convertTimeTicksToDate(e.expiration); | 126 var expiresDate = timeutil.convertTimeTicksToDate(e.expiration); |
| 120 var expiresCell = addNode(tr, 'td'); | 127 var expiresCell = addNode(tr, 'td'); |
| 121 timeutil.addNodeWithDate(expiresCell, expiresDate); | 128 timeutil.addNodeWithDate(expiresCell, expiresDate); |
| 122 if (logDate > timeutil.convertTimeTicksToDate(e.expiration)) { | 129 if (logDate > timeutil.convertTimeTicksToDate(e.expiration)) { |
| 123 ++expiredEntries; | 130 expired = true; |
| 124 var expiredSpan = addNode(expiresCell, 'span'); | 131 var expiredSpan = addNode(expiresCell, 'span'); |
| 125 expiredSpan.classList.add('warning-text'); | 132 expiredSpan.classList.add('warning-text'); |
| 126 addTextNode(expiredSpan, ' [Expired]'); | 133 addTextNode(expiredSpan, ' [Expired]'); |
| 127 } | 134 } |
| 135 | |
| 136 var networkChangesCell = addNode(tr, 'td'); | |
| 137 addTextNode(networkChangesCell, e.network_changes); | |
| 138 if (e.network_changes < hostResolverCache.network_changes) { | |
|
eroman
2017/03/28 22:41:59
same comment -- what happens to this comparison wh
mgersh
2017/03/29 18:15:25
undefined < undefined evaluates to false, so the c
| |
| 139 expired = true; | |
| 140 var expiredSpan = addNode(networkChangesCell, 'span'); | |
| 141 expiredSpan.classList.add('warning-text'); | |
| 142 addTextNode(expiredSpan, ' [Expired]'); | |
| 143 } | |
| 144 | |
| 145 if (expired) { | |
| 146 expiredEntries++; | |
| 147 } | |
| 128 } | 148 } |
| 129 | 149 |
| 130 $(DnsView.ACTIVE_SPAN_ID).innerText = | 150 $(DnsView.ACTIVE_SPAN_ID).innerText = |
| 131 hostResolverCache.entries.length - expiredEntries; | 151 hostResolverCache.entries.length - expiredEntries; |
| 132 $(DnsView.EXPIRED_SPAN_ID).innerText = expiredEntries; | 152 $(DnsView.EXPIRED_SPAN_ID).innerText = expiredEntries; |
| 133 return true; | 153 return true; |
| 134 }, | 154 }, |
| 135 }; | 155 }; |
| 136 | 156 |
| 137 /** | 157 /** |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 * @param {DomNode} node The parent node. | 207 * @param {DomNode} node The parent node. |
| 188 * @param {Array<string>} list List of strings to add to the node. | 208 * @param {Array<string>} list List of strings to add to the node. |
| 189 */ | 209 */ |
| 190 function addListToNode_(node, list) { | 210 function addListToNode_(node, list) { |
| 191 for (var i = 0; i < list.length; ++i) | 211 for (var i = 0; i < list.length; ++i) |
| 192 addNodeWithText(node, 'div', list[i]); | 212 addNodeWithText(node, 'div', list[i]); |
| 193 } | 213 } |
| 194 | 214 |
| 195 return DnsView; | 215 return DnsView; |
| 196 })(); | 216 })(); |
| OLD | NEW |