| 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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 return nullptr; | 624 return nullptr; |
| 625 scopedResourceLoadTracker.resourceLoadContinuesBeyondScope(); | 625 scopedResourceLoadTracker.resourceLoadContinuesBeyondScope(); |
| 626 | 626 |
| 627 DCHECK(!resource->errorOccurred() || | 627 DCHECK(!resource->errorOccurred() || |
| 628 request.options().synchronousPolicy == RequestSynchronously); | 628 request.options().synchronousPolicy == RequestSynchronously); |
| 629 return resource; | 629 return resource; |
| 630 } | 630 } |
| 631 | 631 |
| 632 void ResourceFetcher::resourceTimingReportTimerFired(TimerBase* timer) { | 632 void ResourceFetcher::resourceTimingReportTimerFired(TimerBase* timer) { |
| 633 DCHECK_EQ(timer, &m_resourceTimingReportTimer); | 633 DCHECK_EQ(timer, &m_resourceTimingReportTimer); |
| 634 Vector<std::unique_ptr<ResourceTimingInfo>> timingReports; | 634 Vector<RefPtr<ResourceTimingInfo>> timingReports; |
| 635 timingReports.swap(m_scheduledResourceTimingReports); | 635 timingReports.swap(m_scheduledResourceTimingReports); |
| 636 for (const auto& timingInfo : timingReports) | 636 for (const auto& timingInfo : timingReports) |
| 637 context().addResourceTiming(*timingInfo); | 637 context().addResourceTiming(*timingInfo); |
| 638 } | 638 } |
| 639 | 639 |
| 640 void ResourceFetcher::determineRequestContext(ResourceRequest& request, | 640 void ResourceFetcher::determineRequestContext(ResourceRequest& request, |
| 641 Resource::Type type, | 641 Resource::Type type, |
| 642 bool isMainFrame) { | 642 bool isMainFrame) { |
| 643 WebURLRequest::RequestContext requestContext = | 643 WebURLRequest::RequestContext requestContext = |
| 644 requestContextFromType(isMainFrame, type); | 644 requestContextFromType(isMainFrame, type); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 : monotonicallyIncreasingTime(); | 752 : monotonicallyIncreasingTime(); |
| 753 | 753 |
| 754 // This buffer is created and populated for providing transferSize | 754 // This buffer is created and populated for providing transferSize |
| 755 // and redirect timing opt-in information. | 755 // and redirect timing opt-in information. |
| 756 if (isMainResource) { | 756 if (isMainResource) { |
| 757 DCHECK(!m_navigationTimingInfo); | 757 DCHECK(!m_navigationTimingInfo); |
| 758 m_navigationTimingInfo = | 758 m_navigationTimingInfo = |
| 759 ResourceTimingInfo::create(fetchInitiator, startTime, isMainResource); | 759 ResourceTimingInfo::create(fetchInitiator, startTime, isMainResource); |
| 760 } | 760 } |
| 761 | 761 |
| 762 std::unique_ptr<ResourceTimingInfo> info = | 762 RefPtr<ResourceTimingInfo> info = |
| 763 ResourceTimingInfo::create(fetchInitiator, startTime, isMainResource); | 763 ResourceTimingInfo::create(fetchInitiator, startTime, isMainResource); |
| 764 | 764 |
| 765 if (resource->isCacheValidator()) { | 765 if (resource->isCacheValidator()) { |
| 766 const AtomicString& timingAllowOrigin = | 766 const AtomicString& timingAllowOrigin = |
| 767 resource->response().httpHeaderField(HTTPNames::Timing_Allow_Origin); | 767 resource->response().httpHeaderField(HTTPNames::Timing_Allow_Origin); |
| 768 if (!timingAllowOrigin.isEmpty()) | 768 if (!timingAllowOrigin.isEmpty()) |
| 769 info->setOriginalTimingAllowOrigin(timingAllowOrigin); | 769 info->setOriginalTimingAllowOrigin(timingAllowOrigin); |
| 770 } | 770 } |
| 771 | 771 |
| 772 if (!isMainResource || | 772 if (!isMainResource || |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1159 if (resource->getType() == Resource::MainResource) { | 1159 if (resource->getType() == Resource::MainResource) { |
| 1160 DCHECK(m_navigationTimingInfo); | 1160 DCHECK(m_navigationTimingInfo); |
| 1161 // Store redirect responses that were packed inside the final response. | 1161 // Store redirect responses that were packed inside the final response. |
| 1162 addRedirectsToTimingInfo(resource, m_navigationTimingInfo.get()); | 1162 addRedirectsToTimingInfo(resource, m_navigationTimingInfo.get()); |
| 1163 if (resource->response().isHTTP()) { | 1163 if (resource->response().isHTTP()) { |
| 1164 populateTimingInfo(m_navigationTimingInfo.get(), resource); | 1164 populateTimingInfo(m_navigationTimingInfo.get(), resource); |
| 1165 m_navigationTimingInfo->addFinalTransferSize( | 1165 m_navigationTimingInfo->addFinalTransferSize( |
| 1166 encodedDataLength == -1 ? 0 : encodedDataLength); | 1166 encodedDataLength == -1 ? 0 : encodedDataLength); |
| 1167 } | 1167 } |
| 1168 } | 1168 } |
| 1169 if (std::unique_ptr<ResourceTimingInfo> info = | 1169 if (RefPtr<ResourceTimingInfo> info = |
| 1170 m_resourceTimingInfoMap.take(resource)) { | 1170 m_resourceTimingInfoMap.take(resource)) { |
| 1171 // Store redirect responses that were packed inside the final response. | 1171 // Store redirect responses that were packed inside the final response. |
| 1172 addRedirectsToTimingInfo(resource, info.get()); | 1172 addRedirectsToTimingInfo(resource, info.get()); |
| 1173 | 1173 |
| 1174 if (resource->response().isHTTP() && | 1174 if (resource->response().isHTTP() && |
| 1175 resource->response().httpStatusCode() < 400) { | 1175 resource->response().httpStatusCode() < 400) { |
| 1176 populateTimingInfo(info.get(), resource); | 1176 populateTimingInfo(info.get(), resource); |
| 1177 info->setLoadFinishTime(finishTime); | 1177 info->setLoadFinishTime(finishTime); |
| 1178 // encodedDataLength == -1 means "not available". | 1178 // encodedDataLength == -1 means "not available". |
| 1179 // TODO(ricea): Find cases where it is not available but the | 1179 // TODO(ricea): Find cases where it is not available but the |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1540 visitor->trace(m_context); | 1540 visitor->trace(m_context); |
| 1541 visitor->trace(m_archive); | 1541 visitor->trace(m_archive); |
| 1542 visitor->trace(m_loaders); | 1542 visitor->trace(m_loaders); |
| 1543 visitor->trace(m_nonBlockingLoaders); | 1543 visitor->trace(m_nonBlockingLoaders); |
| 1544 visitor->trace(m_documentResources); | 1544 visitor->trace(m_documentResources); |
| 1545 visitor->trace(m_preloads); | 1545 visitor->trace(m_preloads); |
| 1546 visitor->trace(m_resourceTimingInfoMap); | 1546 visitor->trace(m_resourceTimingInfoMap); |
| 1547 } | 1547 } |
| 1548 | 1548 |
| 1549 } // namespace blink | 1549 } // namespace blink |
| OLD | NEW |