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

Unified Diff: third_party/WebKit/Source/core/loader/resource/ImageResource.cpp

Issue 2642823005: Phase II Step 1: Remove updateImage() reentrancy around decodeError() (Closed)
Patch Set: Rebase Created 3 years, 10 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/loader/resource/ImageResourceContent.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/loader/resource/ImageResource.cpp
diff --git a/third_party/WebKit/Source/core/loader/resource/ImageResource.cpp b/third_party/WebKit/Source/core/loader/resource/ImageResource.cpp
index 468011deb7ae629f2f155048b3d4854167c1ed1d..8e51801e45a6450109f1e143fa3274b004f32be1 100644
--- a/third_party/WebKit/Source/core/loader/resource/ImageResource.cpp
+++ b/third_party/WebKit/Source/core/loader/resource/ImageResource.cpp
@@ -99,9 +99,6 @@ class ImageResource::ImageResourceInfoImpl final
return m_resource->resourceError();
}
- void decodeError(bool allDataReceived) override {
- m_resource->decodeError(allDataReceived);
- }
void setIsPlaceholder(bool isPlaceholder) override {
m_resource->m_isPlaceholder = isPlaceholder;
}
@@ -334,9 +331,16 @@ void ImageResource::decodeError(bool allDataReceived) {
if (!errorOccurred())
setStatus(ResourceStatus::DecodeError);
+ // Finishes loading if needed, and notifies observers.
if (!allDataReceived && loader()) {
+ // Observers are notified via ImageResource::finish().
// TODO(hiroshige): Do not call didFinishLoading() directly.
loader()->didFinishLoading(monotonicallyIncreasingTime(), size, size);
+ } else {
+ auto result = getContent()->updateImage(
+ nullptr, ImageResourceContent::ClearImageAndNotifyObservers,
+ allDataReceived);
+ DCHECK_EQ(result, ImageResourceContent::UpdateImageResult::NoDecodeError);
}
memoryCache()->remove(this);
@@ -519,8 +523,25 @@ void ImageResource::updateImage(
PassRefPtr<SharedBuffer> sharedBuffer,
ImageResourceContent::UpdateImageOption updateImageOption,
bool allDataReceived) {
- getContent()->updateImage(std::move(sharedBuffer), updateImageOption,
- allDataReceived);
+ auto result = getContent()->updateImage(std::move(sharedBuffer),
+ updateImageOption, allDataReceived);
+ if (result == ImageResourceContent::UpdateImageResult::ShouldDecodeError) {
+ // In case of decode error, we call imageNotifyFinished() iff we don't
+ // initiate reloading:
+ // [(a): when this is in the middle of loading, or (b): otherwise]
+ // 1. The updateImage() call above doesn't call notifyObservers().
+ // 2. notifyObservers(ShouldNotifyFinish) is called
+ // (a) via updateImage() called in ImageResource::finish()
+ // called via didFinishLoading() called in decodeError(), or
+ // (b) via updateImage() called in decodeError().
+ // imageNotifyFinished() is called here iff we will not initiate
+ // reloading in Step 3 due to notifyObservers()'s
+ // schedulingReloadOrShouldReloadBrokenPlaceholder() check.
+ // 3. reloadIfLoFiOrPlaceholderImage() is called via ResourceFetcher
+ // (a) via didFinishLoading() called in decodeError(), or
+ // (b) after returning ImageResource::updateImage().
+ decodeError(allDataReceived);
+ }
}
} // namespace blink
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/loader/resource/ImageResourceContent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698