| 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. |
| 11 | 11 |
| 12 This library is distributed in the hope that it will be useful, | 12 This library is distributed in the hope that it will be useful, |
| 13 but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 Library General Public License for more details. | 15 Library General Public License for more details. |
| 16 | 16 |
| 17 You should have received a copy of the GNU Library General Public License | 17 You should have received a copy of the GNU Library General Public License |
| 18 along with this library; see the file COPYING.LIB. If not, write to | 18 along with this library; see the file COPYING.LIB. If not, write to |
| 19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 Boston, MA 02110-1301, USA. | 20 Boston, MA 02110-1301, USA. |
| 21 */ | 21 */ |
| 22 | 22 |
| 23 #include "config.h" | 23 #include "config.h" |
| 24 #include "core/fetch/MemoryCache.h" | 24 #include "core/fetch/MemoryCache.h" |
| 25 | 25 |
| 26 #include "core/fetch/ResourcePtr.h" | 26 #include "core/fetch/ResourcePtr.h" |
| 27 #include "core/fetch/WebCacheMemoryDumpProvider.h" |
| 27 #include "platform/Logging.h" | 28 #include "platform/Logging.h" |
| 28 #include "platform/TraceEvent.h" | 29 #include "platform/TraceEvent.h" |
| 29 #include "platform/weborigin/SecurityOrigin.h" | 30 #include "platform/weborigin/SecurityOrigin.h" |
| 30 #include "platform/weborigin/SecurityOriginHash.h" | 31 #include "platform/weborigin/SecurityOriginHash.h" |
| 31 #include "public/platform/Platform.h" | 32 #include "public/platform/Platform.h" |
| 32 #include "wtf/Assertions.h" | 33 #include "wtf/Assertions.h" |
| 33 #include "wtf/CurrentTime.h" | 34 #include "wtf/CurrentTime.h" |
| 34 #include "wtf/MainThread.h" | 35 #include "wtf/MainThread.h" |
| 35 #include "wtf/MathExtras.h" | 36 #include "wtf/MathExtras.h" |
| 36 #include "wtf/TemporaryChange.h" | 37 #include "wtf/TemporaryChange.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 58 { | 59 { |
| 59 #if ENABLE(OILPAN) | 60 #if ENABLE(OILPAN) |
| 60 // Move m_liveResources content to keep Resource objects alive. | 61 // Move m_liveResources content to keep Resource objects alive. |
| 61 for (const auto& resource : memoryCache()->m_liveResources) | 62 for (const auto& resource : memoryCache()->m_liveResources) |
| 62 cache->m_liveResources.add(resource); | 63 cache->m_liveResources.add(resource); |
| 63 memoryCache()->m_liveResources.clear(); | 64 memoryCache()->m_liveResources.clear(); |
| 64 #endif | 65 #endif |
| 65 memoryCache(); | 66 memoryCache(); |
| 66 MemoryCache* oldCache = gMemoryCache->release(); | 67 MemoryCache* oldCache = gMemoryCache->release(); |
| 67 *gMemoryCache = cache; | 68 *gMemoryCache = cache; |
| 69 WebCacheMemoryDumpProvider::instance()->setMemoryCache(cache); |
| 68 return oldCache; | 70 return oldCache; |
| 69 } | 71 } |
| 70 | 72 |
| 71 DEFINE_TRACE(MemoryCacheEntry) | 73 DEFINE_TRACE(MemoryCacheEntry) |
| 72 { | 74 { |
| 73 visitor->trace(m_previousInLiveResourcesList); | 75 visitor->trace(m_previousInLiveResourcesList); |
| 74 visitor->trace(m_nextInLiveResourcesList); | 76 visitor->trace(m_nextInLiveResourcesList); |
| 75 visitor->trace(m_previousInAllResourcesList); | 77 visitor->trace(m_previousInAllResourcesList); |
| 76 visitor->trace(m_nextInAllResourcesList); | 78 visitor->trace(m_nextInAllResourcesList); |
| 77 } | 79 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 98 , m_minDeadCapacity(0) | 100 , m_minDeadCapacity(0) |
| 99 , m_maxDeadCapacity(cDefaultCacheCapacity) | 101 , m_maxDeadCapacity(cDefaultCacheCapacity) |
| 100 , m_maxDeferredPruneDeadCapacity(cDeferredPruneDeadCapacityFactor * cDefault
CacheCapacity) | 102 , m_maxDeferredPruneDeadCapacity(cDeferredPruneDeadCapacityFactor * cDefault
CacheCapacity) |
| 101 , m_delayBeforeLiveDecodedPrune(cMinDelayBeforeLiveDecodedPrune) | 103 , m_delayBeforeLiveDecodedPrune(cMinDelayBeforeLiveDecodedPrune) |
| 102 , m_liveSize(0) | 104 , m_liveSize(0) |
| 103 , m_deadSize(0) | 105 , m_deadSize(0) |
| 104 #ifdef MEMORY_CACHE_STATS | 106 #ifdef MEMORY_CACHE_STATS |
| 105 , m_statsTimer(this, &MemoryCache::dumpStats) | 107 , m_statsTimer(this, &MemoryCache::dumpStats) |
| 106 #endif | 108 #endif |
| 107 { | 109 { |
| 110 WebCacheMemoryDumpProvider::instance()->setMemoryCache(this); |
| 108 #ifdef MEMORY_CACHE_STATS | 111 #ifdef MEMORY_CACHE_STATS |
| 109 const double statsIntervalInSeconds = 15; | 112 const double statsIntervalInSeconds = 15; |
| 110 m_statsTimer.startRepeating(statsIntervalInSeconds, BLINK_FROM_HERE); | 113 m_statsTimer.startRepeating(statsIntervalInSeconds, BLINK_FROM_HERE); |
| 111 #endif | 114 #endif |
| 112 } | 115 } |
| 113 | 116 |
| 114 MemoryCache* MemoryCache::create() | 117 MemoryCache* MemoryCache::create() |
| 115 { | 118 { |
| 116 return new MemoryCache; | 119 return new MemoryCache; |
| 117 } | 120 } |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 pruneLiveResources(strategy); | 776 pruneLiveResources(strategy); |
| 774 m_pruneFrameTimeStamp = m_lastFramePaintTimeStamp; | 777 m_pruneFrameTimeStamp = m_lastFramePaintTimeStamp; |
| 775 m_pruneTimeStamp = currentTime; | 778 m_pruneTimeStamp = currentTime; |
| 776 } | 779 } |
| 777 | 780 |
| 778 void MemoryCache::updateFramePaintTimestamp() | 781 void MemoryCache::updateFramePaintTimestamp() |
| 779 { | 782 { |
| 780 m_lastFramePaintTimeStamp = currentTime(); | 783 m_lastFramePaintTimeStamp = currentTime(); |
| 781 } | 784 } |
| 782 | 785 |
| 786 void MemoryCache::onMemoryDump(WebProcessMemoryDump* memoryDump) |
| 787 { |
| 788 for (const auto& resourceMapIter : m_resourceMaps) { |
| 789 for (const auto& resourceIter : *resourceMapIter.value) { |
| 790 Resource* resource = resourceIter.value->m_resource.get(); |
| 791 resource->onMemoryDump(memoryDump); |
| 792 } |
| 793 } |
| 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 |