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

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

Issue 2257513002: Refactor ImageDecoder factories (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 4 years, 4 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 50d5fe282aa1de2d9e0bc7ae06ff4a6533ce53af..af677889fd789baf92d0d7bef58f28ab5f52c2ed 100644
--- a/third_party/WebKit/Source/platform/graphics/ImageSource.cpp
+++ b/third_party/WebKit/Source/platform/graphics/ImageSource.cpp
@@ -51,16 +51,21 @@ PassRefPtr<SharedBuffer> ImageSource::data()
return m_decoder ? m_decoder->data() : nullptr;
}
-ImageDecoder::SniffResult ImageSource::setData(SharedBuffer& data, bool allDataReceived)
+bool ImageSource::setData(PassRefPtr<SharedBuffer> passData, bool allDataReceived)
{
- ImageDecoder::SniffResult result = ImageDecoder::determineImageType(data);
- if (!m_decoder)
- m_decoder = DeferredImageDecoder::create(result, ImageDecoder::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileApplied);
+ RefPtr<SharedBuffer> data = passData;
+
+ if (m_decoder) {
+ m_decoder->setData(data.release(), allDataReceived);
+ // If the decoder is pre-instantiated, it means we've already validated the data/signature
+ // at some point.
+ return true;
+ }
- if (m_decoder)
- m_decoder->setData(data, allDataReceived);
+ m_decoder = DeferredImageDecoder::create(data, allDataReceived, ImageDecoder::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileApplied);
- return result;
+ // Insufficient data is not a failure.
+ return m_decoder || !ImageDecoder::hasSufficientDataToSniffImageType(*data);
}
String ImageSource::filenameExtension() const

Powered by Google App Engine
This is Rietveld 408576698