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