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 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 { | 887 { |
888 if (!existingResource) | 888 if (!existingResource) |
889 return Load; | 889 return Load; |
890 | 890 |
891 // We already have a preload going for this URL. | 891 // We already have a preload going for this URL. |
892 if (forPreload && existingResource->isPreloaded()) | 892 if (forPreload && existingResource->isPreloaded()) |
893 return Use; | 893 return Use; |
894 | 894 |
895 // If the same URL has been loaded as a different type, we need to reload. | 895 // If the same URL has been loaded as a different type, we need to reload. |
896 if (existingResource->type() != type) { | 896 if (existingResource->type() != type) { |
| 897 // FIXME: If existingResource is a Preload and the new type is LinkPrefe
tch |
| 898 // We really should discard the new prefetch since the preload has more |
| 899 // specific type information! crbug.com/379893 |
| 900 // fast/dom/HTMLLinkElement/link-and-subresource-test hits this case. |
897 WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicy r
eloading due to type mismatch."); | 901 WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicy r
eloading due to type mismatch."); |
898 return Reload; | 902 return Reload; |
899 } | 903 } |
900 | 904 |
901 // Do not load from cache if images are not enabled. The load for this image
will be blocked | 905 // Do not load from cache if images are not enabled. The load for this image
will be blocked |
902 // in ImageResource::load. | 906 // in ImageResource::load. |
903 if (FetchRequest::DeferredByClient == defer) | 907 if (FetchRequest::DeferredByClient == defer) |
904 return Reload; | 908 return Reload; |
905 | 909 |
906 // Always use data uris. | 910 // Always use data uris. |
(...skipping 15 matching lines...) Expand all Loading... |
922 // Certain requests (e.g., XHRs) might have manually set headers that requir
e revalidation. | 926 // Certain requests (e.g., XHRs) might have manually set headers that requir
e revalidation. |
923 // FIXME: In theory, this should be a Revalidate case. In practice, the Memo
ryCache revalidation path assumes a whole bunch | 927 // FIXME: In theory, this should be a Revalidate case. In practice, the Memo
ryCache revalidation path assumes a whole bunch |
924 // of things about how revalidation works that manual headers violate, so pu
nt to Reload instead. | 928 // of things about how revalidation works that manual headers violate, so pu
nt to Reload instead. |
925 if (request.isConditional()) | 929 if (request.isConditional()) |
926 return Reload; | 930 return Reload; |
927 | 931 |
928 // Don't reload resources while pasting. | 932 // Don't reload resources while pasting. |
929 if (m_allowStaleResources) | 933 if (m_allowStaleResources) |
930 return Use; | 934 return Use; |
931 | 935 |
| 936 // If fetching a resource with a different 'CORS enabled' flag, reload. |
| 937 if (type != Resource::MainResource && options.corsEnabled != existingResourc
e->options().corsEnabled) |
| 938 return Reload; |
| 939 |
932 // Always use preloads. | 940 // Always use preloads. |
933 if (existingResource->isPreloaded()) | 941 if (existingResource->isPreloaded()) |
934 return Use; | 942 return Use; |
935 | 943 |
936 // CachePolicyHistoryBuffer uses the cache no matter what. | 944 // CachePolicyHistoryBuffer uses the cache no matter what. |
937 CachePolicy cachePolicy = context().cachePolicy(document()); | 945 CachePolicy cachePolicy = context().cachePolicy(document()); |
938 if (cachePolicy == CachePolicyHistoryBuffer) | 946 if (cachePolicy == CachePolicyHistoryBuffer) |
939 return Use; | 947 return Use; |
940 | 948 |
941 // Don't reuse resources with Cache-control: no-store. | 949 // Don't reuse resources with Cache-control: no-store. |
942 if (existingResource->hasCacheControlNoStoreHeader()) { | 950 if (existingResource->hasCacheControlNoStoreHeader()) { |
943 WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicy r
eloading due to Cache-control: no-store."); | 951 WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicy r
eloading due to Cache-control: no-store."); |
944 return Reload; | 952 return Reload; |
945 } | 953 } |
946 | 954 |
947 // If fetching a resource with a different 'CORS enabled' flag, reload. | |
948 if (type != Resource::MainResource && options.corsEnabled != existingResourc
e->options().corsEnabled) | |
949 return Reload; | |
950 | |
951 // If credentials were sent with the previous request and won't be | 955 // If credentials were sent with the previous request and won't be |
952 // with this one, or vice versa, re-fetch the resource. | 956 // with this one, or vice versa, re-fetch the resource. |
953 // | 957 // |
954 // This helps with the case where the server sends back | 958 // This helps with the case where the server sends back |
955 // "Access-Control-Allow-Origin: *" all the time, but some of the | 959 // "Access-Control-Allow-Origin: *" all the time, but some of the |
956 // client's requests are made without CORS and some with. | 960 // client's requests are made without CORS and some with. |
957 if (existingResource->resourceRequest().allowStoredCredentials() != request.
allowStoredCredentials()) { | 961 if (existingResource->resourceRequest().allowStoredCredentials() != request.
allowStoredCredentials()) { |
958 WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicy r
eloading due to difference in credentials settings."); | 962 WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicy r
eloading due to difference in credentials settings."); |
959 return Reload; | 963 return Reload; |
960 } | 964 } |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1463 } | 1467 } |
1464 } | 1468 } |
1465 | 1469 |
1466 void ResourceFetcher::trace(Visitor* visitor) | 1470 void ResourceFetcher::trace(Visitor* visitor) |
1467 { | 1471 { |
1468 visitor->trace(m_document); | 1472 visitor->trace(m_document); |
1469 ResourceLoaderHost::trace(visitor); | 1473 ResourceLoaderHost::trace(visitor); |
1470 } | 1474 } |
1471 | 1475 |
1472 } | 1476 } |
OLD | NEW |