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 "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "core/fetch/ResourceStatus.h" | 9 #include "core/fetch/ResourceStatus.h" |
10 #include "platform/geometry/IntRect.h" | 10 #include "platform/geometry/IntRect.h" |
11 #include "platform/geometry/IntSizeHash.h" | 11 #include "platform/geometry/IntSizeHash.h" |
12 #include "platform/geometry/LayoutSize.h" | 12 #include "platform/geometry/LayoutSize.h" |
13 #include "platform/graphics/Image.h" | 13 #include "platform/graphics/Image.h" |
14 #include "platform/graphics/ImageObserver.h" | 14 #include "platform/graphics/ImageObserver.h" |
15 #include "platform/graphics/ImageOrientation.h" | 15 #include "platform/graphics/ImageOrientation.h" |
16 #include "platform/network/ResourceLoadPriority.h" | 16 #include "platform/network/ResourceLoadPriority.h" |
17 #include "platform/weborigin/KURL.h" | 17 #include "platform/weborigin/KURL.h" |
18 #include "wtf/HashCountedSet.h" | 18 #include "wtf/HashCountedSet.h" |
19 #include "wtf/HashMap.h" | 19 #include "wtf/HashMap.h" |
20 #include <memory> | 20 #include <memory> |
21 | 21 |
22 namespace blink { | 22 namespace blink { |
23 | 23 |
24 class FetchRequest; | 24 class FetchRequest; |
25 class ImageResource; | |
25 class ImageResourceInfo; | 26 class ImageResourceInfo; |
26 class ImageResourceObserver; | 27 class ImageResourceObserver; |
27 class ResourceError; | 28 class ResourceError; |
28 class ResourceFetcher; | 29 class ResourceFetcher; |
29 class ResourceResponse; | 30 class ResourceResponse; |
30 class SecurityOrigin; | 31 class SecurityOrigin; |
31 | 32 |
32 // ImageResourceContent is a container that holds fetch result of | 33 // ImageResourceContent is a container that holds fetch result of |
33 // an ImageResource in a decoded form. | 34 // an ImageResource in a decoded form. |
34 // Classes that use the fetched images | 35 // Classes that use the fetched images |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 UpdateImage, | 118 UpdateImage, |
118 | 119 |
119 // Clears the image and then updates the image. | 120 // Clears the image and then updates the image. |
120 ClearAndUpdateImage, | 121 ClearAndUpdateImage, |
121 | 122 |
122 // Clears the image and notifies observers only (without updating). | 123 // Clears the image and notifies observers only (without updating). |
123 ClearImageOnly, | 124 ClearImageOnly, |
124 }; | 125 }; |
125 void updateImage(PassRefPtr<SharedBuffer>, | 126 void updateImage(PassRefPtr<SharedBuffer>, |
126 UpdateImageOption, | 127 UpdateImageOption, |
127 bool allDataReceived); | 128 bool allDataReceived, |
129 ResourceFetcher* fetcherForReload); | |
128 ResourcePriority priorityFromObservers() const; | 130 ResourcePriority priorityFromObservers() const; |
129 void destroyDecodedData(); | 131 void destroyDecodedData(); |
130 void doResetAnimation(); | 132 void doResetAnimation(); |
131 PassRefPtr<const SharedBuffer> resourceBuffer() const; | 133 PassRefPtr<const SharedBuffer> resourceBuffer() const; |
132 bool shouldUpdateImageImmediately() const; | 134 bool shouldUpdateImageImmediately() const; |
133 bool hasObservers() const { | 135 bool hasObservers() const { |
134 return !m_observers.isEmpty() || !m_finishedObservers.isEmpty(); | 136 return !m_observers.isEmpty() || !m_finishedObservers.isEmpty(); |
135 } | 137 } |
136 bool isRefetchableDataFromDiskCache() const { | 138 bool isRefetchableDataFromDiskCache() const { |
137 return m_isRefetchableDataFromDiskCache; | 139 return m_isRefetchableDataFromDiskCache; |
138 } | 140 } |
139 | 141 |
142 // Only for tests. | |
143 const ImageResource* resourceForTest() const; | |
Nate Chapin
2016/12/28 00:14:58
This is a pretty bad layering violation, right? Bu
hiroshige
2017/01/25 02:01:49
Yes, bad violation.
This is currently needed for t
| |
144 | |
140 private: | 145 private: |
141 explicit ImageResourceContent(PassRefPtr<blink::Image> = nullptr); | 146 explicit ImageResourceContent(PassRefPtr<blink::Image> = nullptr); |
142 | 147 |
143 // ImageObserver | 148 // ImageObserver |
144 void decodedSizeChangedTo(const blink::Image*, size_t newSize) override; | 149 void decodedSizeChangedTo(const blink::Image*, size_t newSize) override; |
145 bool shouldPauseAnimation(const blink::Image*) override; | 150 bool shouldPauseAnimation(const blink::Image*) override; |
146 void animationAdvanced(const blink::Image*) override; | 151 void animationAdvanced(const blink::Image*) override; |
147 void changedInRect(const blink::Image*, const IntRect&) override; | 152 void changedInRect(const blink::Image*, const IntRect&) override; |
148 | 153 |
149 PassRefPtr<Image> createImage(); | 154 PassRefPtr<Image> createImage(); |
(...skipping 15 matching lines...) Expand all Loading... | |
165 Image::SizeAvailability m_sizeAvailable = Image::SizeUnavailable; | 170 Image::SizeAvailability m_sizeAvailable = Image::SizeUnavailable; |
166 | 171 |
167 // Indicates if this resource's encoded image data can be purged and refetched | 172 // Indicates if this resource's encoded image data can be purged and refetched |
168 // from disk cache to save memory usage. See crbug/664437. | 173 // from disk cache to save memory usage. See crbug/664437. |
169 bool m_isRefetchableDataFromDiskCache; | 174 bool m_isRefetchableDataFromDiskCache; |
170 }; | 175 }; |
171 | 176 |
172 } // namespace blink | 177 } // namespace blink |
173 | 178 |
174 #endif | 179 #endif |
OLD | NEW |