WillBeHeapVector<RawPtrWillBeMember<Resource>> MemoryCache::resourcesForURL(const KURL& resourceURL) { ASSERT(WTF::isMainThread()); KURL url = removeFragmentIdentifierIfNeeded(resourceURL); WillBeHeapVector<RawPtrWillBeMember<Resource>> results; for (const auto& resourceMapIter : m_resourceMaps) { if (MemoryCacheEntry* entry = resourceMapIter.value->get(url)) results.append(entry->m_resource.get()); } return results; }
Resource* MemoryCache::resourceForURL(const KURL& resourceURL) { ASSERT(WTF::isMainThread()); KURL url = removeFragmentIdentifierIfNeeded(resourceURL); Resource* resource = m_resources.get(url); if (resource && !resource->makePurgeable(false)) { ASSERT(!resource->hasClients()); evict(resource); return 0; } return resource; }
CachedResource* MemoryCache::resourceForRequestImpl(const ResourceRequest& request, CachedResourceMap& resources) { ASSERT(WTF::isMainThread()); URL url = removeFragmentIdentifierIfNeeded(request.url()); #if ENABLE(CACHE_PARTITIONING) auto key = std::make_pair(url, request.cachePartition()); #else auto& key = url; #endif return resources.get(key); }
Resource* MemoryCache::resourceForURL(const KURL& resourceURL, const String& cacheIdentifier) { ASSERT(WTF::isMainThread()); ResourceMap* resources = m_resourceMaps.get(cacheIdentifier); if (!resources) return nullptr; KURL url = removeFragmentIdentifierIfNeeded(resourceURL); MemoryCacheEntry* entry = resources->get(url); if (!entry) return nullptr; Resource* resource = entry->m_resource.get(); if (resource && !resource->lock()) { ASSERT(!resource->hasClients()); bool didEvict = evict(entry); ASSERT_UNUSED(didEvict, didEvict); return nullptr; } return resource; }
CachedResource* MemoryCache::resourceForRequest(const ResourceRequest& request) { ASSERT(WTF::isMainThread()); KURL url = removeFragmentIdentifierIfNeeded(request.url()); #if ENABLE(CACHE_PARTITIONING) CachedResourceItem* item = m_resources.get(url); CachedResource* resource = 0; if (item) resource = item->get(request.cachePartition()); #else CachedResource* resource = m_resources.get(url); #endif bool wasPurgeable = MemoryCache::shouldMakeResourcePurgeableOnEviction() && resource && resource->isPurgeable(); if (resource && !resource->makePurgeable(false)) { ASSERT(!resource->hasClients()); evict(resource); return 0; } // Add the size back since we had subtracted it when we marked the memory as purgeable. if (wasPurgeable) adjustSize(resource->hasClients(), resource->size()); return resource; }