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 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 if (resource->isCacheValidator()) { | 770 if (resource->isCacheValidator()) { |
771 const AtomicString& timingAllowOrigin = | 771 const AtomicString& timingAllowOrigin = |
772 resource->response().httpHeaderField(HTTPNames::Timing_Allow_Origin); | 772 resource->response().httpHeaderField(HTTPNames::Timing_Allow_Origin); |
773 if (!timingAllowOrigin.isEmpty()) | 773 if (!timingAllowOrigin.isEmpty()) |
774 info->setOriginalTimingAllowOrigin(timingAllowOrigin); | 774 info->setOriginalTimingAllowOrigin(timingAllowOrigin); |
775 } | 775 } |
776 | 776 |
777 if (!isMainResource || | 777 if (!isMainResource || |
778 context().updateTimingInfoForIFrameNavigation(info.get())) | 778 context().updateTimingInfoForIFrameNavigation(info.get())) |
779 m_resourceTimingInfoMap.add(resource, std::move(info)); | 779 m_resourceTimingInfoMap.add(resource, std::move(info)); |
| 780 else |
| 781 m_mainResourceTimingInfoMap.add(resource->identifier(), std::move(info)); |
780 } | 782 } |
781 | 783 |
782 ResourceFetcher::RevalidationPolicy | 784 ResourceFetcher::RevalidationPolicy |
783 ResourceFetcher::determineRevalidationPolicy(Resource::Type type, | 785 ResourceFetcher::determineRevalidationPolicy(Resource::Type type, |
784 const FetchRequest& fetchRequest, | 786 const FetchRequest& fetchRequest, |
785 Resource* existingResource, | 787 Resource* existingResource, |
786 bool isStaticData) const { | 788 bool isStaticData) const { |
787 const ResourceRequest& request = fetchRequest.resourceRequest(); | 789 const ResourceRequest& request = fetchRequest.resourceRequest(); |
788 | 790 |
789 if (!existingResource) | 791 if (!existingResource) |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 } | 1113 } |
1112 | 1114 |
1113 ArchiveResource* ResourceFetcher::createArchive(Resource* resource) { | 1115 ArchiveResource* ResourceFetcher::createArchive(Resource* resource) { |
1114 // Only the top-frame can load MHTML. | 1116 // Only the top-frame can load MHTML. |
1115 if (!context().isMainFrame()) | 1117 if (!context().isMainFrame()) |
1116 return nullptr; | 1118 return nullptr; |
1117 m_archive = MHTMLArchive::create(resource->url(), resource->resourceBuffer()); | 1119 m_archive = MHTMLArchive::create(resource->url(), resource->resourceBuffer()); |
1118 return m_archive ? m_archive->mainResource() : nullptr; | 1120 return m_archive ? m_archive->mainResource() : nullptr; |
1119 } | 1121 } |
1120 | 1122 |
| 1123 ResourceTimingInfo* ResourceFetcher::getMainResourceTimingInfo( |
| 1124 unsigned long identifier) { |
| 1125 MainResourceTimingInfoMap::iterator it = |
| 1126 m_mainResourceTimingInfoMap.find(identifier); |
| 1127 if (it != m_mainResourceTimingInfoMap.end()) { |
| 1128 return it->value.get(); |
| 1129 } |
| 1130 return nullptr; |
| 1131 } |
| 1132 |
1121 void ResourceFetcher::didFinishLoading(Resource* resource, | 1133 void ResourceFetcher::didFinishLoading(Resource* resource, |
1122 double finishTime, | 1134 double finishTime, |
1123 int64_t encodedDataLength, | 1135 int64_t encodedDataLength, |
1124 DidFinishLoadingReason finishReason) { | 1136 DidFinishLoadingReason finishReason) { |
1125 network_instrumentation::endResourceLoad( | 1137 network_instrumentation::endResourceLoad( |
1126 resource->identifier(), network_instrumentation::RequestOutcome::Success); | 1138 resource->identifier(), network_instrumentation::RequestOutcome::Success); |
1127 DCHECK(resource); | 1139 DCHECK(resource); |
1128 | 1140 |
1129 // When loading a multipart resource, make the loader non-block when finishing | 1141 // When loading a multipart resource, make the loader non-block when finishing |
1130 // loading the first part. | 1142 // loading the first part. |
1131 if (finishReason == DidFinishFirstPartInMultipart) | 1143 if (finishReason == DidFinishFirstPartInMultipart) |
1132 moveResourceLoaderToNonBlocking(resource->loader()); | 1144 moveResourceLoaderToNonBlocking(resource->loader()); |
1133 else | 1145 else |
1134 removeResourceLoader(resource->loader()); | 1146 removeResourceLoader(resource->loader()); |
1135 DCHECK(!m_loaders.contains(resource->loader())); | 1147 DCHECK(!m_loaders.contains(resource->loader())); |
1136 DCHECK(finishReason == DidFinishFirstPartInMultipart || | 1148 DCHECK(finishReason == DidFinishFirstPartInMultipart || |
1137 !m_nonBlockingLoaders.contains(resource->loader())); | 1149 !m_nonBlockingLoaders.contains(resource->loader())); |
1138 | 1150 |
| 1151 MainResourceTimingInfoMap::iterator it = |
| 1152 m_mainResourceTimingInfoMap.find(resource->identifier()); |
| 1153 if (it != m_mainResourceTimingInfoMap.end()) { |
| 1154 // Store redirect responses that were packed inside the final response. |
| 1155 const Vector<ResourceResponse>& responses = |
| 1156 resource->response().redirectResponses(); |
| 1157 for (size_t i = 0; i < responses.size(); ++i) { |
| 1158 const KURL& newURL = i + 1 < responses.size() |
| 1159 ? KURL(responses[i + 1].url()) |
| 1160 : resource->resourceRequest().url(); |
| 1161 bool crossOrigin = IsCrossOrigin(responses[i].url(), newURL); |
| 1162 it->value->addRedirect(responses[i], crossOrigin); |
| 1163 } |
| 1164 it->value->addFinalTransferSize( |
| 1165 encodedDataLength == -1 ? 0 : encodedDataLength); |
| 1166 } |
1139 if (std::unique_ptr<ResourceTimingInfo> info = | 1167 if (std::unique_ptr<ResourceTimingInfo> info = |
1140 m_resourceTimingInfoMap.take(resource)) { | 1168 m_resourceTimingInfoMap.take(resource)) { |
1141 // Store redirect responses that were packed inside the final response. | 1169 // Store redirect responses that were packed inside the final response. |
1142 const Vector<ResourceResponse>& responses = | 1170 const Vector<ResourceResponse>& responses = |
1143 resource->response().redirectResponses(); | 1171 resource->response().redirectResponses(); |
1144 for (size_t i = 0; i < responses.size(); ++i) { | 1172 for (size_t i = 0; i < responses.size(); ++i) { |
1145 const KURL& newURL = i + 1 < responses.size() | 1173 const KURL& newURL = i + 1 < responses.size() |
1146 ? KURL(responses[i + 1].url()) | 1174 ? KURL(responses[i + 1].url()) |
1147 : resource->resourceRequest().url(); | 1175 : resource->resourceRequest().url(); |
1148 bool crossOrigin = IsCrossOrigin(responses[i].url(), newURL); | 1176 bool crossOrigin = IsCrossOrigin(responses[i].url(), newURL); |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1396 if (resource->getType() == Resource::Image && | 1424 if (resource->getType() == Resource::Image && |
1397 shouldDeferImageLoad(newRequest.url())) | 1425 shouldDeferImageLoad(newRequest.url())) |
1398 return false; | 1426 return false; |
1399 } | 1427 } |
1400 | 1428 |
1401 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resource); | 1429 ResourceTimingInfoMap::iterator it = m_resourceTimingInfoMap.find(resource); |
1402 if (it != m_resourceTimingInfoMap.end()) { | 1430 if (it != m_resourceTimingInfoMap.end()) { |
1403 bool crossOrigin = IsCrossOrigin(redirectResponse.url(), newRequest.url()); | 1431 bool crossOrigin = IsCrossOrigin(redirectResponse.url(), newRequest.url()); |
1404 it->value->addRedirect(redirectResponse, crossOrigin); | 1432 it->value->addRedirect(redirectResponse, crossOrigin); |
1405 } | 1433 } |
| 1434 MainResourceTimingInfoMap::iterator itt = |
| 1435 m_mainResourceTimingInfoMap.find(resource->identifier()); |
| 1436 if (itt != m_mainResourceTimingInfoMap.end()) { |
| 1437 bool crossOrigin = IsCrossOrigin(redirectResponse.url(), newRequest.url()); |
| 1438 itt->value->addRedirect(redirectResponse, crossOrigin); |
| 1439 } |
| 1440 |
1406 newRequest.setAllowStoredCredentials(resource->options().allowCredentials == | 1441 newRequest.setAllowStoredCredentials(resource->options().allowCredentials == |
1407 AllowStoredCredentials); | 1442 AllowStoredCredentials); |
1408 willSendRequest(resource->identifier(), newRequest, redirectResponse, | 1443 willSendRequest(resource->identifier(), newRequest, redirectResponse, |
1409 resource->options()); | 1444 resource->options()); |
1410 return true; | 1445 return true; |
1411 } | 1446 } |
1412 | 1447 |
1413 void ResourceFetcher::willSendRequest(unsigned long identifier, | 1448 void ResourceFetcher::willSendRequest(unsigned long identifier, |
1414 ResourceRequest& newRequest, | 1449 ResourceRequest& newRequest, |
1415 const ResourceResponse& redirectResponse, | 1450 const ResourceResponse& redirectResponse, |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1641 visitor->trace(m_context); | 1676 visitor->trace(m_context); |
1642 visitor->trace(m_archive); | 1677 visitor->trace(m_archive); |
1643 visitor->trace(m_loaders); | 1678 visitor->trace(m_loaders); |
1644 visitor->trace(m_nonBlockingLoaders); | 1679 visitor->trace(m_nonBlockingLoaders); |
1645 visitor->trace(m_documentResources); | 1680 visitor->trace(m_documentResources); |
1646 visitor->trace(m_preloads); | 1681 visitor->trace(m_preloads); |
1647 visitor->trace(m_resourceTimingInfoMap); | 1682 visitor->trace(m_resourceTimingInfoMap); |
1648 } | 1683 } |
1649 | 1684 |
1650 } // namespace blink | 1685 } // namespace blink |
OLD | NEW |