Changeset 249498 in webkit
- Timestamp:
- Sep 4, 2019 2:11:04 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r249497 r249498 1 2019-09-04 Alex Christensen <achristensen@webkit.org> 2 3 Remove unused SPI that accesses MemoryCache directly 4 https://bugs.webkit.org/show_bug.cgi?id=201468 5 6 Reviewed by Tim Horton. 7 8 * loader/cache/MemoryCache.cpp: 9 (WebCore::dummyCachedImageClient): Deleted. 10 (WebCore::MemoryCache::addImageToCache): Deleted. 11 (WebCore::MemoryCache::removeImageFromCache): Deleted. 12 * loader/cache/MemoryCache.h: 13 1 14 2019-09-04 Zalan Bujtas <zalan@apple.com> 2 15 -
trunk/Source/WebCore/loader/cache/MemoryCache.cpp
r248846 r249498 203 203 // Live resource capacity is whatever is left over after calculating dead resource capacity. 204 204 return m_capacity - deadCapacity(); 205 }206 207 static CachedImageClient& dummyCachedImageClient()208 {209 static NeverDestroyed<CachedImageClient> client;210 return client;211 }212 213 bool MemoryCache::addImageToCache(NativeImagePtr&& image, const URL& url, const String& domainForCachePartition, const PAL::SessionID& sessionID, const CookieJar* cookieJar)214 {215 ASSERT(image);216 removeImageFromCache(url, domainForCachePartition); // Remove cache entry if it already exists.217 218 auto bitmapImage = BitmapImage::create(WTFMove(image), nullptr);219 auto cachedImage = makeUnique<CachedImage>(url, bitmapImage.ptr(), sessionID, cookieJar, domainForCachePartition);220 221 cachedImage->addClient(dummyCachedImageClient());222 cachedImage->setDecodedSize(bitmapImage->decodedSize());223 224 return add(*cachedImage.release());225 }226 227 void MemoryCache::removeImageFromCache(const URL& url, const String& domainForCachePartition)228 {229 auto* resources = sessionResourceMap(PAL::SessionID::defaultSessionID());230 if (!resources)231 return;232 233 auto key = std::make_pair(url, ResourceRequest::partitionName(domainForCachePartition));234 235 CachedResource* resource = resources->get(key);236 if (!resource)237 return;238 239 // A resource exists and is not a manually cached image, so just remove it.240 if (!is<CachedImage>(*resource) || !downcast<CachedImage>(*resource).isManuallyCached()) {241 remove(*resource);242 return;243 }244 245 // Removing the last client of a CachedImage turns the resource246 // into a dead resource which will eventually be evicted when247 // dead resources are pruned. That might be immediately since248 // removing the last client triggers a MemoryCache::prune, so the249 // resource may be deleted after this call.250 downcast<CachedImage>(*resource).removeClient(dummyCachedImageClient());251 205 } 252 206 -
trunk/Source/WebCore/loader/cache/MemoryCache.h
r240014 r249498 158 158 WEBCORE_EXPORT HashSet<RefPtr<SecurityOrigin>> originsWithCache(PAL::SessionID) const; 159 159 160 WEBCORE_EXPORT bool addImageToCache(NativeImagePtr&&, const URL&, const String& domainForCachePartition, const PAL::SessionID&, const CookieJar*);161 WEBCORE_EXPORT void removeImageFromCache(const URL&, const String& domainForCachePartition);162 163 160 // pruneDead*() - Flush decoded and encoded data from resources not referenced by Web pages. 164 161 // pruneLive*() - Flush decoded data from resources still referenced by Web pages. -
trunk/Source/WebKitLegacy/mac/ChangeLog
r249327 r249498 1 2019-09-04 Alex Christensen <achristensen@webkit.org> 2 3 Remove unused SPI that accesses MemoryCache directly 4 https://bugs.webkit.org/show_bug.cgi?id=201468 5 6 Reviewed by Tim Horton. 7 8 * Misc/WebCache.h: 9 * Misc/WebCache.mm: 10 (+[WebCache addImageToCache:forURL:]): Deleted. 11 (+[WebCache addImageToCache:forURL:forFrame:]): Deleted. 12 (+[WebCache removeImageFromCacheForURL:]): Deleted. 13 (+[WebCache removeImageFromCacheForURL:forFrame:]): Deleted. 14 1 15 2019-08-30 Keith Rollin <krollin@apple.com> 2 16 -
trunk/Source/WebKitLegacy/mac/Misc/WebCache.h
r186476 r249498 37 37 + (void)emptyInMemoryResources; 38 38 + (void)sizeOfDeadResources:(int *)resources; 39 // SPI to add a CGImageRef directly to the WebCore cache.40 + (bool)addImageToCache:(CGImageRef)image forURL:(NSURL *)url;41 + (bool)addImageToCache:(CGImageRef)image forURL:(NSURL *)url forFrame:(WebFrame *)frame;42 + (void)removeImageFromCacheForURL:(NSURL *)url;43 + (void)removeImageFromCacheForURL:(NSURL *)url forFrame:(WebFrame *)frame;44 39 + (CGImageRef)imageForURL:(NSURL *)url; 45 40 #endif -
trunk/Source/WebKitLegacy/mac/Misc/WebCache.mm
r240355 r249498 165 165 } 166 166 167 + (bool)addImageToCache:(CGImageRef)image forURL:(NSURL *)url168 {169 return [WebCache addImageToCache:image forURL:url forFrame:nil];170 }171 172 + (bool)addImageToCache:(CGImageRef)image forURL:(NSURL *)url forFrame:(WebFrame *)frame173 {174 if (!image || !url || ![[url absoluteString] length])175 return false;176 177 auto provider = adoptRef(*new DefaultStorageSessionProvider);178 return WebCore::MemoryCache::singleton().addImageToCache(RetainPtr<CGImageRef>(image), url, frame ? core(frame)->document()->domainForCachePartition() : emptyString(), PAL::SessionID::defaultSessionID(), WebCore::CookieJar::create(WTFMove(provider)).ptr());179 }180 181 + (void)removeImageFromCacheForURL:(NSURL *)url182 {183 [WebCache removeImageFromCacheForURL:url forFrame:nil];184 }185 186 + (void)removeImageFromCacheForURL:(NSURL *)url forFrame:(WebFrame *)frame187 {188 if (!url)189 return;190 191 return WebCore::MemoryCache::singleton().removeImageFromCache(url, frame ? core(frame)->document()->domainForCachePartition() : emptyString());192 }193 194 167 + (CGImageRef)imageForURL:(NSURL *)url 195 168 {
Note: See TracChangeset
for help on using the changeset viewer.