Commit 410856a9 authored by mahesh.kk@samsung.com's avatar mahesh.kk@samsung.com

Handle main resource preload request better

Return early from preload request for main resource
to avoid spinning up ResourceLoader unnecessarily.

Review URL: https://codereview.chromium.org/314423004

git-svn-id: svn://svn.chromium.org/blink/trunk@175815 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent b327e697
...@@ -755,15 +755,11 @@ ResourcePtr<Resource> ResourceFetcher::requestResource(Resource::Type type, Fetc ...@@ -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 // see https://bugs.webkit.org/show_bug.cgi?id=107962. Before caching main
// resources, we should be sure to understand the implications for memory // resources, we should be sure to understand the implications for memory
// use. // use.
// // Remove main resource from cache to prevent reuse.
// Ensure main resources aren't preloaded, and other main resource loads
// are removed from cache to prevent reuse.
if (type == Resource::MainResource) { if (type == Resource::MainResource) {
ASSERT(policy != Use || m_documentLoader->substituteData().isValid()); ASSERT(policy != Use || m_documentLoader->substituteData().isValid());
ASSERT(policy != Revalidate); ASSERT(policy != Revalidate);
memoryCache()->remove(resource.get()); memoryCache()->remove(resource.get());
if (request.forPreload())
return 0;
} }
requestLoadStarted(resource.get(), request, policy == Use ? ResourceLoadingFromCache : ResourceLoadingFromNetwork); requestLoadStarted(resource.get(), request, policy == Use ? ResourceLoadingFromCache : ResourceLoadingFromNetwork);
...@@ -1197,6 +1193,10 @@ void ResourceFetcher::preload(Resource::Type type, FetchRequest& request, const ...@@ -1197,6 +1193,10 @@ void ResourceFetcher::preload(Resource::Type type, FetchRequest& request, const
void ResourceFetcher::requestPreload(Resource::Type type, FetchRequest& request, const String& charset) 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; String encoding;
if (type == Resource::Script || type == Resource::CSSStyleSheet) if (type == Resource::Script || type == Resource::CSSStyleSheet)
encoding = charset.isEmpty() ? m_document->charset().string() : charset; encoding = charset.isEmpty() ? m_document->charset().string() : charset;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment