| OLD | NEW |
| 1 /* | 1 /* |
| 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
| 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) | 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) |
| 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) | 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
| 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 6 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 6 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
| 7 | 7 |
| 8 This library is free software; you can redistribute it and/or | 8 This library is free software; you can redistribute it and/or |
| 9 modify it under the terms of the GNU Library General Public | 9 modify it under the terms of the GNU Library General Public |
| 10 License as published by the Free Software Foundation; either | 10 License as published by the Free Software Foundation; either |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 return m_resource->isAccessAllowed(securityOrigin, | 92 return m_resource->isAccessAllowed(securityOrigin, |
| 93 doesCurrentFrameHasSingleSecurityOrigin); | 93 doesCurrentFrameHasSingleSecurityOrigin); |
| 94 } | 94 } |
| 95 bool hasCacheControlNoStoreHeader() const override { | 95 bool hasCacheControlNoStoreHeader() const override { |
| 96 return m_resource->hasCacheControlNoStoreHeader(); | 96 return m_resource->hasCacheControlNoStoreHeader(); |
| 97 } | 97 } |
| 98 const ResourceError& resourceError() const override { | 98 const ResourceError& resourceError() const override { |
| 99 return m_resource->resourceError(); | 99 return m_resource->resourceError(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void decodeError(bool allDataReceived) override { | |
| 103 m_resource->decodeError(allDataReceived); | |
| 104 } | |
| 105 void setIsPlaceholder(bool isPlaceholder) override { | 102 void setIsPlaceholder(bool isPlaceholder) override { |
| 106 m_resource->m_isPlaceholder = isPlaceholder; | 103 m_resource->m_isPlaceholder = isPlaceholder; |
| 107 } | 104 } |
| 108 void setDecodedSize(size_t size) override { | 105 void setDecodedSize(size_t size) override { |
| 109 m_resource->setDecodedSize(size); | 106 m_resource->setDecodedSize(size); |
| 110 } | 107 } |
| 111 void willAddClientOrObserver() override { | 108 void willAddClientOrObserver() override { |
| 112 m_resource->willAddClientOrObserver(Resource::MarkAsReferenced); | 109 m_resource->willAddClientOrObserver(Resource::MarkAsReferenced); |
| 113 } | 110 } |
| 114 void didRemoveClientOrObserver() override { | 111 void didRemoveClientOrObserver() override { |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 } | 324 } |
| 328 | 325 |
| 329 void ImageResource::decodeError(bool allDataReceived) { | 326 void ImageResource::decodeError(bool allDataReceived) { |
| 330 size_t size = encodedSize(); | 327 size_t size = encodedSize(); |
| 331 | 328 |
| 332 clearData(); | 329 clearData(); |
| 333 setEncodedSize(0); | 330 setEncodedSize(0); |
| 334 if (!errorOccurred()) | 331 if (!errorOccurred()) |
| 335 setStatus(ResourceStatus::DecodeError); | 332 setStatus(ResourceStatus::DecodeError); |
| 336 | 333 |
| 334 // Finishes loading if needed, and notifies observers. |
| 337 if (!allDataReceived && loader()) { | 335 if (!allDataReceived && loader()) { |
| 336 // Observers are notified via ImageResource::finish(). |
| 338 // TODO(hiroshige): Do not call didFinishLoading() directly. | 337 // TODO(hiroshige): Do not call didFinishLoading() directly. |
| 339 loader()->didFinishLoading(monotonicallyIncreasingTime(), size, size); | 338 loader()->didFinishLoading(monotonicallyIncreasingTime(), size, size); |
| 339 } else { |
| 340 auto result = getContent()->updateImage( |
| 341 nullptr, ImageResourceContent::ClearImageAndNotifyObservers, |
| 342 allDataReceived); |
| 343 DCHECK_EQ(result, ImageResourceContent::UpdateImageResult::NoDecodeError); |
| 340 } | 344 } |
| 341 | 345 |
| 342 memoryCache()->remove(this); | 346 memoryCache()->remove(this); |
| 343 } | 347 } |
| 344 | 348 |
| 345 void ImageResource::updateImageAndClearBuffer() { | 349 void ImageResource::updateImageAndClearBuffer() { |
| 346 updateImage(data(), ImageResourceContent::ClearAndUpdateImage, true); | 350 updateImage(data(), ImageResourceContent::ClearAndUpdateImage, true); |
| 347 clearData(); | 351 clearData(); |
| 348 } | 352 } |
| 349 | 353 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 } | 516 } |
| 513 | 517 |
| 514 ResourcePriority ImageResource::priorityFromObservers() { | 518 ResourcePriority ImageResource::priorityFromObservers() { |
| 515 return getContent()->priorityFromObservers(); | 519 return getContent()->priorityFromObservers(); |
| 516 } | 520 } |
| 517 | 521 |
| 518 void ImageResource::updateImage( | 522 void ImageResource::updateImage( |
| 519 PassRefPtr<SharedBuffer> sharedBuffer, | 523 PassRefPtr<SharedBuffer> sharedBuffer, |
| 520 ImageResourceContent::UpdateImageOption updateImageOption, | 524 ImageResourceContent::UpdateImageOption updateImageOption, |
| 521 bool allDataReceived) { | 525 bool allDataReceived) { |
| 522 getContent()->updateImage(std::move(sharedBuffer), updateImageOption, | 526 auto result = getContent()->updateImage(std::move(sharedBuffer), |
| 523 allDataReceived); | 527 updateImageOption, allDataReceived); |
| 528 if (result == ImageResourceContent::UpdateImageResult::ShouldDecodeError) { |
| 529 // In case of decode error, we call imageNotifyFinished() iff we don't |
| 530 // initiate reloading: |
| 531 // [(a): when this is in the middle of loading, or (b): otherwise] |
| 532 // 1. The updateImage() call above doesn't call notifyObservers(). |
| 533 // 2. notifyObservers(ShouldNotifyFinish) is called |
| 534 // (a) via updateImage() called in ImageResource::finish() |
| 535 // called via didFinishLoading() called in decodeError(), or |
| 536 // (b) via updateImage() called in decodeError(). |
| 537 // imageNotifyFinished() is called here iff we will not initiate |
| 538 // reloading in Step 3 due to notifyObservers()'s |
| 539 // schedulingReloadOrShouldReloadBrokenPlaceholder() check. |
| 540 // 3. reloadIfLoFiOrPlaceholderImage() is called via ResourceFetcher |
| 541 // (a) via didFinishLoading() called in decodeError(), or |
| 542 // (b) after returning ImageResource::updateImage(). |
| 543 decodeError(allDataReceived); |
| 544 } |
| 524 } | 545 } |
| 525 | 546 |
| 526 } // namespace blink | 547 } // namespace blink |
| OLD | NEW |