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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 } | 74 } |
75 bool HasDevicePixelRatioHeaderValue() const override { | 75 bool HasDevicePixelRatioHeaderValue() const override { |
76 return resource_->has_device_pixel_ratio_header_value_; | 76 return resource_->has_device_pixel_ratio_header_value_; |
77 } | 77 } |
78 float DevicePixelRatioHeaderValue() const override { | 78 float DevicePixelRatioHeaderValue() const override { |
79 return resource_->device_pixel_ratio_header_value_; | 79 return resource_->device_pixel_ratio_header_value_; |
80 } | 80 } |
81 const ResourceResponse& GetResponse() const override { | 81 const ResourceResponse& GetResponse() const override { |
82 return resource_->GetResponse(); | 82 return resource_->GetResponse(); |
83 } | 83 } |
84 ResourceStatus GetStatus() const override { return resource_->GetStatus(); } | |
85 bool ShouldShowPlaceholder() const override { | 84 bool ShouldShowPlaceholder() const override { |
86 return resource_->ShouldShowPlaceholder(); | 85 return resource_->ShouldShowPlaceholder(); |
87 } | 86 } |
88 bool IsCacheValidator() const override { | 87 bool IsCacheValidator() const override { |
89 return resource_->IsCacheValidator(); | 88 return resource_->IsCacheValidator(); |
90 } | 89 } |
91 bool SchedulingReloadOrShouldReloadBrokenPlaceholder() const override { | 90 bool SchedulingReloadOrShouldReloadBrokenPlaceholder() const override { |
92 return resource_->is_scheduling_reload_ || | 91 return resource_->is_scheduling_reload_ || |
93 resource_->ShouldReloadBrokenPlaceholder(); | 92 resource_->ShouldReloadBrokenPlaceholder(); |
94 } | 93 } |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 if (!ErrorOccurred()) | 328 if (!ErrorOccurred()) |
330 SetStatus(ResourceStatus::kDecodeError); | 329 SetStatus(ResourceStatus::kDecodeError); |
331 | 330 |
332 // Finishes loading if needed, and notifies observers. | 331 // Finishes loading if needed, and notifies observers. |
333 if (!all_data_received && Loader()) { | 332 if (!all_data_received && Loader()) { |
334 // Observers are notified via ImageResource::finish(). | 333 // Observers are notified via ImageResource::finish(). |
335 // TODO(hiroshige): Do not call didFinishLoading() directly. | 334 // TODO(hiroshige): Do not call didFinishLoading() directly. |
336 Loader()->DidFinishLoading(MonotonicallyIncreasingTime(), size, size, size); | 335 Loader()->DidFinishLoading(MonotonicallyIncreasingTime(), size, size, size); |
337 } else { | 336 } else { |
338 auto result = GetContent()->UpdateImage( | 337 auto result = GetContent()->UpdateImage( |
339 nullptr, ImageResourceContent::kClearImageAndNotifyObservers, | 338 nullptr, GetStatus(), |
340 all_data_received); | 339 ImageResourceContent::kClearImageAndNotifyObservers, all_data_received); |
341 DCHECK_EQ(result, ImageResourceContent::UpdateImageResult::kNoDecodeError); | 340 DCHECK_EQ(result, ImageResourceContent::UpdateImageResult::kNoDecodeError); |
342 } | 341 } |
343 | 342 |
344 GetMemoryCache()->Remove(this); | 343 GetMemoryCache()->Remove(this); |
345 } | 344 } |
346 | 345 |
347 void ImageResource::UpdateImageAndClearBuffer() { | 346 void ImageResource::UpdateImageAndClearBuffer() { |
348 UpdateImage(Data(), ImageResourceContent::kClearAndUpdateImage, true); | 347 UpdateImage(Data(), ImageResourceContent::kClearAndUpdateImage, true); |
349 ClearData(); | 348 ClearData(); |
350 } | 349 } |
351 | 350 |
| 351 void ImageResource::NotifyStartLoad() { |
| 352 CHECK_EQ(GetStatus(), ResourceStatus::kPending); |
| 353 GetContent()->NotifyStartLoad(); |
| 354 } |
| 355 |
352 void ImageResource::Finish(double load_finish_time) { | 356 void ImageResource::Finish(double load_finish_time) { |
353 if (multipart_parser_) { | 357 if (multipart_parser_) { |
354 multipart_parser_->Finish(); | 358 multipart_parser_->Finish(); |
355 if (Data()) | 359 if (Data()) |
356 UpdateImageAndClearBuffer(); | 360 UpdateImageAndClearBuffer(); |
357 } else { | 361 } else { |
358 UpdateImage(Data(), ImageResourceContent::kUpdateImage, true); | 362 UpdateImage(Data(), ImageResourceContent::kUpdateImage, true); |
359 // As encoded image data can be created from m_image (see | 363 // As encoded image data can be created from m_image (see |
360 // ImageResource::resourceBuffer(), we don't have to keep m_data. Let's | 364 // ImageResource::resourceBuffer(), we don't have to keep m_data. Let's |
361 // clear this. As for the lifetimes of m_image and m_data, see this | 365 // clear this. As for the lifetimes of m_image and m_data, see this |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 } | 576 } |
573 | 577 |
574 ResourcePriority ImageResource::PriorityFromObservers() { | 578 ResourcePriority ImageResource::PriorityFromObservers() { |
575 return GetContent()->PriorityFromObservers(); | 579 return GetContent()->PriorityFromObservers(); |
576 } | 580 } |
577 | 581 |
578 void ImageResource::UpdateImage( | 582 void ImageResource::UpdateImage( |
579 PassRefPtr<SharedBuffer> shared_buffer, | 583 PassRefPtr<SharedBuffer> shared_buffer, |
580 ImageResourceContent::UpdateImageOption update_image_option, | 584 ImageResourceContent::UpdateImageOption update_image_option, |
581 bool all_data_received) { | 585 bool all_data_received) { |
582 auto result = GetContent()->UpdateImage( | 586 auto result = |
583 std::move(shared_buffer), update_image_option, all_data_received); | 587 GetContent()->UpdateImage(std::move(shared_buffer), GetStatus(), |
| 588 update_image_option, all_data_received); |
584 if (result == ImageResourceContent::UpdateImageResult::kShouldDecodeError) { | 589 if (result == ImageResourceContent::UpdateImageResult::kShouldDecodeError) { |
585 // In case of decode error, we call imageNotifyFinished() iff we don't | 590 // In case of decode error, we call imageNotifyFinished() iff we don't |
586 // initiate reloading: | 591 // initiate reloading: |
587 // [(a): when this is in the middle of loading, or (b): otherwise] | 592 // [(a): when this is in the middle of loading, or (b): otherwise] |
588 // 1. The updateImage() call above doesn't call notifyObservers(). | 593 // 1. The updateImage() call above doesn't call notifyObservers(). |
589 // 2. notifyObservers(ShouldNotifyFinish) is called | 594 // 2. notifyObservers(ShouldNotifyFinish) is called |
590 // (a) via updateImage() called in ImageResource::finish() | 595 // (a) via updateImage() called in ImageResource::finish() |
591 // called via didFinishLoading() called in decodeError(), or | 596 // called via didFinishLoading() called in decodeError(), or |
592 // (b) via updateImage() called in decodeError(). | 597 // (b) via updateImage() called in decodeError(). |
593 // imageNotifyFinished() is called here iff we will not initiate | 598 // imageNotifyFinished() is called here iff we will not initiate |
594 // reloading in Step 3 due to notifyObservers()'s | 599 // reloading in Step 3 due to notifyObservers()'s |
595 // schedulingReloadOrShouldReloadBrokenPlaceholder() check. | 600 // schedulingReloadOrShouldReloadBrokenPlaceholder() check. |
596 // 3. reloadIfLoFiOrPlaceholderImage() is called via ResourceFetcher | 601 // 3. reloadIfLoFiOrPlaceholderImage() is called via ResourceFetcher |
597 // (a) via didFinishLoading() called in decodeError(), or | 602 // (a) via didFinishLoading() called in decodeError(), or |
598 // (b) after returning ImageResource::updateImage(). | 603 // (b) after returning ImageResource::updateImage(). |
599 DecodeError(all_data_received); | 604 DecodeError(all_data_received); |
600 } | 605 } |
601 } | 606 } |
602 | 607 |
603 } // namespace blink | 608 } // namespace blink |
OLD | NEW |