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

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

Issue 2587503002: Merge clearImage() and clearImageAndNotifyObservers() into updateImage() (Closed)
Patch Set: Rebase Created 4 years 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 "core/fetch/ResourceStatus.h" 9 #include "core/fetch/ResourceStatus.h"
10 #include "platform/geometry/IntRect.h" 10 #include "platform/geometry/IntRect.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 void emulateLoadStartedForInspector(ResourceFetcher*, 104 void emulateLoadStartedForInspector(ResourceFetcher*,
105 const KURL&, 105 const KURL&,
106 const AtomicString& initiatorName); 106 const AtomicString& initiatorName);
107 107
108 void setNotRefetchableDataFromDiskCache() { 108 void setNotRefetchableDataFromDiskCache() {
109 m_isRefetchableDataFromDiskCache = false; 109 m_isRefetchableDataFromDiskCache = false;
110 } 110 }
111 111
112 // For ImageResource only. 112 // For ImageResource only.
113 void setImageResourceInfo(ImageResourceInfo*); 113 void setImageResourceInfo(ImageResourceInfo*);
114 enum ClearImageOption { ClearExistingImage, KeepExistingImage }; 114 enum UpdateImageOption {
115 // Updates the image (including placeholder and decode error handling
116 // and notifying observers).
117 UpdateImage,
118
119 // Clears the image and then updates the image.
120 ClearAndUpdateImage,
121
122 // Clears the image and notifies observers only (without updating).
123 ClearImageOnly,
124 };
115 void updateImage(PassRefPtr<SharedBuffer>, 125 void updateImage(PassRefPtr<SharedBuffer>,
116 ClearImageOption, 126 UpdateImageOption,
117 bool allDataReceived); 127 bool allDataReceived);
118 enum NotifyFinishOption { ShouldNotifyFinish, DoNotNotifyFinish };
119 void clearImage();
120 void clearImageAndNotifyObservers(NotifyFinishOption);
121 ResourcePriority priorityFromObservers() const; 128 ResourcePriority priorityFromObservers() const;
122 void destroyDecodedData(); 129 void destroyDecodedData();
123 void doResetAnimation(); 130 void doResetAnimation();
124 PassRefPtr<const SharedBuffer> resourceBuffer() const; 131 PassRefPtr<const SharedBuffer> resourceBuffer() const;
125 bool shouldUpdateImageImmediately() const; 132 bool shouldUpdateImageImmediately() const;
126 bool hasObservers() const { 133 bool hasObservers() const {
127 return !m_observers.isEmpty() || !m_finishedObservers.isEmpty(); 134 return !m_observers.isEmpty() || !m_finishedObservers.isEmpty();
128 } 135 }
129 bool isRefetchableDataFromDiskCache() const { 136 bool isRefetchableDataFromDiskCache() const {
130 return m_isRefetchableDataFromDiskCache; 137 return m_isRefetchableDataFromDiskCache;
131 } 138 }
132 139
133 private: 140 private:
134 explicit ImageResourceContent(PassRefPtr<blink::Image> = nullptr); 141 explicit ImageResourceContent(PassRefPtr<blink::Image> = nullptr);
135 142
136 // ImageObserver 143 // ImageObserver
137 void decodedSizeChangedTo(const blink::Image*, size_t newSize) override; 144 void decodedSizeChangedTo(const blink::Image*, size_t newSize) override;
138 bool shouldPauseAnimation(const blink::Image*) override; 145 bool shouldPauseAnimation(const blink::Image*) override;
139 void animationAdvanced(const blink::Image*) override; 146 void animationAdvanced(const blink::Image*) override;
140 void changedInRect(const blink::Image*, const IntRect&) override; 147 void changedInRect(const blink::Image*, const IntRect&) override;
141 148
142 PassRefPtr<Image> createImage(); 149 PassRefPtr<Image> createImage();
150 void clearImage();
151
152 enum NotifyFinishOption { ShouldNotifyFinish, DoNotNotifyFinish };
143 153
144 // If not null, changeRect is the changed part of the image. 154 // If not null, changeRect is the changed part of the image.
145 void notifyObservers(NotifyFinishOption, const IntRect* changeRect = nullptr); 155 void notifyObservers(NotifyFinishOption, const IntRect* changeRect = nullptr);
146 void markObserverFinished(ImageResourceObserver*); 156 void markObserverFinished(ImageResourceObserver*);
147 157
148 Member<ImageResourceInfo> m_info; 158 Member<ImageResourceInfo> m_info;
149 159
150 RefPtr<blink::Image> m_image; 160 RefPtr<blink::Image> m_image;
151 161
152 HashCountedSet<ImageResourceObserver*> m_observers; 162 HashCountedSet<ImageResourceObserver*> m_observers;
153 HashCountedSet<ImageResourceObserver*> m_finishedObservers; 163 HashCountedSet<ImageResourceObserver*> m_finishedObservers;
154 164
155 Image::SizeAvailability m_sizeAvailable = Image::SizeUnavailable; 165 Image::SizeAvailability m_sizeAvailable = Image::SizeUnavailable;
156 166
157 // Indicates if this resource's encoded image data can be purged and refetched 167 // Indicates if this resource's encoded image data can be purged and refetched
158 // from disk cache to save memory usage. See crbug/664437. 168 // from disk cache to save memory usage. See crbug/664437.
159 bool m_isRefetchableDataFromDiskCache; 169 bool m_isRefetchableDataFromDiskCache;
160 }; 170 };
161 171
162 } // namespace blink 172 } // namespace blink
163 173
164 #endif 174 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698