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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 ASSERT(WTF::isMainThread()); | 55 ASSERT(WTF::isMainThread()); |
56 if (!gMemoryCache) | 56 if (!gMemoryCache) |
57 gMemoryCache = new OwnPtrWillBePersistent<MemoryCache>(MemoryCache::crea
te()); | 57 gMemoryCache = new OwnPtrWillBePersistent<MemoryCache>(MemoryCache::crea
te()); |
58 return gMemoryCache->get(); | 58 return gMemoryCache->get(); |
59 } | 59 } |
60 | 60 |
61 PassOwnPtrWillBeRawPtr<MemoryCache> replaceMemoryCacheForTesting(PassOwnPtrWillB
eRawPtr<MemoryCache> cache) | 61 PassOwnPtrWillBeRawPtr<MemoryCache> replaceMemoryCacheForTesting(PassOwnPtrWillB
eRawPtr<MemoryCache> cache) |
62 { | 62 { |
63 #if ENABLE(OILPAN) | 63 #if ENABLE(OILPAN) |
64 // Move m_liveResources content to keep Resource objects alive. | 64 // Move m_liveResources content to keep Resource objects alive. |
65 for (HeapHashSet<Member<Resource> >::iterator i = memoryCache()->m_liveResou
rces.begin(); | 65 for (const auto& resource : memoryCache()->m_liveResources) |
66 i != memoryCache()->m_liveResources.end(); | 66 cache->m_liveResources.add(resource); |
67 ++i) { | |
68 cache->m_liveResources.add(*i); | |
69 } | |
70 memoryCache()->m_liveResources.clear(); | 67 memoryCache()->m_liveResources.clear(); |
71 #else | 68 #else |
72 // Make sure we have non-empty gMemoryCache. | 69 // Make sure we have non-empty gMemoryCache. |
73 memoryCache(); | 70 memoryCache(); |
74 #endif | 71 #endif |
75 OwnPtrWillBeRawPtr<MemoryCache> oldCache = gMemoryCache->release(); | 72 OwnPtrWillBeRawPtr<MemoryCache> oldCache = gMemoryCache->release(); |
76 *gMemoryCache = cache; | 73 *gMemoryCache = cache; |
77 return oldCache.release(); | 74 return oldCache.release(); |
78 } | 75 } |
79 | 76 |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 decodedSize += o->decodedSize(); | 606 decodedSize += o->decodedSize(); |
610 encodedSize += o->encodedSize(); | 607 encodedSize += o->encodedSize(); |
611 encodedSizeDuplicatedInDataURLs += o->url().protocolIsData() ? o->encodedSiz
e() : 0; | 608 encodedSizeDuplicatedInDataURLs += o->url().protocolIsData() ? o->encodedSiz
e() : 0; |
612 purgeableSize += purgeable ? pageSize : 0; | 609 purgeableSize += purgeable ? pageSize : 0; |
613 purgedSize += purged ? pageSize : 0; | 610 purgedSize += purged ? pageSize : 0; |
614 } | 611 } |
615 | 612 |
616 MemoryCache::Statistics MemoryCache::getStatistics() | 613 MemoryCache::Statistics MemoryCache::getStatistics() |
617 { | 614 { |
618 Statistics stats; | 615 Statistics stats; |
619 ResourceMap::iterator e = m_resources.end(); | 616 for (const auto& resourceIter : m_resources) { |
620 for (ResourceMap::iterator i = m_resources.begin(); i != e; ++i) { | 617 Resource* resource = resourceIter.value->m_resource.get(); |
621 Resource* resource = i->value->m_resource.get(); | |
622 switch (resource->type()) { | 618 switch (resource->type()) { |
623 case Resource::Image: | 619 case Resource::Image: |
624 stats.images.addResource(resource); | 620 stats.images.addResource(resource); |
625 break; | 621 break; |
626 case Resource::CSSStyleSheet: | 622 case Resource::CSSStyleSheet: |
627 stats.cssStyleSheets.addResource(resource); | 623 stats.cssStyleSheets.addResource(resource); |
628 break; | 624 break; |
629 case Resource::Script: | 625 case Resource::Script: |
630 stats.scripts.addResource(resource); | 626 stats.scripts.addResource(resource); |
631 break; | 627 break; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 printf("(%.1fK, %.1fK, %uA, %dR, %d, %d); ", current->decodedSiz
e() / 1024.0f, (current->encodedSize() + current->overheadSize()) / 1024.0f, cur
rent->accessCount(), current->hasClients(), current->isPurgeable(), current->was
Purged()); | 785 printf("(%.1fK, %.1fK, %uA, %dR, %d, %d); ", current->decodedSiz
e() / 1024.0f, (current->encodedSize() + current->overheadSize()) / 1024.0f, cur
rent->accessCount(), current->hasClients(), current->isPurgeable(), current->was
Purged()); |
790 | 786 |
791 current = prev; | 787 current = prev; |
792 } | 788 } |
793 } | 789 } |
794 } | 790 } |
795 | 791 |
796 #endif // MEMORY_CACHE_STATS | 792 #endif // MEMORY_CACHE_STATS |
797 | 793 |
798 } // namespace blink | 794 } // namespace blink |
OLD | NEW |