| OLD | NEW |
| 1 /* | 1 /* |
| 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
| 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) | 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) |
| 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) | 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
| 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All | 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All |
| 6 rights reserved. | 6 rights reserved. |
| 7 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ | 7 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ |
| 8 | 8 |
| 9 This library is free software; you can redistribute it and/or | 9 This library is free software; you can redistribute it and/or |
| 10 modify it under the terms of the GNU Library General Public | 10 modify it under the terms of the GNU Library General Public |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 request.resourceRequest().requestContext()); | 305 request.resourceRequest().requestContext()); |
| 306 } | 306 } |
| 307 | 307 |
| 308 if (isStaticData) | 308 if (isStaticData) |
| 309 return; | 309 return; |
| 310 | 310 |
| 311 if (type == ResourceLoadingFromCache && !resource->stillNeedsLoad() && | 311 if (type == ResourceLoadingFromCache && !resource->stillNeedsLoad() && |
| 312 !m_validatedURLs.contains(request.resourceRequest().url())) { | 312 !m_validatedURLs.contains(request.resourceRequest().url())) { |
| 313 // Resources loaded from memory cache should be reported the first time | 313 // Resources loaded from memory cache should be reported the first time |
| 314 // they're used. | 314 // they're used. |
| 315 std::unique_ptr<ResourceTimingInfo> info = ResourceTimingInfo::create( | 315 RefPtr<ResourceTimingInfo> info = ResourceTimingInfo::create( |
| 316 request.options().initiatorInfo.name, monotonicallyIncreasingTime(), | 316 request.options().initiatorInfo.name, monotonicallyIncreasingTime(), |
| 317 resource->getType() == Resource::MainResource); | 317 resource->getType() == Resource::MainResource); |
| 318 populateTimingInfo(info.get(), resource); | 318 populateTimingInfo(info.get(), resource); |
| 319 info->clearLoadTimings(); | 319 info->clearLoadTimings(); |
| 320 info->setLoadFinishTime(info->initialTime()); | 320 info->setLoadFinishTime(info->initialTime()); |
| 321 m_scheduledResourceTimingReports.push_back(std::move(info)); | 321 m_scheduledResourceTimingReports.push_back(info.release()); |
| 322 if (!m_resourceTimingReportTimer.isActive()) | 322 if (!m_resourceTimingReportTimer.isActive()) |
| 323 m_resourceTimingReportTimer.startOneShot(0, BLINK_FROM_HERE); | 323 m_resourceTimingReportTimer.startOneShot(0, BLINK_FROM_HERE); |
| 324 } | 324 } |
| 325 | 325 |
| 326 if (m_validatedURLs.size() >= kMaxValidatedURLsSize) { | 326 if (m_validatedURLs.size() >= kMaxValidatedURLsSize) { |
| 327 m_validatedURLs.clear(); | 327 m_validatedURLs.clear(); |
| 328 } | 328 } |
| 329 m_validatedURLs.insert(request.resourceRequest().url()); | 329 m_validatedURLs.insert(request.resourceRequest().url()); |
| 330 } | 330 } |
| 331 | 331 |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 return nullptr; | 626 return nullptr; |
| 627 scopedResourceLoadTracker.resourceLoadContinuesBeyondScope(); | 627 scopedResourceLoadTracker.resourceLoadContinuesBeyondScope(); |
| 628 | 628 |
| 629 DCHECK(!resource->errorOccurred() || | 629 DCHECK(!resource->errorOccurred() || |
| 630 request.options().synchronousPolicy == RequestSynchronously); | 630 request.options().synchronousPolicy == RequestSynchronously); |
| 631 return resource; | 631 return resource; |
| 632 } | 632 } |
| 633 | 633 |
| 634 void ResourceFetcher::resourceTimingReportTimerFired(TimerBase* timer) { | 634 void ResourceFetcher::resourceTimingReportTimerFired(TimerBase* timer) { |
| 635 DCHECK_EQ(timer, &m_resourceTimingReportTimer); | 635 DCHECK_EQ(timer, &m_resourceTimingReportTimer); |
| 636 Vector<std::unique_ptr<ResourceTimingInfo>> timingReports; | 636 Vector<RefPtr<ResourceTimingInfo>> timingReports; |
| 637 timingReports.swap(m_scheduledResourceTimingReports); | 637 timingReports.swap(m_scheduledResourceTimingReports); |
| 638 for (const auto& timingInfo : timingReports) | 638 for (const auto& timingInfo : timingReports) |
| 639 context().addResourceTiming(*timingInfo); | 639 context().addResourceTiming(*timingInfo); |
| 640 } | 640 } |
| 641 | 641 |
| 642 WebURLRequest::RequestContext ResourceFetcher::determineRequestContext( | 642 WebURLRequest::RequestContext ResourceFetcher::determineRequestContext( |
| 643 Resource::Type type) const { | 643 Resource::Type type) const { |
| 644 return determineRequestContext(type, context().isMainFrame()); | 644 return determineRequestContext(type, context().isMainFrame()); |
| 645 } | 645 } |
| 646 | 646 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 : monotonicallyIncreasingTime(); | 748 : monotonicallyIncreasingTime(); |
| 749 | 749 |
| 750 // This buffer is created and populated for providing transferSize | 750 // This buffer is created and populated for providing transferSize |
| 751 // and redirect timing opt-in information. | 751 // and redirect timing opt-in information. |
| 752 if (isMainResource) { | 752 if (isMainResource) { |
| 753 DCHECK(!m_navigationTimingInfo); | 753 DCHECK(!m_navigationTimingInfo); |
| 754 m_navigationTimingInfo = | 754 m_navigationTimingInfo = |
| 755 ResourceTimingInfo::create(fetchInitiator, startTime, isMainResource); | 755 ResourceTimingInfo::create(fetchInitiator, startTime, isMainResource); |
| 756 } | 756 } |
| 757 | 757 |
| 758 std::unique_ptr<ResourceTimingInfo> info = | 758 RefPtr<ResourceTimingInfo> info = |
| 759 ResourceTimingInfo::create(fetchInitiator, startTime, isMainResource); | 759 ResourceTimingInfo::create(fetchInitiator, startTime, isMainResource); |
| 760 | 760 |
| 761 if (resource->isCacheValidator()) { | 761 if (resource->isCacheValidator()) { |
| 762 const AtomicString& timingAllowOrigin = | 762 const AtomicString& timingAllowOrigin = |
| 763 resource->response().httpHeaderField(HTTPNames::Timing_Allow_Origin); | 763 resource->response().httpHeaderField(HTTPNames::Timing_Allow_Origin); |
| 764 if (!timingAllowOrigin.isEmpty()) | 764 if (!timingAllowOrigin.isEmpty()) |
| 765 info->setOriginalTimingAllowOrigin(timingAllowOrigin); | 765 info->setOriginalTimingAllowOrigin(timingAllowOrigin); |
| 766 } | 766 } |
| 767 | 767 |
| 768 if (!isMainResource || | 768 if (!isMainResource || |
| 769 context().updateTimingInfoForIFrameNavigation(info.get())) { | 769 context().updateTimingInfoForIFrameNavigation(info.get())) { |
| 770 m_resourceTimingInfoMap.insert(resource, std::move(info)); | 770 m_resourceTimingInfoMap.insert(resource, info.release()); |
| 771 } | 771 } |
| 772 } | 772 } |
| 773 | 773 |
| 774 void ResourceFetcher::recordResourceTimingOnRedirect( | 774 void ResourceFetcher::recordResourceTimingOnRedirect( |
| 775 Resource* resource, | 775 Resource* resource, |
| 776 const ResourceResponse& redirectResponse, | 776 const ResourceResponse& redirectResponse, |
| 777 bool crossOrigin) { | 777 bool crossOrigin) { |
| 778 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resource); | 778 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resource); |
| 779 if (it != m_resourceTimingInfoMap.end()) { | 779 if (it != m_resourceTimingInfoMap.end()) { |
| 780 it->value->addRedirect(redirectResponse, crossOrigin); | 780 it->value->addRedirect(redirectResponse, crossOrigin); |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1164 if (resource->getType() == Resource::MainResource) { | 1164 if (resource->getType() == Resource::MainResource) { |
| 1165 DCHECK(m_navigationTimingInfo); | 1165 DCHECK(m_navigationTimingInfo); |
| 1166 // Store redirect responses that were packed inside the final response. | 1166 // Store redirect responses that were packed inside the final response. |
| 1167 addRedirectsToTimingInfo(resource, m_navigationTimingInfo.get()); | 1167 addRedirectsToTimingInfo(resource, m_navigationTimingInfo.get()); |
| 1168 if (resource->response().isHTTP()) { | 1168 if (resource->response().isHTTP()) { |
| 1169 populateTimingInfo(m_navigationTimingInfo.get(), resource); | 1169 populateTimingInfo(m_navigationTimingInfo.get(), resource); |
| 1170 m_navigationTimingInfo->addFinalTransferSize( | 1170 m_navigationTimingInfo->addFinalTransferSize( |
| 1171 encodedDataLength == -1 ? 0 : encodedDataLength); | 1171 encodedDataLength == -1 ? 0 : encodedDataLength); |
| 1172 } | 1172 } |
| 1173 } | 1173 } |
| 1174 if (std::unique_ptr<ResourceTimingInfo> info = | 1174 if (RefPtr<ResourceTimingInfo> info = |
| 1175 m_resourceTimingInfoMap.take(resource)) { | 1175 m_resourceTimingInfoMap.take(resource)) { |
| 1176 // Store redirect responses that were packed inside the final response. | 1176 // Store redirect responses that were packed inside the final response. |
| 1177 addRedirectsToTimingInfo(resource, info.get()); | 1177 addRedirectsToTimingInfo(resource, info.get()); |
| 1178 | 1178 |
| 1179 if (resource->response().isHTTP() && | 1179 if (resource->response().isHTTP() && |
| 1180 resource->response().httpStatusCode() < 400) { | 1180 resource->response().httpStatusCode() < 400) { |
| 1181 populateTimingInfo(info.get(), resource); | 1181 populateTimingInfo(info.get(), resource); |
| 1182 info->setLoadFinishTime(finishTime); | 1182 info->setLoadFinishTime(finishTime); |
| 1183 // encodedDataLength == -1 means "not available". | 1183 // encodedDataLength == -1 means "not available". |
| 1184 // TODO(ricea): Find cases where it is not available but the | 1184 // TODO(ricea): Find cases where it is not available but the |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1546 visitor->trace(m_context); | 1546 visitor->trace(m_context); |
| 1547 visitor->trace(m_archive); | 1547 visitor->trace(m_archive); |
| 1548 visitor->trace(m_loaders); | 1548 visitor->trace(m_loaders); |
| 1549 visitor->trace(m_nonBlockingLoaders); | 1549 visitor->trace(m_nonBlockingLoaders); |
| 1550 visitor->trace(m_documentResources); | 1550 visitor->trace(m_documentResources); |
| 1551 visitor->trace(m_preloads); | 1551 visitor->trace(m_preloads); |
| 1552 visitor->trace(m_resourceTimingInfoMap); | 1552 visitor->trace(m_resourceTimingInfoMap); |
| 1553 } | 1553 } |
| 1554 | 1554 |
| 1555 } // namespace blink | 1555 } // namespace blink |
| OLD | NEW |