Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ImageResourceContent_h | 5 #ifndef ImageResourceContent_h |
| 6 #define ImageResourceContent_h | 6 #define ImageResourceContent_h |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include "core/CoreExport.h" | 9 #include "core/CoreExport.h" |
| 10 #include "platform/geometry/IntRect.h" | 10 #include "platform/geometry/IntRect.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 | 86 |
| 87 void AddObserver(ImageResourceObserver*); | 87 void AddObserver(ImageResourceObserver*); |
| 88 void RemoveObserver(ImageResourceObserver*); | 88 void RemoveObserver(ImageResourceObserver*); |
| 89 | 89 |
| 90 bool IsSizeAvailable() const { | 90 bool IsSizeAvailable() const { |
| 91 return size_available_ == Image::kSizeAvailable; | 91 return size_available_ == Image::kSizeAvailable; |
| 92 } | 92 } |
| 93 | 93 |
| 94 DECLARE_TRACE(); | 94 DECLARE_TRACE(); |
| 95 | 95 |
| 96 // Content status and deriving predicates. | |
| 97 // Normal transitions: | |
| 98 // kNotStarted -> kPending -> kCached|kLoadError|kDecodeError. | |
| 99 // Additional transitions in multipart images: | |
| 100 // kCached -> kLoadError|kDecodeError. | |
| 101 // Transitions due to revalidation: | |
| 102 // kCached -> kPending. | |
| 103 // Transitions due to reload: | |
| 104 // kCached|kLoadError|kDecodeError -> kPending. | |
| 105 // | |
| 106 // ImageResourceContent::getContentStatus() can be different from | |
|
yhirano
2017/05/08 05:28:51
CamelCase
hiroshige
2017/05/08 17:08:14
Done.
| |
| 107 // ImageResource::getStatus(). Use ImageResourceContent::getContentStatus(). | |
|
kouhei (in TOK)
2017/05/08 05:36:22
I'd also add link to https://docs.google.com/docum
hiroshige
2017/05/08 17:08:14
Done.
| |
| 108 ResourceStatus GetContentStatus() const; | |
| 109 bool IsLoaded() const; | |
| 110 bool IsLoading() const; | |
| 111 bool ErrorOccurred() const; | |
| 112 bool LoadFailedOrCanceled() const; | |
| 113 | |
| 96 // Redirecting methods to Resource. | 114 // Redirecting methods to Resource. |
| 97 const KURL& Url() const; | 115 const KURL& Url() const; |
| 98 bool IsAccessAllowed(SecurityOrigin*); | 116 bool IsAccessAllowed(SecurityOrigin*); |
| 99 const ResourceResponse& GetResponse() const; | 117 const ResourceResponse& GetResponse() const; |
| 100 bool IsLoaded() const; | |
| 101 bool IsLoading() const; | |
| 102 bool ErrorOccurred() const; | |
| 103 bool LoadFailedOrCanceled() const; | |
| 104 ResourceStatus GetStatus() const; | |
| 105 const ResourceError& GetResourceError() const; | 118 const ResourceError& GetResourceError() const; |
| 106 | 119 |
| 107 // For FrameSerializer. | 120 // For FrameSerializer. |
| 108 bool HasCacheControlNoStoreHeader() const; | 121 bool HasCacheControlNoStoreHeader() const; |
| 109 | 122 |
| 110 void EmulateLoadStartedForInspector(ResourceFetcher*, | 123 void EmulateLoadStartedForInspector(ResourceFetcher*, |
| 111 const KURL&, | 124 const KURL&, |
| 112 const AtomicString& initiator_name); | 125 const AtomicString& initiator_name); |
| 113 | 126 |
| 114 void SetNotRefetchableDataFromDiskCache() { | 127 void SetNotRefetchableDataFromDiskCache() { |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 135 kClearImageAndNotifyObservers, | 148 kClearImageAndNotifyObservers, |
| 136 }; | 149 }; |
| 137 enum class UpdateImageResult { | 150 enum class UpdateImageResult { |
| 138 kNoDecodeError, | 151 kNoDecodeError, |
| 139 | 152 |
| 140 // Decode error occurred. Observers are not notified. | 153 // Decode error occurred. Observers are not notified. |
| 141 // Only occurs when UpdateImage or ClearAndUpdateImage is specified. | 154 // Only occurs when UpdateImage or ClearAndUpdateImage is specified. |
| 142 kShouldDecodeError, | 155 kShouldDecodeError, |
| 143 }; | 156 }; |
| 144 WARN_UNUSED_RESULT UpdateImageResult UpdateImage(PassRefPtr<SharedBuffer>, | 157 WARN_UNUSED_RESULT UpdateImageResult UpdateImage(PassRefPtr<SharedBuffer>, |
| 158 ResourceStatus, | |
| 145 UpdateImageOption, | 159 UpdateImageOption, |
| 146 bool all_data_received); | 160 bool all_data_received); |
| 147 | 161 |
| 162 void NotifyStartLoad(); | |
| 148 void DestroyDecodedData(); | 163 void DestroyDecodedData(); |
| 149 void DoResetAnimation(); | 164 void DoResetAnimation(); |
| 150 | 165 |
| 151 void SetImageResourceInfo(ImageResourceInfo*); | 166 void SetImageResourceInfo(ImageResourceInfo*); |
| 152 | 167 |
| 153 ResourcePriority PriorityFromObservers() const; | 168 ResourcePriority PriorityFromObservers() const; |
| 154 PassRefPtr<const SharedBuffer> ResourceBuffer() const; | 169 PassRefPtr<const SharedBuffer> ResourceBuffer() const; |
| 155 bool ShouldUpdateImageImmediately() const; | 170 bool ShouldUpdateImageImmediately() const; |
| 156 bool HasObservers() const { | 171 bool HasObservers() const { |
| 157 return !observers_.IsEmpty() || !finished_observers_.IsEmpty(); | 172 return !observers_.IsEmpty() || !finished_observers_.IsEmpty(); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 171 | 186 |
| 172 PassRefPtr<Image> CreateImage(); | 187 PassRefPtr<Image> CreateImage(); |
| 173 void ClearImage(); | 188 void ClearImage(); |
| 174 | 189 |
| 175 enum NotifyFinishOption { kShouldNotifyFinish, kDoNotNotifyFinish }; | 190 enum NotifyFinishOption { kShouldNotifyFinish, kDoNotNotifyFinish }; |
| 176 | 191 |
| 177 // If not null, changeRect is the changed part of the image. | 192 // If not null, changeRect is the changed part of the image. |
| 178 void NotifyObservers(NotifyFinishOption, | 193 void NotifyObservers(NotifyFinishOption, |
| 179 const IntRect* change_rect = nullptr); | 194 const IntRect* change_rect = nullptr); |
| 180 void MarkObserverFinished(ImageResourceObserver*); | 195 void MarkObserverFinished(ImageResourceObserver*); |
| 196 void UpdateToLoadedContentStatus(ResourceStatus); | |
| 181 | 197 |
| 182 class ProhibitAddRemoveObserverInScope : public AutoReset<bool> { | 198 class ProhibitAddRemoveObserverInScope : public AutoReset<bool> { |
| 183 public: | 199 public: |
| 184 ProhibitAddRemoveObserverInScope(const ImageResourceContent* content) | 200 ProhibitAddRemoveObserverInScope(const ImageResourceContent* content) |
| 185 : AutoReset(&content->is_add_remove_observer_prohibited_, true) {} | 201 : AutoReset(&content->is_add_remove_observer_prohibited_, true) {} |
| 186 }; | 202 }; |
| 187 | 203 |
| 188 Member<ImageResourceInfo> info_; | 204 Member<ImageResourceInfo> info_; |
| 205 ResourceStatus content_status_ = ResourceStatus::kNotStarted; | |
| 189 | 206 |
| 190 RefPtr<blink::Image> image_; | 207 RefPtr<blink::Image> image_; |
| 191 | 208 |
| 192 HashCountedSet<ImageResourceObserver*> observers_; | 209 HashCountedSet<ImageResourceObserver*> observers_; |
| 193 HashCountedSet<ImageResourceObserver*> finished_observers_; | 210 HashCountedSet<ImageResourceObserver*> finished_observers_; |
| 194 | 211 |
| 195 Image::SizeAvailability size_available_ = Image::kSizeUnavailable; | 212 Image::SizeAvailability size_available_ = Image::kSizeUnavailable; |
| 196 | 213 |
| 197 // Indicates if this resource's encoded image data can be purged and refetched | 214 // Indicates if this resource's encoded image data can be purged and refetched |
| 198 // from disk cache to save memory usage. See crbug/664437. | 215 // from disk cache to save memory usage. See crbug/664437. |
| 199 bool is_refetchable_data_from_disk_cache_; | 216 bool is_refetchable_data_from_disk_cache_; |
| 200 | 217 |
| 201 mutable bool is_add_remove_observer_prohibited_ = false; | 218 mutable bool is_add_remove_observer_prohibited_ = false; |
| 202 | 219 |
| 203 #if DCHECK_IS_ON() | 220 #if DCHECK_IS_ON() |
| 204 bool is_update_image_being_called_ = false; | 221 bool is_update_image_being_called_ = false; |
| 205 #endif | 222 #endif |
| 206 }; | 223 }; |
| 207 | 224 |
| 208 } // namespace blink | 225 } // namespace blink |
| 209 | 226 |
| 210 #endif | 227 #endif |
| OLD | NEW |