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

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

Issue 632213002: Fetcher: Disable memory caching when Service Worker handles a request (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: s/getJSON/getJSONP Created 6 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
« no previous file with comments | « LayoutTests/http/tests/serviceworker/chromium/resources/memory-cache-worker.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/fetch/ResourceFetcher.cpp
diff --git a/Source/core/fetch/ResourceFetcher.cpp b/Source/core/fetch/ResourceFetcher.cpp
index 2677d952bb19eb4fb119c2109c1bdbd846202d78..fbf71f27d96e634db53df4ac2be3bd09209e8279 100644
--- a/Source/core/fetch/ResourceFetcher.cpp
+++ b/Source/core/fetch/ResourceFetcher.cpp
@@ -784,6 +784,17 @@ ResourcePtr<Resource> ResourceFetcher::requestResource(Resource::Type type, Fetc
ASSERT(policy != Use || m_documentLoader->substituteData().isValid());
ASSERT(policy != Revalidate);
memoryCache()->remove(resource.get());
+ } else {
+ // Remove a resource to be handled by Service Worker from the cache to
+ // prevent reuse because Service Worker can serve an arbitrary resource
+ // for an URL and pollute a memory cache entry.
+ // FIXME: isControlledByServiceWorker() always returns false on main
+ // resource request, but main resource is always removed from the cache
+ // as the above comment (http://crbug.com/388375).
+ if (frame() && m_documentLoader && frame()->loader().client()->isControlledByServiceWorker(*m_documentLoader)) {
+ ASSERT(policy == Load || policy == Reload);
+ memoryCache()->remove(resource.get());
+ }
}
requestLoadStarted(resource.get(), request, policy == Use ? ResourceLoadingFromCache : ResourceLoadingFromNetwork);
@@ -942,6 +953,11 @@ ResourceFetcher::RevalidationPolicy ResourceFetcher::determineRevalidationPolicy
if (!existingResource)
return Load;
+ // FIXME: Currently caching for a resource to be handled by Service Worker
+ // is disabled (http://crbug.com/388375).
+ if (frame() && m_documentLoader && frame()->loader().client()->isControlledByServiceWorker(*m_documentLoader))
+ return Reload;
+
// We already have a preload going for this URL.
if (fetchRequest.forPreload() && existingResource->isPreloaded())
return Use;
« no previous file with comments | « LayoutTests/http/tests/serviceworker/chromium/resources/memory-cache-worker.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698