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

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

Issue 2182023002: Bug fix: Fix wrong assumption in ImageResource when adding observer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address on hiroshige's review 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp » ('j') | 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 c08e465ee78fe5722792924a619f9acb8341854e..8e05180d257ca2d23b93c79dc02d7c8e7437bd6d 100644
--- a/third_party/WebKit/Source/core/fetch/ImageResource.cpp
+++ b/third_party/WebKit/Source/core/fetch/ImageResource.cpp
@@ -117,7 +117,7 @@ void ImageResource::markClientsAndObserversFinished()
void ImageResource::didAddClient(ResourceClient* client)
{
- DCHECK(!m_data || m_image);
+ DCHECK((m_multipartParser && isLoading()) || !m_data || m_image);
Resource::didAddClient(client);
}
@@ -130,7 +130,15 @@ void ImageResource::addObserver(ImageResourceObserver* observer)
if (isCacheValidator())
return;
- DCHECK(!m_data || m_image);
+ // When the response is not multipart, if |m_data| exists, |m_image| must
+ // be created. This is assured that |updateImage()| is called when
+ // |appendData()| is called.
+ //
+ // On the other hand, when the response is multipart, |updateImage()| is
+ // not called in |appendData()|, which means |m_image| might not be created
+ // even when |m_data| exists. This is intentional since creating a |m_image|
+ // on receiving data might destroy an existing image in a previous part.
+ DCHECK((m_multipartParser && isLoading()) || !m_data || m_image);
if (m_image && !m_image->isNull()) {
observer->imageChanged(this);
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/fetch/ImageResourceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698