| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 , m_minDeadCapacity(0) | 98 , m_minDeadCapacity(0) |
| 99 , m_maxDeadCapacity(cDefaultCacheCapacity) | 99 , m_maxDeadCapacity(cDefaultCacheCapacity) |
| 100 , m_maxDeferredPruneDeadCapacity(cDeferredPruneDeadCapacityFactor * cDefault
CacheCapacity) | 100 , m_maxDeferredPruneDeadCapacity(cDeferredPruneDeadCapacityFactor * cDefault
CacheCapacity) |
| 101 , m_delayBeforeLiveDecodedPrune(cMinDelayBeforeLiveDecodedPrune) | 101 , m_delayBeforeLiveDecodedPrune(cMinDelayBeforeLiveDecodedPrune) |
| 102 , m_liveSize(0) | 102 , m_liveSize(0) |
| 103 , m_deadSize(0) | 103 , m_deadSize(0) |
| 104 #ifdef MEMORY_CACHE_STATS | 104 #ifdef MEMORY_CACHE_STATS |
| 105 , m_statsTimer(this, &MemoryCache::dumpStats) | 105 , m_statsTimer(this, &MemoryCache::dumpStats) |
| 106 #endif | 106 #endif |
| 107 { | 107 { |
| 108 Platform::current()->registerMemoryDumpProvider(this); |
| 108 #ifdef MEMORY_CACHE_STATS | 109 #ifdef MEMORY_CACHE_STATS |
| 109 const double statsIntervalInSeconds = 15; | 110 const double statsIntervalInSeconds = 15; |
| 110 m_statsTimer.startRepeating(statsIntervalInSeconds, FROM_HERE); | 111 m_statsTimer.startRepeating(statsIntervalInSeconds, FROM_HERE); |
| 111 #endif | 112 #endif |
| 112 } | 113 } |
| 113 | 114 |
| 114 MemoryCache* MemoryCache::create() | 115 MemoryCache* MemoryCache::create() |
| 115 { | 116 { |
| 116 return new MemoryCache; | 117 return new MemoryCache; |
| 117 } | 118 } |
| 118 | 119 |
| 119 MemoryCache::~MemoryCache() | 120 MemoryCache::~MemoryCache() |
| 120 { | 121 { |
| 122 Platform::current()->unregisterMemoryDumpProvider(this); |
| 121 if (m_prunePending) | 123 if (m_prunePending) |
| 122 Platform::current()->currentThread()->removeTaskObserver(this); | 124 Platform::current()->currentThread()->removeTaskObserver(this); |
| 123 } | 125 } |
| 124 | 126 |
| 125 DEFINE_TRACE(MemoryCache) | 127 DEFINE_TRACE(MemoryCache) |
| 126 { | 128 { |
| 127 visitor->trace(m_allResources); | 129 visitor->trace(m_allResources); |
| 128 for (size_t i = 0; i < WTF_ARRAY_LENGTH(m_liveDecodedResources); ++i) | 130 for (size_t i = 0; i < WTF_ARRAY_LENGTH(m_liveDecodedResources); ++i) |
| 129 visitor->trace(m_liveDecodedResources[i]); | 131 visitor->trace(m_liveDecodedResources[i]); |
| 130 visitor->trace(m_resourceMaps); | 132 visitor->trace(m_resourceMaps); |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 pruneLiveResources(strategy); | 775 pruneLiveResources(strategy); |
| 774 m_pruneFrameTimeStamp = m_lastFramePaintTimeStamp; | 776 m_pruneFrameTimeStamp = m_lastFramePaintTimeStamp; |
| 775 m_pruneTimeStamp = currentTime; | 777 m_pruneTimeStamp = currentTime; |
| 776 } | 778 } |
| 777 | 779 |
| 778 void MemoryCache::updateFramePaintTimestamp() | 780 void MemoryCache::updateFramePaintTimestamp() |
| 779 { | 781 { |
| 780 m_lastFramePaintTimeStamp = currentTime(); | 782 m_lastFramePaintTimeStamp = currentTime(); |
| 781 } | 783 } |
| 782 | 784 |
| 785 bool MemoryCache::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebProc
essMemoryDump* memoryDump) |
| 786 { |
| 787 for (const auto& resourceMapIter : m_resourceMaps) { |
| 788 for (const auto& resourceIter : *resourceMapIter.value) { |
| 789 Resource* resource = resourceIter.value->m_resource.get(); |
| 790 resource->onMemoryDump(memoryDump); |
| 791 } |
| 792 } |
| 793 return true; |
| 794 } |
| 795 |
| 783 void MemoryCache::registerLiveResource(Resource& resource) | 796 void MemoryCache::registerLiveResource(Resource& resource) |
| 784 { | 797 { |
| 785 #if ENABLE(OILPAN) | 798 #if ENABLE(OILPAN) |
| 786 ASSERT(!m_liveResources.contains(&resource)); | 799 ASSERT(!m_liveResources.contains(&resource)); |
| 787 m_liveResources.add(&resource); | 800 m_liveResources.add(&resource); |
| 788 #endif | 801 #endif |
| 789 } | 802 } |
| 790 | 803 |
| 791 void MemoryCache::unregisterLiveResource(Resource& resource) | 804 void MemoryCache::unregisterLiveResource(Resource& resource) |
| 792 { | 805 { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 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()); |
| 835 | 848 |
| 836 current = current->m_previousInAllResourcesList; | 849 current = current->m_previousInAllResourcesList; |
| 837 } | 850 } |
| 838 } | 851 } |
| 839 } | 852 } |
| 840 | 853 |
| 841 #endif // MEMORY_CACHE_STATS | 854 #endif // MEMORY_CACHE_STATS |
| 842 | 855 |
| 843 } // namespace blink | 856 } // namespace blink |
| OLD | NEW |