Chromium Code Reviews| 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 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 620 break; | 620 break; |
| 621 default: | 621 default: |
| 622 stats.other.addResource(resource); | 622 stats.other.addResource(resource); |
| 623 break; | 623 break; |
| 624 } | 624 } |
| 625 } | 625 } |
| 626 } | 626 } |
| 627 return stats; | 627 return stats; |
| 628 } | 628 } |
| 629 | 629 |
| 630 void MemoryCache::evictResources() { | 630 void MemoryCache::evictResources(EvictResourcePolicy policy) { |
| 631 while (true) { | 631 for (auto resourceMapIter = m_resourceMaps.begin(); |
| 632 ResourceMapIndex::iterator resourceMapIter = m_resourceMaps.begin(); | 632 resourceMapIter != m_resourceMaps.end();) { |
| 633 if (resourceMapIter == m_resourceMaps.end()) | |
| 634 break; | |
| 635 ResourceMap* resources = resourceMapIter->value.get(); | 633 ResourceMap* resources = resourceMapIter->value.get(); |
| 636 while (true) { | 634 for (auto resourceIter = resources->begin(); |
| 637 ResourceMap::iterator resourceIter = resources->begin(); | 635 resourceIter != resources->end();) { |
| 638 if (resourceIter == resources->end()) | 636 DCHECK(resourceIter.get()); |
| 639 break; | 637 DCHECK(resourceIter->value.get()); |
| 640 evict(resourceIter->value.get()); | 638 DCHECK(resourceIter->value->resource()); |
| 639 if (policy == EvictAllResources || !resourceIter->value->resource() || | |
|
Charlie Harrison
2016/10/03 21:48:21
Optional nit: I think !(resourceIter->value->resou
| |
| 640 !resourceIter->value->resource()->isUnusedPreload()) { | |
| 641 evict(resourceIter->value.get()); | |
| 642 resourceIter = resources->begin(); | |
|
Charlie Harrison
2016/10/03 21:48:21
Hm... If we have N unused preloads, and then M reg
| |
| 643 } else { | |
| 644 ++resourceIter; | |
| 645 } | |
| 641 } | 646 } |
| 642 m_resourceMaps.remove(resourceMapIter); | 647 if (!resources->size()) { |
| 648 m_resourceMaps.remove(resourceMapIter); | |
| 649 resourceMapIter = m_resourceMaps.begin(); | |
| 650 } else { | |
| 651 ++resourceMapIter; | |
| 652 } | |
| 643 } | 653 } |
| 644 } | 654 } |
| 645 | 655 |
| 646 void MemoryCache::prune() { | 656 void MemoryCache::prune() { |
| 647 TRACE_EVENT0("renderer", "MemoryCache::prune()"); | 657 TRACE_EVENT0("renderer", "MemoryCache::prune()"); |
| 648 | 658 |
| 649 if (m_inPruneResources) | 659 if (m_inPruneResources) |
| 650 return; | 660 return; |
| 651 if (m_liveSize + m_deadSize <= m_capacity && m_maxDeadCapacity && | 661 if (m_liveSize + m_deadSize <= m_capacity && m_maxDeadCapacity && |
| 652 m_deadSize <= m_maxDeadCapacity) // Fast path. | 662 m_deadSize <= m_maxDeadCapacity) // Fast path. |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 753 bool MemoryCache::isInSameLRUListForTest(const Resource* x, const Resource* y) { | 763 bool MemoryCache::isInSameLRUListForTest(const Resource* x, const Resource* y) { |
| 754 MemoryCacheEntry* ex = getEntryForResource(x); | 764 MemoryCacheEntry* ex = getEntryForResource(x); |
| 755 MemoryCacheEntry* ey = getEntryForResource(y); | 765 MemoryCacheEntry* ey = getEntryForResource(y); |
| 756 DCHECK(ex); | 766 DCHECK(ex); |
| 757 DCHECK(ey); | 767 DCHECK(ey); |
| 758 return lruListFor(ex->m_accessCount, x->size()) == | 768 return lruListFor(ex->m_accessCount, x->size()) == |
| 759 lruListFor(ey->m_accessCount, y->size()); | 769 lruListFor(ey->m_accessCount, y->size()); |
| 760 } | 770 } |
| 761 | 771 |
| 762 } // namespace blink | 772 } // namespace blink |
| OLD | NEW |