| 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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 if (!isResourceTimingBufferFull()) | 329 if (!isResourceTimingBufferFull()) |
| 330 addResourceTimingBuffer(*entry); | 330 addResourceTimingBuffer(*entry); |
| 331 } | 331 } |
| 332 | 332 |
| 333 void PerformanceBase::addNavigationTiming(LocalFrame* frame) { | 333 void PerformanceBase::addNavigationTiming(LocalFrame* frame) { |
| 334 if (!RuntimeEnabledFeatures::performanceNavigationTiming2Enabled()) | 334 if (!RuntimeEnabledFeatures::performanceNavigationTiming2Enabled()) |
| 335 return; | 335 return; |
| 336 DCHECK(frame); | 336 DCHECK(frame); |
| 337 const DocumentLoader* documentLoader = frame->loader().documentLoader(); | 337 const DocumentLoader* documentLoader = frame->loader().documentLoader(); |
| 338 DCHECK(documentLoader); | 338 DCHECK(documentLoader); |
| 339 |
| 339 const DocumentLoadTiming& documentLoadTiming = documentLoader->timing(); | 340 const DocumentLoadTiming& documentLoadTiming = documentLoader->timing(); |
| 340 | 341 |
| 341 const DocumentTiming* documentTiming = | 342 const DocumentTiming* documentTiming = |
| 342 frame->document() ? &(frame->document()->timing()) : nullptr; | 343 frame->document() ? &(frame->document()->timing()) : nullptr; |
| 343 | 344 |
| 344 const ResourceResponse& finalResponse = documentLoader->response(); | 345 const ResourceResponse& finalResponse = documentLoader->response(); |
| 346 ResourceTimingInfo* navigationTimingInfo = |
| 347 documentLoader->getNavigationTimingInfo(); |
| 348 if (!navigationTimingInfo) |
| 349 return; |
| 345 | 350 |
| 346 ResourceLoadTiming* resourceLoadTiming = finalResponse.resourceLoadTiming(); | 351 ResourceLoadTiming* resourceLoadTiming = finalResponse.resourceLoadTiming(); |
| 347 // Don't create a navigation timing instance when | 352 // Don't create a navigation timing instance when |
| 348 // resourceLoadTiming is null, which could happen when visiting non-http sites | 353 // resourceLoadTiming is null, which could happen when visiting non-http sites |
| 349 // such as about:blank or in some error cases. | 354 // such as about:blank or in some error cases. |
| 350 if (!resourceLoadTiming) | 355 if (!resourceLoadTiming) |
| 351 return; | 356 return; |
| 352 double lastRedirectEndTime = documentLoadTiming.redirectEnd(); | 357 double lastRedirectEndTime = documentLoadTiming.redirectEnd(); |
| 353 double finishTime = documentLoadTiming.loadEventEnd(); | 358 double finishTime = documentLoadTiming.loadEventEnd(); |
| 354 | 359 |
| 355 // TODO(sunjian) Implement transfer size. crbug/663187 | 360 unsigned long long transferSize = navigationTimingInfo->transferSize(); |
| 356 unsigned long long transferSize = 0; | |
| 357 unsigned long long encodedBodyLength = finalResponse.encodedBodyLength(); | 361 unsigned long long encodedBodyLength = finalResponse.encodedBodyLength(); |
| 358 unsigned long long decodedBodyLength = finalResponse.decodedBodyLength(); | 362 unsigned long long decodedBodyLength = finalResponse.decodedBodyLength(); |
| 359 bool didReuseConnection = finalResponse.connectionReused(); | 363 bool didReuseConnection = finalResponse.connectionReused(); |
| 360 PerformanceNavigationTiming::NavigationType type = | 364 PerformanceNavigationTiming::NavigationType type = |
| 361 getNavigationType(documentLoader->getNavigationType(), frame->document()); | 365 getNavigationType(documentLoader->getNavigationType(), frame->document()); |
| 362 | 366 |
| 363 m_navigationTiming = new PerformanceNavigationTiming( | 367 m_navigationTiming = new PerformanceNavigationTiming( |
| 364 timeOrigin(), documentLoadTiming.unloadEventStart(), | 368 timeOrigin(), documentLoadTiming.unloadEventStart(), |
| 365 documentLoadTiming.unloadEventEnd(), documentLoadTiming.loadEventStart(), | 369 documentLoadTiming.unloadEventEnd(), documentLoadTiming.loadEventStart(), |
| 366 documentLoadTiming.loadEventEnd(), documentLoadTiming.redirectCount(), | 370 documentLoadTiming.loadEventEnd(), documentLoadTiming.redirectCount(), |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 visitor->trace(m_resourceTimingBuffer); | 558 visitor->trace(m_resourceTimingBuffer); |
| 555 visitor->trace(m_navigationTiming); | 559 visitor->trace(m_navigationTiming); |
| 556 visitor->trace(m_userTiming); | 560 visitor->trace(m_userTiming); |
| 557 visitor->trace(m_observers); | 561 visitor->trace(m_observers); |
| 558 visitor->trace(m_activeObservers); | 562 visitor->trace(m_activeObservers); |
| 559 visitor->trace(m_suspendedObservers); | 563 visitor->trace(m_suspendedObservers); |
| 560 EventTargetWithInlineData::trace(visitor); | 564 EventTargetWithInlineData::trace(visitor); |
| 561 } | 565 } |
| 562 | 566 |
| 563 } // namespace blink | 567 } // namespace blink |
| OLD | NEW |