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

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

Issue 179943002: MemoryCache: make sure that Resources are evicted only when they can be deleted (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 9 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 | Source/core/fetch/MemoryCacheTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/fetch/MemoryCache.cpp
diff --git a/Source/core/fetch/MemoryCache.cpp b/Source/core/fetch/MemoryCache.cpp
index 680536596b9316712c76f2c1dbab49d8fcdb5d1c..89f13fc6d5a54623dadccef8c695e42df57ba4d4 100644
--- a/Source/core/fetch/MemoryCache.cpp
+++ b/Source/core/fetch/MemoryCache.cpp
@@ -233,10 +233,11 @@ void MemoryCache::pruneDeadResources()
MemoryCacheEntry* current = m_allResources[i].m_tail;
while (current) {
MemoryCacheEntry* previous = current->m_previousInAllResourcesList;
- if (current->m_resource->wasPurged()) {
+ if (current->m_resource->wasPurged() && current->m_resource->canDelete()) {
ASSERT(!current->m_resource->hasClients());
ASSERT(!current->m_resource->isPreloaded());
- evict(current);
+ bool wasEvicted = evict(current);
+ ASSERT_UNUSED(wasEvicted, wasEvicted);
}
current = previous;
}
@@ -275,8 +276,10 @@ void MemoryCache::pruneDeadResources()
while (current) {
MemoryCacheEntry* previous = current->m_previousInAllResourcesList;
ASSERT(!previous || contains(previous->m_resource.get()));
- if (!current->m_resource->hasClients() && !current->m_resource->isPreloaded() && !current->m_resource->isCacheValidator()) {
- evict(current);
+ if (!current->m_resource->hasClients() && !current->m_resource->isPreloaded()
+ && !current->m_resource->isCacheValidator() && current->m_resource->canDelete()) {
+ bool wasEvicted = evict(current);
+ ASSERT_UNUSED(wasEvicted, wasEvicted);
if (targetSize && m_deadSize <= targetSize)
return;
}
« no previous file with comments | « no previous file | Source/core/fetch/MemoryCacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698