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 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1142 } | 1142 } |
1143 context().dispatchDidFinishLoading(resource->identifier(), finishTime, | 1143 context().dispatchDidFinishLoading(resource->identifier(), finishTime, |
1144 encodedDataLength); | 1144 encodedDataLength); |
1145 if (finishReason == DidFinishLoading) | 1145 if (finishReason == DidFinishLoading) |
1146 resource->finish(finishTime); | 1146 resource->finish(finishTime); |
1147 context().didLoadResource(resource); | 1147 context().didLoadResource(resource); |
1148 } | 1148 } |
1149 | 1149 |
1150 void ResourceFetcher::didFailLoading(Resource* resource, | 1150 void ResourceFetcher::didFailLoading(Resource* resource, |
1151 const ResourceError& error) { | 1151 const ResourceError& error) { |
| 1152 if (resource->resourceRequest().isCacheAwareLoadingActivated() && |
| 1153 !error.isCancellation() && !error.isAccessCheck()) { |
| 1154 // Assume error.errorCode() == net::ERR_CACHE_MISS, resend request with |
| 1155 // existing ResourceLoader. |
| 1156 resource->deactivateCacheAwareLoading(); |
| 1157 resource->willReloadAfterDiskCacheMiss(); |
| 1158 resource->loader()->start(resource->resourceRequest(), |
| 1159 context().loadingTaskRunner(), |
| 1160 context().defersLoading()); |
| 1161 return; |
| 1162 } |
| 1163 |
1152 TRACE_EVENT_ASYNC_END0("blink.net", "Resource", resource->identifier()); | 1164 TRACE_EVENT_ASYNC_END0("blink.net", "Resource", resource->identifier()); |
1153 removeResourceLoader(resource->loader()); | 1165 removeResourceLoader(resource->loader()); |
1154 m_resourceTimingInfoMap.take(const_cast<Resource*>(resource)); | 1166 m_resourceTimingInfoMap.take(const_cast<Resource*>(resource)); |
1155 bool isInternalRequest = resource->options().initiatorInfo.name == | 1167 bool isInternalRequest = resource->options().initiatorInfo.name == |
1156 FetchInitiatorTypeNames::internal; | 1168 FetchInitiatorTypeNames::internal; |
1157 context().dispatchDidFail(resource->identifier(), error, isInternalRequest); | 1169 context().dispatchDidFail(resource->identifier(), error, isInternalRequest); |
1158 resource->error(error); | 1170 resource->error(error); |
1159 context().didLoadResource(resource); | 1171 context().didLoadResource(resource); |
1160 } | 1172 } |
1161 | 1173 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1255 resource->options()); | 1267 resource->options()); |
1256 | 1268 |
1257 // Resource requests from suborigins should not be intercepted by the service | 1269 // Resource requests from suborigins should not be intercepted by the service |
1258 // worker of the physical origin. This has the effect that, for now, | 1270 // worker of the physical origin. This has the effect that, for now, |
1259 // suborigins do not work with service workers. See | 1271 // suborigins do not work with service workers. See |
1260 // https://w3c.github.io/webappsec-suborigins/. | 1272 // https://w3c.github.io/webappsec-suborigins/. |
1261 SecurityOrigin* sourceOrigin = context().getSecurityOrigin(); | 1273 SecurityOrigin* sourceOrigin = context().getSecurityOrigin(); |
1262 if (sourceOrigin && sourceOrigin->hasSuborigin()) | 1274 if (sourceOrigin && sourceOrigin->hasSuborigin()) |
1263 request.setSkipServiceWorker(WebURLRequest::SkipServiceWorker::All); | 1275 request.setSkipServiceWorker(WebURLRequest::SkipServiceWorker::All); |
1264 | 1276 |
| 1277 // TODO(632580): Workaround to persist cache-aware state, remove after fixed. |
| 1278 resource->setResourceRequest(request); |
| 1279 |
1265 ResourceLoader* loader = ResourceLoader::create(this, resource); | 1280 ResourceLoader* loader = ResourceLoader::create(this, resource); |
1266 if (resource->shouldBlockLoadEvent()) | 1281 if (resource->shouldBlockLoadEvent()) |
1267 m_loaders.add(loader); | 1282 m_loaders.add(loader); |
1268 else | 1283 else |
1269 m_nonBlockingLoaders.add(loader); | 1284 m_nonBlockingLoaders.add(loader); |
1270 | 1285 |
1271 storeResourceTimingInitiatorInformation(resource); | 1286 storeResourceTimingInitiatorInformation(resource); |
1272 resource->setFetcherSecurityOrigin(sourceOrigin); | 1287 resource->setFetcherSecurityOrigin(sourceOrigin); |
1273 loader->start(request, context().loadingTaskRunner(), | 1288 loader->start(request, context().loadingTaskRunner(), |
1274 context().defersLoading()); | 1289 context().defersLoading()); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1361 resource->options()); | 1376 resource->options()); |
1362 return true; | 1377 return true; |
1363 } | 1378 } |
1364 | 1379 |
1365 void ResourceFetcher::willSendRequest(unsigned long identifier, | 1380 void ResourceFetcher::willSendRequest(unsigned long identifier, |
1366 ResourceRequest& newRequest, | 1381 ResourceRequest& newRequest, |
1367 const ResourceResponse& redirectResponse, | 1382 const ResourceResponse& redirectResponse, |
1368 const ResourceLoaderOptions& options) { | 1383 const ResourceLoaderOptions& options) { |
1369 context().dispatchWillSendRequest(identifier, newRequest, redirectResponse, | 1384 context().dispatchWillSendRequest(identifier, newRequest, redirectResponse, |
1370 options.initiatorInfo); | 1385 options.initiatorInfo); |
| 1386 newRequest.mayActivateCacheAwareLoading(); |
1371 } | 1387 } |
1372 | 1388 |
1373 void ResourceFetcher::updateAllImageResourcePriorities() { | 1389 void ResourceFetcher::updateAllImageResourcePriorities() { |
1374 TRACE_EVENT0( | 1390 TRACE_EVENT0( |
1375 "blink", | 1391 "blink", |
1376 "ResourceLoadPriorityOptimizer::updateAllImageResourcePriorities"); | 1392 "ResourceLoadPriorityOptimizer::updateAllImageResourcePriorities"); |
1377 for (const auto& documentResource : m_documentResources) { | 1393 for (const auto& documentResource : m_documentResources) { |
1378 Resource* resource = documentResource.value.get(); | 1394 Resource* resource = documentResource.value.get(); |
1379 if (!resource || !resource->isImage() || !resource->isLoading()) | 1395 if (!resource || !resource->isImage() || !resource->isLoading()) |
1380 continue; | 1396 continue; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1592 visitor->trace(m_context); | 1608 visitor->trace(m_context); |
1593 visitor->trace(m_archive); | 1609 visitor->trace(m_archive); |
1594 visitor->trace(m_loaders); | 1610 visitor->trace(m_loaders); |
1595 visitor->trace(m_nonBlockingLoaders); | 1611 visitor->trace(m_nonBlockingLoaders); |
1596 visitor->trace(m_documentResources); | 1612 visitor->trace(m_documentResources); |
1597 visitor->trace(m_preloads); | 1613 visitor->trace(m_preloads); |
1598 visitor->trace(m_resourceTimingInfoMap); | 1614 visitor->trace(m_resourceTimingInfoMap); |
1599 } | 1615 } |
1600 | 1616 |
1601 } // namespace blink | 1617 } // namespace blink |
OLD | NEW |