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

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

Issue 2454983002: Cache-aware Resource loading (Closed)
Patch Set: fix #3, add DCHECK, add missing header 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..958ce90824b4556b1d142b725a1a2a3a55f86e55 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;
+ }
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
+
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->activateCacheAwareLoading(request))
+ resource->willReloadAfterDiskCacheMiss();
+ }
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
+
loader->start(request, context().loadingTaskRunner(),
context().defersLoading());
return true;
« no previous file with comments | « third_party/WebKit/Source/core/fetch/Resource.h ('k') | third_party/WebKit/Source/core/fetch/ResourceLoader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698