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

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

Issue 1706083002: Split ImageResourceClient into ResourceClient and ImageResourceObserver [1/2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reflect comments and Rebase Created 4 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
Index: third_party/WebKit/Source/core/fetch/MemoryCache.cpp
diff --git a/third_party/WebKit/Source/core/fetch/MemoryCache.cpp b/third_party/WebKit/Source/core/fetch/MemoryCache.cpp
index 8aa8ab83ad78f9b6479caa3a5a9abe94431b33cd..8b01a72701244618468cba0ad751b2ac709a100b 100644
--- a/third_party/WebKit/Source/core/fetch/MemoryCache.cpp
+++ b/third_party/WebKit/Source/core/fetch/MemoryCache.cpp
@@ -254,7 +254,7 @@ void MemoryCache::pruneLiveResources(PruneStrategy strategy)
MemoryCacheEntry* current = m_liveDecodedResources.m_tail;
while (current) {
MemoryCacheEntry* previous = current->m_previousInLiveResourcesList;
- ASSERT(current->m_resource->hasClients());
+ ASSERT(current->m_resource->hasClientsOrObservers());
if (current->m_resource->isLoaded() && current->m_resource->decodedSize()) {
// Check to see if the remaining resources are too new to prune.
double elapsedTime = m_pruneFrameTimeStamp - current->m_lastDecodedAccessTime;
@@ -299,7 +299,7 @@ void MemoryCache::pruneDeadResources(PruneStrategy strategy)
ASSERT(previous->m_resource);
ASSERT(contains(previous->m_resource.get()));
}
- if (!current->m_resource->hasClients() && !current->m_resource->isPreloaded() && current->m_resource->isLoaded()) {
+ if (!current->m_resource->hasClientsOrObservers() && !current->m_resource->isPreloaded() && current->m_resource->isLoaded()) {
// Destroy our decoded data. This will remove us from
// m_liveDecodedResources, and possibly move us to a different
// LRU list in m_allResources.
@@ -323,7 +323,7 @@ void MemoryCache::pruneDeadResources(PruneStrategy strategy)
ASSERT(previous->m_resource);
ASSERT(contains(previous->m_resource.get()));
}
- if (!current->m_resource->hasClients() && !current->m_resource->isPreloaded()) {
+ if (!current->m_resource->hasClientsOrObservers() && !current->m_resource->isPreloaded()) {
evict(current);
if (targetSize && m_deadSize <= targetSize)
return;
@@ -535,7 +535,7 @@ void MemoryCache::update(Resource* resource, size_t oldSize, size_t newSize, boo
insertInLRUList(entry, lruListFor(entry->m_accessCount, newSize));
ptrdiff_t delta = newSize - oldSize;
- if (resource->hasClients()) {
+ if (resource->hasClientsOrObservers()) {
ASSERT(delta >= 0 || m_liveSize >= static_cast<size_t>(-delta) );
m_liveSize += delta;
} else {
@@ -551,7 +551,7 @@ void MemoryCache::updateDecodedResource(Resource* resource, UpdateReason reason)
return;
removeFromLiveDecodedResourcesList(entry);
- if (resource->decodedSize() && resource->hasClients())
+ if (resource->decodedSize() && resource->hasClientsOrObservers())
insertInLiveDecodedResourcesList(entry);
if (reason != UpdateForAccess)
@@ -576,7 +576,7 @@ void MemoryCache::TypeStatistic::addResource(Resource* o)
size_t pageSize = (o->encodedSize() + o->overheadSize() + 4095) & ~4095;
count++;
size += o->size();
- liveSize += o->hasClients() ? o->size() : 0;
+ liveSize += o->hasClientsOrObservers() ? o->size() : 0;
decodedSize += o->decodedSize();
encodedSize += o->encodedSize();
encodedSizeDuplicatedInDataURLs += o->url().protocolIsData() ? o->encodedSize() : 0;
@@ -767,8 +767,8 @@ void MemoryCache::dumpLRULists(bool includeLive) const
MemoryCacheEntry* current = m_allResources[i].m_tail;
while (current) {
RefPtrWillBeRawPtr<Resource> currentResource = current->m_resource;
- if (includeLive || !currentResource->hasClients())
- printf("(%.1fK, %.1fK, %uA, %dR, %d); ", currentResource->decodedSize() / 1024.0f, (currentResource->encodedSize() + currentResource->overheadSize()) / 1024.0f, current->m_accessCount, currentResource->hasClients(), currentResource->isPurgeable());
+ if (includeLive || !currentResource->hasClientsOrObservers())
+ printf("(%.1fK, %.1fK, %uA, %dR, %d); ", currentResource->decodedSize() / 1024.0f, (currentResource->encodedSize() + currentResource->overheadSize()) / 1024.0f, current->m_accessCount, currentResource->hasClientsOrObservers(), currentResource->isPurgeable());
current = current->m_previousInAllResourcesList;
}

Powered by Google App Engine
This is Rietveld 408576698