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

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

Issue 2361263003: Blink: Throttle progressively loaded images. (Closed)
Patch Set: throttle-images: update 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
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ImageResource.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/fetch/ImageResource.cpp
diff --git a/third_party/WebKit/Source/core/fetch/ImageResource.cpp b/third_party/WebKit/Source/core/fetch/ImageResource.cpp
index d0267f99ccf05b41ce82815333f210a8c96abad3..5f68101c75238f86cb26eff681bad68204007404 100644
--- a/third_party/WebKit/Source/core/fetch/ImageResource.cpp
+++ b/third_party/WebKit/Source/core/fetch/ImageResource.cpp
@@ -45,6 +45,11 @@
namespace blink {
+// The amount of time to wait before informing the clients that the image has
+// been updated (in seconds). This effectively throttles invalidations that
+// result from new data arriving for this image.
+static double flushDelaySeconds = 1.;
pdr. 2016/10/05 02:07:31 Should we use constexpr and a k prefix here? E.g.,
+
ImageResource* ImageResource::fetch(FetchRequest& request,
ResourceFetcher* fetcher) {
if (request.resourceRequest().requestContext() ==
@@ -242,7 +247,18 @@ void ImageResource::appendData(const char* data, size_t length) {
m_multipartParser->appendData(data, length);
} else {
Resource::appendData(data, length);
- updateImage(false);
+
+ // If we have an animated image, then update as soon as we have more data.
+ if (m_image && m_image->maybeAnimated()) {
+ updateImage(false);
+ return;
+ }
+
+ // For other images, only update at |flushDelaySeconds| intervals.
pdr. 2016/10/05 02:07:31 Can you expand on this comment a bit? Similar to y
+ double now = WTF::currentTime();
+ if (m_lastFlushTime && (m_lastFlushTime + flushDelaySeconds <= now))
+ updateImage(false);
+ m_lastFlushTime = now;
}
}
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ImageResource.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698