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/HashMap.h" | 18 #include "wtf/HashMap.h" |
19 #include <memory> | 19 #include <memory> |
20 | 20 |
21 namespace blink { | 21 namespace blink { |
22 | 22 |
23 class FetchRequest; | 23 class FetchRequest; |
| 24 class ImageResource; |
24 class ImageResourceInfo; | 25 class ImageResourceInfo; |
25 class ImageResourceObserver; | 26 class ImageResourceObserver; |
26 class ResourceError; | 27 class ResourceError; |
27 class ResourceFetcher; | 28 class ResourceFetcher; |
28 class ResourceResponse; | 29 class ResourceResponse; |
29 class SecurityOrigin; | 30 class SecurityOrigin; |
30 | 31 |
31 // ImageResourceContent is the image-related part of image loading that | 32 // ImageResourceContent is the image-related part of image loading that |
32 // - Stores decoded data (blink::Image) of ImageResource, and | 33 // - Stores decoded data (blink::Image) of ImageResource, and |
33 // - Handles ImageResourceObserver. | 34 // - Handles ImageResourceObserver. |
(...skipping 66 matching lines...) Loading... |
100 | 101 |
101 void setNotRefetchableDataFromDiskCache() { | 102 void setNotRefetchableDataFromDiskCache() { |
102 m_isRefetchableDataFromDiskCache = false; | 103 m_isRefetchableDataFromDiskCache = false; |
103 } | 104 } |
104 | 105 |
105 // For ImageResource only. | 106 // For ImageResource only. |
106 void setImageResourceInfo(ImageResourceInfo*); | 107 void setImageResourceInfo(ImageResourceInfo*); |
107 enum ClearImageOption { ClearExistingImage, KeepExistingImage }; | 108 enum ClearImageOption { ClearExistingImage, KeepExistingImage }; |
108 void updateImage(PassRefPtr<SharedBuffer>, | 109 void updateImage(PassRefPtr<SharedBuffer>, |
109 ClearImageOption, | 110 ClearImageOption, |
110 bool allDataReceived); | 111 bool allDataReceived, |
| 112 ResourceFetcher* fetcherForReload); |
111 ResourcePriority priorityFromObservers() const; | 113 ResourcePriority priorityFromObservers() const; |
112 void destroyDecodedData(); | 114 void destroyDecodedData(); |
113 bool hasObservers() const { | 115 bool hasObservers() const { |
114 return !m_observers.isEmpty() || !m_finishedObservers.isEmpty(); | 116 return !m_observers.isEmpty() || !m_finishedObservers.isEmpty(); |
115 } | 117 } |
116 bool isSizeAvailable() const { | 118 bool isSizeAvailable() const { |
117 return m_sizeAvailable == Image::SizeAvailable; | 119 return m_sizeAvailable == Image::SizeAvailable; |
118 } | 120 } |
119 bool isRefetchableDataFromDiskCache() const { | 121 bool isRefetchableDataFromDiskCache() const { |
120 return m_isRefetchableDataFromDiskCache; | 122 return m_isRefetchableDataFromDiskCache; |
121 } | 123 } |
122 void doResetAnimation(); | 124 void doResetAnimation(); |
123 | 125 |
| 126 // Only for tests. |
| 127 ImageResource* resourceForTest() const; |
| 128 |
124 private: | 129 private: |
125 ImageResourceContent(PassRefPtr<blink::Image> = nullptr); | 130 ImageResourceContent(PassRefPtr<blink::Image> = nullptr); |
126 | 131 |
127 // ImageObserver | 132 // ImageObserver |
128 void decodedSizeChangedTo(const blink::Image*, size_t newSize) override; | 133 void decodedSizeChangedTo(const blink::Image*, size_t newSize) override; |
129 bool shouldPauseAnimation(const blink::Image*) override; | 134 bool shouldPauseAnimation(const blink::Image*) override; |
130 void animationAdvanced(const blink::Image*) override; | 135 void animationAdvanced(const blink::Image*) override; |
131 void changedInRect(const blink::Image*, const IntRect&) override; | 136 void changedInRect(const blink::Image*, const IntRect&) override; |
132 | 137 |
133 PassRefPtr<Image> createImage(); | 138 PassRefPtr<Image> createImage(); |
(...skipping 14 matching lines...) Loading... |
148 Image::SizeAvailability m_sizeAvailable = Image::SizeUnavailable; | 153 Image::SizeAvailability m_sizeAvailable = Image::SizeUnavailable; |
149 | 154 |
150 // Indicates if this resource's encoded image data can be purged and refetched | 155 // Indicates if this resource's encoded image data can be purged and refetched |
151 // from disk cache to save memory usage. See crbug/664437. | 156 // from disk cache to save memory usage. See crbug/664437. |
152 bool m_isRefetchableDataFromDiskCache; | 157 bool m_isRefetchableDataFromDiskCache; |
153 }; | 158 }; |
154 | 159 |
155 } // namespace blink | 160 } // namespace blink |
156 | 161 |
157 #endif | 162 #endif |
OLD | NEW |