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

Side by Side Diff: third_party/WebKit/Source/core/loader/resource/ImageResourceContent.h

Issue 2746343002: Phase III Step 1: Make ImageResourceContent manage its own ResourceStatus (Closed)
Patch Set: Rewind Created 3 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 // 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 "platform/geometry/IntRect.h" 9 #include "platform/geometry/IntRect.h"
10 #include "platform/geometry/IntSizeHash.h" 10 #include "platform/geometry/IntSizeHash.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 void addObserver(ImageResourceObserver*); 85 void addObserver(ImageResourceObserver*);
86 void removeObserver(ImageResourceObserver*); 86 void removeObserver(ImageResourceObserver*);
87 87
88 bool isSizeAvailable() const { 88 bool isSizeAvailable() const {
89 return m_sizeAvailable == Image::SizeAvailable; 89 return m_sizeAvailable == Image::SizeAvailable;
90 } 90 }
91 91
92 DECLARE_TRACE(); 92 DECLARE_TRACE();
93 93
94 // ResourceStatus and deriving predicates.
95 // ImageResourceContent::getStatus() can be different from
96 // ImageResource::getStatus(). Use ImageResourceContent::getStatus().
97 ResourceStatus getStatus() const;
98 bool isLoaded() const;
99 bool isLoading() const;
100 bool errorOccurred() const;
101 bool loadFailedOrCanceled() const;
102
94 // Redirecting methods to Resource. 103 // Redirecting methods to Resource.
95 const KURL& url() const; 104 const KURL& url() const;
96 bool isAccessAllowed(SecurityOrigin*); 105 bool isAccessAllowed(SecurityOrigin*);
97 const ResourceResponse& response() const; 106 const ResourceResponse& response() const;
98 bool isLoaded() const;
99 bool isLoading() const;
100 bool errorOccurred() const;
101 bool loadFailedOrCanceled() const;
102 ResourceStatus getStatus() const;
103 const ResourceError& resourceError() const; 107 const ResourceError& resourceError() const;
104 108
105 // For FrameSerializer. 109 // For FrameSerializer.
106 bool hasCacheControlNoStoreHeader() const; 110 bool hasCacheControlNoStoreHeader() const;
107 111
108 void emulateLoadStartedForInspector(ResourceFetcher*, 112 void emulateLoadStartedForInspector(ResourceFetcher*,
109 const KURL&, 113 const KURL&,
110 const AtomicString& initiatorName); 114 const AtomicString& initiatorName);
111 115
112 void setNotRefetchableDataFromDiskCache() { 116 void setNotRefetchableDataFromDiskCache() {
(...skipping 20 matching lines...) Expand all
133 ClearImageAndNotifyObservers, 137 ClearImageAndNotifyObservers,
134 }; 138 };
135 enum class UpdateImageResult { 139 enum class UpdateImageResult {
136 NoDecodeError, 140 NoDecodeError,
137 141
138 // Decode error occurred. Observers are not notified. 142 // Decode error occurred. Observers are not notified.
139 // Only occurs when UpdateImage or ClearAndUpdateImage is specified. 143 // Only occurs when UpdateImage or ClearAndUpdateImage is specified.
140 ShouldDecodeError, 144 ShouldDecodeError,
141 }; 145 };
142 WARN_UNUSED_RESULT UpdateImageResult updateImage(PassRefPtr<SharedBuffer>, 146 WARN_UNUSED_RESULT UpdateImageResult updateImage(PassRefPtr<SharedBuffer>,
147 ResourceStatus,
143 UpdateImageOption, 148 UpdateImageOption,
144 bool allDataReceived); 149 bool allDataReceived);
145 150
151 void notifyStartLoad();
146 void destroyDecodedData(); 152 void destroyDecodedData();
147 void doResetAnimation(); 153 void doResetAnimation();
148 154
149 void setImageResourceInfo(ImageResourceInfo*); 155 void setImageResourceInfo(ImageResourceInfo*);
150 156
151 ResourcePriority priorityFromObservers() const; 157 ResourcePriority priorityFromObservers() const;
152 PassRefPtr<const SharedBuffer> resourceBuffer() const; 158 PassRefPtr<const SharedBuffer> resourceBuffer() const;
153 bool shouldUpdateImageImmediately() const; 159 bool shouldUpdateImageImmediately() const;
154 bool hasObservers() const { 160 bool hasObservers() const {
155 return !m_observers.isEmpty() || !m_finishedObservers.isEmpty(); 161 return !m_observers.isEmpty() || !m_finishedObservers.isEmpty();
(...skipping 12 matching lines...) Expand all
168 void changedInRect(const blink::Image*, const IntRect&) override; 174 void changedInRect(const blink::Image*, const IntRect&) override;
169 175
170 PassRefPtr<Image> createImage(); 176 PassRefPtr<Image> createImage();
171 void clearImage(); 177 void clearImage();
172 178
173 enum NotifyFinishOption { ShouldNotifyFinish, DoNotNotifyFinish }; 179 enum NotifyFinishOption { ShouldNotifyFinish, DoNotNotifyFinish };
174 180
175 // If not null, changeRect is the changed part of the image. 181 // If not null, changeRect is the changed part of the image.
176 void notifyObservers(NotifyFinishOption, const IntRect* changeRect = nullptr); 182 void notifyObservers(NotifyFinishOption, const IntRect* changeRect = nullptr);
177 void markObserverFinished(ImageResourceObserver*); 183 void markObserverFinished(ImageResourceObserver*);
184 void updateStatus(ResourceStatus, NotifyFinishOption);
178 185
179 Member<ImageResourceInfo> m_info; 186 Member<ImageResourceInfo> m_info;
187 ResourceStatus m_status = ResourceStatus::NotStarted;
180 188
181 RefPtr<blink::Image> m_image; 189 RefPtr<blink::Image> m_image;
182 190
183 HashCountedSet<ImageResourceObserver*> m_observers; 191 HashCountedSet<ImageResourceObserver*> m_observers;
184 HashCountedSet<ImageResourceObserver*> m_finishedObservers; 192 HashCountedSet<ImageResourceObserver*> m_finishedObservers;
185 193
186 Image::SizeAvailability m_sizeAvailable = Image::SizeUnavailable; 194 Image::SizeAvailability m_sizeAvailable = Image::SizeUnavailable;
187 195
188 // Indicates if this resource's encoded image data can be purged and refetched 196 // Indicates if this resource's encoded image data can be purged and refetched
189 // from disk cache to save memory usage. See crbug/664437. 197 // from disk cache to save memory usage. See crbug/664437.
190 bool m_isRefetchableDataFromDiskCache; 198 bool m_isRefetchableDataFromDiskCache;
191 199
192 #if DCHECK_IS_ON() 200 #if DCHECK_IS_ON()
193 bool m_isUpdateImageBeingCalled = false; 201 bool m_isUpdateImageBeingCalled = false;
194 #endif 202 #endif
195 }; 203 };
196 204
197 } // namespace blink 205 } // namespace blink
198 206
199 #endif 207 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698