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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 static const float cTargetPrunePercentage = .95f; // Percentage of capacity towa rd which we prune, to avoid immediately pruning again. | 47 static const float cTargetPrunePercentage = .95f; // Percentage of capacity towa rd which we prune, to avoid immediately pruning again. |
| 48 | 48 |
| 49 MemoryCache* memoryCache() | 49 MemoryCache* memoryCache() |
| 50 { | 50 { |
| 51 ASSERT(WTF::isMainThread()); | 51 ASSERT(WTF::isMainThread()); |
| 52 if (!gMemoryCache) | 52 if (!gMemoryCache) |
| 53 gMemoryCache = new Persistent<MemoryCache>(MemoryCache::create()); | 53 gMemoryCache = new Persistent<MemoryCache>(MemoryCache::create()); |
| 54 return gMemoryCache->get(); | 54 return gMemoryCache->get(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void shutdownCache() | |
| 58 { | |
| 59 *gMemoryCache = nullptr; | |
|
haraken
2015/10/14 00:49:01
I now realized that this approach won't work... (I
| |
| 60 delete gMemoryCache; | |
| 61 } | |
| 62 | |
| 57 MemoryCache* replaceMemoryCacheForTesting(MemoryCache* cache) | 63 MemoryCache* replaceMemoryCacheForTesting(MemoryCache* cache) |
| 58 { | 64 { |
| 59 #if ENABLE(OILPAN) | 65 #if ENABLE(OILPAN) |
| 60 // Move m_liveResources content to keep Resource objects alive. | 66 // Move m_liveResources content to keep Resource objects alive. |
| 61 for (const auto& resource : memoryCache()->m_liveResources) | 67 for (const auto& resource : memoryCache()->m_liveResources) |
| 62 cache->m_liveResources.add(resource); | 68 cache->m_liveResources.add(resource); |
| 63 memoryCache()->m_liveResources.clear(); | 69 memoryCache()->m_liveResources.clear(); |
| 64 #endif | 70 #endif |
| 65 memoryCache(); | 71 memoryCache(); |
| 66 MemoryCache* oldCache = gMemoryCache->release(); | 72 MemoryCache* oldCache = gMemoryCache->release(); |
| (...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 834 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()); | 840 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()); |
| 835 | 841 |
| 836 current = current->m_previousInAllResourcesList; | 842 current = current->m_previousInAllResourcesList; |
| 837 } | 843 } |
| 838 } | 844 } |
| 839 } | 845 } |
| 840 | 846 |
| 841 #endif // MEMORY_CACHE_STATS | 847 #endif // MEMORY_CACHE_STATS |
| 842 | 848 |
| 843 } // namespace blink | 849 } // namespace blink |
| OLD | NEW |