Chromium Code Reviews| 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 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 775 ResourceFetcher::RevalidationPolicy | 775 ResourceFetcher::RevalidationPolicy |
| 776 ResourceFetcher::determineRevalidationPolicy(Resource::Type type, | 776 ResourceFetcher::determineRevalidationPolicy(Resource::Type type, |
| 777 const FetchRequest& fetchRequest, | 777 const FetchRequest& fetchRequest, |
| 778 Resource* existingResource, | 778 Resource* existingResource, |
| 779 bool isStaticData) const { | 779 bool isStaticData) const { |
| 780 const ResourceRequest& request = fetchRequest.resourceRequest(); | 780 const ResourceRequest& request = fetchRequest.resourceRequest(); |
| 781 | 781 |
| 782 if (!existingResource) | 782 if (!existingResource) |
| 783 return Load; | 783 return Load; |
| 784 | 784 |
| 785 if (fetchRequest.enforceNewResource()) | |
|
Nate Chapin
2016/12/28 00:14:57
Adding yet another clause to this function makes m
hiroshige
2017/01/25 02:01:49
ACK, I'll handle this.
hiroshige
2017/03/13 21:27:04
Removed.
hiroshige
2017/03/13 21:29:16
In Patch Set 31, I merged FetchRequest::enforceNew
| |
| 786 return Reload; | |
| 787 | |
| 785 // Checks if the resource has an explicit policy about integrity metadata. | 788 // Checks if the resource has an explicit policy about integrity metadata. |
| 786 // | 789 // |
| 787 // This is necessary because ScriptResource and CSSStyleSheetResource objects | 790 // This is necessary because ScriptResource and CSSStyleSheetResource objects |
| 788 // do not keep the raw data around after the source is accessed once, so if | 791 // do not keep the raw data around after the source is accessed once, so if |
| 789 // the resource is accessed from the MemoryCache for a second time, there is | 792 // the resource is accessed from the MemoryCache for a second time, there is |
| 790 // no way to redo an integrity check. | 793 // no way to redo an integrity check. |
| 791 // | 794 // |
| 792 // Thus, Blink implements a scheme where it caches the integrity information | 795 // Thus, Blink implements a scheme where it caches the integrity information |
| 793 // for those resources after the first time it is checked, and if there is | 796 // for those resources after the first time it is checked, and if there is |
| 794 // another request for that resource, with the same integrity metadata, Blink | 797 // another request for that resource, with the same integrity metadata, Blink |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1108 if (!context().isMainFrame()) | 1111 if (!context().isMainFrame()) |
| 1109 return nullptr; | 1112 return nullptr; |
| 1110 m_archive = MHTMLArchive::create(resource->url(), resource->resourceBuffer()); | 1113 m_archive = MHTMLArchive::create(resource->url(), resource->resourceBuffer()); |
| 1111 return m_archive ? m_archive->mainResource() : nullptr; | 1114 return m_archive ? m_archive->mainResource() : nullptr; |
| 1112 } | 1115 } |
| 1113 | 1116 |
| 1114 ResourceTimingInfo* ResourceFetcher::getNavigationTimingInfo() { | 1117 ResourceTimingInfo* ResourceFetcher::getNavigationTimingInfo() { |
| 1115 return m_navigationTimingInfo.get(); | 1118 return m_navigationTimingInfo.get(); |
| 1116 } | 1119 } |
| 1117 | 1120 |
| 1118 void ResourceFetcher::handleLoadCompletion(Resource* resource) { | 1121 void ResourceFetcher::handleLoadCompletion(Resource* resource) { |
|
Nate Chapin
2016/12/28 00:14:57
This helper seems like it's not useful if it's onl
hiroshige
2016/12/28 01:04:21
+tyoshino@ (who introduced this method), is it fin
hiroshige
2017/01/25 02:01:49
I reverted this change (while I was removing reloa
| |
| 1119 context().didLoadResource(resource); | 1122 context().didLoadResource(resource); |
| 1120 | |
| 1121 resource->reloadIfLoFiOrPlaceholderImage(this, Resource::kReloadIfNeeded); | |
| 1122 } | 1123 } |
| 1123 | 1124 |
| 1124 void ResourceFetcher::handleLoaderFinish(Resource* resource, | 1125 void ResourceFetcher::handleLoaderFinish(Resource* resource, |
| 1125 double finishTime, | 1126 double finishTime, |
| 1126 LoaderFinishType type) { | 1127 LoaderFinishType type) { |
| 1127 DCHECK(resource); | 1128 DCHECK(resource); |
| 1128 | 1129 |
| 1129 ResourceLoader* loader = resource->loader(); | 1130 ResourceLoader* loader = resource->loader(); |
| 1130 if (type == DidFinishFirstPartInMultipart) { | 1131 if (type == DidFinishFirstPartInMultipart) { |
| 1131 // When loading a multipart resource, make the loader non-block when | 1132 // When loading a multipart resource, make the loader non-block when |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1167 if (resource->options().requestInitiatorContext == DocumentContext) | 1168 if (resource->options().requestInitiatorContext == DocumentContext) |
| 1168 context().addResourceTiming(*info); | 1169 context().addResourceTiming(*info); |
| 1169 resource->reportResourceTimingToClients(*info); | 1170 resource->reportResourceTimingToClients(*info); |
| 1170 } | 1171 } |
| 1171 } | 1172 } |
| 1172 | 1173 |
| 1173 context().dispatchDidFinishLoading(resource->identifier(), finishTime, | 1174 context().dispatchDidFinishLoading(resource->identifier(), finishTime, |
| 1174 encodedDataLength); | 1175 encodedDataLength); |
| 1175 | 1176 |
| 1176 if (type == DidFinishLoading) | 1177 if (type == DidFinishLoading) |
| 1177 resource->finish(finishTime); | 1178 resource->finish(finishTime, this); |
| 1178 | 1179 |
| 1179 handleLoadCompletion(resource); | 1180 handleLoadCompletion(resource); |
| 1180 } | 1181 } |
| 1181 | 1182 |
| 1182 void ResourceFetcher::handleLoaderError(Resource* resource, | 1183 void ResourceFetcher::handleLoaderError(Resource* resource, |
| 1183 const ResourceError& error) { | 1184 const ResourceError& error) { |
| 1184 DCHECK(resource); | 1185 DCHECK(resource); |
| 1185 | 1186 |
| 1186 removeResourceLoader(resource->loader()); | 1187 removeResourceLoader(resource->loader()); |
| 1187 | 1188 |
| 1188 m_resourceTimingInfoMap.take(resource); | 1189 m_resourceTimingInfoMap.take(resource); |
| 1189 | 1190 |
| 1190 bool isInternalRequest = resource->options().initiatorInfo.name == | 1191 bool isInternalRequest = resource->options().initiatorInfo.name == |
| 1191 FetchInitiatorTypeNames::internal; | 1192 FetchInitiatorTypeNames::internal; |
| 1192 | 1193 |
| 1193 context().dispatchDidFail(resource->identifier(), error, | 1194 context().dispatchDidFail(resource->identifier(), error, |
| 1194 resource->response().encodedDataLength(), | 1195 resource->response().encodedDataLength(), |
| 1195 isInternalRequest); | 1196 isInternalRequest); |
| 1196 | 1197 |
| 1197 resource->error(error); | 1198 resource->error(error, this); |
| 1198 | 1199 |
| 1199 handleLoadCompletion(resource); | 1200 handleLoadCompletion(resource); |
| 1200 } | 1201 } |
| 1201 | 1202 |
| 1202 void ResourceFetcher::moveResourceLoaderToNonBlocking(ResourceLoader* loader) { | 1203 void ResourceFetcher::moveResourceLoaderToNonBlocking(ResourceLoader* loader) { |
| 1203 DCHECK(loader); | 1204 DCHECK(loader); |
| 1204 // TODO(yoav): Convert CHECK to DCHECK if no crash reports come in. | 1205 // TODO(yoav): Convert CHECK to DCHECK if no crash reports come in. |
| 1205 CHECK(m_loaders.contains(loader)); | 1206 CHECK(m_loaders.contains(loader)); |
| 1206 m_nonBlockingLoaders.add(loader); | 1207 m_nonBlockingLoaders.add(loader); |
| 1207 m_loaders.remove(loader); | 1208 m_loaders.remove(loader); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1302 resourcePriority.intraPriorityValue); | 1303 resourcePriority.intraPriorityValue); |
| 1303 network_instrumentation::resourcePrioritySet(resource->identifier(), | 1304 network_instrumentation::resourcePrioritySet(resource->identifier(), |
| 1304 resourceLoadPriority); | 1305 resourceLoadPriority); |
| 1305 context().dispatchDidChangeResourcePriority( | 1306 context().dispatchDidChangeResourcePriority( |
| 1306 resource->identifier(), resourceLoadPriority, | 1307 resource->identifier(), resourceLoadPriority, |
| 1307 resourcePriority.intraPriorityValue); | 1308 resourcePriority.intraPriorityValue); |
| 1308 } | 1309 } |
| 1309 } | 1310 } |
| 1310 | 1311 |
| 1311 void ResourceFetcher::reloadLoFiImages() { | 1312 void ResourceFetcher::reloadLoFiImages() { |
| 1312 for (const auto& documentResource : m_documentResources) { | 1313 for (auto& documentResource : m_documentResources) { |
| 1313 Resource* resource = documentResource.value.get(); | 1314 Resource* resource = documentResource.value.get(); |
| 1314 if (resource) | 1315 if (resource) |
| 1315 resource->reloadIfLoFiOrPlaceholderImage(this, Resource::kReloadAlways); | 1316 resource->reloadIfLoFiOrPlaceholderImage(this, Resource::kReloadAlways); |
| 1316 } | 1317 } |
| 1317 } | 1318 } |
| 1318 | 1319 |
| 1319 void ResourceFetcher::logPreloadStats(ClearPreloadsPolicy policy) { | 1320 void ResourceFetcher::logPreloadStats(ClearPreloadsPolicy policy) { |
| 1320 if (!m_preloads) | 1321 if (!m_preloads) |
| 1321 return; | 1322 return; |
| 1322 unsigned scripts = 0; | 1323 unsigned scripts = 0; |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1522 visitor->trace(m_context); | 1523 visitor->trace(m_context); |
| 1523 visitor->trace(m_archive); | 1524 visitor->trace(m_archive); |
| 1524 visitor->trace(m_loaders); | 1525 visitor->trace(m_loaders); |
| 1525 visitor->trace(m_nonBlockingLoaders); | 1526 visitor->trace(m_nonBlockingLoaders); |
| 1526 visitor->trace(m_documentResources); | 1527 visitor->trace(m_documentResources); |
| 1527 visitor->trace(m_preloads); | 1528 visitor->trace(m_preloads); |
| 1528 visitor->trace(m_resourceTimingInfoMap); | 1529 visitor->trace(m_resourceTimingInfoMap); |
| 1529 } | 1530 } |
| 1530 | 1531 |
| 1531 } // namespace blink | 1532 } // namespace blink |
| OLD | NEW |