Example #1
0
bool MemoryCache::evict(MemoryCacheEntry* entry)
{
    ASSERT(WTF::isMainThread());

    Resource* resource = entry->m_resource.get();
    bool canDelete = resource->canDelete();
    WTF_LOG(ResourceLoading, "Evicting resource %p for '%s' from cache", resource, resource->url().string().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>.
    update(resource, resource->size(), 0, false);
    removeFromLiveDecodedResourcesList(entry);

    ResourceMap* resources = m_resourceMaps.get(resource->cacheIdentifier());
    ASSERT(resources);
    ResourceMap::iterator it = resources->find(resource->url());
    ASSERT(it != resources->end());
#if ENABLE(OILPAN)
    MemoryCacheEntry* entryPtr = it->value;
#else
    OwnPtr<MemoryCacheEntry> entryPtr;
    entryPtr.swap(it->value);
#endif
    resources->remove(it);
#if ENABLE(OILPAN)
    if (entryPtr)
        entryPtr->dispose();
#endif
    return canDelete;
}