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

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

Issue 314423004: Handle main resource preload request better (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update comment Created 6 years, 6 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 | « no previous file | 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 f92a1d343172d46cdbbddd5226f0d742b20f7dfe..28a2426382f06de7229a4bbe95b3afdcc30fa241 100644
--- a/Source/core/fetch/ResourceFetcher.cpp
+++ b/Source/core/fetch/ResourceFetcher.cpp
@@ -755,15 +755,11 @@ ResourcePtr<Resource> ResourceFetcher::requestResource(Resource::Type type, Fetc
// see https://bugs.webkit.org/show_bug.cgi?id=107962. Before caching main
// resources, we should be sure to understand the implications for memory
// use.
- //
- // Ensure main resources aren't preloaded, and other main resource loads
- // are removed from cache to prevent reuse.
+ // Remove main resource from cache to prevent reuse.
if (type == Resource::MainResource) {
ASSERT(policy != Use || m_documentLoader->substituteData().isValid());
ASSERT(policy != Revalidate);
memoryCache()->remove(resource.get());
- if (request.forPreload())
- return 0;
}
requestLoadStarted(resource.get(), request, policy == Use ? ResourceLoadingFromCache : ResourceLoadingFromNetwork);
@@ -1197,6 +1193,10 @@ void ResourceFetcher::preload(Resource::Type type, FetchRequest& request, const
void ResourceFetcher::requestPreload(Resource::Type type, FetchRequest& request, const String& charset)
{
+ // Ensure main resources aren't preloaded, since the cache can't actually reuse the preload.
+ if (type == Resource::MainResource)
+ return;
+
String encoding;
if (type == Resource::Script || type == Resource::CSSStyleSheet)
encoding = charset.isEmpty() ? m_document->charset().string() : charset;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698