| 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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 } | 335 } |
| 336 | 336 |
| 337 void ImageResource::DecodeError(bool all_data_received) { | 337 void ImageResource::DecodeError(bool all_data_received) { |
| 338 size_t size = EncodedSize(); | 338 size_t size = EncodedSize(); |
| 339 | 339 |
| 340 ClearData(); | 340 ClearData(); |
| 341 SetEncodedSize(0); | 341 SetEncodedSize(0); |
| 342 if (!ErrorOccurred()) | 342 if (!ErrorOccurred()) |
| 343 SetStatus(ResourceStatus::kDecodeError); | 343 SetStatus(ResourceStatus::kDecodeError); |
| 344 | 344 |
| 345 bool is_multipart = !!multipart_parser_; |
| 345 // Finishes loading if needed, and notifies observers. | 346 // Finishes loading if needed, and notifies observers. |
| 346 if (!all_data_received && Loader()) { | 347 if (!all_data_received && Loader()) { |
| 347 // Observers are notified via ImageResource::finish(). | 348 // Observers are notified via ImageResource::finish(). |
| 348 // TODO(hiroshige): Do not call didFinishLoading() directly. | 349 // TODO(hiroshige): Do not call didFinishLoading() directly. |
| 349 Loader()->DidFinishLoading(MonotonicallyIncreasingTime(), size, size, size); | 350 Loader()->DidFinishLoading(MonotonicallyIncreasingTime(), size, size, size); |
| 350 } else { | 351 } else { |
| 351 auto result = GetContent()->UpdateImage( | 352 auto result = GetContent()->UpdateImage( |
| 352 nullptr, GetStatus(), | 353 nullptr, GetStatus(), |
| 353 ImageResourceContent::kClearImageAndNotifyObservers, all_data_received); | 354 ImageResourceContent::kClearImageAndNotifyObservers, all_data_received, |
| 355 is_multipart); |
| 354 DCHECK_EQ(result, ImageResourceContent::UpdateImageResult::kNoDecodeError); | 356 DCHECK_EQ(result, ImageResourceContent::UpdateImageResult::kNoDecodeError); |
| 355 } | 357 } |
| 356 | 358 |
| 357 GetMemoryCache()->Remove(this); | 359 GetMemoryCache()->Remove(this); |
| 358 } | 360 } |
| 359 | 361 |
| 360 void ImageResource::UpdateImageAndClearBuffer() { | 362 void ImageResource::UpdateImageAndClearBuffer() { |
| 361 UpdateImage(Data(), ImageResourceContent::kClearAndUpdateImage, true); | 363 UpdateImage(Data(), ImageResourceContent::kClearAndUpdateImage, true); |
| 362 ClearData(); | 364 ClearData(); |
| 363 } | 365 } |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 } | 605 } |
| 604 | 606 |
| 605 ResourcePriority ImageResource::PriorityFromObservers() { | 607 ResourcePriority ImageResource::PriorityFromObservers() { |
| 606 return GetContent()->PriorityFromObservers(); | 608 return GetContent()->PriorityFromObservers(); |
| 607 } | 609 } |
| 608 | 610 |
| 609 void ImageResource::UpdateImage( | 611 void ImageResource::UpdateImage( |
| 610 PassRefPtr<SharedBuffer> shared_buffer, | 612 PassRefPtr<SharedBuffer> shared_buffer, |
| 611 ImageResourceContent::UpdateImageOption update_image_option, | 613 ImageResourceContent::UpdateImageOption update_image_option, |
| 612 bool all_data_received) { | 614 bool all_data_received) { |
| 613 auto result = | 615 bool is_multipart = !!multipart_parser_; |
| 614 GetContent()->UpdateImage(std::move(shared_buffer), GetStatus(), | 616 auto result = GetContent()->UpdateImage(std::move(shared_buffer), GetStatus(), |
| 615 update_image_option, all_data_received); | 617 update_image_option, |
| 618 all_data_received, is_multipart); |
| 616 if (result == ImageResourceContent::UpdateImageResult::kShouldDecodeError) { | 619 if (result == ImageResourceContent::UpdateImageResult::kShouldDecodeError) { |
| 617 // In case of decode error, we call imageNotifyFinished() iff we don't | 620 // In case of decode error, we call imageNotifyFinished() iff we don't |
| 618 // initiate reloading: | 621 // initiate reloading: |
| 619 // [(a): when this is in the middle of loading, or (b): otherwise] | 622 // [(a): when this is in the middle of loading, or (b): otherwise] |
| 620 // 1. The updateImage() call above doesn't call notifyObservers(). | 623 // 1. The updateImage() call above doesn't call notifyObservers(). |
| 621 // 2. notifyObservers(ShouldNotifyFinish) is called | 624 // 2. notifyObservers(ShouldNotifyFinish) is called |
| 622 // (a) via updateImage() called in ImageResource::finish() | 625 // (a) via updateImage() called in ImageResource::finish() |
| 623 // called via didFinishLoading() called in decodeError(), or | 626 // called via didFinishLoading() called in decodeError(), or |
| 624 // (b) via updateImage() called in decodeError(). | 627 // (b) via updateImage() called in decodeError(). |
| 625 // imageNotifyFinished() is called here iff we will not initiate | 628 // imageNotifyFinished() is called here iff we will not initiate |
| 626 // reloading in Step 3 due to notifyObservers()'s | 629 // reloading in Step 3 due to notifyObservers()'s |
| 627 // schedulingReloadOrShouldReloadBrokenPlaceholder() check. | 630 // schedulingReloadOrShouldReloadBrokenPlaceholder() check. |
| 628 // 3. reloadIfLoFiOrPlaceholderImage() is called via ResourceFetcher | 631 // 3. reloadIfLoFiOrPlaceholderImage() is called via ResourceFetcher |
| 629 // (a) via didFinishLoading() called in decodeError(), or | 632 // (a) via didFinishLoading() called in decodeError(), or |
| 630 // (b) after returning ImageResource::updateImage(). | 633 // (b) after returning ImageResource::updateImage(). |
| 631 DecodeError(all_data_received); | 634 DecodeError(all_data_received); |
| 632 } | 635 } |
| 633 } | 636 } |
| 634 | 637 |
| 635 } // namespace blink | 638 } // namespace blink |
| OLD | NEW |