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

Side by Side Diff: Source/core/loader/cache/CachedResource.cpp

Issue 17436003: Evict CachedResources if they are cancelled due to last client being removed. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/loader/cache/CachedImageTest.cpp ('k') | 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) 2006 Samuel Weinig (sam.weinig@gmail.com) 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 154 }
155 155
156 CachedResource::~CachedResource() 156 CachedResource::~CachedResource()
157 { 157 {
158 ASSERT(!m_resourceToRevalidate); // Should be true because canDelete() check s this. 158 ASSERT(!m_resourceToRevalidate); // Should be true because canDelete() check s this.
159 ASSERT(canDelete()); 159 ASSERT(canDelete());
160 ASSERT(!inCache()); 160 ASSERT(!inCache());
161 ASSERT(!m_deleted); 161 ASSERT(!m_deleted);
162 ASSERT(url().isNull() || memoryCache()->resourceForURL(KURL(ParsedURLString, url())) != this); 162 ASSERT(url().isNull() || memoryCache()->resourceForURL(KURL(ParsedURLString, url())) != this);
163 163
164 if (m_cancelTimer.isActive())
165 m_cancelTimer.stop();
abarth-chromium 2013/06/18 23:15:26 This doesn't happen automatically when the timer i
Nate Chapin 2013/06/18 23:24:48 Derp, I didn't look in Timer's base class :( Will
166
164 #ifndef NDEBUG 167 #ifndef NDEBUG
165 m_deleted = true; 168 m_deleted = true;
166 cachedResourceLeakCounter.decrement(); 169 cachedResourceLeakCounter.decrement();
167 #endif 170 #endif
168 } 171 }
169 172
170 void CachedResource::failBeforeStarting() 173 void CachedResource::failBeforeStarting()
171 { 174 {
172 // FIXME: What if resources in other frames were waiting for this revalidati on? 175 // FIXME: What if resources in other frames were waiting for this revalidati on?
173 LOG(ResourceLoading, "Cannot start loading '%s'", url().string().latin1().da ta()); 176 LOG(ResourceLoading, "Cannot start loading '%s'", url().string().latin1().da ta());
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 if (url().protocolIs("https")) 443 if (url().protocolIs("https"))
441 memoryCache()->remove(this); 444 memoryCache()->remove(this);
442 } else 445 } else
443 memoryCache()->prune(); 446 memoryCache()->prune();
444 } 447 }
445 // This object may be dead here. 448 // This object may be dead here.
446 } 449 }
447 450
448 void CachedResource::allClientsRemoved() 451 void CachedResource::allClientsRemoved()
449 { 452 {
453 if (!m_loader)
454 return;
450 if (m_type == MainResource || m_type == RawResource) 455 if (m_type == MainResource || m_type == RawResource)
451 cancelTimerFired(&m_cancelTimer); 456 cancelTimerFired(&m_cancelTimer);
452 else if (!m_cancelTimer.isActive()) 457 else if (!m_cancelTimer.isActive())
453 m_cancelTimer.startOneShot(0); 458 m_cancelTimer.startOneShot(0);
454 } 459 }
455 460
456 void CachedResource::cancelTimerFired(Timer<CachedResource>* timer) 461 void CachedResource::cancelTimerFired(Timer<CachedResource>* timer)
457 { 462 {
458 ASSERT_UNUSED(timer, timer == &m_cancelTimer); 463 ASSERT_UNUSED(timer, timer == &m_cancelTimer);
459 if (hasClients() || !m_loader) 464 if (hasClients() || !m_loader)
460 return; 465 return;
461 m_loader->cancelIfNotFinishing(); 466 m_loader->cancelIfNotFinishing();
467 if (m_status != Cached)
468 memoryCache()->remove(this);
462 } 469 }
463 470
464 void CachedResource::destroyDecodedDataIfNeeded() 471 void CachedResource::destroyDecodedDataIfNeeded()
465 { 472 {
466 if (!m_decodedSize) 473 if (!m_decodedSize)
467 return; 474 return;
468 475
469 if (double interval = memoryCache()->deadDecodedDataDeletionInterval()) 476 if (double interval = memoryCache()->deadDecodedDataDeletionInterval())
470 m_decodedDataDeletionTimer.startOneShot(interval); 477 m_decodedDataDeletionTimer.startOneShot(interval);
471 } 478 }
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 info.addMember(m_proxyResource, "proxyResource"); 889 info.addMember(m_proxyResource, "proxyResource");
883 info.addMember(m_handlesToRevalidate, "handlesToRevalidate"); 890 info.addMember(m_handlesToRevalidate, "handlesToRevalidate");
884 info.addMember(m_options, "options"); 891 info.addMember(m_options, "options");
885 info.addMember(m_decodedDataDeletionTimer, "decodedDataDeletionTimer"); 892 info.addMember(m_decodedDataDeletionTimer, "decodedDataDeletionTimer");
886 info.ignoreMember(m_clientsAwaitingCallback); 893 info.ignoreMember(m_clientsAwaitingCallback);
887 894
888 if (m_purgeableData && !m_purgeableData->wasPurged()) 895 if (m_purgeableData && !m_purgeableData->wasPurged())
889 info.addRawBuffer(m_purgeableData.get(), m_purgeableData->size(), "Purge ableData", "purgeableData"); 896 info.addRawBuffer(m_purgeableData.get(), m_purgeableData->size(), "Purge ableData", "purgeableData");
890 } 897 }
891 } 898 }
OLDNEW
« no previous file with comments | « Source/core/loader/cache/CachedImageTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698