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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 static ImageResource* fetch(FetchRequest&, ResourceFetcher*); | 63 static ImageResource* fetch(FetchRequest&, ResourceFetcher*); |
64 | 64 |
65 // TODO(hiroshige): Make create() test-only by refactoring ImageDocument. | 65 // TODO(hiroshige): Make create() test-only by refactoring ImageDocument. |
66 static ImageResource* create(const ResourceRequest&); | 66 static ImageResource* create(const ResourceRequest&); |
67 | 67 |
68 ~ImageResource() override; | 68 ~ImageResource() override; |
69 | 69 |
70 ImageResourceContent* getContent(); | 70 ImageResourceContent* getContent(); |
71 const ImageResourceContent* getContent() const; | 71 const ImageResourceContent* getContent() const; |
72 | 72 |
73 void reloadIfLoFiOrPlaceholderImage(ResourceFetcher*, | 73 ImageResource* reloadIfLoFiOrPlaceholderImage( |
74 ReloadLoFiOrPlaceholderPolicy); | 74 ResourceFetcher*, |
| 75 ReloadLoFiOrPlaceholderPolicy) override; |
75 | 76 |
76 void didAddClient(ResourceClient*) override; | 77 void didAddClient(ResourceClient*) override; |
77 | 78 |
78 ResourcePriority priorityFromObservers() override; | 79 ResourcePriority priorityFromObservers() override; |
79 | 80 |
80 void allClientsAndObserversRemoved() override; | 81 void allClientsAndObserversRemoved() override; |
81 | 82 |
82 PassRefPtr<const SharedBuffer> resourceBuffer() const override; | 83 PassRefPtr<const SharedBuffer> resourceBuffer() const override; |
83 void appendData(const char*, size_t) override; | 84 void appendData(const char*, size_t) override; |
84 void error(const ResourceError&) override; | 85 void error(const ResourceError&, ResourceFetcher* fetcherForReload) override; |
85 void responseReceived(const ResourceResponse&, | 86 void responseReceived(const ResourceResponse&, |
86 std::unique_ptr<WebDataConsumerHandle>) override; | 87 std::unique_ptr<WebDataConsumerHandle>) override; |
87 void finish(double finishTime = 0.0) override; | 88 void finish(double finishTime = 0.0, |
| 89 ResourceFetcher* fetcherForReload = nullptr) override; |
88 | 90 |
89 // For compatibility, images keep loading even if there are HTTP errors. | 91 // For compatibility, images keep loading even if there are HTTP errors. |
90 bool shouldIgnoreHTTPStatusCodeErrors() const override { return true; } | 92 bool shouldIgnoreHTTPStatusCodeErrors() const override { return true; } |
91 | 93 |
92 bool isImage() const override { return true; } | 94 bool isImage() const override { return true; } |
93 | 95 |
94 // MultipartImageResourceParser::Client | 96 // MultipartImageResourceParser::Client |
95 void onePartInMultipartReceived(const ResourceResponse&) final; | 97 void onePartInMultipartReceived(const ResourceResponse&) final; |
96 void multipartDataReceived(const char*, size_t) final; | 98 void multipartDataReceived(const char*, size_t) final; |
97 | 99 |
(...skipping 20 matching lines...) Expand all Loading... |
118 // Only for ImageResourceInfoImpl. | 120 // Only for ImageResourceInfoImpl. |
119 void decodeError(bool allDataReceived); | 121 void decodeError(bool allDataReceived); |
120 bool isAccessAllowed( | 122 bool isAccessAllowed( |
121 SecurityOrigin*, | 123 SecurityOrigin*, |
122 ImageResourceInfo::DoesCurrentFrameHaveSingleSecurityOrigin) const; | 124 ImageResourceInfo::DoesCurrentFrameHaveSingleSecurityOrigin) const; |
123 | 125 |
124 bool hasClientsOrObservers() const override; | 126 bool hasClientsOrObservers() const override; |
125 | 127 |
126 void updateImageAndClearBuffer(); | 128 void updateImageAndClearBuffer(); |
127 | 129 |
128 void checkNotify() override; | |
129 | |
130 void destroyDecodedDataIfPossible() override; | 130 void destroyDecodedDataIfPossible() override; |
131 void destroyDecodedDataForFailedRevalidation() override; | 131 void destroyDecodedDataForFailedRevalidation() override; |
132 | 132 |
133 // When UpdateImageOption is UpdateImage but this is the first | 133 // When UpdateImageOption is UpdateImage but this is the first |
134 // updateImage() call, then ClearAndUpdateImage is used instead to enforce | 134 // updateImage() call, then ClearAndUpdateImage is used instead to enforce |
135 // new image creation. | 135 // new image creation. |
136 void updateImage(PassRefPtr<SharedBuffer>, | 136 void updateImage(PassRefPtr<SharedBuffer>, |
137 ImageResourceContent::UpdateImageOption, | 137 ImageResourceContent::UpdateImageOption, |
138 bool allDataReceived); | 138 bool allDataReceived, |
| 139 ResourceFetcher* fetcherForReload = nullptr); |
139 void flushImageIfNeeded(TimerBase*); | 140 void flushImageIfNeeded(TimerBase*); |
140 | 141 |
141 bool shouldReloadBrokenPlaceholder() const { | 142 bool shouldReloadBrokenPlaceholder() const { |
142 return m_isPlaceholder && willPaintBrokenImage(); | 143 return m_isPlaceholder && willPaintBrokenImage(); |
143 } | 144 } |
144 | 145 |
145 bool willPaintBrokenImage() const; | 146 bool willPaintBrokenImage() const; |
146 | 147 |
| 148 void detachContent(); |
| 149 |
147 Member<ImageResourceContent> m_content; | 150 Member<ImageResourceContent> m_content; |
148 | 151 |
149 // Indicates whether updateImage() is called for this resource, or for this | 152 // Indicates whether updateImage() is called for this resource, or for this |
150 // part (in case of multipart images), and is used for enforcing creation of | 153 // part (in case of multipart images), and is used for enforcing creation of |
151 // new blink::Image in ImageResourceContent for the first updateImage(). | 154 // new blink::Image in ImageResourceContent for the first updateImage(). |
152 bool m_isUpdateImageCalled = false; | 155 bool m_isUpdateImageCalled = false; |
153 | 156 |
154 // TODO(hiroshige): move |m_devicePixelRatioHeaderValue| and | 157 // TODO(hiroshige): move |m_devicePixelRatioHeaderValue| and |
155 // |m_hasDevicePixelRatioHeaderValue| to ImageResourceContent and update | 158 // |m_hasDevicePixelRatioHeaderValue| to ImageResourceContent and update |
156 // it via ImageResourceContent::updateImage(). | 159 // it via ImageResourceContent::updateImage(). |
157 float m_devicePixelRatioHeaderValue; | 160 float m_devicePixelRatioHeaderValue; |
158 | 161 |
159 Member<MultipartImageResourceParser> m_multipartParser; | 162 Member<MultipartImageResourceParser> m_multipartParser; |
160 MultipartParsingState m_multipartParsingState = | 163 MultipartParsingState m_multipartParsingState = |
161 MultipartParsingState::WaitingForFirstPart; | 164 MultipartParsingState::WaitingForFirstPart; |
162 bool m_hasDevicePixelRatioHeaderValue; | 165 bool m_hasDevicePixelRatioHeaderValue; |
163 | 166 |
164 // Indicates if the ImageResource is currently scheduling a reload, e.g. | |
165 // because reloadIfLoFi() was called. | |
166 bool m_isSchedulingReload; | |
167 | |
168 // Indicates if this ImageResource is either attempting to load a placeholder | 167 // Indicates if this ImageResource is either attempting to load a placeholder |
169 // image, or is a (possibly broken) placeholder image. | 168 // image, or is a (possibly broken) placeholder image. |
170 bool m_isPlaceholder; | 169 bool m_isPlaceholder; |
171 | 170 |
172 Timer<ImageResource> m_flushTimer; | 171 Timer<ImageResource> m_flushTimer; |
173 double m_lastFlushTime = 0.; | 172 double m_lastFlushTime = 0.; |
174 }; | 173 }; |
175 | 174 |
176 DEFINE_RESOURCE_TYPE_CASTS(Image); | 175 DEFINE_RESOURCE_TYPE_CASTS(Image); |
177 | 176 |
178 } // namespace blink | 177 } // namespace blink |
179 | 178 |
180 #endif | 179 #endif |
OLD | NEW |