#include "wtf/TemporaryChange.h"
#include "wtf/text/CString.h"
-using namespace std;
-
namespace WebCore {
static MemoryCache* gMemoryCache;
ASSERT(WTF::isMainThread());
KURL url = removeFragmentIdentifierIfNeeded(resourceURL);
Resource* resource = m_resources.get(url);
- if (resource && !resource->makePurgeable(false)) {
+ if (resource && !resource->lock()) {
ASSERT(!resource->hasClients());
bool didEvict = evict(resource);
ASSERT_UNUSED(didEvict, didEvict);
size_t MemoryCache::deadCapacity() const
{
// Dead resource capacity is whatever space is not occupied by live resources, bounded by an independent minimum and maximum.
- size_t capacity = m_capacity - min(m_liveSize, m_capacity); // Start with available capacity.
- capacity = max(capacity, m_minDeadCapacity); // Make sure it's above the minimum.
- capacity = min(capacity, m_maxDeadCapacity); // Make sure it's below the maximum.
+ size_t capacity = m_capacity - std::min(m_liveSize, m_capacity); // Start with available capacity.
+ capacity = std::max(capacity, m_minDeadCapacity); // Make sure it's above the minimum.
+ capacity = std::min(capacity, m_maxDeadCapacity); // Make sure it's below the maximum.
return capacity;
}
if (elapsedTime < m_delayBeforeLiveDecodedPrune)
return;
- // Destroy our decoded data. This will remove us from
- // m_liveDecodedResources, and possibly move us to a different LRU
- // list in m_allResources.
- current->destroyDecodedData();
+ // Destroy our decoded data if possible. This will remove us
+ // from m_liveDecodedResources, and possibly move us to a
+ // different LRU list in m_allResources.
+ current->prune();
if (targetSize && m_liveSize <= targetSize)
return;
ResourcePtr<Resource> previous = current->m_prevInAllResourcesList;
ASSERT(!previous || previous->inCache());
if (!current->hasClients() && !current->isPreloaded() && current->isLoaded()) {
- // Destroy our decoded data. This will remove us from
- // m_liveDecodedResources, and possibly move us to a different
- // LRU list in m_allResources.
- current->destroyDecodedData();
+ // Destroy our decoded data if possible. This will remove us
+ // from m_liveDecodedResources, and possibly move us to a
+ // different LRU list in m_allResources.
+ current->prune();
if (targetSize && m_deadSize <= targetSize)
return;
MemoryCache::LRUList* MemoryCache::lruListFor(Resource* resource)
{
- unsigned accessCount = max(resource->accessCount(), 1U);
+ unsigned accessCount = std::max(resource->accessCount(), 1U);
unsigned queueIndex = WTF::fastLog2(resource->size() / accessCount);
#ifndef NDEBUG
resource->m_lruIndex = queueIndex;