Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: sky/engine/core/fetch/MemoryCache.cpp

Issue 710383002: Remove preload support from the MemoryCache (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 // See if we have any purged resources we can evict. 258 // See if we have any purged resources we can evict.
259 for (int i = 0; i < size; i++) { 259 for (int i = 0; i < size; i++) {
260 MemoryCacheEntry* current = m_allResources[i].m_tail; 260 MemoryCacheEntry* current = m_allResources[i].m_tail;
261 while (current) { 261 while (current) {
262 MemoryCacheEntry* previous = current->m_previousInAllResourcesList; 262 MemoryCacheEntry* previous = current->m_previousInAllResourcesList;
263 // Main Resources in the cache are only substitue data that was 263 // Main Resources in the cache are only substitue data that was
264 // precached and should not be evicted. 264 // precached and should not be evicted.
265 if (current->m_resource->wasPurged() && current->m_resource->canDele te() 265 if (current->m_resource->wasPurged() && current->m_resource->canDele te()
266 && current->m_resource->type() != Resource::MainResource) { 266 && current->m_resource->type() != Resource::MainResource) {
267 ASSERT(!current->m_resource->hasClients()); 267 ASSERT(!current->m_resource->hasClients());
268 ASSERT(!current->m_resource->isPreloaded());
269 bool wasEvicted = evict(current); 268 bool wasEvicted = evict(current);
270 ASSERT_UNUSED(wasEvicted, wasEvicted); 269 ASSERT_UNUSED(wasEvicted, wasEvicted);
271 } 270 }
272 current = previous; 271 current = previous;
273 } 272 }
274 } 273 }
275 if (targetSize && m_deadSize <= targetSize) 274 if (targetSize && m_deadSize <= targetSize)
276 return; 275 return;
277 276
278 bool canShrinkLRULists = true; 277 bool canShrinkLRULists = true;
279 for (int i = size - 1; i >= 0; i--) { 278 for (int i = size - 1; i >= 0; i--) {
280 // Remove from the tail, since this is the least frequently accessed of the objects. 279 // Remove from the tail, since this is the least frequently accessed of the objects.
281 MemoryCacheEntry* current = m_allResources[i].m_tail; 280 MemoryCacheEntry* current = m_allResources[i].m_tail;
282 281
283 // First flush all the decoded data in this queue. 282 // First flush all the decoded data in this queue.
284 while (current) { 283 while (current) {
285 // Protect 'previous' so it can't get deleted during destroyDecodedD ata(). 284 // Protect 'previous' so it can't get deleted during destroyDecodedD ata().
286 MemoryCacheEntry* previous = current->m_previousInAllResourcesList; 285 MemoryCacheEntry* previous = current->m_previousInAllResourcesList;
287 ASSERT(!previous || contains(previous->m_resource.get())); 286 ASSERT(!previous || contains(previous->m_resource.get()));
288 if (!current->m_resource->hasClients() && !current->m_resource->isPr eloaded() && current->m_resource->isLoaded()) { 287 if (!current->m_resource->hasClients() && current->m_resource->isLoa ded()) {
289 // Destroy our decoded data. This will remove us from 288 // Destroy our decoded data. This will remove us from
290 // m_liveDecodedResources, and possibly move us to a different 289 // m_liveDecodedResources, and possibly move us to a different
291 // LRU list in m_allResources. 290 // LRU list in m_allResources.
292 current->m_resource->prune(); 291 current->m_resource->prune();
293 292
294 if (targetSize && m_deadSize <= targetSize) 293 if (targetSize && m_deadSize <= targetSize)
295 return; 294 return;
296 } 295 }
297 // Decoded data may reference other resources. Stop iterating if 'pr evious' somehow got 296 // Decoded data may reference other resources. Stop iterating if 'pr evious' somehow got
298 // kicked out of cache during destroyDecodedData(). 297 // kicked out of cache during destroyDecodedData().
299 if (previous && !contains(previous->m_resource.get())) 298 if (previous && !contains(previous->m_resource.get()))
300 break; 299 break;
301 current = previous; 300 current = previous;
302 } 301 }
303 302
304 // Now evict objects from this queue. 303 // Now evict objects from this queue.
305 current = m_allResources[i].m_tail; 304 current = m_allResources[i].m_tail;
306 while (current) { 305 while (current) {
307 MemoryCacheEntry* previous = current->m_previousInAllResourcesList; 306 MemoryCacheEntry* previous = current->m_previousInAllResourcesList;
308 ASSERT(!previous || contains(previous->m_resource.get())); 307 ASSERT(!previous || contains(previous->m_resource.get()));
309 if (!current->m_resource->hasClients() && !current->m_resource->isPr eloaded() 308 if (!current->m_resource->hasClients()
310 && !current->m_resource->isCacheValidator() && current->m_resour ce->canDelete() 309 && !current->m_resource->isCacheValidator() && current->m_resour ce->canDelete()
311 && current->m_resource->type() != Resource::MainResource) { 310 && current->m_resource->type() != Resource::MainResource) {
312 // Main Resources in the cache are only substitue data that was 311 // Main Resources in the cache are only substitue data that was
313 // precached and should not be evicted. 312 // precached and should not be evicted.
314 bool wasEvicted = evict(current); 313 bool wasEvicted = evict(current);
315 ASSERT_UNUSED(wasEvicted, wasEvicted); 314 ASSERT_UNUSED(wasEvicted, wasEvicted);
316 if (targetSize && m_deadSize <= targetSize) 315 if (targetSize && m_deadSize <= targetSize)
317 return; 316 return;
318 } 317 }
319 if (previous && !contains(previous->m_resource.get())) 318 if (previous && !contains(previous->m_resource.get()))
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 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()); 745 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());
747 746
748 current = prev; 747 current = prev;
749 } 748 }
750 } 749 }
751 } 750 }
752 751
753 #endif // MEMORY_CACHE_STATS 752 #endif // MEMORY_CACHE_STATS
754 753
755 } // namespace blink 754 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698