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

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

Issue 2174563003: Clear all preloads when document is detached (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix issues inside clearPreloads and add tests Created 4 years, 4 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 e31018cc8d8f4776e0afcfba786ac6152a05a333..6db6c2d35b85efd5dced7bc46785ff2bda8f6139 100644
--- a/third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp
+++ b/third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp
@@ -887,11 +887,15 @@ void ResourceFetcher::clearPreloads(ClearPreloadsPolicy policy)
logPreloadStats();
for (auto resource : *m_preloads) {
- resource->decreasePreloadCount();
- if (resource->getPreloadResult() == Resource::PreloadNotReferenced && (policy == ClearAllPreloads || !resource->isLinkPreload()))
- memoryCache()->remove(resource.get());
+ if (policy == ClearAllPreloads || !resource->isLinkPreload()) {
+ resource->decreasePreloadCount();
+ if (resource->getPreloadResult() == Resource::PreloadNotReferenced)
+ memoryCache()->remove(resource.get());
+ m_preloads->remove(resource);
+ }
}
- m_preloads.clear();
+ if (!m_preloads->size())
Charlie Harrison 2016/08/04 18:10:26 This is confusing. Clear the preloads only if they
Yoav Weiss 2016/08/04 20:26:14 AFAICT the clear here clears the Member (and enabl
Charlie Harrison 2016/08/04 20:59:57 Ah, makes sense. Thanks for the clarification.
+ m_preloads.clear();
}
ArchiveResource* ResourceFetcher::createArchive(Resource* resource)

Powered by Google App Engine
This is Rietveld 408576698