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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 // Destroy our decoded data. This will remove us from | 347 // Destroy our decoded data. This will remove us from |
348 // m_liveDecodedResources, and possibly move us to a different | 348 // m_liveDecodedResources, and possibly move us to a different |
349 // LRU list in m_allResources. | 349 // LRU list in m_allResources. |
350 current->m_resource->prune(); | 350 current->m_resource->prune(); |
351 | 351 |
352 if (targetSize && m_deadSize <= targetSize) | 352 if (targetSize && m_deadSize <= targetSize) |
353 return; | 353 return; |
354 } | 354 } |
355 // Decoded data may reference other resources. Stop iterating if 'pr
evious' somehow got | 355 // Decoded data may reference other resources. Stop iterating if 'pr
evious' somehow got |
356 // kicked out of cache during destroyDecodedData(). | 356 // kicked out of cache during destroyDecodedData(). |
357 if (!previous || !previous->m_resource || !contains(previous->m_reso
urce.get())) | 357 if (previous && !contains(previous->m_resource.get())) |
358 break; | 358 break; |
359 current = previous; | 359 current = previous; |
360 } | 360 } |
361 | 361 |
362 // Now evict objects from this queue. | 362 // Now evict objects from this queue. |
363 current = m_allResources[i].m_tail; | 363 current = m_allResources[i].m_tail; |
364 while (current) { | 364 while (current) { |
365 MemoryCacheEntry* previous = current->m_previousInAllResourcesList; | 365 MemoryCacheEntry* previous = current->m_previousInAllResourcesList; |
366 ASSERT(!previous || contains(previous->m_resource.get())); | 366 ASSERT(!previous || contains(previous->m_resource.get())); |
367 if (!current->m_resource->hasClients() && !current->m_resource->isPr
eloaded() | 367 if (!current->m_resource->hasClients() && !current->m_resource->isPr
eloaded() |
368 && !current->m_resource->isCacheValidator() && current->m_resour
ce->canDelete() | 368 && !current->m_resource->isCacheValidator() && current->m_resour
ce->canDelete() |
369 && current->m_resource->type() != Resource::MainResource) { | 369 && current->m_resource->type() != Resource::MainResource) { |
370 // Main Resources in the cache are only substitue data that was | 370 // Main Resources in the cache are only substitue data that was |
371 // precached and should not be evicted. | 371 // precached and should not be evicted. |
372 bool wasEvicted = evict(current); | 372 bool wasEvicted = evict(current); |
373 ASSERT_UNUSED(wasEvicted, wasEvicted); | 373 ASSERT_UNUSED(wasEvicted, wasEvicted); |
374 if (targetSize && m_deadSize <= targetSize) | 374 if (targetSize && m_deadSize <= targetSize) |
375 return; | 375 return; |
376 } | 376 } |
377 if (!previous || !previous->m_resource || !contains(previous->m_reso
urce.get())) | 377 if (previous && !contains(previous->m_resource.get())) |
378 break; | 378 break; |
379 current = previous; | 379 current = previous; |
380 } | 380 } |
381 | 381 |
382 // Shrink the vector back down so we don't waste time inspecting | 382 // Shrink the vector back down so we don't waste time inspecting |
383 // empty LRU lists on future prunes. | 383 // empty LRU lists on future prunes. |
384 if (m_allResources[i].m_head) | 384 if (m_allResources[i].m_head) |
385 canShrinkLRULists = false; | 385 canShrinkLRULists = false; |
386 else if (canShrinkLRULists) | 386 else if (canShrinkLRULists) |
387 m_allResources.resize(i); | 387 m_allResources.resize(i); |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 void MemoryCache::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebProc
essMemoryDump* memoryDump) | 786 void MemoryCache::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebProc
essMemoryDump* memoryDump) |
787 { | 787 { |
788 for (const auto& resourceMapIter : m_resourceMaps) { | 788 for (const auto& resourceMapIter : m_resourceMaps) { |
789 for (const auto& resourceIter : *resourceMapIter.value) { | 789 for (const auto& resourceIter : *resourceMapIter.value) { |
790 Resource* resource = resourceIter.value->m_resource.get(); | 790 Resource* resource = resourceIter.value->m_resource.get(); |
791 resource->onMemoryDump(levelOfDetail, memoryDump); | 791 resource->onMemoryDump(levelOfDetail, memoryDump); |
792 } | 792 } |
793 } | 793 } |
794 } | 794 } |
795 | 795 |
796 bool MemoryCache::isInSameLRUListForTest(const Resource* x, const Resource* y) | |
797 { | |
798 MemoryCacheEntry* ex = getEntryForResource(x); | |
799 MemoryCacheEntry* ey = getEntryForResource(y); | |
800 ASSERT(ex); | |
801 ASSERT(ey); | |
802 return lruListFor(ex->m_accessCount, x->size()) == lruListFor(ey->m_accessCo
unt, y->size()); | |
803 } | |
804 | |
805 void MemoryCache::registerLiveResource(Resource& resource) | 796 void MemoryCache::registerLiveResource(Resource& resource) |
806 { | 797 { |
807 #if ENABLE(OILPAN) | 798 #if ENABLE(OILPAN) |
808 ASSERT(!m_liveResources.contains(&resource)); | 799 ASSERT(!m_liveResources.contains(&resource)); |
809 m_liveResources.add(&resource); | 800 m_liveResources.add(&resource); |
810 #endif | 801 #endif |
811 } | 802 } |
812 | 803 |
813 void MemoryCache::unregisterLiveResource(Resource& resource) | 804 void MemoryCache::unregisterLiveResource(Resource& resource) |
814 { | 805 { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 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()); | 847 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()); |
857 | 848 |
858 current = current->m_previousInAllResourcesList; | 849 current = current->m_previousInAllResourcesList; |
859 } | 850 } |
860 } | 851 } |
861 } | 852 } |
862 | 853 |
863 #endif // MEMORY_CACHE_STATS | 854 #endif // MEMORY_CACHE_STATS |
864 | 855 |
865 } // namespace blink | 856 } // namespace blink |
OLD | NEW |