Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: third_party/WebKit/Source/core/fetch/ImageResource.h

Issue 1710733002: Move multipart resource handling to core/fetch (2/2) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@multipart-cleanup
Patch Set: rebase Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. 20 Boston, MA 02110-1301, USA.
21 */ 21 */
22 22
23 #ifndef ImageResource_h 23 #ifndef ImageResource_h
24 #define ImageResource_h 24 #define ImageResource_h
25 25
26 #include "core/CoreExport.h" 26 #include "core/CoreExport.h"
27 #include "core/fetch/MultipartImageResourceParser.h"
27 #include "core/fetch/Resource.h" 28 #include "core/fetch/Resource.h"
28 #include "platform/geometry/IntRect.h" 29 #include "platform/geometry/IntRect.h"
29 #include "platform/geometry/IntSizeHash.h" 30 #include "platform/geometry/IntSizeHash.h"
30 #include "platform/geometry/LayoutSize.h" 31 #include "platform/geometry/LayoutSize.h"
31 #include "platform/graphics/ImageObserver.h" 32 #include "platform/graphics/ImageObserver.h"
32 #include "platform/graphics/ImageOrientation.h" 33 #include "platform/graphics/ImageOrientation.h"
33 #include "wtf/HashMap.h" 34 #include "wtf/HashMap.h"
34 35
35 namespace blink { 36 namespace blink {
36 37
37 class ImageResourceClient; 38 class ImageResourceClient;
38 class FetchRequest; 39 class FetchRequest;
39 class ResourceFetcher; 40 class ResourceFetcher;
40 class FloatSize; 41 class FloatSize;
41 class Length; 42 class Length;
42 class MemoryCache; 43 class MemoryCache;
43 class SecurityOrigin; 44 class SecurityOrigin;
44 45
45 class CORE_EXPORT ImageResource final : public Resource, public ImageObserver { 46 class CORE_EXPORT ImageResource final : public Resource, public ImageObserver, p ublic MultipartImageResourceParser::Client {
46 friend class MemoryCache; 47 friend class MemoryCache;
47 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ImageResource); 48 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(ImageResource);
48 public: 49 public:
49 using ClientType = ImageResourceClient; 50 using ClientType = ImageResourceClient;
50 51
51 static PassRefPtrWillBeRawPtr<ImageResource> fetch(FetchRequest&, ResourceFe tcher*); 52 static PassRefPtrWillBeRawPtr<ImageResource> fetch(FetchRequest&, ResourceFe tcher*);
52 53
53 static PassRefPtrWillBeRawPtr<ImageResource> create(blink::Image* image) 54 static PassRefPtrWillBeRawPtr<ImageResource> create(blink::Image* image)
54 { 55 {
55 return adoptRefWillBeNoop(new ImageResource(image)); 56 return adoptRefWillBeNoop(new ImageResource(image));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 void reloadIfLoFi(ResourceFetcher*); 98 void reloadIfLoFi(ResourceFetcher*);
98 99
99 void didAddClient(ResourceClient*) override; 100 void didAddClient(ResourceClient*) override;
100 void didRemoveClient(ResourceClient*) override; 101 void didRemoveClient(ResourceClient*) override;
101 102
102 void allClientsRemoved() override; 103 void allClientsRemoved() override;
103 104
104 void appendData(const char*, size_t) override; 105 void appendData(const char*, size_t) override;
105 void error(Resource::Status) override; 106 void error(Resource::Status) override;
106 void responseReceived(const ResourceResponse&, PassOwnPtr<WebDataConsumerHan dle>) override; 107 void responseReceived(const ResourceResponse&, PassOwnPtr<WebDataConsumerHan dle>) override;
107 void finishOnePart() override; 108 void finish() override;
108 109
109 // For compatibility, images keep loading even if there are HTTP errors. 110 // For compatibility, images keep loading even if there are HTTP errors.
110 bool shouldIgnoreHTTPStatusCodeErrors() const override { return true; } 111 bool shouldIgnoreHTTPStatusCodeErrors() const override { return true; }
111 112
112 bool isImage() const override { return true; } 113 bool isImage() const override { return true; }
113 bool stillNeedsLoad() const override { return !errorOccurred() && getStatus( ) == Unknown && !isLoading(); } 114 bool stillNeedsLoad() const override { return !errorOccurred() && getStatus( ) == Unknown && !isLoading(); }
114 115
115 // ImageObserver 116 // ImageObserver
116 void decodedSizeChanged(const blink::Image*, int delta) override; 117 void decodedSizeChanged(const blink::Image*, int delta) override;
117 void didDraw(const blink::Image*) override; 118 void didDraw(const blink::Image*) override;
118 119
119 bool shouldPauseAnimation(const blink::Image*) override; 120 bool shouldPauseAnimation(const blink::Image*) override;
120 void animationAdvanced(const blink::Image*) override; 121 void animationAdvanced(const blink::Image*) override;
121 void changedInRect(const blink::Image*, const IntRect&) override; 122 void changedInRect(const blink::Image*, const IntRect&) override;
122 123
124 // MultipartImageResourceParser::Client
125 void onePartInMultipartReceived(const ResourceResponse&, bool isFirstPart) f inal;
126 void multipartDataReceived(const char*, size_t) final;
127
123 DECLARE_VIRTUAL_TRACE(); 128 DECLARE_VIRTUAL_TRACE();
124 129
125 protected: 130 protected:
126 bool isSafeToUnlock() const override; 131 bool isSafeToUnlock() const override;
127 void destroyDecodedDataIfPossible() override; 132 void destroyDecodedDataIfPossible() override;
128 void destroyDecodedDataForFailedRevalidation() override; 133 void destroyDecodedDataForFailedRevalidation() override;
129 134
130 private: 135 private:
131 explicit ImageResource(blink::Image*); 136 explicit ImageResource(blink::Image*);
132 ImageResource(const ResourceRequest&, blink::Image*); 137 ImageResource(const ResourceRequest&, blink::Image*);
(...skipping 11 matching lines...) Expand all
144 ImageResource(const ResourceRequest&); 149 ImageResource(const ResourceRequest&);
145 150
146 void clear(); 151 void clear();
147 152
148 void setCustomAcceptHeader(); 153 void setCustomAcceptHeader();
149 void createImage(); 154 void createImage();
150 void updateImage(bool allDataReceived); 155 void updateImage(bool allDataReceived);
151 void clearImage(); 156 void clearImage();
152 // If not null, changeRect is the changed part of the image. 157 // If not null, changeRect is the changed part of the image.
153 void notifyObservers(const IntRect* changeRect = nullptr); 158 void notifyObservers(const IntRect* changeRect = nullptr);
154 bool loadingMultipartContent() const;
155 159
156 float m_devicePixelRatioHeaderValue; 160 float m_devicePixelRatioHeaderValue;
157 161
162 PersistentWillBeMember<MultipartImageResourceParser> m_multipartParser;
158 RefPtr<blink::Image> m_image; 163 RefPtr<blink::Image> m_image;
159 bool m_hasDevicePixelRatioHeaderValue; 164 bool m_hasDevicePixelRatioHeaderValue;
160 }; 165 };
161 166
162 DEFINE_RESOURCE_TYPE_CASTS(Image); 167 DEFINE_RESOURCE_TYPE_CASTS(Image);
163 168
164 } // namespace blink 169 } // namespace blink
165 170
166 #endif 171 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698