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

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: Fix issues inside clearPreloads and add tests 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
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 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 } 880 }
881 881
882 void ResourceFetcher::clearPreloads(ClearPreloadsPolicy policy) 882 void ResourceFetcher::clearPreloads(ClearPreloadsPolicy policy)
883 { 883 {
884 if (!m_preloads) 884 if (!m_preloads)
885 return; 885 return;
886 886
887 logPreloadStats(); 887 logPreloadStats();
888 888
889 for (auto resource : *m_preloads) { 889 for (auto resource : *m_preloads) {
890 resource->decreasePreloadCount(); 890 if (policy == ClearAllPreloads || !resource->isLinkPreload()) {
891 if (resource->getPreloadResult() == Resource::PreloadNotReferenced && (p olicy == ClearAllPreloads || !resource->isLinkPreload())) 891 resource->decreasePreloadCount();
892 memoryCache()->remove(resource.get()); 892 if (resource->getPreloadResult() == Resource::PreloadNotReferenced)
893 memoryCache()->remove(resource.get());
894 m_preloads->remove(resource);
895 }
893 } 896 }
894 m_preloads.clear(); 897 if (!m_preloads->size())
Charlie Harrison 2016/08/04 18:10:26 This is confusing. Clear the preloads only if they
Yoav Weiss 2016/08/04 20:26:14 AFAICT the clear here clears the Member (and enabl
Charlie Harrison 2016/08/04 20:59:57 Ah, makes sense. Thanks for the clarification.
898 m_preloads.clear();
895 } 899 }
896 900
897 ArchiveResource* ResourceFetcher::createArchive(Resource* resource) 901 ArchiveResource* ResourceFetcher::createArchive(Resource* resource)
898 { 902 {
899 // Only the top-frame can load MHTML. 903 // Only the top-frame can load MHTML.
900 if (!context().isMainFrame()) 904 if (!context().isMainFrame())
901 return nullptr; 905 return nullptr;
902 m_archive = MHTMLArchive::create(resource->url(), resource->resourceBuffer() ); 906 m_archive = MHTMLArchive::create(resource->url(), resource->resourceBuffer() );
903 return m_archive ? m_archive->mainResource() : nullptr; 907 return m_archive ? m_archive->mainResource() : nullptr;
904 } 908 }
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 visitor->trace(m_context); 1305 visitor->trace(m_context);
1302 visitor->trace(m_archive); 1306 visitor->trace(m_archive);
1303 visitor->trace(m_loaders); 1307 visitor->trace(m_loaders);
1304 visitor->trace(m_nonBlockingLoaders); 1308 visitor->trace(m_nonBlockingLoaders);
1305 visitor->trace(m_documentResources); 1309 visitor->trace(m_documentResources);
1306 visitor->trace(m_preloads); 1310 visitor->trace(m_preloads);
1307 visitor->trace(m_resourceTimingInfoMap); 1311 visitor->trace(m_resourceTimingInfoMap);
1308 } 1312 }
1309 1313
1310 } // namespace blink 1314 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698