| 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 | 226 |
| 227 size_t targetSize = static_cast<size_t>(capacity * cTargetPrunePercentage);
// Cut by a percentage to avoid immediately pruning again. | 227 size_t targetSize = static_cast<size_t>(capacity * cTargetPrunePercentage);
// Cut by a percentage to avoid immediately pruning again. |
| 228 | 228 |
| 229 int size = m_allResources.size(); | 229 int size = m_allResources.size(); |
| 230 | 230 |
| 231 // See if we have any purged resources we can evict. | 231 // See if we have any purged resources we can evict. |
| 232 for (int i = 0; i < size; i++) { | 232 for (int i = 0; i < size; i++) { |
| 233 MemoryCacheEntry* current = m_allResources[i].m_tail; | 233 MemoryCacheEntry* current = m_allResources[i].m_tail; |
| 234 while (current) { | 234 while (current) { |
| 235 MemoryCacheEntry* previous = current->m_previousInAllResourcesList; | 235 MemoryCacheEntry* previous = current->m_previousInAllResourcesList; |
| 236 if (current->m_resource->wasPurged() && current->m_resource->canDele
te()) { | 236 if (current->m_resource->wasPurged()) { |
| 237 ASSERT(!current->m_resource->hasClients()); | 237 ASSERT(!current->m_resource->hasClients()); |
| 238 ASSERT(!current->m_resource->isPreloaded()); | 238 ASSERT(!current->m_resource->isPreloaded()); |
| 239 bool wasEvicted = evict(current); | 239 evict(current); |
| 240 ASSERT_UNUSED(wasEvicted, wasEvicted); | |
| 241 } | 240 } |
| 242 current = previous; | 241 current = previous; |
| 243 } | 242 } |
| 244 } | 243 } |
| 245 if (targetSize && m_deadSize <= targetSize) | 244 if (targetSize && m_deadSize <= targetSize) |
| 246 return; | 245 return; |
| 247 | 246 |
| 248 bool canShrinkLRULists = true; | 247 bool canShrinkLRULists = true; |
| 249 for (int i = size - 1; i >= 0; i--) { | 248 for (int i = size - 1; i >= 0; i--) { |
| 250 // Remove from the tail, since this is the least frequently accessed of
the objects. | 249 // Remove from the tail, since this is the least frequently accessed of
the objects. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 269 if (previous && !contains(previous->m_resource.get())) | 268 if (previous && !contains(previous->m_resource.get())) |
| 270 break; | 269 break; |
| 271 current = previous; | 270 current = previous; |
| 272 } | 271 } |
| 273 | 272 |
| 274 // Now evict objects from this queue. | 273 // Now evict objects from this queue. |
| 275 current = m_allResources[i].m_tail; | 274 current = m_allResources[i].m_tail; |
| 276 while (current) { | 275 while (current) { |
| 277 MemoryCacheEntry* previous = current->m_previousInAllResourcesList; | 276 MemoryCacheEntry* previous = current->m_previousInAllResourcesList; |
| 278 ASSERT(!previous || contains(previous->m_resource.get())); | 277 ASSERT(!previous || contains(previous->m_resource.get())); |
| 279 if (!current->m_resource->hasClients() && !current->m_resource->isPr
eloaded() | 278 if (!current->m_resource->hasClients() && !current->m_resource->isPr
eloaded() && !current->m_resource->isCacheValidator()) { |
| 280 && !current->m_resource->isCacheValidator() && current->m_resour
ce->canDelete()) { | 279 evict(current); |
| 281 bool wasEvicted = evict(current); | |
| 282 ASSERT_UNUSED(wasEvicted, wasEvicted); | |
| 283 if (targetSize && m_deadSize <= targetSize) | 280 if (targetSize && m_deadSize <= targetSize) |
| 284 return; | 281 return; |
| 285 } | 282 } |
| 286 if (previous && !contains(previous->m_resource.get())) | 283 if (previous && !contains(previous->m_resource.get())) |
| 287 break; | 284 break; |
| 288 current = previous; | 285 current = previous; |
| 289 } | 286 } |
| 290 | 287 |
| 291 // Shrink the vector back down so we don't waste time inspecting | 288 // Shrink the vector back down so we don't waste time inspecting |
| 292 // empty LRU lists on future prunes. | 289 // empty LRU lists on future prunes. |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 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()); | 681 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()); |
| 685 | 682 |
| 686 current = prev; | 683 current = prev; |
| 687 } | 684 } |
| 688 } | 685 } |
| 689 } | 686 } |
| 690 | 687 |
| 691 #endif // MEMORY_CACHE_STATS | 688 #endif // MEMORY_CACHE_STATS |
| 692 | 689 |
| 693 } // namespace WebCore | 690 } // namespace WebCore |
| OLD | NEW |