OLD | NEW |
1 /* | 1 /* |
2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) | 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) |
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) | 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
5 Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 5 Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
6 | 6 |
7 This library is free software; you can redistribute it and/or | 7 This library is free software; you can redistribute it and/or |
8 modify it under the terms of the GNU Library General Public | 8 modify it under the terms of the GNU Library General Public |
9 License as published by the Free Software Foundation; either | 9 License as published by the Free Software Foundation; either |
10 version 2 of the License, or (at your option) any later version. | 10 version 2 of the License, or (at your option) any later version. |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 Resource* resource = entry->m_resource.get(); | 219 Resource* resource = entry->m_resource.get(); |
220 if (resource && !resource->lock()) { | 220 if (resource && !resource->lock()) { |
221 ASSERT(!resource->hasClients()); | 221 ASSERT(!resource->hasClients()); |
222 bool didEvict = evict(entry); | 222 bool didEvict = evict(entry); |
223 ASSERT_UNUSED(didEvict, didEvict); | 223 ASSERT_UNUSED(didEvict, didEvict); |
224 return nullptr; | 224 return nullptr; |
225 } | 225 } |
226 return resource; | 226 return resource; |
227 } | 227 } |
228 | 228 |
229 WillBeHeapVector<Member<Resource>> MemoryCache::resourcesForURL(const KURL& reso
urceURL) | 229 WillBeHeapVector<RawPtrWillBeMember<Resource>> MemoryCache::resourcesForURL(cons
t KURL& resourceURL) |
230 { | 230 { |
231 ASSERT(WTF::isMainThread()); | 231 ASSERT(WTF::isMainThread()); |
232 KURL url = removeFragmentIdentifierIfNeeded(resourceURL); | 232 KURL url = removeFragmentIdentifierIfNeeded(resourceURL); |
233 WillBeHeapVector<Member<Resource>> results; | 233 WillBeHeapVector<RawPtrWillBeMember<Resource>> results; |
234 for (const auto& resourceMapIter : m_resourceMaps) { | 234 for (const auto& resourceMapIter : m_resourceMaps) { |
235 if (MemoryCacheEntry* entry = resourceMapIter.value->get(url)) | 235 if (MemoryCacheEntry* entry = resourceMapIter.value->get(url)) |
236 results.append(entry->m_resource.get()); | 236 results.append(entry->m_resource.get()); |
237 } | 237 } |
238 return results; | 238 return results; |
239 } | 239 } |
240 | 240 |
241 size_t MemoryCache::deadCapacity() const | 241 size_t MemoryCache::deadCapacity() const |
242 { | 242 { |
243 // Dead resource capacity is whatever space is not occupied by live resource
s, bounded by an independent minimum and maximum. | 243 // Dead resource capacity is whatever space is not occupied by live resource
s, bounded by an independent minimum and maximum. |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 MemoryCacheLiveResourcePriority MemoryCache::priority(Resource* resource) const | 624 MemoryCacheLiveResourcePriority MemoryCache::priority(Resource* resource) const |
625 { | 625 { |
626 MemoryCacheEntry* entry = getEntryForResource(resource); | 626 MemoryCacheEntry* entry = getEntryForResource(resource); |
627 if (!entry) | 627 if (!entry) |
628 return MemoryCacheLiveResourcePriorityUnknown; | 628 return MemoryCacheLiveResourcePriorityUnknown; |
629 return entry->m_liveResourcePriority; | 629 return entry->m_liveResourcePriority; |
630 } | 630 } |
631 | 631 |
632 void MemoryCache::removeURLFromCache(const KURL& url) | 632 void MemoryCache::removeURLFromCache(const KURL& url) |
633 { | 633 { |
634 WillBeHeapVector<Member<Resource>> resources = resourcesForURL(url); | 634 WillBeHeapVector<RawPtrWillBeMember<Resource>> resources = resourcesForURL(u
rl); |
635 for (Resource* resource : resources) | 635 for (Resource* resource : resources) |
636 memoryCache()->remove(resource); | 636 memoryCache()->remove(resource); |
637 } | 637 } |
638 | 638 |
639 void MemoryCache::TypeStatistic::addResource(Resource* o) | 639 void MemoryCache::TypeStatistic::addResource(Resource* o) |
640 { | 640 { |
641 bool purged = o->wasPurged(); | 641 bool purged = o->wasPurged(); |
642 bool purgeable = o->isPurgeable() && !purged; | 642 bool purgeable = o->isPurgeable() && !purged; |
643 size_t pageSize = (o->encodedSize() + o->overheadSize() + 4095) & ~4095; | 643 size_t pageSize = (o->encodedSize() + o->overheadSize() + 4095) & ~4095; |
644 count++; | 644 count++; |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 printf("(%.1fK, %.1fK, %uA, %dR, %d, %d); ", currentResource->de
codedSize() / 1024.0f, (currentResource->encodedSize() + currentResource->overhe
adSize()) / 1024.0f, current->m_accessCount, currentResource->hasClients(), curr
entResource->isPurgeable(), currentResource->wasPurged()); | 848 printf("(%.1fK, %.1fK, %uA, %dR, %d, %d); ", currentResource->de
codedSize() / 1024.0f, (currentResource->encodedSize() + currentResource->overhe
adSize()) / 1024.0f, current->m_accessCount, currentResource->hasClients(), curr
entResource->isPurgeable(), currentResource->wasPurged()); |
849 | 849 |
850 current = current->m_previousInAllResourcesList; | 850 current = current->m_previousInAllResourcesList; |
851 } | 851 } |
852 } | 852 } |
853 } | 853 } |
854 | 854 |
855 #endif // MEMORY_CACHE_STATS | 855 #endif // MEMORY_CACHE_STATS |
856 | 856 |
857 } // namespace blink | 857 } // namespace blink |
OLD | NEW |