OLD | NEW |
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 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
898 return m_preloadedURLsForTest->contains(url.getString()); | 898 return m_preloadedURLsForTest->contains(url.getString()); |
899 } | 899 } |
900 | 900 |
901 void ResourceFetcher::clearPreloads(ClearPreloadsPolicy policy) | 901 void ResourceFetcher::clearPreloads(ClearPreloadsPolicy policy) |
902 { | 902 { |
903 if (!m_preloads) | 903 if (!m_preloads) |
904 return; | 904 return; |
905 | 905 |
906 logPreloadStats(); | 906 logPreloadStats(); |
907 | 907 |
908 for (auto resource : *m_preloads) { | 908 for (const auto& resource : *m_preloads) { |
909 if (policy == ClearAllPreloads || !resource->isLinkPreload()) { | 909 if (policy == ClearAllPreloads || !resource->isLinkPreload()) { |
910 resource->decreasePreloadCount(); | 910 resource->decreasePreloadCount(); |
911 if (resource->getPreloadResult() == Resource::PreloadNotReferenced) | 911 if (resource->getPreloadResult() == Resource::PreloadNotReferenced) |
912 memoryCache()->remove(resource.get()); | 912 memoryCache()->remove(resource.get()); |
913 m_preloads->remove(resource); | 913 m_preloads->remove(resource); |
914 } | 914 } |
915 } | 915 } |
916 if (!m_preloads->size()) | 916 if (!m_preloads->size()) |
917 m_preloads.clear(); | 917 m_preloads.clear(); |
918 } | 918 } |
919 | 919 |
| 920 void ResourceFetcher::warnUnusedPreloads() |
| 921 { |
| 922 if (!m_preloads) |
| 923 return; |
| 924 for (const auto& resource : *m_preloads) { |
| 925 if (resource && resource->isLinkPreload() && resource->getPreloadResult(
) == Resource::PreloadNotReferenced) { |
| 926 context().addConsoleMessage("The resource " + resource->url().getStr
ing() + " was preloaded using link preload but not used within a few seconds fro
m the window's load event. Please make sure it wasn't preloaded for nothing.", F
etchContext::LogWarningMessage); |
| 927 } |
| 928 } |
| 929 } |
| 930 |
920 ArchiveResource* ResourceFetcher::createArchive(Resource* resource) | 931 ArchiveResource* ResourceFetcher::createArchive(Resource* resource) |
921 { | 932 { |
922 // Only the top-frame can load MHTML. | 933 // Only the top-frame can load MHTML. |
923 if (!context().isMainFrame()) | 934 if (!context().isMainFrame()) |
924 return nullptr; | 935 return nullptr; |
925 m_archive = MHTMLArchive::create(resource->url(), resource->resourceBuffer()
); | 936 m_archive = MHTMLArchive::create(resource->url(), resource->resourceBuffer()
); |
926 return m_archive ? m_archive->mainResource() : nullptr; | 937 return m_archive ? m_archive->mainResource() : nullptr; |
927 } | 938 } |
928 | 939 |
929 void ResourceFetcher::didFinishLoading(Resource* resource, double finishTime, in
t64_t encodedDataLength, DidFinishLoadingReason finishReason) | 940 void ResourceFetcher::didFinishLoading(Resource* resource, double finishTime, in
t64_t encodedDataLength, DidFinishLoadingReason finishReason) |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1185 unsigned fonts = 0; | 1196 unsigned fonts = 0; |
1186 unsigned fontMisses = 0; | 1197 unsigned fontMisses = 0; |
1187 unsigned medias = 0; | 1198 unsigned medias = 0; |
1188 unsigned mediaMisses = 0; | 1199 unsigned mediaMisses = 0; |
1189 unsigned textTracks = 0; | 1200 unsigned textTracks = 0; |
1190 unsigned textTrackMisses = 0; | 1201 unsigned textTrackMisses = 0; |
1191 unsigned imports = 0; | 1202 unsigned imports = 0; |
1192 unsigned importMisses = 0; | 1203 unsigned importMisses = 0; |
1193 unsigned raws = 0; | 1204 unsigned raws = 0; |
1194 unsigned rawMisses = 0; | 1205 unsigned rawMisses = 0; |
1195 for (auto resource : *m_preloads) { | 1206 for (const auto& resource : *m_preloads) { |
1196 int missCount = resource->getPreloadResult() == Resource::PreloadNotRefe
renced ? 1 : 0; | 1207 int missCount = resource->getPreloadResult() == Resource::PreloadNotRefe
renced ? 1 : 0; |
1197 switch (resource->getType()) { | 1208 switch (resource->getType()) { |
1198 case Resource::Image: | 1209 case Resource::Image: |
1199 images++; | 1210 images++; |
1200 imageMisses += missCount; | 1211 imageMisses += missCount; |
1201 break; | 1212 break; |
1202 case Resource::Script: | 1213 case Resource::Script: |
1203 scripts++; | 1214 scripts++; |
1204 scriptMisses += missCount; | 1215 scriptMisses += missCount; |
1205 break; | 1216 break; |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1335 visitor->trace(m_context); | 1346 visitor->trace(m_context); |
1336 visitor->trace(m_archive); | 1347 visitor->trace(m_archive); |
1337 visitor->trace(m_loaders); | 1348 visitor->trace(m_loaders); |
1338 visitor->trace(m_nonBlockingLoaders); | 1349 visitor->trace(m_nonBlockingLoaders); |
1339 visitor->trace(m_documentResources); | 1350 visitor->trace(m_documentResources); |
1340 visitor->trace(m_preloads); | 1351 visitor->trace(m_preloads); |
1341 visitor->trace(m_resourceTimingInfoMap); | 1352 visitor->trace(m_resourceTimingInfoMap); |
1342 } | 1353 } |
1343 | 1354 |
1344 } // namespace blink | 1355 } // namespace blink |
OLD | NEW |