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

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

Issue 2174563003: Clear all preloads when document is detached (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 4 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 | « third_party/WebKit/Source/core/fetch/ResourceFetcher.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, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 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 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 } 843 }
844 844
845 void ResourceFetcher::reloadImagesIfNotDeferred() 845 void ResourceFetcher::reloadImagesIfNotDeferred()
846 { 846 {
847 for (Resource* resource : m_documentResources.values()) { 847 for (Resource* resource : m_documentResources.values()) {
848 if (resource->getType() == Resource::Image && resource->stillNeedsLoad() && !shouldDeferImageLoad(resource->url())) 848 if (resource->getType() == Resource::Image && resource->stillNeedsLoad() && !shouldDeferImageLoad(resource->url()))
849 startLoad(resource); 849 startLoad(resource);
850 } 850 }
851 } 851 }
852 852
853 void ResourceFetcher::clearContext()
854 {
855 clearPreloads(ResourceFetcher::ClearAllPreloads);
856 m_context.clear();
857 }
858
853 int ResourceFetcher::requestCount() const 859 int ResourceFetcher::requestCount() const
854 { 860 {
855 return m_loaders.size(); 861 return m_loaders.size();
856 } 862 }
857 863
858 void ResourceFetcher::preloadStarted(Resource* resource) 864 void ResourceFetcher::preloadStarted(Resource* resource)
859 { 865 {
860 if (m_preloads && m_preloads->contains(resource)) 866 if (m_preloads && m_preloads->contains(resource))
861 return; 867 return;
862 TRACE_EVENT_ASYNC_STEP_INTO0("blink.net", "Resource", resource->identifier() , "Preload"); 868 TRACE_EVENT_ASYNC_STEP_INTO0("blink.net", "Resource", resource->identifier() , "Preload");
(...skipping 17 matching lines...) Expand all
880 } 886 }
881 887
882 void ResourceFetcher::clearPreloads(ClearPreloadsPolicy policy) 888 void ResourceFetcher::clearPreloads(ClearPreloadsPolicy policy)
883 { 889 {
884 if (!m_preloads) 890 if (!m_preloads)
885 return; 891 return;
886 892
887 logPreloadStats(); 893 logPreloadStats();
888 894
889 for (auto resource : *m_preloads) { 895 for (auto resource : *m_preloads) {
890 resource->decreasePreloadCount(); 896 if (policy == ClearAllPreloads || !resource->isLinkPreload()) {
891 if (resource->getPreloadResult() == Resource::PreloadNotReferenced && (p olicy == ClearAllPreloads || !resource->isLinkPreload())) 897 resource->decreasePreloadCount();
892 memoryCache()->remove(resource.get()); 898 if (resource->getPreloadResult() == Resource::PreloadNotReferenced)
899 memoryCache()->remove(resource.get());
900 m_preloads->remove(resource);
901 }
893 } 902 }
894 m_preloads.clear(); 903 if (!m_preloads->size())
904 m_preloads.clear();
895 } 905 }
896 906
897 ArchiveResource* ResourceFetcher::createArchive(Resource* resource) 907 ArchiveResource* ResourceFetcher::createArchive(Resource* resource)
898 { 908 {
899 // Only the top-frame can load MHTML. 909 // Only the top-frame can load MHTML.
900 if (!context().isMainFrame()) 910 if (!context().isMainFrame())
901 return nullptr; 911 return nullptr;
902 m_archive = MHTMLArchive::create(resource->url(), resource->resourceBuffer() ); 912 m_archive = MHTMLArchive::create(resource->url(), resource->resourceBuffer() );
903 return m_archive ? m_archive->mainResource() : nullptr; 913 return m_archive ? m_archive->mainResource() : nullptr;
904 } 914 }
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 visitor->trace(m_context); 1311 visitor->trace(m_context);
1302 visitor->trace(m_archive); 1312 visitor->trace(m_archive);
1303 visitor->trace(m_loaders); 1313 visitor->trace(m_loaders);
1304 visitor->trace(m_nonBlockingLoaders); 1314 visitor->trace(m_nonBlockingLoaders);
1305 visitor->trace(m_documentResources); 1315 visitor->trace(m_documentResources);
1306 visitor->trace(m_preloads); 1316 visitor->trace(m_preloads);
1307 visitor->trace(m_resourceTimingInfoMap); 1317 visitor->trace(m_resourceTimingInfoMap);
1308 } 1318 }
1309 1319
1310 } // namespace blink 1320 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ResourceFetcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698