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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 97 |
98 // Fill in the cache contents table. | 98 // Fill in the cache contents table. |
99 for (var i = 0; i < hostResolverCache.entries.length; ++i) { | 99 for (var i = 0; i < hostResolverCache.entries.length; ++i) { |
100 var e = hostResolverCache.entries[i]; | 100 var e = hostResolverCache.entries[i]; |
101 var tr = addNode($(DnsView.CACHE_TBODY_ID), 'tr'); | 101 var tr = addNode($(DnsView.CACHE_TBODY_ID), 'tr'); |
102 | 102 |
103 var hostnameCell = addNode(tr, 'td'); | 103 var hostnameCell = addNode(tr, 'td'); |
104 addTextNode(hostnameCell, e.hostname); | 104 addTextNode(hostnameCell, e.hostname); |
105 | 105 |
106 var familyCell = addNode(tr, 'td'); | 106 var familyCell = addNode(tr, 'td'); |
107 addTextNode(familyCell, | 107 addTextNode(familyCell, addressFamilyToString(e.address_family)); |
108 addressFamilyToString(e.address_family)); | |
109 | 108 |
110 var addressesCell = addNode(tr, 'td'); | 109 var addressesCell = addNode(tr, 'td'); |
111 | 110 |
112 if (e.error != undefined) { | 111 if (e.error != undefined) { |
113 var errorText = | 112 var errorText = e.error + ' (' + netErrorToString(e.error) + ')'; |
114 e.error + ' (' + netErrorToString(e.error) + ')'; | |
115 var errorNode = addTextNode(addressesCell, 'error: ' + errorText); | 113 var errorNode = addTextNode(addressesCell, 'error: ' + errorText); |
116 addressesCell.classList.add('warning-text'); | 114 addressesCell.classList.add('warning-text'); |
117 } else { | 115 } else { |
118 addListToNode_(addNode(addressesCell, 'div'), e.addresses); | 116 addListToNode_(addNode(addressesCell, 'div'), e.addresses); |
119 } | 117 } |
120 | 118 |
121 var expiresDate = timeutil.convertTimeTicksToDate(e.expiration); | 119 var expiresDate = timeutil.convertTimeTicksToDate(e.expiration); |
122 var expiresCell = addNode(tr, 'td'); | 120 var expiresCell = addNode(tr, 'td'); |
123 timeutil.addNodeWithDate(expiresCell, expiresDate); | 121 timeutil.addNodeWithDate(expiresCell, expiresDate); |
124 if (logDate > timeutil.convertTimeTicksToDate(e.expiration)) { | 122 if (logDate > timeutil.convertTimeTicksToDate(e.expiration)) { |
(...skipping 14 matching lines...) Expand all Loading... |
139 /** | 137 /** |
140 * Displays information corresponding to the current async DNS configuration. | 138 * Displays information corresponding to the current async DNS configuration. |
141 * @param {Object} hostResolverInfo The host resolver information. | 139 * @param {Object} hostResolverInfo The host resolver information. |
142 */ | 140 */ |
143 function displayAsyncDnsConfig_(hostResolverInfo) { | 141 function displayAsyncDnsConfig_(hostResolverInfo) { |
144 // Clear the table. | 142 // Clear the table. |
145 $(DnsView.INTERNAL_DNS_CONFIG_TBODY_ID).innerHTML = ''; | 143 $(DnsView.INTERNAL_DNS_CONFIG_TBODY_ID).innerHTML = ''; |
146 | 144 |
147 // Figure out if the internal DNS resolver is disabled or has no valid | 145 // Figure out if the internal DNS resolver is disabled or has no valid |
148 // configuration information, and update display accordingly. | 146 // configuration information, and update display accordingly. |
149 var enabled = hostResolverInfo && | 147 var enabled = hostResolverInfo && hostResolverInfo.dns_config !== undefined; |
150 hostResolverInfo.dns_config !== undefined; | 148 var noConfig = |
151 var noConfig = enabled && | 149 enabled && hostResolverInfo.dns_config.nameservers === undefined; |
152 hostResolverInfo.dns_config.nameservers === undefined; | |
153 $(DnsView.INTERNAL_DNS_ENABLED_SPAN_ID).innerText = enabled; | 150 $(DnsView.INTERNAL_DNS_ENABLED_SPAN_ID).innerText = enabled; |
154 setNodeDisplay($(DnsView.INTERNAL_DNS_INVALID_CONFIG_SPAN_ID), noConfig); | 151 setNodeDisplay($(DnsView.INTERNAL_DNS_INVALID_CONFIG_SPAN_ID), noConfig); |
155 | 152 |
156 // If the internal DNS resolver is disabled or has no valid configuration, | 153 // If the internal DNS resolver is disabled or has no valid configuration, |
157 // we're done. | 154 // we're done. |
158 if (!enabled || noConfig) | 155 if (!enabled || noConfig) |
159 return; | 156 return; |
160 | 157 |
161 var dnsConfig = hostResolverInfo.dns_config; | 158 var dnsConfig = hostResolverInfo.dns_config; |
162 | 159 |
(...skipping 27 matching lines...) Expand all Loading... |
190 * @param {DomNode} node The parent node. | 187 * @param {DomNode} node The parent node. |
191 * @param {Array<string>} list List of strings to add to the node. | 188 * @param {Array<string>} list List of strings to add to the node. |
192 */ | 189 */ |
193 function addListToNode_(node, list) { | 190 function addListToNode_(node, list) { |
194 for (var i = 0; i < list.length; ++i) | 191 for (var i = 0; i < list.length; ++i) |
195 addNodeWithText(node, 'div', list[i]); | 192 addNodeWithText(node, 'div', list[i]); |
196 } | 193 } |
197 | 194 |
198 return DnsView; | 195 return DnsView; |
199 })(); | 196 })(); |
OLD | NEW |