| 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 10 matching lines...) Expand all Loading... |
| 21 */ | 21 */ |
| 22 | 22 |
| 23 #include "core/fetch/MemoryCache.h" | 23 #include "core/fetch/MemoryCache.h" |
| 24 | 24 |
| 25 #include "platform/Logging.h" | 25 #include "platform/Logging.h" |
| 26 #include "platform/TraceEvent.h" | 26 #include "platform/TraceEvent.h" |
| 27 #include "platform/weborigin/SecurityOrigin.h" | 27 #include "platform/weborigin/SecurityOrigin.h" |
| 28 #include "platform/weborigin/SecurityOriginHash.h" | 28 #include "platform/weborigin/SecurityOriginHash.h" |
| 29 #include "public/platform/Platform.h" | 29 #include "public/platform/Platform.h" |
| 30 #include "wtf/Assertions.h" | 30 #include "wtf/Assertions.h" |
| 31 #include "wtf/AutoReset.h" |
| 31 #include "wtf/CurrentTime.h" | 32 #include "wtf/CurrentTime.h" |
| 32 #include "wtf/MathExtras.h" | 33 #include "wtf/MathExtras.h" |
| 33 #include "wtf/TemporaryChange.h" | |
| 34 #include "wtf/text/CString.h" | 34 #include "wtf/text/CString.h" |
| 35 | 35 |
| 36 namespace blink { | 36 namespace blink { |
| 37 | 37 |
| 38 static Persistent<MemoryCache>* gMemoryCache; | 38 static Persistent<MemoryCache>* gMemoryCache; |
| 39 | 39 |
| 40 static const unsigned cDefaultCacheCapacity = 8192 * 1024; | 40 static const unsigned cDefaultCacheCapacity = 8192 * 1024; |
| 41 static const unsigned cDeferredPruneDeadCapacityFactor = 2; | 41 static const unsigned cDeferredPruneDeadCapacityFactor = 2; |
| 42 static const int cMinDelayBeforeLiveDecodedPrune = 1; // Seconds. | 42 static const int cMinDelayBeforeLiveDecodedPrune = 1; // Seconds. |
| 43 static const double cMaxPruneDeferralDelay = 0.5; // Seconds. | 43 static const double cMaxPruneDeferralDelay = 0.5; // Seconds. |
| (...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 pruneNow(currentTime, MaximalPrune); | 704 pruneNow(currentTime, MaximalPrune); |
| 705 } | 705 } |
| 706 | 706 |
| 707 void MemoryCache::pruneNow(double currentTime, PruneStrategy strategy) | 707 void MemoryCache::pruneNow(double currentTime, PruneStrategy strategy) |
| 708 { | 708 { |
| 709 if (m_prunePending) { | 709 if (m_prunePending) { |
| 710 m_prunePending = false; | 710 m_prunePending = false; |
| 711 Platform::current()->currentThread()->removeTaskObserver(this); | 711 Platform::current()->currentThread()->removeTaskObserver(this); |
| 712 } | 712 } |
| 713 | 713 |
| 714 TemporaryChange<bool> reentrancyProtector(m_inPruneResources, true); | 714 AutoReset<bool> reentrancyProtector(&m_inPruneResources, true); |
| 715 pruneDeadResources(strategy); // Prune dead first, in case it was "borrowing
" capacity from live. | 715 pruneDeadResources(strategy); // Prune dead first, in case it was "borrowing
" capacity from live. |
| 716 pruneLiveResources(strategy); | 716 pruneLiveResources(strategy); |
| 717 m_pruneFrameTimeStamp = m_lastFramePaintTimeStamp; | 717 m_pruneFrameTimeStamp = m_lastFramePaintTimeStamp; |
| 718 m_pruneTimeStamp = currentTime; | 718 m_pruneTimeStamp = currentTime; |
| 719 } | 719 } |
| 720 | 720 |
| 721 void MemoryCache::updateFramePaintTimestamp() | 721 void MemoryCache::updateFramePaintTimestamp() |
| 722 { | 722 { |
| 723 m_lastFramePaintTimeStamp = currentTime(); | 723 m_lastFramePaintTimeStamp = currentTime(); |
| 724 } | 724 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 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()); | 781 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()); |
| 782 | 782 |
| 783 current = current->m_previousInAllResourcesList; | 783 current = current->m_previousInAllResourcesList; |
| 784 } | 784 } |
| 785 } | 785 } |
| 786 } | 786 } |
| 787 | 787 |
| 788 #endif // MEMORY_CACHE_STATS | 788 #endif // MEMORY_CACHE_STATS |
| 789 | 789 |
| 790 } // namespace blink | 790 } // namespace blink |
| OLD | NEW |