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 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1166 context().didLoadResource(resource); | 1166 context().didLoadResource(resource); |
| 1167 | 1167 |
| 1168 if (resource->isImage() && | 1168 if (resource->isImage() && |
| 1169 toImageResource(resource)->shouldReloadBrokenPlaceholder()) { | 1169 toImageResource(resource)->shouldReloadBrokenPlaceholder()) { |
| 1170 toImageResource(resource)->reloadIfLoFiOrPlaceholder(this); | 1170 toImageResource(resource)->reloadIfLoFiOrPlaceholder(this); |
| 1171 } | 1171 } |
| 1172 } | 1172 } |
| 1173 | 1173 |
| 1174 void ResourceFetcher::didFailLoading(Resource* resource, | 1174 void ResourceFetcher::didFailLoading(Resource* resource, |
| 1175 const ResourceError& error) { | 1175 const ResourceError& error) { |
| 1176 if (resource->loader()->isCacheAwareLoadingActivated() && | |
| 1177 error.isCacheMiss()) { | |
| 1178 resource->willReloadAfterDiskCacheMiss(); | |
| 1179 resource->loader()->deactivateCacheAwareLoading(); | |
| 1180 resource->loader()->restart(resource->resourceRequest(), | |
| 1181 context().loadingTaskRunner(), | |
| 1182 context().defersLoading()); | |
| 1183 return; | |
| 1184 } | |
|
hiroshige
2016/10/27 08:21:48
Can we move this block to ResourceLoader::didFail(
Shao-Chuan Lee
2016/10/28 04:14:14
Done.
As for isCacheAwareLoadingActivated() I'm pl
| |
| 1185 | |
| 1176 TRACE_EVENT_ASYNC_END0("blink.net", "Resource", resource->identifier()); | 1186 TRACE_EVENT_ASYNC_END0("blink.net", "Resource", resource->identifier()); |
| 1177 removeResourceLoader(resource->loader()); | 1187 removeResourceLoader(resource->loader()); |
| 1178 m_resourceTimingInfoMap.take(const_cast<Resource*>(resource)); | 1188 m_resourceTimingInfoMap.take(const_cast<Resource*>(resource)); |
| 1179 bool isInternalRequest = resource->options().initiatorInfo.name == | 1189 bool isInternalRequest = resource->options().initiatorInfo.name == |
| 1180 FetchInitiatorTypeNames::internal; | 1190 FetchInitiatorTypeNames::internal; |
| 1181 context().dispatchDidFail(resource->identifier(), error, isInternalRequest); | 1191 context().dispatchDidFail(resource->identifier(), error, isInternalRequest); |
| 1182 resource->error(error); | 1192 resource->error(error); |
| 1183 context().didLoadResource(resource); | 1193 context().didLoadResource(resource); |
| 1184 | 1194 |
| 1185 if (resource->isImage() && | 1195 if (resource->isImage() && |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1277 DCHECK(resource->stillNeedsLoad()); | 1287 DCHECK(resource->stillNeedsLoad()); |
| 1278 if (!context().shouldLoadNewResource(resource->getType())) { | 1288 if (!context().shouldLoadNewResource(resource->getType())) { |
| 1279 memoryCache()->remove(resource); | 1289 memoryCache()->remove(resource); |
| 1280 return false; | 1290 return false; |
| 1281 } | 1291 } |
| 1282 | 1292 |
| 1283 ResourceRequest request(resource->resourceRequest()); | 1293 ResourceRequest request(resource->resourceRequest()); |
| 1284 willSendRequest(resource->identifier(), request, ResourceResponse(), | 1294 willSendRequest(resource->identifier(), request, ResourceResponse(), |
| 1285 resource->options()); | 1295 resource->options()); |
| 1286 | 1296 |
| 1297 // TODO(shaochuan): Saving modified ResourceRequest back to |resource|, remove | |
| 1298 // once willSendRequest() takes const ResourceRequest. crbug.com/632580 | |
| 1299 resource->setResourceRequest(request); | |
| 1300 | |
| 1287 // Resource requests from suborigins should not be intercepted by the service | 1301 // Resource requests from suborigins should not be intercepted by the service |
| 1288 // worker of the physical origin. This has the effect that, for now, | 1302 // worker of the physical origin. This has the effect that, for now, |
| 1289 // suborigins do not work with service workers. See | 1303 // suborigins do not work with service workers. See |
| 1290 // https://w3c.github.io/webappsec-suborigins/. | 1304 // https://w3c.github.io/webappsec-suborigins/. |
| 1291 SecurityOrigin* sourceOrigin = context().getSecurityOrigin(); | 1305 SecurityOrigin* sourceOrigin = context().getSecurityOrigin(); |
| 1292 if (sourceOrigin && sourceOrigin->hasSuborigin()) | 1306 if (sourceOrigin && sourceOrigin->hasSuborigin()) |
| 1293 request.setSkipServiceWorker(WebURLRequest::SkipServiceWorker::All); | 1307 request.setSkipServiceWorker(WebURLRequest::SkipServiceWorker::All); |
| 1294 | 1308 |
| 1295 ResourceLoader* loader = ResourceLoader::create(this, resource); | 1309 ResourceLoader* loader = ResourceLoader::create(this, resource); |
| 1296 if (resource->shouldBlockLoadEvent()) | 1310 if (resource->shouldBlockLoadEvent()) |
| 1297 m_loaders.add(loader); | 1311 m_loaders.add(loader); |
| 1298 else | 1312 else |
| 1299 m_nonBlockingLoaders.add(loader); | 1313 m_nonBlockingLoaders.add(loader); |
| 1300 | 1314 |
| 1301 storeResourceTimingInitiatorInformation(resource); | 1315 storeResourceTimingInitiatorInformation(resource); |
| 1302 resource->setFetcherSecurityOrigin(sourceOrigin); | 1316 resource->setFetcherSecurityOrigin(sourceOrigin); |
| 1317 | |
| 1318 if (resource->options().cacheAwareLoadingEnabled == | |
| 1319 IsCacheAwareLoadingEnabled) { | |
| 1320 // Call cache miss callback immediately if cache-aware loading is enabled | |
| 1321 // but cannot be activated. | |
| 1322 if (!loader->activateCacheAwareLoading(request)) | |
| 1323 resource->willReloadAfterDiskCacheMiss(); | |
| 1324 } | |
|
hiroshige
2016/10/27 08:21:48
Can we move this block to ResourceLoader::start()
Shao-Chuan Lee
2016/10/28 04:14:14
The activation should only occur in startLoad(), i
hiroshige
2016/10/31 08:25:19
Makes sense. There might be a room for refactoring
| |
| 1325 | |
| 1303 loader->start(request, context().loadingTaskRunner(), | 1326 loader->start(request, context().loadingTaskRunner(), |
| 1304 context().defersLoading()); | 1327 context().defersLoading()); |
| 1305 return true; | 1328 return true; |
| 1306 } | 1329 } |
| 1307 | 1330 |
| 1308 void ResourceFetcher::removeResourceLoader(ResourceLoader* loader) { | 1331 void ResourceFetcher::removeResourceLoader(ResourceLoader* loader) { |
| 1309 if (m_loaders.contains(loader)) | 1332 if (m_loaders.contains(loader)) |
| 1310 m_loaders.remove(loader); | 1333 m_loaders.remove(loader); |
| 1311 else if (m_nonBlockingLoaders.contains(loader)) | 1334 else if (m_nonBlockingLoaders.contains(loader)) |
| 1312 m_nonBlockingLoaders.remove(loader); | 1335 m_nonBlockingLoaders.remove(loader); |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1622 visitor->trace(m_context); | 1645 visitor->trace(m_context); |
| 1623 visitor->trace(m_archive); | 1646 visitor->trace(m_archive); |
| 1624 visitor->trace(m_loaders); | 1647 visitor->trace(m_loaders); |
| 1625 visitor->trace(m_nonBlockingLoaders); | 1648 visitor->trace(m_nonBlockingLoaders); |
| 1626 visitor->trace(m_documentResources); | 1649 visitor->trace(m_documentResources); |
| 1627 visitor->trace(m_preloads); | 1650 visitor->trace(m_preloads); |
| 1628 visitor->trace(m_resourceTimingInfoMap); | 1651 visitor->trace(m_resourceTimingInfoMap); |
| 1629 } | 1652 } |
| 1630 | 1653 |
| 1631 } // namespace blink | 1654 } // namespace blink |
| OLD | NEW |