| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 } | 116 } |
| 117 | 117 |
| 118 PassOwnPtrWillBeRawPtr<MemoryCache> MemoryCache::create() | 118 PassOwnPtrWillBeRawPtr<MemoryCache> MemoryCache::create() |
| 119 { | 119 { |
| 120 return adoptPtrWillBeNoop(new MemoryCache()); | 120 return adoptPtrWillBeNoop(new MemoryCache()); |
| 121 } | 121 } |
| 122 | 122 |
| 123 MemoryCache::~MemoryCache() | 123 MemoryCache::~MemoryCache() |
| 124 { | 124 { |
| 125 if (m_prunePending) | 125 if (m_prunePending) |
| 126 blink::Platform::current()->currentThread()->removeTaskObserver(this); | 126 Platform::current()->currentThread()->removeTaskObserver(this); |
| 127 } | 127 } |
| 128 | 128 |
| 129 DEFINE_TRACE(MemoryCache) | 129 DEFINE_TRACE(MemoryCache) |
| 130 { | 130 { |
| 131 #if ENABLE(OILPAN) | 131 #if ENABLE(OILPAN) |
| 132 visitor->trace(m_allResources); | 132 visitor->trace(m_allResources); |
| 133 for (size_t i = 0; i < WTF_ARRAY_LENGTH(m_liveDecodedResources); ++i) | 133 for (size_t i = 0; i < WTF_ARRAY_LENGTH(m_liveDecodedResources); ++i) |
| 134 visitor->trace(m_liveDecodedResources[i]); | 134 visitor->trace(m_liveDecodedResources[i]); |
| 135 visitor->trace(m_resourceMaps); | 135 visitor->trace(m_resourceMaps); |
| 136 visitor->trace(m_liveResources); | 136 visitor->trace(m_liveResources); |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 double currentTime = WTF::currentTime(); | 718 double currentTime = WTF::currentTime(); |
| 719 if (m_prunePending) { | 719 if (m_prunePending) { |
| 720 if (currentTime - m_pruneTimeStamp >= m_maxPruneDeferralDelay) { | 720 if (currentTime - m_pruneTimeStamp >= m_maxPruneDeferralDelay) { |
| 721 pruneNow(currentTime, AutomaticPrune); | 721 pruneNow(currentTime, AutomaticPrune); |
| 722 } | 722 } |
| 723 } else { | 723 } else { |
| 724 if (currentTime - m_pruneTimeStamp >= m_maxPruneDeferralDelay) { | 724 if (currentTime - m_pruneTimeStamp >= m_maxPruneDeferralDelay) { |
| 725 pruneNow(currentTime, AutomaticPrune); // Delay exceeded, prune now. | 725 pruneNow(currentTime, AutomaticPrune); // Delay exceeded, prune now. |
| 726 } else { | 726 } else { |
| 727 // Defer. | 727 // Defer. |
| 728 blink::Platform::current()->currentThread()->addTaskObserver(this); | 728 Platform::current()->currentThread()->addTaskObserver(this); |
| 729 m_prunePending = true; | 729 m_prunePending = true; |
| 730 } | 730 } |
| 731 } | 731 } |
| 732 | 732 |
| 733 if (m_prunePending && m_deadSize > m_maxDeferredPruneDeadCapacity && justRel
easedResource) { | 733 if (m_prunePending && m_deadSize > m_maxDeferredPruneDeadCapacity && justRel
easedResource) { |
| 734 // The following eviction does not respect LRU order, but it can be done | 734 // The following eviction does not respect LRU order, but it can be done |
| 735 // immediately in constant time, as opposed to pruneDeadResources, which | 735 // immediately in constant time, as opposed to pruneDeadResources, which |
| 736 // we would rather defer because it is O(N), which would make tear-down
of N | 736 // we would rather defer because it is O(N), which would make tear-down
of N |
| 737 // objects O(N^2) if we pruned immediately. This immediate eviction is a | 737 // objects O(N^2) if we pruned immediately. This immediate eviction is a |
| 738 // safeguard against runaway memory consumption by dead resources | 738 // safeguard against runaway memory consumption by dead resources |
| (...skipping 25 matching lines...) Expand all Loading... |
| 764 void MemoryCache::pruneAll() | 764 void MemoryCache::pruneAll() |
| 765 { | 765 { |
| 766 double currentTime = WTF::currentTime(); | 766 double currentTime = WTF::currentTime(); |
| 767 pruneNow(currentTime, MaximalPrune); | 767 pruneNow(currentTime, MaximalPrune); |
| 768 } | 768 } |
| 769 | 769 |
| 770 void MemoryCache::pruneNow(double currentTime, PruneStrategy strategy) | 770 void MemoryCache::pruneNow(double currentTime, PruneStrategy strategy) |
| 771 { | 771 { |
| 772 if (m_prunePending) { | 772 if (m_prunePending) { |
| 773 m_prunePending = false; | 773 m_prunePending = false; |
| 774 blink::Platform::current()->currentThread()->removeTaskObserver(this); | 774 Platform::current()->currentThread()->removeTaskObserver(this); |
| 775 } | 775 } |
| 776 | 776 |
| 777 TemporaryChange<bool> reentrancyProtector(m_inPruneResources, true); | 777 TemporaryChange<bool> reentrancyProtector(m_inPruneResources, true); |
| 778 pruneDeadResources(strategy); // Prune dead first, in case it was "borrowing
" capacity from live. | 778 pruneDeadResources(strategy); // Prune dead first, in case it was "borrowing
" capacity from live. |
| 779 pruneLiveResources(strategy); | 779 pruneLiveResources(strategy); |
| 780 m_pruneFrameTimeStamp = m_lastFramePaintTimeStamp; | 780 m_pruneFrameTimeStamp = m_lastFramePaintTimeStamp; |
| 781 m_pruneTimeStamp = currentTime; | 781 m_pruneTimeStamp = currentTime; |
| 782 } | 782 } |
| 783 | 783 |
| 784 void MemoryCache::updateFramePaintTimestamp() | 784 void MemoryCache::updateFramePaintTimestamp() |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 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()); | 848 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()); |
| 849 | 849 |
| 850 current = current->m_previousInAllResourcesList; | 850 current = current->m_previousInAllResourcesList; |
| 851 } | 851 } |
| 852 } | 852 } |
| 853 } | 853 } |
| 854 | 854 |
| 855 #endif // MEMORY_CACHE_STATS | 855 #endif // MEMORY_CACHE_STATS |
| 856 | 856 |
| 857 } // namespace blink | 857 } // namespace blink |
| OLD | NEW |