Chromium Code Reviews| 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; |
| } |
| } |