Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Unified Diff: third_party/WebKit/Source/core/fetch/ImageResource.h

Issue 2423683002: Add Blink support for showing image placeholders using range requests. (Closed)
Patch Set: Addressed comments and fixed bugs Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..ab138ab819f22df07b894f5220003e24d05992f8 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 reloadIfLoFiOrPlaceholder(ResourceFetcher*, bool bypassCache = true);
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; }
Nate Chapin 2016/10/18 18:23:17 Looks like this is test-only? Maybe note it? Or te
sclittle 2016/10/18 23:53:03 Added comment saying that it's test-only.
+ 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);

Powered by Google App Engine
This is Rietveld 408576698