Changeset 249498 in webkit


Ignore:
Timestamp:
Sep 4, 2019 2:11:04 PM (5 years ago)
Author:
achristensen@apple.com
Message:

Remove unused SPI that accesses MemoryCache directly
https://bugs.webkit.org/show_bug.cgi?id=201468

Reviewed by Tim Horton.

Source/WebCore:

  • loader/cache/MemoryCache.cpp:

(WebCore::dummyCachedImageClient): Deleted.
(WebCore::MemoryCache::addImageToCache): Deleted.
(WebCore::MemoryCache::removeImageFromCache): Deleted.

  • loader/cache/MemoryCache.h:

Source/WebKitLegacy/mac:

  • Misc/WebCache.h:
  • Misc/WebCache.mm:

(+[WebCache addImageToCache:forURL:]): Deleted.
(+[WebCache addImageToCache:forURL:forFrame:]): Deleted.
(+[WebCache removeImageFromCacheForURL:]): Deleted.
(+[WebCache removeImageFromCacheForURL:forFrame:]): Deleted.

Location:
trunk/Source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r249497 r249498  
     12019-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
    1142019-09-04  Zalan Bujtas  <zalan@apple.com>
    215
  • trunk/Source/WebCore/loader/cache/MemoryCache.cpp

    r248846 r249498  
    203203    // Live resource capacity is whatever is left over after calculating dead resource capacity.
    204204    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 resource
    246     // into a dead resource which will eventually be evicted when
    247     // dead resources are pruned. That might be immediately since
    248     // removing the last client triggers a MemoryCache::prune, so the
    249     // resource may be deleted after this call.
    250     downcast<CachedImage>(*resource).removeClient(dummyCachedImageClient());
    251205}
    252206
  • trunk/Source/WebCore/loader/cache/MemoryCache.h

    r240014 r249498  
    158158    WEBCORE_EXPORT HashSet<RefPtr<SecurityOrigin>> originsWithCache(PAL::SessionID) const;
    159159
    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 
    163160    // pruneDead*() - Flush decoded and encoded data from resources not referenced by Web pages.
    164161    // pruneLive*() - Flush decoded data from resources still referenced by Web pages.
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r249327 r249498  
     12019-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
    1152019-08-30  Keith Rollin  <krollin@apple.com>
    216
  • trunk/Source/WebKitLegacy/mac/Misc/WebCache.h

    r186476 r249498  
    3737+ (void)emptyInMemoryResources;
    3838+ (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;
    4439+ (CGImageRef)imageForURL:(NSURL *)url;
    4540#endif
  • trunk/Source/WebKitLegacy/mac/Misc/WebCache.mm

    r240355 r249498  
    165165}
    166166
    167 + (bool)addImageToCache:(CGImageRef)image forURL:(NSURL *)url
    168 {
    169     return [WebCache addImageToCache:image forURL:url forFrame:nil];
    170 }
    171 
    172 + (bool)addImageToCache:(CGImageRef)image forURL:(NSURL *)url forFrame:(WebFrame *)frame
    173 {
    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 *)url
    182 {
    183     [WebCache removeImageFromCacheForURL:url forFrame:nil];
    184 }
    185 
    186 + (void)removeImageFromCacheForURL:(NSURL *)url forFrame:(WebFrame *)frame
    187 {
    188     if (!url)
    189         return;
    190 
    191     return WebCore::MemoryCache::singleton().removeImageFromCache(url, frame ? core(frame)->document()->domainForCachePartition() : emptyString());
    192 }
    193 
    194167+ (CGImageRef)imageForURL:(NSURL *)url
    195168{
Note: See TracChangeset for help on using the changeset viewer.