Chromium Code Reviews| Index: third_party/WebKit/Source/core/fetch/ImageResource.h |
| diff --git a/third_party/WebKit/Source/core/fetch/ImageResource.h b/third_party/WebKit/Source/core/fetch/ImageResource.h |
| index 4652299c640c00894707b7f084ec90e42f393a66..35557e413500762f249b6aec3c10790351007b7e 100644 |
| --- a/third_party/WebKit/Source/core/fetch/ImageResource.h |
| +++ b/third_party/WebKit/Source/core/fetch/ImageResource.h |
| @@ -65,7 +65,7 @@ class CORE_EXPORT ImageResource final |
| } |
| static ImageResource* create(const ResourceRequest& request) { |
| - return new ImageResource(request, ResourceLoaderOptions()); |
| + return new ImageResource(request, ResourceLoaderOptions(), false); |
| } |
| ~ImageResource() override; |
| @@ -108,9 +108,10 @@ class CORE_EXPORT ImageResource final |
| void updateImageAnimationPolicy(); |
| - // If this ImageResource has the Lo-Fi response headers, reload it with the |
| - // Lo-Fi state set to off and bypassing the cache. |
| - void reloadIfLoFi(ResourceFetcher*); |
| + // If this ImageResource has the Lo-Fi response headers or is a placeholder, |
| + // reload the full original image with the Lo-Fi state set to off and |
| + // optionally bypassing the cache. |
| + void reloadIfLoFi(ResourceFetcher*, bool bypassCache = true); |
|
Stephen Chennney
2016/10/17 18:09:17
Rename this to reloadIfLoFiOrPlaceholder.
sclittle
2016/10/18 00:54:11
Done.
|
| void didAddClient(ResourceClient*) override; |
| @@ -145,6 +146,11 @@ class CORE_EXPORT ImageResource final |
| void onePartInMultipartReceived(const ResourceResponse&) final; |
| void multipartDataReceived(const char*, size_t) final; |
| + bool isPlaceholder() const { return m_isPlaceholder; } |
| + bool shouldReloadBrokenPlaceholder() const { |
| + return m_isPlaceholder && willPaintBrokenImage(); |
| + } |
| + |
| DECLARE_VIRTUAL_TRACE(); |
| private: |
| @@ -156,17 +162,11 @@ class CORE_EXPORT ImageResource final |
| FinishedParsingFirstPart, |
| }; |
| - class ImageResourceFactory : public ResourceFactory { |
| - public: |
| - ImageResourceFactory() : ResourceFactory(Resource::Image) {} |
| + class ImageResourceFactory; |
| - Resource* create(const ResourceRequest& request, |
| - const ResourceLoaderOptions& options, |
| - const String&) const override { |
| - return new ImageResource(request, options); |
| - } |
| - }; |
| - ImageResource(const ResourceRequest&, const ResourceLoaderOptions&); |
| + ImageResource(const ResourceRequest&, |
| + const ResourceLoaderOptions&, |
| + bool isPlaceholder); |
| bool hasClientsOrObservers() const override { |
| return Resource::hasClientsOrObservers() || !m_observers.isEmpty() || |
| @@ -205,6 +205,10 @@ class CORE_EXPORT ImageResource final |
| // Indicates if the ImageResource is currently scheduling a reload, e.g. |
| // because reloadIfLoFi() was called. |
| bool m_isSchedulingReload; |
| + |
| + // Indicates if this ImageResource is either attempting to load a placeholder |
| + // image, or is a (possibly broken) placeholder image. |
| + bool m_isPlaceholder; |
| }; |
| DEFINE_RESOURCE_TYPE_CASTS(Image); |