OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 */ | 124 */ |
125 function firstPositive(numbers) | 125 function firstPositive(numbers) |
126 { | 126 { |
127 for (var i = 0; i < numbers.length; ++i) { | 127 for (var i = 0; i < numbers.length; ++i) { |
128 if (numbers[i] > 0) | 128 if (numbers[i] > 0) |
129 return numbers[i]; | 129 return numbers[i]; |
130 } | 130 } |
131 return undefined; | 131 return undefined; |
132 } | 132 } |
133 | 133 |
| 134 function createCommunicationTimingTable() |
| 135 { |
| 136 if (blocking > 0) |
| 137 addRow(WebInspector.UIString("Stalled"), "blocking", 0, blocking); |
| 138 |
| 139 if (timing.proxyStart !== -1) |
| 140 addRow(WebInspector.UIString("Proxy negotiation"), "proxy", timing.p
roxyStart, timing.proxyEnd); |
| 141 |
| 142 if (timing.dnsStart !== -1) |
| 143 addRow(WebInspector.UIString("DNS Lookup"), "dns", timing.dnsStart,
timing.dnsEnd); |
| 144 |
| 145 if (timing.connectStart !== -1) |
| 146 addRow(WebInspector.UIString("Initial connection"), "connecting", ti
ming.connectStart, timing.connectEnd); |
| 147 |
| 148 if (timing.sslStart !== -1) |
| 149 addRow(WebInspector.UIString("SSL"), "ssl", timing.sslStart, timing.
sslEnd); |
| 150 |
| 151 addRow(WebInspector.UIString("Request sent"), "sending", timing.sendStar
t, timing.sendEnd); |
| 152 addRow(WebInspector.UIString("Waiting (TTFB)"), "waiting", timing.sendEn
d, timing.receiveHeadersEnd); |
| 153 |
| 154 if (request.endTime !== -1) |
| 155 addRow(WebInspector.UIString("Content Download"), "receiving", (requ
est.responseReceivedTime - timing.requestTime) * 1000, total); |
| 156 } |
| 157 |
| 158 function createServiceWorkerTimingTable() |
| 159 { |
| 160 addRow(WebInspector.UIString("Stalled"), "blocking", 0, timing.serviceWo
rkerFetchStart); |
| 161 |
| 162 addRow(WebInspector.UIString("Request to ServiceWorker"), "serviceworker
", timing.serviceWorkerFetchStart, timing.serviceWorkerFetchEnd); |
| 163 addRow(WebInspector.UIString("ServiceWorker Preparation"), "serviceworke
r", timing.serviceWorkerFetchStart, timing.serviceWorkerFetchReady); |
| 164 addRow(WebInspector.UIString("Waiting (TTFB)"), "waiting", timing.servic
eWorkerFetchEnd, timing.receiveHeadersEnd); |
| 165 |
| 166 if (request.endTime !== -1) |
| 167 addRow(WebInspector.UIString("Content Download"), "receiving", (requ
est.responseReceivedTime - timing.requestTime) * 1000, total); |
| 168 } |
| 169 |
134 var timing = request.timing; | 170 var timing = request.timing; |
135 var blocking = firstPositive([timing.dnsStart, timing.connectStart, timing.s
endStart]); | 171 var blocking = firstPositive([timing.dnsStart, timing.connectStart, timing.s
endStart]); |
136 var endTime = firstPositive([request.endTime, request.responseReceivedTime,
timing.requestTime]); | 172 var endTime = firstPositive([request.endTime, request.responseReceivedTime,
timing.requestTime]); |
137 var total = (endTime - timing.requestTime) * 1000; | 173 var total = (endTime - timing.requestTime) * 1000; |
138 const chartWidth = 200; | 174 const chartWidth = 200; |
139 var scale = chartWidth / total; | 175 var scale = chartWidth / total; |
140 | 176 |
141 if (blocking > 0) | 177 if (request.fetchedViaServiceWorker) |
142 addRow(WebInspector.UIString("Stalled"), "blocking", 0, blocking); | 178 createServiceWorkerTimingTable(); |
143 | 179 else |
144 if (timing.proxyStart !== -1) | 180 createCommunicationTimingTable(); |
145 addRow(WebInspector.UIString("Proxy negotiation"), "proxy", timing.proxy
Start, timing.proxyEnd); | |
146 | |
147 if (timing.dnsStart !== -1) | |
148 addRow(WebInspector.UIString("DNS Lookup"), "dns", timing.dnsStart, timi
ng.dnsEnd); | |
149 | |
150 if (timing.connectStart !== -1) | |
151 addRow(WebInspector.UIString("Initial connection"), "connecting", timing
.connectStart, timing.connectEnd); | |
152 | |
153 if (timing.sslStart !== -1) | |
154 addRow(WebInspector.UIString("SSL"), "ssl", timing.sslStart, timing.sslE
nd); | |
155 | |
156 addRow(WebInspector.UIString("Request sent"), "sending", timing.sendStart, t
iming.sendEnd); | |
157 addRow(WebInspector.UIString("Waiting (TTFB)"), "waiting", timing.sendEnd, t
iming.receiveHeadersEnd); | |
158 | |
159 if (request.endTime !== -1) | |
160 addRow(WebInspector.UIString("Content Download"), "receiving", (request.
responseReceivedTime - timing.requestTime) * 1000, total); | |
161 | 181 |
162 if (!request.finished) { | 182 if (!request.finished) { |
163 var cell = tableElement.createChild("tr").createChild("td", "caution"); | 183 var cell = tableElement.createChild("tr").createChild("td", "caution"); |
164 cell.colSpan = 2; | 184 cell.colSpan = 2; |
165 cell.createTextChild(WebInspector.UIString("CAUTION: request is not fini
shed yet!")); | 185 cell.createTextChild(WebInspector.UIString("CAUTION: request is not fini
shed yet!")); |
166 } | 186 } |
167 | 187 |
168 return tableElement; | 188 return tableElement; |
169 } | 189 } |
OLD | NEW |