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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 | 119 |
120 return monotonicTimeToIntegerMilliseconds(timing->fetchStart()); | 120 return monotonicTimeToIntegerMilliseconds(timing->fetchStart()); |
121 } | 121 } |
122 | 122 |
123 unsigned long long PerformanceTiming::domainLookupStart() const | 123 unsigned long long PerformanceTiming::domainLookupStart() const |
124 { | 124 { |
125 ResourceLoadTiming* timing = resourceLoadTiming(); | 125 ResourceLoadTiming* timing = resourceLoadTiming(); |
126 if (!timing) | 126 if (!timing) |
127 return fetchStart(); | 127 return fetchStart(); |
128 | 128 |
129 // This will be -1 when a DNS request is not performed. | 129 // This will be zero when a DNS request is not performed. |
130 // Rather than exposing a special value that indicates no DNS, we "backfill"
with fetchStart. | 130 // Rather than exposing a special value that indicates no DNS, we "backfill"
with fetchStart. |
131 int dnsStart = timing->dnsStart; | 131 double dnsStart = timing->dnsStart; |
132 if (dnsStart < 0) | 132 if (dnsStart == 0.0) |
133 return fetchStart(); | 133 return fetchStart(); |
134 | 134 |
135 return resourceLoadTimeRelativeToAbsolute(dnsStart); | 135 return monotonicTimeToIntegerMilliseconds(dnsStart); |
136 } | 136 } |
137 | 137 |
138 unsigned long long PerformanceTiming::domainLookupEnd() const | 138 unsigned long long PerformanceTiming::domainLookupEnd() const |
139 { | 139 { |
140 ResourceLoadTiming* timing = resourceLoadTiming(); | 140 ResourceLoadTiming* timing = resourceLoadTiming(); |
141 if (!timing) | 141 if (!timing) |
142 return domainLookupStart(); | 142 return domainLookupStart(); |
143 | 143 |
144 // This will be -1 when a DNS request is not performed. | 144 // This will be zero when a DNS request is not performed. |
145 // Rather than exposing a special value that indicates no DNS, we "backfill"
with domainLookupStart. | 145 // Rather than exposing a special value that indicates no DNS, we "backfill"
with domainLookupStart. |
146 int dnsEnd = timing->dnsEnd; | 146 double dnsEnd = timing->dnsEnd; |
147 if (dnsEnd < 0) | 147 if (dnsEnd == 0.0) |
148 return domainLookupStart(); | 148 return domainLookupStart(); |
149 | 149 |
150 return resourceLoadTimeRelativeToAbsolute(dnsEnd); | 150 return monotonicTimeToIntegerMilliseconds(dnsEnd); |
151 } | 151 } |
152 | 152 |
153 unsigned long long PerformanceTiming::connectStart() const | 153 unsigned long long PerformanceTiming::connectStart() const |
154 { | 154 { |
155 DocumentLoader* loader = documentLoader(); | 155 DocumentLoader* loader = documentLoader(); |
156 if (!loader) | 156 if (!loader) |
157 return domainLookupEnd(); | 157 return domainLookupEnd(); |
158 | 158 |
159 ResourceLoadTiming* timing = loader->response().resourceLoadTiming(); | 159 ResourceLoadTiming* timing = loader->response().resourceLoadTiming(); |
160 if (!timing) | 160 if (!timing) |
161 return domainLookupEnd(); | 161 return domainLookupEnd(); |
162 | 162 |
163 // connectStart will be -1 when a network request is not made. | 163 // connectStart will be -1 when a network request is not made. |
164 // Rather than exposing a special value that indicates no new connection, we
"backfill" with domainLookupEnd. | 164 // Rather than exposing a special value that indicates no new connection, we
"backfill" with domainLookupEnd. |
165 int connectStart = timing->connectStart; | 165 double connectStart = timing->connectStart; |
166 if (connectStart < 0 || loader->response().connectionReused()) | 166 if (connectStart == 0.0 || loader->response().connectionReused()) |
167 return domainLookupEnd(); | 167 return domainLookupEnd(); |
168 | 168 |
169 // ResourceLoadTiming's connect phase includes DNS, however Navigation Timin
g's | 169 // ResourceLoadTiming's connect phase includes DNS, however Navigation Timin
g's |
170 // connect phase should not. So if there is DNS time, trim it from the start
. | 170 // connect phase should not. So if there is DNS time, trim it from the start
. |
171 if (timing->dnsEnd >= 0 && timing->dnsEnd > connectStart) | 171 if (timing->dnsEnd > 0.0 && timing->dnsEnd > connectStart) |
172 connectStart = timing->dnsEnd; | 172 connectStart = timing->dnsEnd; |
173 | 173 |
174 return resourceLoadTimeRelativeToAbsolute(connectStart); | 174 return monotonicTimeToIntegerMilliseconds(connectStart); |
175 } | 175 } |
176 | 176 |
177 unsigned long long PerformanceTiming::connectEnd() const | 177 unsigned long long PerformanceTiming::connectEnd() const |
178 { | 178 { |
179 DocumentLoader* loader = documentLoader(); | 179 DocumentLoader* loader = documentLoader(); |
180 if (!loader) | 180 if (!loader) |
181 return connectStart(); | 181 return connectStart(); |
182 | 182 |
183 ResourceLoadTiming* timing = loader->response().resourceLoadTiming(); | 183 ResourceLoadTiming* timing = loader->response().resourceLoadTiming(); |
184 if (!timing) | 184 if (!timing) |
185 return connectStart(); | 185 return connectStart(); |
186 | 186 |
187 // connectEnd will be -1 when a network request is not made. | 187 // connectEnd will be zero when a network request is not made. |
188 // Rather than exposing a special value that indicates no new connection, we
"backfill" with connectStart. | 188 // Rather than exposing a special value that indicates no new connection, we
"backfill" with connectStart. |
189 int connectEnd = timing->connectEnd; | 189 double connectEnd = timing->connectEnd; |
190 if (connectEnd < 0 || loader->response().connectionReused()) | 190 if (connectEnd == 0.0 || loader->response().connectionReused()) |
191 return connectStart(); | 191 return connectStart(); |
192 | 192 |
193 return resourceLoadTimeRelativeToAbsolute(connectEnd); | 193 return monotonicTimeToIntegerMilliseconds(connectEnd); |
194 } | 194 } |
195 | 195 |
196 unsigned long long PerformanceTiming::secureConnectionStart() const | 196 unsigned long long PerformanceTiming::secureConnectionStart() const |
197 { | 197 { |
198 DocumentLoader* loader = documentLoader(); | 198 DocumentLoader* loader = documentLoader(); |
199 if (!loader) | 199 if (!loader) |
200 return 0; | 200 return 0; |
201 | 201 |
202 ResourceLoadTiming* timing = loader->response().resourceLoadTiming(); | 202 ResourceLoadTiming* timing = loader->response().resourceLoadTiming(); |
203 if (!timing) | 203 if (!timing) |
204 return 0; | 204 return 0; |
205 | 205 |
206 int sslStart = timing->sslStart; | 206 double sslStart = timing->sslStart; |
207 if (sslStart < 0) | 207 if (sslStart == 0.0) |
208 return 0; | 208 return 0; |
209 | 209 |
210 return resourceLoadTimeRelativeToAbsolute(sslStart); | 210 return monotonicTimeToIntegerMilliseconds(sslStart); |
211 } | 211 } |
212 | 212 |
213 unsigned long long PerformanceTiming::requestStart() const | 213 unsigned long long PerformanceTiming::requestStart() const |
214 { | 214 { |
215 ResourceLoadTiming* timing = resourceLoadTiming(); | 215 ResourceLoadTiming* timing = resourceLoadTiming(); |
216 if (!timing || timing->sendStart < 0) | 216 if (!timing || timing->sendStart == 0.0) |
217 return connectEnd(); | 217 return connectEnd(); |
218 | 218 |
219 return resourceLoadTimeRelativeToAbsolute(timing->sendStart); | 219 return monotonicTimeToIntegerMilliseconds(timing->sendStart); |
220 } | 220 } |
221 | 221 |
222 unsigned long long PerformanceTiming::responseStart() const | 222 unsigned long long PerformanceTiming::responseStart() const |
223 { | 223 { |
224 ResourceLoadTiming* timing = resourceLoadTiming(); | 224 ResourceLoadTiming* timing = resourceLoadTiming(); |
225 if (!timing || timing->receiveHeadersEnd < 0) | 225 if (!timing || timing->receiveHeadersEnd == 0.0) |
226 return requestStart(); | 226 return requestStart(); |
227 | 227 |
228 // FIXME: Response start needs to be the time of the first received byte. | 228 // FIXME: Response start needs to be the time of the first received byte. |
229 // However, the ResourceLoadTiming API currently only supports the time | 229 // However, the ResourceLoadTiming API currently only supports the time |
230 // the last header byte was received. For many responses with reasonable | 230 // the last header byte was received. For many responses with reasonable |
231 // sized cookies, the HTTP headers fit into a single packet so this time | 231 // sized cookies, the HTTP headers fit into a single packet so this time |
232 // is basically equivalent. But for some responses, particularly those with | 232 // is basically equivalent. But for some responses, particularly those with |
233 // headers larger than a single packet, this time will be too late. | 233 // headers larger than a single packet, this time will be too late. |
234 return resourceLoadTimeRelativeToAbsolute(timing->receiveHeadersEnd); | 234 return monotonicTimeToIntegerMilliseconds(timing->receiveHeadersEnd); |
235 } | 235 } |
236 | 236 |
237 unsigned long long PerformanceTiming::responseEnd() const | 237 unsigned long long PerformanceTiming::responseEnd() const |
238 { | 238 { |
239 DocumentLoadTiming* timing = documentLoadTiming(); | 239 DocumentLoadTiming* timing = documentLoadTiming(); |
240 if (!timing) | 240 if (!timing) |
241 return 0; | 241 return 0; |
242 | 242 |
243 return monotonicTimeToIntegerMilliseconds(timing->responseEnd()); | 243 return monotonicTimeToIntegerMilliseconds(timing->responseEnd()); |
244 } | 244 } |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 | 337 |
338 ResourceLoadTiming* PerformanceTiming::resourceLoadTiming() const | 338 ResourceLoadTiming* PerformanceTiming::resourceLoadTiming() const |
339 { | 339 { |
340 DocumentLoader* loader = documentLoader(); | 340 DocumentLoader* loader = documentLoader(); |
341 if (!loader) | 341 if (!loader) |
342 return 0; | 342 return 0; |
343 | 343 |
344 return loader->response().resourceLoadTiming(); | 344 return loader->response().resourceLoadTiming(); |
345 } | 345 } |
346 | 346 |
347 unsigned long long PerformanceTiming::resourceLoadTimeRelativeToAbsolute(int rel
ativeMilliseconds) const | |
348 { | |
349 ASSERT(relativeMilliseconds >= 0); | |
350 ResourceLoadTiming* resourceTiming = resourceLoadTiming(); | |
351 ASSERT(resourceTiming); | |
352 return monotonicTimeToIntegerMilliseconds(resourceTiming->convertResourceLoa
dTimeToMonotonicTime(relativeMilliseconds)); | |
353 } | |
354 | |
355 unsigned long long PerformanceTiming::monotonicTimeToIntegerMilliseconds(double
monotonicSeconds) const | 347 unsigned long long PerformanceTiming::monotonicTimeToIntegerMilliseconds(double
monotonicSeconds) const |
356 { | 348 { |
357 ASSERT(monotonicSeconds >= 0); | 349 ASSERT(monotonicSeconds >= 0); |
358 const DocumentLoadTiming* timing = documentLoadTiming(); | 350 const DocumentLoadTiming* timing = documentLoadTiming(); |
359 ASSERT(timing); | 351 ASSERT(timing); |
360 return toIntegerMilliseconds(timing->monotonicTimeToPseudoWallTime(monotonic
Seconds)); | 352 return toIntegerMilliseconds(timing->monotonicTimeToPseudoWallTime(monotonic
Seconds)); |
361 } | 353 } |
362 | 354 |
363 } // namespace WebCore | 355 } // namespace WebCore |
OLD | NEW |