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) { |
Mike West
2014/10/17 10:38:49
Nit: Drop the {} for one-liners.
riju_
2014/10/17 18:36:48
Done.
| |
66 i != memoryCache()->m_liveResources.end(); | 66 cache->m_liveResources.add(resource); |
67 ++i) { | |
68 cache->m_liveResources.add(*i); | |
69 } | 67 } |
70 memoryCache()->m_liveResources.clear(); | 68 memoryCache()->m_liveResources.clear(); |
71 #else | 69 #else |
72 // Make sure we have non-empty gMemoryCache. | 70 // Make sure we have non-empty gMemoryCache. |
73 memoryCache(); | 71 memoryCache(); |
74 #endif | 72 #endif |
75 OwnPtrWillBeRawPtr<MemoryCache> oldCache = gMemoryCache->release(); | 73 OwnPtrWillBeRawPtr<MemoryCache> oldCache = gMemoryCache->release(); |
76 *gMemoryCache = cache; | 74 *gMemoryCache = cache; |
77 return oldCache.release(); | 75 return oldCache.release(); |
78 } | 76 } |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
609 decodedSize += o->decodedSize(); | 607 decodedSize += o->decodedSize(); |
610 encodedSize += o->encodedSize(); | 608 encodedSize += o->encodedSize(); |
611 encodedSizeDuplicatedInDataURLs += o->url().protocolIsData() ? o->encodedSiz e() : 0; | 609 encodedSizeDuplicatedInDataURLs += o->url().protocolIsData() ? o->encodedSiz e() : 0; |
612 purgeableSize += purgeable ? pageSize : 0; | 610 purgeableSize += purgeable ? pageSize : 0; |
613 purgedSize += purged ? pageSize : 0; | 611 purgedSize += purged ? pageSize : 0; |
614 } | 612 } |
615 | 613 |
616 MemoryCache::Statistics MemoryCache::getStatistics() | 614 MemoryCache::Statistics MemoryCache::getStatistics() |
617 { | 615 { |
618 Statistics stats; | 616 Statistics stats; |
619 ResourceMap::iterator e = m_resources.end(); | 617 for (const auto& resourceIter : m_resources) { |
620 for (ResourceMap::iterator i = m_resources.begin(); i != e; ++i) { | 618 Resource* resource = resourceIter.value->m_resource.get(); |
621 Resource* resource = i->value->m_resource.get(); | |
622 switch (resource->type()) { | 619 switch (resource->type()) { |
623 case Resource::Image: | 620 case Resource::Image: |
624 stats.images.addResource(resource); | 621 stats.images.addResource(resource); |
625 break; | 622 break; |
626 case Resource::CSSStyleSheet: | 623 case Resource::CSSStyleSheet: |
627 stats.cssStyleSheets.addResource(resource); | 624 stats.cssStyleSheets.addResource(resource); |
628 break; | 625 break; |
629 case Resource::Script: | 626 case Resource::Script: |
630 stats.scripts.addResource(resource); | 627 stats.scripts.addResource(resource); |
631 break; | 628 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()); | 786 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 | 787 |
791 current = prev; | 788 current = prev; |
792 } | 789 } |
793 } | 790 } |
794 } | 791 } |
795 | 792 |
796 #endif // MEMORY_CACHE_STATS | 793 #endif // MEMORY_CACHE_STATS |
797 | 794 |
798 } // namespace blink | 795 } // namespace blink |
OLD | NEW |