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

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

Issue 7542020: Merge 91725 - REGRESSION (r39725?): Resources removed from document can not be freed until the do... (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') | 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, 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)
90 , m_autoLoadImages(true) 89 , m_autoLoadImages(true)
91 , m_loadFinishing(false) 90 , m_loadFinishing(false)
92 , m_allowStaleResources(false) 91 , m_allowStaleResources(false)
93 { 92 {
94 } 93 }
95 94
96 CachedResourceLoader::~CachedResourceLoader() 95 CachedResourceLoader::~CachedResourceLoader()
97 { 96 {
98 m_document = 0; 97 m_document = 0;
99 98
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 #endif 565 #endif
567 m_documentResources.remove(resource->url()); 566 m_documentResources.remove(resource->url());
568 } 567 }
569 568
570 void CachedResourceLoader::loadDone() 569 void CachedResourceLoader::loadDone()
571 { 570 {
572 m_loadFinishing = false; 571 m_loadFinishing = false;
573 if (frame()) 572 if (frame())
574 frame()->loader()->loadDone(); 573 frame()->loader()->loadDone();
575 performPostLoadActions(); 574 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 Vector<String, 10> toDelete;
592
593 for (DocumentResourceMap::iterator it = m_documentResources.begin(); it != m _documentResources.end(); ++it) {
594 if (it->second->hasOneHandle())
595 toDelete.append(it->first);
596 }
597
598 for (Vector<String, 10>::const_iterator idel = toDelete.begin(); idel != toD elete.end(); ++idel)
599 m_documentResources.remove(*idel);
600 } 575 }
601 576
602 void CachedResourceLoader::performPostLoadActions() 577 void CachedResourceLoader::performPostLoadActions()
603 { 578 {
604 checkForPendingPreloads(); 579 checkForPendingPreloads();
605 resourceLoadScheduler()->servePendingRequests(); 580 resourceLoadScheduler()->servePendingRequests();
606 } 581 }
607 582
608 void CachedResourceLoader::notifyLoadedFromMemoryCache(CachedResource* resource) 583 void CachedResourceLoader::notifyLoadedFromMemoryCache(CachedResource* resource)
609 { 584 {
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 if (scripts) 753 if (scripts)
779 printf("SCRIPTS: %d (%d hits, hit rate %d%%)\n", scripts, scripts - scri ptMisses, (scripts - scriptMisses) * 100 / scripts); 754 printf("SCRIPTS: %d (%d hits, hit rate %d%%)\n", scripts, scripts - scri ptMisses, (scripts - scriptMisses) * 100 / scripts);
780 if (stylesheets) 755 if (stylesheets)
781 printf("STYLESHEETS: %d (%d hits, hit rate %d%%)\n", stylesheets, styles heets - stylesheetMisses, (stylesheets - stylesheetMisses) * 100 / stylesheets); 756 printf("STYLESHEETS: %d (%d hits, hit rate %d%%)\n", stylesheets, styles heets - stylesheetMisses, (stylesheets - stylesheetMisses) * 100 / stylesheets);
782 if (images) 757 if (images)
783 printf("IMAGES: %d (%d hits, hit rate %d%%)\n", images, images - imageM isses, (images - imageMisses) * 100 / images); 758 printf("IMAGES: %d (%d hits, hit rate %d%%)\n", images, images - imageM isses, (images - imageMisses) * 100 / images);
784 } 759 }
785 #endif 760 #endif
786 761
787 } 762 }
OLDNEW
« no previous file with comments | « Source/WebCore/loader/cache/CachedResourceLoader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698