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

Unified Diff: third_party/WebKit/Source/platform/graphics/ImageSource.cpp

Issue 2108033003: Cancel image loads if decoding failed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 5 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/platform/graphics/ImageSource.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/ImageSource.cpp b/third_party/WebKit/Source/platform/graphics/ImageSource.cpp
index 1f98fe0c758eff0810568866402fec5778431fe7..f35627610c93a7849ae6564c57212d9be1ba095e 100644
--- a/third_party/WebKit/Source/platform/graphics/ImageSource.cpp
+++ b/third_party/WebKit/Source/platform/graphics/ImageSource.cpp
@@ -51,15 +51,19 @@ PassRefPtr<SharedBuffer> ImageSource::data()
return m_decoder ? m_decoder->data() : nullptr;
}
-void ImageSource::setData(SharedBuffer& data, bool allDataReceived)
+bool ImageSource::setData(SharedBuffer& data, bool allDataReceived)
{
// Create a decoder by sniffing the encoded data. If insufficient data bytes are available to
// determine the encoded image type, no decoder is created.
if (!m_decoder)
m_decoder = DeferredImageDecoder::create(data, ImageDecoder::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileApplied);
- if (m_decoder)
+ if (m_decoder) {
m_decoder->setData(data, allDataReceived);
+ return true;
+ }
+ // If enough data has been received to know that we won't have a valid decoded, bail.
pdr. 2016/07/20 20:39:16 nit: valid decoded -> valid decode
Nate Chapin 2016/07/20 22:50:00 Done.
+ return data.size() < ImageDecoder::longestSignatureLength();
pdr. 2016/07/20 20:39:16 This signature length check is now in two places,
Nate Chapin 2016/07/20 22:50:00 The failure to create a decoder could be because w
}
String ImageSource::filenameExtension() const

Powered by Google App Engine
This is Rietveld 408576698