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

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

Issue 2361263003: Blink: Throttle progressively loaded images. (Closed)
Patch Set: wip: update Created 4 years, 3 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.cpp
diff --git a/third_party/WebKit/Source/core/fetch/ImageResource.cpp b/third_party/WebKit/Source/core/fetch/ImageResource.cpp
index be3e5de6e7041ee64971b7cbd566affdb0d64bc1..5701e37b361154aaed590bc83a4dfc835cd64db7 100644
--- a/third_party/WebKit/Source/core/fetch/ImageResource.cpp
+++ b/third_party/WebKit/Source/core/fetch/ImageResource.cpp
@@ -45,6 +45,8 @@
namespace blink {
+static double flushDelay = 1.;
enne (OOO) 2016/09/29 22:49:34 flushDelayInSeconds? Mumble mumble wtb base::Time
vmpstr 2016/10/04 21:18:36 Done.
+
ImageResource* ImageResource::fetch(FetchRequest& request, ResourceFetcher* fetcher)
{
if (request.resourceRequest().requestContext() == WebURLRequest::RequestContextUnspecified)
@@ -64,6 +66,7 @@ ImageResource::ImageResource(const ResourceRequest& resourceRequest, const Resou
, m_devicePixelRatioHeaderValue(1.0)
, m_image(nullptr)
, m_hasDevicePixelRatioHeaderValue(false)
+ , m_lastFlushTime(0.)
{
RESOURCE_LOADING_DVLOG(1) << "new ImageResource(ResourceRequest) " << this;
}
@@ -73,6 +76,7 @@ ImageResource::ImageResource(blink::Image* image, const ResourceLoaderOptions& o
, m_devicePixelRatioHeaderValue(1.0)
, m_image(image)
, m_hasDevicePixelRatioHeaderValue(false)
+ , m_lastFlushTime(0.)
{
RESOURCE_LOADING_DVLOG(1) << "new ImageResource(Image) " << this;
setStatus(Cached);
@@ -247,7 +251,13 @@ void ImageResource::appendData(const char* data, size_t length)
m_multipartParser->appendData(data, length);
} else {
Resource::appendData(data, length);
- updateImage(false);
+ double now = WTF::currentTime();
+ if (m_lastFlushTime == 0.) {
+ m_lastFlushTime = now;
+ } else if (m_lastFlushTime + flushDelay <= now) {
+ updateImage(false);
enne (OOO) 2016/09/29 22:49:34 Can you leave a big ol' comment here saying this t
vmpstr 2016/10/04 21:18:36 Actually looking closer at the code, I think even
+ m_lastFlushTime = now;
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698