OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * Copyright (C) 2012 Intel Inc. All rights reserved. | 3 * Copyright (C) 2012 Intel Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
338 DCHECK(documentLoader); | 338 DCHECK(documentLoader); |
339 | 339 |
340 const DocumentLoadTiming& documentLoadTiming = documentLoader->timing(); | 340 const DocumentLoadTiming& documentLoadTiming = documentLoader->timing(); |
341 | 341 |
342 const DocumentTiming* documentTiming = | 342 const DocumentTiming* documentTiming = |
343 frame->document() ? &(frame->document()->timing()) : nullptr; | 343 frame->document() ? &(frame->document()->timing()) : nullptr; |
344 | 344 |
345 const ResourceResponse& finalResponse = documentLoader->response(); | 345 const ResourceResponse& finalResponse = documentLoader->response(); |
346 ResourceTimingInfo* resourceTimingInfo = | 346 ResourceTimingInfo* resourceTimingInfo = |
347 documentLoader->getMainResourceTimingInfo(); | 347 documentLoader->getMainResourceTimingInfo(); |
348 | |
348 // Don't create navigation timing instance when resourceTimingInfo | 349 // Don't create navigation timing instance when resourceTimingInfo |
349 // is null, which could happen when it is an iframe navigation restored | 350 // is null, which could happen when it is an iframe navigation restored |
350 // from history, since its location may have been changed after initial | 351 // from history, since its location may have been changed after initial |
351 // navigation. | 352 // navigation. |
352 if (!resourceTimingInfo) | 353 if (!resourceTimingInfo) |
353 return; | 354 return; |
354 | 355 |
355 ResourceLoadTiming* resourceLoadTiming = finalResponse.resourceLoadTiming(); | 356 ResourceLoadTiming* resourceLoadTiming = finalResponse.resourceLoadTiming(); |
356 // Don't create a navigation timing instance when | 357 // Don't create a navigation timing instance when |
357 // resourceLoadTiming is null, which could happen when visiting non-http sites | 358 // resourceLoadTiming is null, which could happen when visiting non-http sites |
358 // such as about:blank or in some error cases. | 359 // such as about:blank or in some error cases. |
359 if (!resourceLoadTiming) | 360 if (!resourceLoadTiming) |
360 return; | 361 return; |
361 double lastRedirectEndTime = documentLoadTiming.redirectEnd(); | 362 double lastRedirectEndTime = documentLoadTiming.redirectEnd(); |
362 double finishTime = documentLoadTiming.loadEventEnd(); | 363 double finishTime = documentLoadTiming.loadEventEnd(); |
363 | 364 |
365 SecurityOrigin* securityOrigin = nullptr; | |
366 ExecutionContext* context = getExecutionContext(); | |
367 if (context) | |
368 securityOrigin = context->getSecurityOrigin(); | |
369 if (!securityOrigin) | |
370 return; | |
panicker
2016/12/05 19:11:52
Factor code above into a helper method getSecurity
sunjian
2016/12/06 19:46:44
Done.
| |
371 | |
372 const Vector<ResourceResponse>& redirectChain = | |
panicker
2016/12/05 19:11:52
no need for temp variable?
sunjian
2016/12/06 19:46:44
Done.
| |
373 resourceTimingInfo->redirectChain(); | |
374 bool allowRedirectDetails = allowsTimingRedirect(redirectChain, finalResponse, | |
panicker
2016/12/05 19:11:52
let's add a unittest for allowTimingRedirect(..)
sunjian
2016/12/06 19:46:44
Done.
| |
375 *securityOrigin, context); | |
376 | |
364 unsigned long long transferSize = resourceTimingInfo->transferSize(); | 377 unsigned long long transferSize = resourceTimingInfo->transferSize(); |
365 unsigned long long encodedBodyLength = finalResponse.encodedBodyLength(); | 378 unsigned long long encodedBodyLength = finalResponse.encodedBodyLength(); |
366 unsigned long long decodedBodyLength = finalResponse.decodedBodyLength(); | 379 unsigned long long decodedBodyLength = finalResponse.decodedBodyLength(); |
367 bool didReuseConnection = finalResponse.connectionReused(); | 380 bool didReuseConnection = finalResponse.connectionReused(); |
368 PerformanceNavigationTiming::NavigationType type = | 381 PerformanceNavigationTiming::NavigationType type = |
369 getNavigationType(documentLoader->getNavigationType(), frame->document()); | 382 getNavigationType(documentLoader->getNavigationType(), frame->document()); |
370 | 383 |
371 m_navigationTiming = new PerformanceNavigationTiming( | 384 m_navigationTiming = new PerformanceNavigationTiming( |
372 timeOrigin(), documentLoadTiming.unloadEventStart(), | 385 timeOrigin(), documentLoadTiming.unloadEventStart(), |
373 documentLoadTiming.unloadEventEnd(), documentLoadTiming.loadEventStart(), | 386 documentLoadTiming.unloadEventEnd(), documentLoadTiming.loadEventStart(), |
374 documentLoadTiming.loadEventEnd(), documentLoadTiming.redirectCount(), | 387 documentLoadTiming.loadEventEnd(), documentLoadTiming.redirectCount(), |
375 documentTiming ? documentTiming->domInteractive() : 0, | 388 documentTiming ? documentTiming->domInteractive() : 0, |
376 documentTiming ? documentTiming->domContentLoadedEventStart() : 0, | 389 documentTiming ? documentTiming->domContentLoadedEventStart() : 0, |
377 documentTiming ? documentTiming->domContentLoadedEventEnd() : 0, | 390 documentTiming ? documentTiming->domContentLoadedEventEnd() : 0, |
378 documentTiming ? documentTiming->domComplete() : 0, type, | 391 documentTiming ? documentTiming->domComplete() : 0, type, |
379 documentLoadTiming.redirectStart(), documentLoadTiming.redirectEnd(), | 392 documentLoadTiming.redirectStart(), documentLoadTiming.redirectEnd(), |
380 documentLoadTiming.fetchStart(), documentLoadTiming.responseEnd(), | 393 documentLoadTiming.fetchStart(), documentLoadTiming.responseEnd(), |
381 documentLoadTiming.hasCrossOriginRedirect(), | 394 allowRedirectDetails, |
382 documentLoadTiming.hasSameOriginAsPreviousDocument(), resourceLoadTiming, | 395 documentLoadTiming.hasSameOriginAsPreviousDocument(), resourceLoadTiming, |
383 lastRedirectEndTime, finishTime, transferSize, encodedBodyLength, | 396 lastRedirectEndTime, finishTime, transferSize, encodedBodyLength, |
384 decodedBodyLength, didReuseConnection); | 397 decodedBodyLength, didReuseConnection); |
385 notifyObserversOfEntry(*m_navigationTiming); | 398 notifyObserversOfEntry(*m_navigationTiming); |
386 } | 399 } |
387 | 400 |
388 void PerformanceBase::addResourceTimingBuffer(PerformanceEntry& entry) { | 401 void PerformanceBase::addResourceTimingBuffer(PerformanceEntry& entry) { |
389 m_resourceTimingBuffer.append(&entry); | 402 m_resourceTimingBuffer.append(&entry); |
390 | 403 |
391 if (isResourceTimingBufferFull()) { | 404 if (isResourceTimingBufferFull()) { |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
562 visitor->trace(m_resourceTimingBuffer); | 575 visitor->trace(m_resourceTimingBuffer); |
563 visitor->trace(m_navigationTiming); | 576 visitor->trace(m_navigationTiming); |
564 visitor->trace(m_userTiming); | 577 visitor->trace(m_userTiming); |
565 visitor->trace(m_observers); | 578 visitor->trace(m_observers); |
566 visitor->trace(m_activeObservers); | 579 visitor->trace(m_activeObservers); |
567 visitor->trace(m_suspendedObservers); | 580 visitor->trace(m_suspendedObservers); |
568 EventTargetWithInlineData::trace(visitor); | 581 EventTargetWithInlineData::trace(visitor); |
569 } | 582 } |
570 | 583 |
571 } // namespace blink | 584 } // namespace blink |
OLD | NEW |