Chromium Code Reviews| Index: third_party/WebKit/Source/core/fetch/FetchRequest.cpp |
| diff --git a/third_party/WebKit/Source/core/fetch/FetchRequest.cpp b/third_party/WebKit/Source/core/fetch/FetchRequest.cpp |
| index 952e4d42a6954ad986d6f628e54ff29326e327b9..5d4e20e6ddfbff0dc8c3abc308e5563612eb2ec1 100644 |
| --- a/third_party/WebKit/Source/core/fetch/FetchRequest.cpp |
| +++ b/third_party/WebKit/Source/core/fetch/FetchRequest.cpp |
| @@ -27,6 +27,7 @@ |
| #include "core/fetch/CrossOriginAccessControl.h" |
| #include "core/fetch/ResourceFetcher.h" |
| +#include "platform/weborigin/KURL.h" |
| namespace blink { |
| @@ -40,7 +41,8 @@ FetchRequest::FetchRequest(const ResourceRequest& resourceRequest, |
| m_linkPreload(false), |
| m_preloadDiscoveryTime(0.0), |
| m_defer(NoDefer), |
| - m_originRestriction(UseDefaultOriginRestrictionForType) { |
| + m_originRestriction(UseDefaultOriginRestrictionForType), |
| + m_placeholderImageRequestType(DisallowPlaceholder) { |
| m_options.initiatorInfo.name = initiator; |
| } |
| @@ -53,7 +55,9 @@ FetchRequest::FetchRequest(const ResourceRequest& resourceRequest, |
| m_linkPreload(false), |
| m_preloadDiscoveryTime(0.0), |
| m_defer(NoDefer), |
| - m_originRestriction(UseDefaultOriginRestrictionForType) { |
| + m_originRestriction(UseDefaultOriginRestrictionForType), |
| + m_placeholderImageRequestType( |
| + PlaceholderImageRequestType::DisallowPlaceholder) { |
| m_options.initiatorInfo.name = initiator; |
| } |
| @@ -65,7 +69,9 @@ FetchRequest::FetchRequest(const ResourceRequest& resourceRequest, |
| m_linkPreload(false), |
| m_preloadDiscoveryTime(0.0), |
| m_defer(NoDefer), |
| - m_originRestriction(UseDefaultOriginRestrictionForType) { |
| + m_originRestriction(UseDefaultOriginRestrictionForType), |
| + m_placeholderImageRequestType( |
| + PlaceholderImageRequestType::DisallowPlaceholder) { |
| m_options.initiatorInfo = initiator; |
| } |
| @@ -119,4 +125,25 @@ void FetchRequest::makeSynchronous() { |
| m_options.synchronousPolicy = RequestSynchronously; |
| } |
| +void FetchRequest::setAllowImagePlaceholder() { |
| + if (!m_resourceRequest.url().protocolIsInHTTPFamily() || |
| + m_resourceRequest.httpMethod() != "GET" || |
| + !m_resourceRequest.httpHeaderField("range").isNull()) { |
| + m_placeholderImageRequestType = DisallowPlaceholder; |
|
Nate Chapin
2016/10/21 18:23:55
Is this needed? Can we DCHECK(m_placeholderImageRe
sclittle
2016/10/21 18:57:25
Done.
|
| + return; |
| + } |
| + |
| + m_placeholderImageRequestType = AllowPlaceholder; |
| + |
| + // Fetch the first few bytes of the image. This number is tuned to both (a) |
| + // likely capture the entire image for small images and (b) likely contain |
| + // the dimensions for larger images. |
| + // TODO(sclittle): Calculate the optimal value for this number. |
| + m_resourceRequest.setHTTPHeaderField("range", "bytes=0-2047"); |
| + |
| + // TODO(sclittle): Indicate somehow (e.g. through a new request bit) to the |
| + // embedder that it should return the full resource if the entire resource is |
| + // fresh in the cache. |
| +} |
| + |
| } // namespace blink |