Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Unified Diff: third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp

Issue 2454983002: Cache-aware Resource loading (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp
diff --git a/third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp b/third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp
index 87844840edb85a80b9c188695d2e0aa0de7adc67..af242edb9e0522dd9a49e1402d78f79aa058f6d9 100644
--- a/third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp
+++ b/third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp
@@ -1173,6 +1173,16 @@ void ResourceFetcher::didFinishLoading(Resource* resource,
void ResourceFetcher::didFailLoading(Resource* resource,
const ResourceError& error) {
+ if (resource->loader()->isCacheAwareLoadingActivated() &&
+ error.isCacheMiss()) {
+ resource->willReloadAfterDiskCacheMiss();
+ resource->loader()->deactivateCacheAwareLoading();
+ resource->loader()->restart(resource->resourceRequest(),
+ context().loadingTaskRunner(),
+ context().defersLoading());
+ return;
+ }
+
TRACE_EVENT_ASYNC_END0("blink.net", "Resource", resource->identifier());
removeResourceLoader(resource->loader());
m_resourceTimingInfoMap.take(const_cast<Resource*>(resource));
@@ -1284,6 +1294,10 @@ bool ResourceFetcher::startLoad(Resource* resource) {
willSendRequest(resource->identifier(), request, ResourceResponse(),
resource->options());
+ // TODO(shaochuan): Saving modified ResourceRequest back to |resource|, remove
+ // once willSendRequest() takes const ResourceRequest. crbug.com/632580
+ resource->setResourceRequest(request);
+
// Resource requests from suborigins should not be intercepted by the service
// worker of the physical origin. This has the effect that, for now,
// suborigins do not work with service workers. See
@@ -1300,6 +1314,15 @@ bool ResourceFetcher::startLoad(Resource* resource) {
storeResourceTimingInitiatorInformation(resource);
resource->setFetcherSecurityOrigin(sourceOrigin);
+
+ if (resource->options().cacheAwareLoadingEnabled ==
+ IsCacheAwareLoadingEnabled) {
+ // Call cache miss callback immediately if cache-aware loading is enabled
+ // but cannot be activated.
+ if (!loader->willActivateCacheAwareLoading(request))
+ resource->willReloadAfterDiskCacheMiss();
+ }
+
loader->start(request, context().loadingTaskRunner(),
context().defersLoading());
return true;

Powered by Google App Engine
This is Rietveld 408576698