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

Side by Side Diff: Source/WebCore/loader/cache/CachedResourceLoader.cpp

Issue 7548016: Merge 92143 - .: REGRESSION (r39725?): Resources removed from document can not be freed until the... (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/835/
Patch Set: Created 9 years, 4 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 | « Source/WebCore/loader/cache/CachedResourceLoader.h ('k') | Source/WebCore/testing/Internals.h » ('j') | 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, 2008 Apple Inc. All rights reserved. 5 Copyright (C) 2004, 2005, 2006, 2008 Apple Inc. All rights reserved.
6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ 6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 return new CachedResource(request, CachedResource::LinkSubresource); 79 return new CachedResource(request, CachedResource::LinkSubresource);
80 #endif 80 #endif
81 } 81 }
82 ASSERT_NOT_REACHED(); 82 ASSERT_NOT_REACHED();
83 return 0; 83 return 0;
84 } 84 }
85 85
86 CachedResourceLoader::CachedResourceLoader(Document* document) 86 CachedResourceLoader::CachedResourceLoader(Document* document)
87 : m_document(document) 87 : m_document(document)
88 , m_requestCount(0) 88 , m_requestCount(0)
89 , m_garbageCollectDocumentResourcesTimer(this, &CachedResourceLoader::garbag eCollectDocumentResourcesTimerFired)
89 , m_autoLoadImages(true) 90 , m_autoLoadImages(true)
90 , m_loadFinishing(false) 91 , m_loadFinishing(false)
91 , m_allowStaleResources(false) 92 , m_allowStaleResources(false)
92 { 93 {
93 } 94 }
94 95
95 CachedResourceLoader::~CachedResourceLoader() 96 CachedResourceLoader::~CachedResourceLoader()
96 { 97 {
97 m_document = 0; 98 m_document = 0;
98 99
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
565 #endif 566 #endif
566 m_documentResources.remove(resource->url()); 567 m_documentResources.remove(resource->url());
567 } 568 }
568 569
569 void CachedResourceLoader::loadDone() 570 void CachedResourceLoader::loadDone()
570 { 571 {
571 m_loadFinishing = false; 572 m_loadFinishing = false;
572 if (frame()) 573 if (frame())
573 frame()->loader()->loadDone(); 574 frame()->loader()->loadDone();
574 performPostLoadActions(); 575 performPostLoadActions();
576
577 if (!m_garbageCollectDocumentResourcesTimer.isActive())
578 m_garbageCollectDocumentResourcesTimer.startOneShot(0);
579 }
580
581 // Garbage collecting m_documentResources is a workaround for the
582 // CachedResourceHandles on the RHS being strong references. Ideally this
583 // would be a weak map, however CachedResourceHandles perform additional
584 // bookkeeping on CachedResources, so instead pseudo-GC them -- when the
585 // reference count reaches 1, m_documentResources is the only reference, so
586 // remove it from the map.
587 void CachedResourceLoader::garbageCollectDocumentResourcesTimerFired(Timer<Cache dResourceLoader>* timer)
588 {
589 ASSERT_UNUSED(timer, timer == &m_garbageCollectDocumentResourcesTimer);
590
591 typedef Vector<String, 10> StringVector;
592 StringVector resourcesToDelete;
593
594 for (DocumentResourceMap::iterator it = m_documentResources.begin(); it != m _documentResources.end(); ++it) {
595 if (it->second->hasOneHandle()) {
596 resourcesToDelete.append(it->first);
597 it->second->setOwningCachedResourceLoader(0);
598 }
599 }
600
601 for (StringVector::const_iterator it = resourcesToDelete.begin(); it != reso urcesToDelete.end(); ++it)
602 m_documentResources.remove(*it);
575 } 603 }
576 604
577 void CachedResourceLoader::performPostLoadActions() 605 void CachedResourceLoader::performPostLoadActions()
578 { 606 {
579 checkForPendingPreloads(); 607 checkForPendingPreloads();
580 resourceLoadScheduler()->servePendingRequests(); 608 resourceLoadScheduler()->servePendingRequests();
581 } 609 }
582 610
583 void CachedResourceLoader::notifyLoadedFromMemoryCache(CachedResource* resource) 611 void CachedResourceLoader::notifyLoadedFromMemoryCache(CachedResource* resource)
584 { 612 {
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 if (scripts) 781 if (scripts)
754 printf("SCRIPTS: %d (%d hits, hit rate %d%%)\n", scripts, scripts - scri ptMisses, (scripts - scriptMisses) * 100 / scripts); 782 printf("SCRIPTS: %d (%d hits, hit rate %d%%)\n", scripts, scripts - scri ptMisses, (scripts - scriptMisses) * 100 / scripts);
755 if (stylesheets) 783 if (stylesheets)
756 printf("STYLESHEETS: %d (%d hits, hit rate %d%%)\n", stylesheets, styles heets - stylesheetMisses, (stylesheets - stylesheetMisses) * 100 / stylesheets); 784 printf("STYLESHEETS: %d (%d hits, hit rate %d%%)\n", stylesheets, styles heets - stylesheetMisses, (stylesheets - stylesheetMisses) * 100 / stylesheets);
757 if (images) 785 if (images)
758 printf("IMAGES: %d (%d hits, hit rate %d%%)\n", images, images - imageM isses, (images - imageMisses) * 100 / images); 786 printf("IMAGES: %d (%d hits, hit rate %d%%)\n", images, images - imageM isses, (images - imageMisses) * 100 / images);
759 } 787 }
760 #endif 788 #endif
761 789
762 } 790 }
OLDNEW
« no previous file with comments | « Source/WebCore/loader/cache/CachedResourceLoader.h ('k') | Source/WebCore/testing/Internals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698