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) 2006 Samuel Weinig (sam.weinig@gmail.com) | 4 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
5 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 5 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
6 | 6 |
7 This library is free software; you can redistribute it and/or | 7 This library is free software; you can redistribute it and/or |
8 modify it under the terms of the GNU Library General Public | 8 modify it under the terms of the GNU Library General Public |
9 License as published by the Free Software Foundation; either | 9 License as published by the Free Software Foundation; either |
10 version 2 of the License, or (at your option) any later version. | 10 version 2 of the License, or (at your option) any later version. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 ImageResourceContent* getContent() const; | 64 ImageResourceContent* getContent() const; |
65 | 65 |
66 enum class ReloadCachePolicy { | 66 enum class ReloadCachePolicy { |
67 UseExistingPolicy = 0, // Don't modify the request's cache policy. | 67 UseExistingPolicy = 0, // Don't modify the request's cache policy. |
68 BypassCache, // Modify the request so that the reload bypasses the cache. | 68 BypassCache, // Modify the request so that the reload bypasses the cache. |
69 }; | 69 }; |
70 | 70 |
71 // If this ImageResource has the Lo-Fi response headers or is a placeholder, | 71 // If this ImageResource has the Lo-Fi response headers or is a placeholder, |
72 // reload the full original image with the Lo-Fi state set to off and | 72 // reload the full original image with the Lo-Fi state set to off and |
73 // optionally bypassing the cache. | 73 // optionally bypassing the cache. |
74 void reloadIfLoFiOrPlaceholder( | 74 // Returns a new ImageResource that is used for reloading if reloading is |
| 75 // started, and the original ImageResourceContent is attached to the new |
| 76 // ImageResource. The original ImageResource shouldn't be used anymore. |
| 77 ImageResource* reloadIfLoFiOrPlaceholder( |
75 ResourceFetcher*, | 78 ResourceFetcher*, |
76 ReloadCachePolicy = ReloadCachePolicy::BypassCache); | 79 ReloadCachePolicy = ReloadCachePolicy::BypassCache); |
77 | 80 |
78 void didAddClient(ResourceClient*) override; | 81 void didAddClient(ResourceClient*) override; |
79 | 82 |
80 ResourcePriority priorityFromObservers() override; | 83 ResourcePriority priorityFromObservers() override; |
81 | 84 |
82 void allClientsAndObserversRemoved() override; | 85 void allClientsAndObserversRemoved() override; |
83 | 86 |
84 PassRefPtr<const SharedBuffer> resourceBuffer() const override; | 87 PassRefPtr<const SharedBuffer> resourceBuffer() const override; |
85 void appendData(const char*, size_t) override; | 88 void appendData(const char*, size_t) override; |
86 void error(const ResourceError&) override; | 89 void error(const ResourceError&, ResourceFetcher* fetcherForReload) override; |
87 void responseReceived(const ResourceResponse&, | 90 void responseReceived(const ResourceResponse&, |
88 std::unique_ptr<WebDataConsumerHandle>) override; | 91 std::unique_ptr<WebDataConsumerHandle>) override; |
89 void finish(double finishTime = 0.0) override; | 92 void finish(double finishTime = 0.0, |
| 93 ResourceFetcher* fetcherForReload = nullptr) override; |
90 | 94 |
91 // For compatibility, images keep loading even if there are HTTP errors. | 95 // For compatibility, images keep loading even if there are HTTP errors. |
92 bool shouldIgnoreHTTPStatusCodeErrors() const override { return true; } | 96 bool shouldIgnoreHTTPStatusCodeErrors() const override { return true; } |
93 | 97 |
94 bool isImage() const override { return true; } | 98 bool isImage() const override { return true; } |
95 | 99 |
96 // MultipartImageResourceParser::Client | 100 // MultipartImageResourceParser::Client |
97 void onePartInMultipartReceived(const ResourceResponse&) final; | 101 void onePartInMultipartReceived(const ResourceResponse&) final; |
98 void multipartDataReceived(const char*, size_t) final; | 102 void multipartDataReceived(const char*, size_t) final; |
99 | 103 |
(...skipping 23 matching lines...) Expand all Loading... |
123 | 127 |
124 ImageResource(const ResourceRequest&, | 128 ImageResource(const ResourceRequest&, |
125 const ResourceLoaderOptions&, | 129 const ResourceLoaderOptions&, |
126 ImageResourceContent*, | 130 ImageResourceContent*, |
127 bool isPlaceholder); | 131 bool isPlaceholder); |
128 | 132 |
129 bool hasClientsOrObservers() const override; | 133 bool hasClientsOrObservers() const override; |
130 | 134 |
131 void updateImageAndClearBuffer(); | 135 void updateImageAndClearBuffer(); |
132 | 136 |
133 void checkNotify() override; | |
134 | |
135 void destroyDecodedDataIfPossible() override; | 137 void destroyDecodedDataIfPossible() override; |
136 void destroyDecodedDataForFailedRevalidation() override; | 138 void destroyDecodedDataForFailedRevalidation() override; |
137 | 139 |
138 // When ClearImageOption is KeepExistingImage but this is the first | 140 // When ClearImageOption is KeepExistingImage but this is the first |
139 // updateImage() call, then ClearExistingImage is used instead to enforce | 141 // updateImage() call, then ClearExistingImage is used instead to enforce |
140 // new image creation. | 142 // new image creation. |
141 void updateImage(PassRefPtr<SharedBuffer>, | 143 void updateImage(PassRefPtr<SharedBuffer>, |
142 ImageResourceContent::ClearImageOption, | 144 ImageResourceContent::ClearImageOption, |
143 bool allDataReceived); | 145 bool allDataReceived, |
| 146 ResourceFetcher* fetcherForReload = nullptr); |
144 void flushImageIfNeeded(TimerBase*); | 147 void flushImageIfNeeded(TimerBase*); |
145 | 148 |
146 bool willPaintBrokenImage() const; | 149 bool willPaintBrokenImage() const; |
147 | 150 |
| 151 void detachContent(); |
| 152 |
148 Member<ImageResourceContent> m_content; | 153 Member<ImageResourceContent> m_content; |
149 | 154 |
150 // Indicates whether updateImage() is called for this resource, or for this | 155 // Indicates whether updateImage() is called for this resource, or for this |
151 // part (in case of multipart images), and is used for enforcing creation of | 156 // part (in case of multipart images), and is used for enforcing creation of |
152 // new blink::Image in ImageResourceContent for the first updateImage(). | 157 // new blink::Image in ImageResourceContent for the first updateImage(). |
153 bool m_isUpdateImageCalled = false; | 158 bool m_isUpdateImageCalled = false; |
154 | 159 |
155 float m_devicePixelRatioHeaderValue; | 160 float m_devicePixelRatioHeaderValue; |
156 | 161 |
157 Member<MultipartImageResourceParser> m_multipartParser; | 162 Member<MultipartImageResourceParser> m_multipartParser; |
158 MultipartParsingState m_multipartParsingState = | 163 MultipartParsingState m_multipartParsingState = |
159 MultipartParsingState::WaitingForFirstPart; | 164 MultipartParsingState::WaitingForFirstPart; |
160 bool m_hasDevicePixelRatioHeaderValue; | 165 bool m_hasDevicePixelRatioHeaderValue; |
161 | 166 |
162 // Indicates if the ImageResource is currently scheduling a reload, e.g. | |
163 // because reloadIfLoFi() was called. | |
164 bool m_isSchedulingReload; | |
165 | |
166 // Indicates if this ImageResource is either attempting to load a placeholder | 167 // Indicates if this ImageResource is either attempting to load a placeholder |
167 // image, or is a (possibly broken) placeholder image. | 168 // image, or is a (possibly broken) placeholder image. |
168 bool m_isPlaceholder; | 169 bool m_isPlaceholder; |
169 | 170 |
170 Timer<ImageResource> m_flushTimer; | 171 Timer<ImageResource> m_flushTimer; |
171 double m_lastFlushTime = 0.; | 172 double m_lastFlushTime = 0.; |
172 }; | 173 }; |
173 | 174 |
174 DEFINE_RESOURCE_TYPE_CASTS(Image); | 175 DEFINE_RESOURCE_TYPE_CASTS(Image); |
175 | 176 |
176 } // namespace blink | 177 } // namespace blink |
177 | 178 |
178 #endif | 179 #endif |
OLD | NEW |