| 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 KURL url = removeFragmentIdentifierIfNeeded(resourceURL); | 195 KURL url = removeFragmentIdentifierIfNeeded(resourceURL); |
| 196 MemoryCacheEntry* entry = resources->get(url); | 196 MemoryCacheEntry* entry = resources->get(url); |
| 197 if (!entry) | 197 if (!entry) |
| 198 return nullptr; | 198 return nullptr; |
| 199 Resource* resource = entry->m_resource.get(); | 199 Resource* resource = entry->m_resource.get(); |
| 200 if (resource && !resource->lock()) | 200 if (resource && !resource->lock()) |
| 201 return nullptr; | 201 return nullptr; |
| 202 return resource; | 202 return resource; |
| 203 } | 203 } |
| 204 | 204 |
| 205 WillBeHeapVector<RawPtrWillBeMember<Resource>> MemoryCache::resourcesForURL(cons
t KURL& resourceURL) | 205 HeapVector<Member<Resource>> MemoryCache::resourcesForURL(const KURL& resourceUR
L) |
| 206 { | 206 { |
| 207 ASSERT(WTF::isMainThread()); | 207 ASSERT(WTF::isMainThread()); |
| 208 KURL url = removeFragmentIdentifierIfNeeded(resourceURL); | 208 KURL url = removeFragmentIdentifierIfNeeded(resourceURL); |
| 209 WillBeHeapVector<RawPtrWillBeMember<Resource>> results; | 209 HeapVector<Member<Resource>> results; |
| 210 for (const auto& resourceMapIter : m_resourceMaps) { | 210 for (const auto& resourceMapIter : m_resourceMaps) { |
| 211 if (MemoryCacheEntry* entry = resourceMapIter.value->get(url)) | 211 if (MemoryCacheEntry* entry = resourceMapIter.value->get(url)) |
| 212 results.append(entry->m_resource.get()); | 212 results.append(entry->m_resource.get()); |
| 213 } | 213 } |
| 214 return results; | 214 return results; |
| 215 } | 215 } |
| 216 | 216 |
| 217 size_t MemoryCache::deadCapacity() const | 217 size_t MemoryCache::deadCapacity() const |
| 218 { | 218 { |
| 219 // Dead resource capacity is whatever space is not occupied by live resource
s, bounded by an independent minimum and maximum. | 219 // Dead resource capacity is whatever space is not occupied by live resource
s, bounded by an independent minimum and maximum. |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 return; | 563 return; |
| 564 | 564 |
| 565 double timestamp = resource->isImage() ? m_lastFramePaintTimeStamp : 0.0; | 565 double timestamp = resource->isImage() ? m_lastFramePaintTimeStamp : 0.0; |
| 566 if (!timestamp) | 566 if (!timestamp) |
| 567 timestamp = currentTime(); | 567 timestamp = currentTime(); |
| 568 entry->m_lastDecodedAccessTime = timestamp; | 568 entry->m_lastDecodedAccessTime = timestamp; |
| 569 } | 569 } |
| 570 | 570 |
| 571 void MemoryCache::removeURLFromCache(const KURL& url) | 571 void MemoryCache::removeURLFromCache(const KURL& url) |
| 572 { | 572 { |
| 573 WillBeHeapVector<RawPtrWillBeMember<Resource>> resources = resourcesForURL(u
rl); | 573 HeapVector<Member<Resource>> resources = resourcesForURL(url); |
| 574 for (Resource* resource : resources) | 574 for (Resource* resource : resources) |
| 575 memoryCache()->remove(resource); | 575 memoryCache()->remove(resource); |
| 576 } | 576 } |
| 577 | 577 |
| 578 void MemoryCache::TypeStatistic::addResource(Resource* o) | 578 void MemoryCache::TypeStatistic::addResource(Resource* o) |
| 579 { | 579 { |
| 580 bool purgeable = o->isPurgeable(); | 580 bool purgeable = o->isPurgeable(); |
| 581 size_t pageSize = (o->encodedSize() + o->overheadSize() + 4095) & ~4095; | 581 size_t pageSize = (o->encodedSize() + o->overheadSize() + 4095) & ~4095; |
| 582 count++; | 582 count++; |
| 583 size += o->size(); | 583 size += o->size(); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 | 764 |
| 765 void MemoryCache::dumpLRULists(bool includeLive) const | 765 void MemoryCache::dumpLRULists(bool includeLive) const |
| 766 { | 766 { |
| 767 printf("LRU-SP lists in eviction order (Kilobytes decoded, Kilobytes encoded
, Access count, Referenced, isPurgeable):\n"); | 767 printf("LRU-SP lists in eviction order (Kilobytes decoded, Kilobytes encoded
, Access count, Referenced, isPurgeable):\n"); |
| 768 | 768 |
| 769 int size = m_allResources.size(); | 769 int size = m_allResources.size(); |
| 770 for (int i = size - 1; i >= 0; i--) { | 770 for (int i = size - 1; i >= 0; i--) { |
| 771 printf("\n\nList %d: ", i); | 771 printf("\n\nList %d: ", i); |
| 772 MemoryCacheEntry* current = m_allResources[i].m_tail; | 772 MemoryCacheEntry* current = m_allResources[i].m_tail; |
| 773 while (current) { | 773 while (current) { |
| 774 RefPtrWillBeRawPtr<Resource> currentResource = current->m_resource; | 774 RawPtr<Resource> currentResource = current->m_resource; |
| 775 if (includeLive || !currentResource->hasClientsOrObservers()) | 775 if (includeLive || !currentResource->hasClientsOrObservers()) |
| 776 printf("(%.1fK, %.1fK, %uA, %dR, %d); ", currentResource->decode
dSize() / 1024.0f, (currentResource->encodedSize() + currentResource->overheadSi
ze()) / 1024.0f, current->m_accessCount, currentResource->hasClientsOrObservers(
), currentResource->isPurgeable()); | 776 printf("(%.1fK, %.1fK, %uA, %dR, %d); ", currentResource->decode
dSize() / 1024.0f, (currentResource->encodedSize() + currentResource->overheadSi
ze()) / 1024.0f, current->m_accessCount, currentResource->hasClientsOrObservers(
), currentResource->isPurgeable()); |
| 777 | 777 |
| 778 current = current->m_previousInAllResourcesList; | 778 current = current->m_previousInAllResourcesList; |
| 779 } | 779 } |
| 780 } | 780 } |
| 781 } | 781 } |
| 782 | 782 |
| 783 #endif // MEMORY_CACHE_STATS | 783 #endif // MEMORY_CACHE_STATS |
| 784 | 784 |
| 785 } // namespace blink | 785 } // namespace blink |
| OLD | NEW |