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

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

Issue 2110823003: [WeakMemoryCache] Partial revert of Field-Trial: Make Reference from MemoryCache to Resource weak (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 | « third_party/WebKit/Source/core/fetch/MemoryCache.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 8aad84ef9bff434fae49d13d63ca1421cd1fa296..dade33621c1c86616ba772536871ae2abe19f339 100644
--- a/third_party/WebKit/Source/core/fetch/MemoryCache.cpp
+++ b/third_party/WebKit/Source/core/fetch/MemoryCache.cpp
@@ -23,7 +23,6 @@
#include "core/fetch/MemoryCache.h"
#include "platform/Logging.h"
-#include "platform/RuntimeEnabledFeatures.h"
#include "platform/TraceEvent.h"
#include "platform/weborigin/SecurityOrigin.h"
#include "platform/weborigin/SecurityOriginHash.h"
@@ -61,25 +60,9 @@ MemoryCache* replaceMemoryCacheForTesting(MemoryCache* cache)
return oldCache;
}
-MemoryCacheEntry::MemoryCacheEntry(Resource* resource)
- : m_inLiveDecodedResourcesList(false)
- , m_accessCount(0)
- , m_lastDecodedAccessTime(0.0)
- , m_previousInLiveResourcesList(nullptr)
- , m_nextInLiveResourcesList(nullptr)
- , m_previousInAllResourcesList(nullptr)
- , m_nextInAllResourcesList(nullptr)
-{
- if (RuntimeEnabledFeatures::weakMemoryCacheEnabled())
- m_resourceWeak = resource;
- else
- m_resource = resource;
-}
-
DEFINE_TRACE(MemoryCacheEntry)
{
visitor->trace(m_resource);
- visitor->trace(m_resourceWeak);
visitor->trace(m_previousInLiveResourcesList);
visitor->trace(m_nextInLiveResourcesList);
visitor->trace(m_previousInAllResourcesList);
@@ -89,13 +72,10 @@ DEFINE_TRACE(MemoryCacheEntry)
void MemoryCacheEntry::dispose()
{
m_resource.clear();
- m_resourceWeak.clear();
}
Resource* MemoryCacheEntry::resource()
{
- if (RuntimeEnabledFeatures::weakMemoryCacheEnabled())
- return m_resourceWeak.get();
return m_resource.get();
}
@@ -183,7 +163,7 @@ void MemoryCache::add(Resource* resource)
ASSERT(resource->url().isValid());
ResourceMap* resources = ensureResourceMap(resource->cacheIdentifier());
KURL url = removeFragmentIdentifierIfNeeded(resource->url());
- RELEASE_ASSERT(!contains(resource));
+ RELEASE_ASSERT(!resources->contains(url));
resources->set(url, MemoryCacheEntry::create(resource));
update(resource, 0, resource->size(), true);
@@ -233,11 +213,8 @@ HeapVector<Member<Resource>> MemoryCache::resourcesForURL(const KURL& resourceUR
KURL url = removeFragmentIdentifierIfNeeded(resourceURL);
HeapVector<Member<Resource>> results;
for (const auto& resourceMapIter : m_resourceMaps) {
- if (MemoryCacheEntry* entry = resourceMapIter.value->get(url)) {
- Resource* resource = entry->resource();
- if (resource)
- results.append(resource);
- }
+ if (MemoryCacheEntry* entry = resourceMapIter.value->get(url))
+ results.append(entry->resource());
}
return results;
}
@@ -282,10 +259,6 @@ void MemoryCache::pruneLiveResources(PruneStrategy strategy)
while (current) {
Resource* resource = current->resource();
MemoryCacheEntry* previous = current->m_previousInLiveResourcesList;
- if (!resource) {
- current = previous;
- continue;
- }
ASSERT(resource->hasClientsOrObservers());
if (resource->isLoaded() && resource->decodedSize()) {
@@ -392,7 +365,6 @@ void MemoryCache::evict(MemoryCacheEntry* entry)
ASSERT(WTF::isMainThread());
Resource* resource = entry->resource();
- DCHECK(resource);
WTF_LOG(ResourceLoading, "Evicting resource %p for '%s' from cache", resource, resource->url().getString().latin1().data());
// The resource may have already been removed by someone other than our caller,
// who needed a fresh copy for a reload. See <http://bugs.webkit.org/show_bug.cgi?id=12479#c6>.
@@ -413,7 +385,7 @@ void MemoryCache::evict(MemoryCacheEntry* entry)
MemoryCacheEntry* MemoryCache::getEntryForResource(const Resource* resource) const
{
- if (!resource || resource->url().isNull() || resource->url().isEmpty())
+ if (resource->url().isNull() || resource->url().isEmpty())
return nullptr;
ResourceMap* resources = m_resourceMaps.get(resource->cacheIdentifier());
if (!resources)
@@ -626,8 +598,6 @@ MemoryCache::Statistics MemoryCache::getStatistics()
for (const auto& resourceMapIter : m_resourceMaps) {
for (const auto& resourceIter : *resourceMapIter.value) {
Resource* resource = resourceIter.value->resource();
- if (!resource)
- continue;
switch (resource->getType()) {
case Resource::Image:
stats.images.addResource(resource);
@@ -664,10 +634,7 @@ void MemoryCache::evictResources()
ResourceMap::iterator resourceIter = resources->begin();
if (resourceIter == resources->end())
break;
- if (resourceIter->value->resource())
- evict(resourceIter->value.get());
- else
- resources->remove(resourceIter);
+ evict(resourceIter->value.get());
}
m_resourceMaps.remove(resourceMapIter);
}
@@ -761,8 +728,7 @@ bool MemoryCache::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebProc
for (const auto& resourceMapIter : m_resourceMaps) {
for (const auto& resourceIter : *resourceMapIter.value) {
Resource* resource = resourceIter.value->resource();
- if (resource)
- resource->onMemoryDump(levelOfDetail, memoryDump);
+ resource->onMemoryDump(levelOfDetail, memoryDump);
}
}
return true;
@@ -811,7 +777,7 @@ void MemoryCache::dumpLRULists(bool includeLive) const
MemoryCacheEntry* current = m_allResources[i].m_tail;
while (current) {
Resource* currentResource = current->resource();
- if (currentResource && (includeLive || !currentResource->hasClientsOrObservers()))
+ 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;
« no previous file with comments | « third_party/WebKit/Source/core/fetch/MemoryCache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698