| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 | 120 |
| 121 return monotonicTimeToIntegerMilliseconds(timing->fetchStart()); | 121 return monotonicTimeToIntegerMilliseconds(timing->fetchStart()); |
| 122 } | 122 } |
| 123 | 123 |
| 124 unsigned long long PerformanceTiming::domainLookupStart() const | 124 unsigned long long PerformanceTiming::domainLookupStart() const |
| 125 { | 125 { |
| 126 ResourceLoadTiming* timing = resourceLoadTiming(); | 126 ResourceLoadTiming* timing = resourceLoadTiming(); |
| 127 if (!timing) | 127 if (!timing) |
| 128 return fetchStart(); | 128 return fetchStart(); |
| 129 | 129 |
| 130 #ifdef ENABLE_DOUBLE_RESOURCE_LOAD_TIMING |
| 131 // This will be zero when a DNS request is not performed. |
| 132 // Rather than exposing a special value that indicates no DNS, we "backfill"
with fetchStart. |
| 133 double dnsStart = timing->dnsStart; |
| 134 if (dnsStart == 0.0) |
| 135 return fetchStart(); |
| 136 |
| 137 return monotonicTimeToIntegerMilliseconds(dnsStart); |
| 138 #else |
| 130 // This will be -1 when a DNS request is not performed. | 139 // This will be -1 when a DNS request is not performed. |
| 131 // Rather than exposing a special value that indicates no DNS, we "backfill"
with fetchStart. | 140 // Rather than exposing a special value that indicates no DNS, we "backfill"
with fetchStart. |
| 132 int dnsStart = timing->dnsStart; | 141 int dnsStart = timing->dnsStart; |
| 133 if (dnsStart < 0) | 142 if (dnsStart < 0) |
| 134 return fetchStart(); | 143 return fetchStart(); |
| 135 | 144 |
| 136 return resourceLoadTimeRelativeToAbsolute(dnsStart); | 145 return resourceLoadTimeRelativeToAbsolute(dnsStart); |
| 146 #endif |
| 137 } | 147 } |
| 138 | 148 |
| 139 unsigned long long PerformanceTiming::domainLookupEnd() const | 149 unsigned long long PerformanceTiming::domainLookupEnd() const |
| 140 { | 150 { |
| 141 ResourceLoadTiming* timing = resourceLoadTiming(); | 151 ResourceLoadTiming* timing = resourceLoadTiming(); |
| 142 if (!timing) | 152 if (!timing) |
| 143 return domainLookupStart(); | 153 return domainLookupStart(); |
| 144 | 154 |
| 155 #ifdef ENABLE_DOUBLE_RESOURCE_LOAD_TIMING |
| 156 // This will be zero when a DNS request is not performed. |
| 157 // Rather than exposing a special value that indicates no DNS, we "backfill"
with domainLookupStart. |
| 158 double dnsEnd = timing->dnsEnd; |
| 159 if (dnsEnd == 0.0) |
| 160 return domainLookupStart(); |
| 161 |
| 162 return monotonicTimeToIntegerMilliseconds(dnsEnd); |
| 163 #else |
| 145 // This will be -1 when a DNS request is not performed. | 164 // This will be -1 when a DNS request is not performed. |
| 146 // Rather than exposing a special value that indicates no DNS, we "backfill"
with domainLookupStart. | 165 // Rather than exposing a special value that indicates no DNS, we "backfill"
with domainLookupStart. |
| 147 int dnsEnd = timing->dnsEnd; | 166 int dnsEnd = timing->dnsEnd; |
| 148 if (dnsEnd < 0) | 167 if (dnsEnd < 0) |
| 149 return domainLookupStart(); | 168 return domainLookupStart(); |
| 150 | 169 |
| 151 return resourceLoadTimeRelativeToAbsolute(dnsEnd); | 170 return resourceLoadTimeRelativeToAbsolute(dnsEnd); |
| 171 #endif |
| 152 } | 172 } |
| 153 | 173 |
| 154 unsigned long long PerformanceTiming::connectStart() const | 174 unsigned long long PerformanceTiming::connectStart() const |
| 155 { | 175 { |
| 156 DocumentLoader* loader = documentLoader(); | 176 DocumentLoader* loader = documentLoader(); |
| 157 if (!loader) | 177 if (!loader) |
| 158 return domainLookupEnd(); | 178 return domainLookupEnd(); |
| 159 | 179 |
| 160 ResourceLoadTiming* timing = loader->response().resourceLoadTiming(); | 180 ResourceLoadTiming* timing = loader->response().resourceLoadTiming(); |
| 161 if (!timing) | 181 if (!timing) |
| 162 return domainLookupEnd(); | 182 return domainLookupEnd(); |
| 163 | 183 |
| 184 #ifdef ENABLE_DOUBLE_RESOURCE_LOAD_TIMING |
| 185 // connectStart will be zero when a network request is not made. |
| 186 // Rather than exposing a special value that indicates no new connection, we
"backfill" with domainLookupEnd. |
| 187 double connectStart = timing->connectStart; |
| 188 if (connectStart == 0.0 || loader->response().connectionReused()) |
| 189 return domainLookupEnd(); |
| 190 |
| 191 // ResourceLoadTiming's connect phase includes DNS, however Navigation Timin
g's |
| 192 // connect phase should not. So if there is DNS time, trim it from the start
. |
| 193 if (timing->dnsEnd > 0.0 && timing->dnsEnd > connectStart) |
| 194 connectStart = timing->dnsEnd; |
| 195 |
| 196 return monotonicTimeToIntegerMilliseconds(connectStart); |
| 197 #else |
| 164 // connectStart will be -1 when a network request is not made. | 198 // connectStart will be -1 when a network request is not made. |
| 165 // Rather than exposing a special value that indicates no new connection, we
"backfill" with domainLookupEnd. | 199 // Rather than exposing a special value that indicates no new connection, we
"backfill" with domainLookupEnd. |
| 166 int connectStart = timing->connectStart; | 200 int connectStart = timing->connectStart; |
| 167 if (connectStart < 0 || loader->response().connectionReused()) | 201 if (connectStart < 0 || loader->response().connectionReused()) |
| 168 return domainLookupEnd(); | 202 return domainLookupEnd(); |
| 169 | 203 |
| 170 // ResourceLoadTiming's connect phase includes DNS, however Navigation Timin
g's | 204 // ResourceLoadTiming's connect phase includes DNS, however Navigation Timin
g's |
| 171 // connect phase should not. So if there is DNS time, trim it from the start
. | 205 // connect phase should not. So if there is DNS time, trim it from the start
. |
| 172 if (timing->dnsEnd >= 0 && timing->dnsEnd > connectStart) | 206 if (timing->dnsEnd >= 0 && timing->dnsEnd > connectStart) |
| 173 connectStart = timing->dnsEnd; | 207 connectStart = timing->dnsEnd; |
| 174 | 208 |
| 175 return resourceLoadTimeRelativeToAbsolute(connectStart); | 209 return resourceLoadTimeRelativeToAbsolute(connectStart); |
| 210 #endif |
| 176 } | 211 } |
| 177 | 212 |
| 178 unsigned long long PerformanceTiming::connectEnd() const | 213 unsigned long long PerformanceTiming::connectEnd() const |
| 179 { | 214 { |
| 180 DocumentLoader* loader = documentLoader(); | 215 DocumentLoader* loader = documentLoader(); |
| 181 if (!loader) | 216 if (!loader) |
| 182 return connectStart(); | 217 return connectStart(); |
| 183 | 218 |
| 184 ResourceLoadTiming* timing = loader->response().resourceLoadTiming(); | 219 ResourceLoadTiming* timing = loader->response().resourceLoadTiming(); |
| 185 if (!timing) | 220 if (!timing) |
| 186 return connectStart(); | 221 return connectStart(); |
| 187 | 222 |
| 223 #ifdef ENABLE_DOUBLE_RESOURCE_LOAD_TIMING |
| 224 // connectEnd will be zero when a network request is not made. |
| 225 // Rather than exposing a special value that indicates no new connection, we
"backfill" with connectStart. |
| 226 double connectEnd = timing->connectEnd; |
| 227 if (connectEnd == 0.0 || loader->response().connectionReused()) |
| 228 return connectStart(); |
| 229 |
| 230 return monotonicTimeToIntegerMilliseconds(connectEnd); |
| 231 #else |
| 188 // connectEnd will be -1 when a network request is not made. | 232 // connectEnd will be -1 when a network request is not made. |
| 189 // Rather than exposing a special value that indicates no new connection, we
"backfill" with connectStart. | 233 // Rather than exposing a special value that indicates no new connection, we
"backfill" with connectStart. |
| 190 int connectEnd = timing->connectEnd; | 234 int connectEnd = timing->connectEnd; |
| 191 if (connectEnd < 0 || loader->response().connectionReused()) | 235 if (connectEnd < 0 || loader->response().connectionReused()) |
| 192 return connectStart(); | 236 return connectStart(); |
| 193 | 237 |
| 194 return resourceLoadTimeRelativeToAbsolute(connectEnd); | 238 return resourceLoadTimeRelativeToAbsolute(connectEnd); |
| 239 #endif |
| 195 } | 240 } |
| 196 | 241 |
| 197 unsigned long long PerformanceTiming::secureConnectionStart() const | 242 unsigned long long PerformanceTiming::secureConnectionStart() const |
| 198 { | 243 { |
| 199 DocumentLoader* loader = documentLoader(); | 244 DocumentLoader* loader = documentLoader(); |
| 200 if (!loader) | 245 if (!loader) |
| 201 return 0; | 246 return 0; |
| 202 | 247 |
| 203 ResourceLoadTiming* timing = loader->response().resourceLoadTiming(); | 248 ResourceLoadTiming* timing = loader->response().resourceLoadTiming(); |
| 204 if (!timing) | 249 if (!timing) |
| 205 return 0; | 250 return 0; |
| 206 | 251 |
| 252 #ifdef ENABLE_DOUBLE_RESOURCE_LOAD_TIMING |
| 253 double sslStart = timing->sslStart; |
| 254 if (sslStart == 0.0) |
| 255 return 0; |
| 256 |
| 257 return monotonicTimeToIntegerMilliseconds(sslStart); |
| 258 #else |
| 207 int sslStart = timing->sslStart; | 259 int sslStart = timing->sslStart; |
| 208 if (sslStart < 0) | 260 if (sslStart < 0) |
| 209 return 0; | 261 return 0; |
| 210 | 262 |
| 211 return resourceLoadTimeRelativeToAbsolute(sslStart); | 263 return resourceLoadTimeRelativeToAbsolute(sslStart); |
| 264 #endif |
| 212 } | 265 } |
| 213 | 266 |
| 214 unsigned long long PerformanceTiming::requestStart() const | 267 unsigned long long PerformanceTiming::requestStart() const |
| 215 { | 268 { |
| 216 ResourceLoadTiming* timing = resourceLoadTiming(); | 269 ResourceLoadTiming* timing = resourceLoadTiming(); |
| 270 |
| 271 #ifdef ENABLE_DOUBLE_RESOURCE_LOAD_TIMING |
| 272 if (!timing || timing->sendStart == 0.0) |
| 273 return connectEnd(); |
| 274 |
| 275 return monotonicTimeToIntegerMilliseconds(timing->sendStart); |
| 276 #else |
| 217 if (!timing || timing->sendStart < 0) | 277 if (!timing || timing->sendStart < 0) |
| 218 return connectEnd(); | 278 return connectEnd(); |
| 219 | 279 |
| 220 return resourceLoadTimeRelativeToAbsolute(timing->sendStart); | 280 return resourceLoadTimeRelativeToAbsolute(timing->sendStart); |
| 281 #endif |
| 221 } | 282 } |
| 222 | 283 |
| 223 unsigned long long PerformanceTiming::responseStart() const | 284 unsigned long long PerformanceTiming::responseStart() const |
| 224 { | 285 { |
| 225 ResourceLoadTiming* timing = resourceLoadTiming(); | 286 ResourceLoadTiming* timing = resourceLoadTiming(); |
| 287 #ifdef ENABLE_DOUBLE_RESOURCE_LOAD_TIMING |
| 288 if (!timing || timing->receiveHeadersEnd == 0.0) |
| 289 return requestStart(); |
| 290 #else |
| 226 if (!timing || timing->receiveHeadersEnd < 0) | 291 if (!timing || timing->receiveHeadersEnd < 0) |
| 227 return requestStart(); | 292 return requestStart(); |
| 228 | 293 #endif |
| 229 // FIXME: Response start needs to be the time of the first received byte. | 294 // FIXME: Response start needs to be the time of the first received byte. |
| 230 // However, the ResourceLoadTiming API currently only supports the time | 295 // However, the ResourceLoadTiming API currently only supports the time |
| 231 // the last header byte was received. For many responses with reasonable | 296 // the last header byte was received. For many responses with reasonable |
| 232 // sized cookies, the HTTP headers fit into a single packet so this time | 297 // sized cookies, the HTTP headers fit into a single packet so this time |
| 233 // is basically equivalent. But for some responses, particularly those with | 298 // is basically equivalent. But for some responses, particularly those with |
| 234 // headers larger than a single packet, this time will be too late. | 299 // headers larger than a single packet, this time will be too late. |
| 300 #ifdef ENABLE_DOUBLE_RESOURCE_LOAD_TIMING |
| 301 return monotonicTimeToIntegerMilliseconds(timing->receiveHeadersEnd); |
| 302 #else |
| 235 return resourceLoadTimeRelativeToAbsolute(timing->receiveHeadersEnd); | 303 return resourceLoadTimeRelativeToAbsolute(timing->receiveHeadersEnd); |
| 304 #endif |
| 236 } | 305 } |
| 237 | 306 |
| 238 unsigned long long PerformanceTiming::responseEnd() const | 307 unsigned long long PerformanceTiming::responseEnd() const |
| 239 { | 308 { |
| 240 DocumentLoadTiming* timing = documentLoadTiming(); | 309 DocumentLoadTiming* timing = documentLoadTiming(); |
| 241 if (!timing) | 310 if (!timing) |
| 242 return 0; | 311 return 0; |
| 243 | 312 |
| 244 return monotonicTimeToIntegerMilliseconds(timing->responseEnd()); | 313 return monotonicTimeToIntegerMilliseconds(timing->responseEnd()); |
| 245 } | 314 } |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 | 407 |
| 339 ResourceLoadTiming* PerformanceTiming::resourceLoadTiming() const | 408 ResourceLoadTiming* PerformanceTiming::resourceLoadTiming() const |
| 340 { | 409 { |
| 341 DocumentLoader* loader = documentLoader(); | 410 DocumentLoader* loader = documentLoader(); |
| 342 if (!loader) | 411 if (!loader) |
| 343 return 0; | 412 return 0; |
| 344 | 413 |
| 345 return loader->response().resourceLoadTiming(); | 414 return loader->response().resourceLoadTiming(); |
| 346 } | 415 } |
| 347 | 416 |
| 417 #ifndef ENABLE_DOUBLE_RESOURCE_LOAD_TIMING |
| 348 unsigned long long PerformanceTiming::resourceLoadTimeRelativeToAbsolute(int rel
ativeMilliseconds) const | 418 unsigned long long PerformanceTiming::resourceLoadTimeRelativeToAbsolute(int rel
ativeMilliseconds) const |
| 349 { | 419 { |
| 350 ASSERT(relativeMilliseconds >= 0); | 420 ASSERT(relativeMilliseconds >= 0); |
| 351 ResourceLoadTiming* resourceTiming = resourceLoadTiming(); | 421 ResourceLoadTiming* resourceTiming = resourceLoadTiming(); |
| 352 ASSERT(resourceTiming); | 422 ASSERT(resourceTiming); |
| 353 return monotonicTimeToIntegerMilliseconds(resourceTiming->convertResourceLoa
dTimeToMonotonicTime(relativeMilliseconds)); | 423 return monotonicTimeToIntegerMilliseconds(resourceTiming->convertResourceLoa
dTimeToMonotonicTime(relativeMilliseconds)); |
| 354 } | 424 } |
| 425 #endif |
| 355 | 426 |
| 356 unsigned long long PerformanceTiming::monotonicTimeToIntegerMilliseconds(double
monotonicSeconds) const | 427 unsigned long long PerformanceTiming::monotonicTimeToIntegerMilliseconds(double
monotonicSeconds) const |
| 357 { | 428 { |
| 358 ASSERT(monotonicSeconds >= 0); | 429 ASSERT(monotonicSeconds >= 0); |
| 359 const DocumentLoadTiming* timing = documentLoadTiming(); | 430 const DocumentLoadTiming* timing = documentLoadTiming(); |
| 360 ASSERT(timing); | 431 ASSERT(timing); |
| 361 return toIntegerMilliseconds(timing->monotonicTimeToPseudoWallTime(monotonic
Seconds)); | 432 return toIntegerMilliseconds(timing->monotonicTimeToPseudoWallTime(monotonic
Seconds)); |
| 362 } | 433 } |
| 363 | 434 |
| 364 } // namespace WebCore | 435 } // namespace WebCore |
| OLD | NEW |