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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
255 | 255 |
256 bool ResourceFetcher::isControlledByServiceWorker() const | 256 bool ResourceFetcher::isControlledByServiceWorker() const |
257 { | 257 { |
258 return context().isControlledByServiceWorker(); | 258 return context().isControlledByServiceWorker(); |
259 } | 259 } |
260 | 260 |
261 bool ResourceFetcher::resourceNeedsLoad(Resource* resource, const FetchRequest& request, RevalidationPolicy policy) | 261 bool ResourceFetcher::resourceNeedsLoad(Resource* resource, const FetchRequest& request, RevalidationPolicy policy) |
262 { | 262 { |
263 if (FetchRequest::DeferredByClient == request.defer()) | 263 if (FetchRequest::DeferredByClient == request.defer()) |
264 return false; | 264 return false; |
265 if (resource->isImage() && shouldDeferImageLoad(resource->url())) | |
266 return false; | |
265 return policy != Use || resource->stillNeedsLoad(); | 267 return policy != Use || resource->stillNeedsLoad(); |
266 } | 268 } |
267 | 269 |
268 // Limit the number of URLs in m_validatedURLs to avoid memory bloat. | 270 // Limit the number of URLs in m_validatedURLs to avoid memory bloat. |
269 // http://crbug.com/52411 | 271 // http://crbug.com/52411 |
270 static const int kMaxValidatedURLsSize = 10000; | 272 static const int kMaxValidatedURLsSize = 10000; |
271 | 273 |
272 void ResourceFetcher::requestLoadStarted(Resource* resource, const FetchRequest& request, ResourceLoadStartType type, bool isStaticData) | 274 void ResourceFetcher::requestLoadStarted(Resource* resource, const FetchRequest& request, ResourceLoadStartType type, bool isStaticData) |
273 { | 275 { |
274 if (type == ResourceLoadingFromCache && resource->getStatus() == Resource::C ached && !m_validatedURLs.contains(resource->url())) | 276 if (type == ResourceLoadingFromCache && resource->getStatus() == Resource::C ached && !m_validatedURLs.contains(resource->url())) |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
655 // If the same URL has been loaded as a different type, we need to reload. | 657 // If the same URL has been loaded as a different type, we need to reload. |
656 if (existingResource->getType() != type) { | 658 if (existingResource->getType() != type) { |
657 // FIXME: If existingResource is a Preload and the new type is LinkPrefe tch | 659 // FIXME: If existingResource is a Preload and the new type is LinkPrefe tch |
658 // We really should discard the new prefetch since the preload has more | 660 // We really should discard the new prefetch since the preload has more |
659 // specific type information! crbug.com/379893 | 661 // specific type information! crbug.com/379893 |
660 // fast/dom/HTMLLinkElement/link-and-subresource-test hits this case. | 662 // fast/dom/HTMLLinkElement/link-and-subresource-test hits this case. |
661 WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicy r eloading due to type mismatch."); | 663 WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicy r eloading due to type mismatch."); |
662 return Reload; | 664 return Reload; |
663 } | 665 } |
664 | 666 |
665 // Do not load from cache if images are not enabled. The load for this image will be blocked | 667 // Do not load from cache if images are not enabled. |
666 // in ImageResource::load. | |
667 if (FetchRequest::DeferredByClient == fetchRequest.defer()) | 668 if (FetchRequest::DeferredByClient == fetchRequest.defer()) |
668 return Reload; | 669 return Reload; |
670 if (existingResource->isImage() && !context().allowImage(m_imagesEnabled, ex istingResource->url())) | |
Nate Chapin
2016/03/18 21:24:06
shouldDeferImageLoad(), if used here, blocks SVGIm
hiroshige
2016/03/18 23:21:20
Offline discussion memo: can we |m_autoLoadImages|
Nate Chapin
2016/03/21 22:04:01
https://chromium.googlesource.com/chromium/src/+/m
hiroshige
2016/03/22 18:21:33
I see.
So, if allowImage() is false,
(1) we reload
Nate Chapin
2016/03/22 19:51:23
Done.
| |
671 return Reload; | |
669 | 672 |
670 // Never use cache entries for downloadToFile / useStreamOnResponse | 673 // Never use cache entries for downloadToFile / useStreamOnResponse |
671 // requests. The data will be delivered through other paths. | 674 // requests. The data will be delivered through other paths. |
672 if (request.downloadToFile() || request.useStreamOnResponse()) | 675 if (request.downloadToFile() || request.useStreamOnResponse()) |
673 return Reload; | 676 return Reload; |
674 | 677 |
675 // If resource was populated from a SubstituteData load or data: url, use it . | 678 // If resource was populated from a SubstituteData load or data: url, use it . |
676 if (isStaticData) | 679 if (isStaticData) |
677 return Use; | 680 return Use; |
678 | 681 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
809 return; | 812 return; |
810 | 813 |
811 m_imagesEnabled = enable; | 814 m_imagesEnabled = enable; |
812 | 815 |
813 if (!m_imagesEnabled) | 816 if (!m_imagesEnabled) |
814 return; | 817 return; |
815 | 818 |
816 reloadImagesIfNotDeferred(); | 819 reloadImagesIfNotDeferred(); |
817 } | 820 } |
818 | 821 |
819 bool ResourceFetcher::clientDefersImage(const KURL& url) const | |
820 { | |
821 return !context().allowImage(m_imagesEnabled, url); | |
822 } | |
823 | |
824 bool ResourceFetcher::shouldDeferImageLoad(const KURL& url) const | 822 bool ResourceFetcher::shouldDeferImageLoad(const KURL& url) const |
825 { | 823 { |
826 return clientDefersImage(url) || !m_autoLoadImages; | 824 return !context().allowImage(m_imagesEnabled, url) || !m_autoLoadImages; |
827 } | 825 } |
828 | 826 |
829 void ResourceFetcher::reloadImagesIfNotDeferred() | 827 void ResourceFetcher::reloadImagesIfNotDeferred() |
830 { | 828 { |
831 // TODO(japhet): Once oilpan ships, the const auto& | 829 // TODO(japhet): Once oilpan ships, the const auto& |
832 // can be replaced with a Resource*. Also, null checking | 830 // can be replaced with a Resource*. Also, null checking |
833 // the resource probably won't be necesssary. | 831 // the resource probably won't be necesssary. |
834 for (const auto& documentResource : m_documentResources) { | 832 for (const auto& documentResource : m_documentResources) { |
835 Resource* resource = documentResource.value.get(); | 833 Resource* resource = documentResource.value.get(); |
836 if (resource && resource->getType() == Resource::Image && resource->stil lNeedsLoad() && !clientDefersImage(resource->url())) | 834 if (resource && resource->getType() == Resource::Image && resource->stil lNeedsLoad() && !shouldDeferImageLoad(resource->url())) |
837 const_cast<Resource*>(resource)->load(this, defaultResourceOptions() ); | 835 const_cast<Resource*>(resource)->load(this, defaultResourceOptions() ); |
838 } | 836 } |
839 } | 837 } |
840 | 838 |
841 void ResourceFetcher::didLoadResource(Resource* resource) | 839 void ResourceFetcher::didLoadResource(Resource* resource) |
842 { | 840 { |
843 context().didLoadResource(resource); | 841 context().didLoadResource(resource); |
844 } | 842 } |
845 | 843 |
846 int ResourceFetcher::requestCount() const | 844 int ResourceFetcher::requestCount() const |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
908 | 906 |
909 if (!m_archive) | 907 if (!m_archive) |
910 return false; | 908 return false; |
911 | 909 |
912 ArchiveResource* archiveResource = m_archive->subresourceForURL(request.url( )); | 910 ArchiveResource* archiveResource = m_archive->subresourceForURL(request.url( )); |
913 if (!archiveResource) { | 911 if (!archiveResource) { |
914 resource->error(Resource::LoadError); | 912 resource->error(Resource::LoadError); |
915 return false; | 913 return false; |
916 } | 914 } |
917 | 915 |
918 resource->setLoading(true); | 916 resource->setStatus(Resource::Pending); |
919 resource->responseReceived(archiveResource->response(), nullptr); | 917 resource->responseReceived(archiveResource->response(), nullptr); |
920 SharedBuffer* data = archiveResource->data(); | 918 SharedBuffer* data = archiveResource->data(); |
921 if (data) | 919 if (data) |
922 resource->appendData(data->data(), data->size()); | 920 resource->appendData(data->data(), data->size()); |
923 resource->finish(); | 921 resource->finish(); |
924 return true; | 922 return true; |
925 } | 923 } |
926 | 924 |
927 void ResourceFetcher::didFinishLoading(Resource* resource, double finishTime, in t64_t encodedDataLength) | 925 void ResourceFetcher::didFinishLoading(Resource* resource, double finishTime, in t64_t encodedDataLength) |
928 { | 926 { |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1219 visitor->trace(m_loaders); | 1217 visitor->trace(m_loaders); |
1220 visitor->trace(m_nonBlockingLoaders); | 1218 visitor->trace(m_nonBlockingLoaders); |
1221 #if ENABLE(OILPAN) | 1219 #if ENABLE(OILPAN) |
1222 visitor->trace(m_documentResources); | 1220 visitor->trace(m_documentResources); |
1223 visitor->trace(m_preloads); | 1221 visitor->trace(m_preloads); |
1224 visitor->trace(m_resourceTimingInfoMap); | 1222 visitor->trace(m_resourceTimingInfoMap); |
1225 #endif | 1223 #endif |
1226 } | 1224 } |
1227 | 1225 |
1228 } // namespace blink | 1226 } // namespace blink |
OLD | NEW |