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 rights reserved. | 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. |
| 6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ | 6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ |
| 7 | 7 |
| 8 This library is free software; you can redistribute it and/or | 8 This library is free software; you can redistribute it and/or |
| 9 modify it under the terms of the GNU Library General Public | 9 modify it under the terms of the GNU Library General Public |
| 10 License as published by the Free Software Foundation; either | 10 License as published by the Free Software Foundation; either |
| (...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1101 } | 1101 } |
| 1102 context().dispatchDidFinishLoading(resource->identifier(), finishTime, | 1102 context().dispatchDidFinishLoading(resource->identifier(), finishTime, |
| 1103 encodedDataLength); | 1103 encodedDataLength); |
| 1104 if (finishReason == DidFinishLoading) | 1104 if (finishReason == DidFinishLoading) |
| 1105 resource->finish(finishTime); | 1105 resource->finish(finishTime); |
| 1106 context().didLoadResource(resource); | 1106 context().didLoadResource(resource); |
| 1107 } | 1107 } |
| 1108 | 1108 |
| 1109 void ResourceFetcher::didFailLoading(Resource* resource, | 1109 void ResourceFetcher::didFailLoading(Resource* resource, |
| 1110 const ResourceError& error) { | 1110 const ResourceError& error) { |
| 1111 if (resource->resourceRequest().isCacheAwareLoadingActivated() && | |
| 1112 !error.isCancellation() && !error.isAccessCheck()) { | |
| 1113 // Assume error.errorCode() == net::ERR_CACHE_MISS, resend request with | |
| 1114 // existing ResourceLoader. | |
|
Takashi Toyoshima
2016/10/05 07:06:18
Is it difficult to have an explicit method to know
Shao-Chuan Lee
2016/10/05 10:16:10
Should we add a field for this in WebURLError and
Shao-Chuan Lee
2016/10/07 08:10:06
Done.
| |
| 1115 resource->willReloadAfterDiskCacheMiss(); | |
| 1116 resource->loader()->start(resource->resourceRequest(), | |
| 1117 context().loadingTaskRunner(), | |
| 1118 context().defersLoading()); | |
| 1119 return; | |
| 1120 } | |
| 1121 | |
| 1111 TRACE_EVENT_ASYNC_END0("blink.net", "Resource", resource->identifier()); | 1122 TRACE_EVENT_ASYNC_END0("blink.net", "Resource", resource->identifier()); |
| 1112 removeResourceLoader(resource->loader()); | 1123 removeResourceLoader(resource->loader()); |
| 1113 m_resourceTimingInfoMap.take(const_cast<Resource*>(resource)); | 1124 m_resourceTimingInfoMap.take(const_cast<Resource*>(resource)); |
| 1114 bool isInternalRequest = resource->options().initiatorInfo.name == | 1125 bool isInternalRequest = resource->options().initiatorInfo.name == |
| 1115 FetchInitiatorTypeNames::internal; | 1126 FetchInitiatorTypeNames::internal; |
| 1116 context().dispatchDidFail(resource->identifier(), error, isInternalRequest); | 1127 context().dispatchDidFail(resource->identifier(), error, isInternalRequest); |
| 1117 resource->error(error); | 1128 resource->error(error); |
| 1118 context().didLoadResource(resource); | 1129 context().didLoadResource(resource); |
| 1119 } | 1130 } |
| 1120 | 1131 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1213 resource->options()); | 1224 resource->options()); |
| 1214 | 1225 |
| 1215 // Resource requests from suborigins should not be intercepted by the | 1226 // Resource requests from suborigins should not be intercepted by the |
| 1216 // service worker of the physical origin. This has the effect that, for | 1227 // service worker of the physical origin. This has the effect that, for |
| 1217 // now, suborigins do not work with service workers. See | 1228 // now, suborigins do not work with service workers. See |
| 1218 // https://w3c.github.io/webappsec-suborigins/. | 1229 // https://w3c.github.io/webappsec-suborigins/. |
| 1219 SecurityOrigin* sourceOrigin = context().getSecurityOrigin(); | 1230 SecurityOrigin* sourceOrigin = context().getSecurityOrigin(); |
| 1220 if (sourceOrigin && sourceOrigin->hasSuborigin()) | 1231 if (sourceOrigin && sourceOrigin->hasSuborigin()) |
| 1221 request.setSkipServiceWorker(WebURLRequest::SkipServiceWorker::All); | 1232 request.setSkipServiceWorker(WebURLRequest::SkipServiceWorker::All); |
| 1222 | 1233 |
| 1234 // TODO(632580): Workaround to persist cache-aware state, remove after fixed. | |
| 1235 resource->setResourceRequest(request); | |
| 1236 | |
| 1223 ResourceLoader* loader = ResourceLoader::create(this, resource); | 1237 ResourceLoader* loader = ResourceLoader::create(this, resource); |
| 1224 if (resource->shouldBlockLoadEvent()) | 1238 if (resource->shouldBlockLoadEvent()) |
| 1225 m_loaders.add(loader); | 1239 m_loaders.add(loader); |
| 1226 else | 1240 else |
| 1227 m_nonBlockingLoaders.add(loader); | 1241 m_nonBlockingLoaders.add(loader); |
| 1228 | 1242 |
| 1229 storeResourceTimingInitiatorInformation(resource); | 1243 storeResourceTimingInitiatorInformation(resource); |
| 1230 resource->setFetcherSecurityOrigin(sourceOrigin); | 1244 resource->setFetcherSecurityOrigin(sourceOrigin); |
| 1231 loader->start(request, context().loadingTaskRunner(), | 1245 loader->start(request, context().loadingTaskRunner(), |
| 1232 context().defersLoading()); | 1246 context().defersLoading()); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1325 resource->options()); | 1339 resource->options()); |
| 1326 return true; | 1340 return true; |
| 1327 } | 1341 } |
| 1328 | 1342 |
| 1329 void ResourceFetcher::willSendRequest(unsigned long identifier, | 1343 void ResourceFetcher::willSendRequest(unsigned long identifier, |
| 1330 ResourceRequest& newRequest, | 1344 ResourceRequest& newRequest, |
| 1331 const ResourceResponse& redirectResponse, | 1345 const ResourceResponse& redirectResponse, |
| 1332 const ResourceLoaderOptions& options) { | 1346 const ResourceLoaderOptions& options) { |
| 1333 context().dispatchWillSendRequest(identifier, newRequest, redirectResponse, | 1347 context().dispatchWillSendRequest(identifier, newRequest, redirectResponse, |
| 1334 options.initiatorInfo); | 1348 options.initiatorInfo); |
| 1349 newRequest.mayActivateCacheAwareLoading(); | |
| 1335 } | 1350 } |
| 1336 | 1351 |
| 1337 void ResourceFetcher::updateAllImageResourcePriorities() { | 1352 void ResourceFetcher::updateAllImageResourcePriorities() { |
| 1338 TRACE_EVENT0( | 1353 TRACE_EVENT0( |
| 1339 "blink", | 1354 "blink", |
| 1340 "ResourceLoadPriorityOptimizer::updateAllImageResourcePriorities"); | 1355 "ResourceLoadPriorityOptimizer::updateAllImageResourcePriorities"); |
| 1341 for (const auto& documentResource : m_documentResources) { | 1356 for (const auto& documentResource : m_documentResources) { |
| 1342 Resource* resource = documentResource.value.get(); | 1357 Resource* resource = documentResource.value.get(); |
| 1343 if (!resource || !resource->isImage() || !resource->isLoading()) | 1358 if (!resource || !resource->isImage() || !resource->isLoading()) |
| 1344 continue; | 1359 continue; |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1556 visitor->trace(m_context); | 1571 visitor->trace(m_context); |
| 1557 visitor->trace(m_archive); | 1572 visitor->trace(m_archive); |
| 1558 visitor->trace(m_loaders); | 1573 visitor->trace(m_loaders); |
| 1559 visitor->trace(m_nonBlockingLoaders); | 1574 visitor->trace(m_nonBlockingLoaders); |
| 1560 visitor->trace(m_documentResources); | 1575 visitor->trace(m_documentResources); |
| 1561 visitor->trace(m_preloads); | 1576 visitor->trace(m_preloads); |
| 1562 visitor->trace(m_resourceTimingInfoMap); | 1577 visitor->trace(m_resourceTimingInfoMap); |
| 1563 } | 1578 } |
| 1564 | 1579 |
| 1565 } // namespace blink | 1580 } // namespace blink |
| OLD | NEW |