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 | 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All |
6 rights reserved. | 6 rights reserved. |
7 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ | 7 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ |
8 | 8 |
9 This library is free software; you can redistribute it and/or | 9 This library is free software; you can redistribute it and/or |
10 modify it under the terms of the GNU Library General Public | 10 modify it under the terms of the GNU Library General Public |
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
876 if (params.IsLinkPreload()) { | 876 if (params.IsLinkPreload()) { |
877 resource->SetLinkPreload(true); | 877 resource->SetLinkPreload(true); |
878 return resource; | 878 return resource; |
879 } | 879 } |
880 | 880 |
881 if (!IsReusableForPreloading(params, resource, false)) | 881 if (!IsReusableForPreloading(params, resource, false)) |
882 return nullptr; | 882 return nullptr; |
883 | 883 |
884 resource->DecreasePreloadCount(); | 884 resource->DecreasePreloadCount(); |
885 preloads_.erase(it); | 885 preloads_.erase(it); |
| 886 matched_preloads_.push_back(resource); |
886 return resource; | 887 return resource; |
887 } | 888 } |
888 | 889 |
889 void ResourceFetcher::InsertAsPreloadIfNecessary(Resource* resource, | 890 void ResourceFetcher::InsertAsPreloadIfNecessary(Resource* resource, |
890 const FetchParameters& params, | 891 const FetchParameters& params, |
891 Resource::Type type) { | 892 Resource::Type type) { |
892 if (!params.IsSpeculativePreload() && !params.IsLinkPreload()) | 893 if (!params.IsSpeculativePreload() && !params.IsLinkPreload()) |
893 return; | 894 return; |
894 // CSP layout tests verify that preloads are subject to access checks by | 895 // CSP layout tests verify that preloads are subject to access checks by |
895 // seeing if they are in the `preload started` list. Therefore do not add | 896 // seeing if they are in the `preload started` list. Therefore do not add |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1208 for (const auto& pair : preloads_) { | 1209 for (const auto& pair : preloads_) { |
1209 Resource* resource = pair.value; | 1210 Resource* resource = pair.value; |
1210 if (policy == kClearAllPreloads || !resource->IsLinkPreload()) { | 1211 if (policy == kClearAllPreloads || !resource->IsLinkPreload()) { |
1211 resource->DecreasePreloadCount(); | 1212 resource->DecreasePreloadCount(); |
1212 if (resource->GetPreloadResult() == Resource::kPreloadNotReferenced) | 1213 if (resource->GetPreloadResult() == Resource::kPreloadNotReferenced) |
1213 GetMemoryCache()->Remove(resource); | 1214 GetMemoryCache()->Remove(resource); |
1214 keys_to_be_removed.push_back(pair.key); | 1215 keys_to_be_removed.push_back(pair.key); |
1215 } | 1216 } |
1216 } | 1217 } |
1217 preloads_.RemoveAll(keys_to_be_removed); | 1218 preloads_.RemoveAll(keys_to_be_removed); |
| 1219 |
| 1220 matched_preloads_.clear(); |
1218 } | 1221 } |
1219 | 1222 |
1220 void ResourceFetcher::WarnUnusedPreloads() { | 1223 void ResourceFetcher::WarnUnusedPreloads() { |
1221 for (const auto& pair : preloads_) { | 1224 for (const auto& pair : preloads_) { |
1222 Resource* resource = pair.value; | 1225 Resource* resource = pair.value; |
1223 if (resource && resource->IsLinkPreload() && | 1226 if (resource && resource->IsLinkPreload() && |
1224 resource->GetPreloadResult() == Resource::kPreloadNotReferenced) { | 1227 resource->GetPreloadResult() == Resource::kPreloadNotReferenced) { |
1225 Context().AddConsoleMessage( | 1228 Context().AddConsoleMessage( |
1226 "The resource " + resource->Url().GetString() + | 1229 "The resource " + resource->Url().GetString() + |
1227 " was preloaded using link preload but not used within a few " | 1230 " was preloaded using link preload but not used within a few " |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1634 RequestLoadStarted(resource->Identifier(), resource, params, kUse); | 1637 RequestLoadStarted(resource->Identifier(), resource, params, kUse); |
1635 } | 1638 } |
1636 | 1639 |
1637 DEFINE_TRACE(ResourceFetcher) { | 1640 DEFINE_TRACE(ResourceFetcher) { |
1638 visitor->Trace(context_); | 1641 visitor->Trace(context_); |
1639 visitor->Trace(archive_); | 1642 visitor->Trace(archive_); |
1640 visitor->Trace(loaders_); | 1643 visitor->Trace(loaders_); |
1641 visitor->Trace(non_blocking_loaders_); | 1644 visitor->Trace(non_blocking_loaders_); |
1642 visitor->Trace(document_resources_); | 1645 visitor->Trace(document_resources_); |
1643 visitor->Trace(preloads_); | 1646 visitor->Trace(preloads_); |
| 1647 visitor->Trace(matched_preloads_); |
1644 visitor->Trace(resource_timing_info_map_); | 1648 visitor->Trace(resource_timing_info_map_); |
1645 } | 1649 } |
1646 | 1650 |
1647 } // namespace blink | 1651 } // namespace blink |
OLD | NEW |