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

Side by Side Diff: third_party/WebKit/Source/core/fetch/MemoryCache.cpp

Issue 1813673002: Add guard for crash in MemoryCache::pruneDeadResources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add TODO note Created 4 years, 9 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 // Remove from the tail, since this is the least frequently accessed of the objects. 292 // Remove from the tail, since this is the least frequently accessed of the objects.
293 MemoryCacheEntry* current = m_allResources[i].m_tail; 293 MemoryCacheEntry* current = m_allResources[i].m_tail;
294 294
295 // First flush all the decoded data in this queue. 295 // First flush all the decoded data in this queue.
296 while (current) { 296 while (current) {
297 MemoryCacheEntry* previous = current->m_previousInAllResourcesList; 297 MemoryCacheEntry* previous = current->m_previousInAllResourcesList;
298 if (previous) { 298 if (previous) {
299 ASSERT(previous->m_resource); 299 ASSERT(previous->m_resource);
300 ASSERT(contains(previous->m_resource.get())); 300 ASSERT(contains(previous->m_resource.get()));
301 } 301 }
302 if (!current->m_resource->hasClients() && !current->m_resource->isPr eloaded() && current->m_resource->isLoaded()) { 302 // TODO(leon.han@intel.com): We shouldn't be hitting the case
303 // that current->m_resource is null here, would turn the case into
304 // ASSERT(current->m_resource) after crbug.com/594644 got resolved.
305 if (current->m_resource && !current->m_resource->hasClients() && !cu rrent->m_resource->isPreloaded() && current->m_resource->isLoaded()) {
303 // Destroy our decoded data. This will remove us from 306 // Destroy our decoded data. This will remove us from
304 // m_liveDecodedResources, and possibly move us to a different 307 // m_liveDecodedResources, and possibly move us to a different
305 // LRU list in m_allResources. 308 // LRU list in m_allResources.
306 current->m_resource->prune(); 309 current->m_resource->prune();
307 310
308 if (targetSize && m_deadSize <= targetSize) 311 if (targetSize && m_deadSize <= targetSize)
309 return; 312 return;
310 } 313 }
311 // Decoded data may reference other resources. Stop iterating if 'pr evious' somehow got 314 // Decoded data may reference other resources. Stop iterating if 'pr evious' somehow got
312 // kicked out of cache during destroyDecodedData(). 315 // kicked out of cache during destroyDecodedData().
313 if (!previous || !previous->m_resource || !contains(previous->m_reso urce.get())) 316 if (!previous || !previous->m_resource || !contains(previous->m_reso urce.get()))
314 break; 317 break;
315 current = previous; 318 current = previous;
316 } 319 }
317 320
318 // Now evict objects from this queue. 321 // Now evict objects from this queue.
319 current = m_allResources[i].m_tail; 322 current = m_allResources[i].m_tail;
320 while (current) { 323 while (current) {
321 MemoryCacheEntry* previous = current->m_previousInAllResourcesList; 324 MemoryCacheEntry* previous = current->m_previousInAllResourcesList;
322 if (previous) { 325 if (previous) {
323 ASSERT(previous->m_resource); 326 ASSERT(previous->m_resource);
324 ASSERT(contains(previous->m_resource.get())); 327 ASSERT(contains(previous->m_resource.get()));
325 } 328 }
326 if (!current->m_resource->hasClients() && !current->m_resource->isPr eloaded()) { 329 // TODO(leon.han@intel.com): We shouldn't be hitting the case
330 // that current->m_resource is null here, would turn the case into
331 // ASSERT(current->m_resource) after crbug.com/594644 got resolved.
332 if (current->m_resource && !current->m_resource->hasClients() && !cu rrent->m_resource->isPreloaded()) {
327 evict(current); 333 evict(current);
328 if (targetSize && m_deadSize <= targetSize) 334 if (targetSize && m_deadSize <= targetSize)
329 return; 335 return;
330 } 336 }
331 if (!previous || !previous->m_resource || !contains(previous->m_reso urce.get())) 337 if (!previous || !previous->m_resource || !contains(previous->m_reso urce.get()))
332 break; 338 break;
333 current = previous; 339 current = previous;
334 } 340 }
335 341
336 // Shrink the vector back down so we don't waste time inspecting 342 // Shrink the vector back down so we don't waste time inspecting
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 printf("(%.1fK, %.1fK, %uA, %dR, %d); ", currentResource->decode dSize() / 1024.0f, (currentResource->encodedSize() + currentResource->overheadSi ze()) / 1024.0f, current->m_accessCount, currentResource->hasClients(), currentR esource->isPurgeable()); 777 printf("(%.1fK, %.1fK, %uA, %dR, %d); ", currentResource->decode dSize() / 1024.0f, (currentResource->encodedSize() + currentResource->overheadSi ze()) / 1024.0f, current->m_accessCount, currentResource->hasClients(), currentR esource->isPurgeable());
772 778
773 current = current->m_previousInAllResourcesList; 779 current = current->m_previousInAllResourcesList;
774 } 780 }
775 } 781 }
776 } 782 }
777 783
778 #endif // MEMORY_CACHE_STATS 784 #endif // MEMORY_CACHE_STATS
779 785
780 } // namespace blink 786 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698