Changeset 219249 in webkit


Ignore:
Timestamp:
Jul 7, 2017 12:22:12 AM (7 years ago)
Author:
Antti Koivisto
Message:

WKWebSiteDataStore.removeDataOfTypes should wait until disk cache files are actually removed before invoking completion handler
https://bugs.webkit.org/show_bug.cgi?id=174224
<rdar://problem/33067545>

Reviewed by Sam Weinig.

Currently we dispatch file deletion operations to a background queue and call the completion
handler without waiting for the I/O to complete.

  • NetworkProcess/NetworkProcess.cpp:

(WebKit::clearDiskCacheEntries):

Call a new version of NetworkCache::remove() for bulk deletion.
Note that it is fine to call this with an empty vector.

  • NetworkProcess/cache/NetworkCache.cpp:

(WebKit::NetworkCache::Cache::remove):

Bulk deletion with a completion handler.

(WebKit::NetworkCache::Cache::deleteFiles): Added.

Factor to a helper function.

  • NetworkProcess/cache/NetworkCache.h:
  • NetworkProcess/cache/NetworkCacheStorage.cpp:

(WebKit::NetworkCache::Storage::remove):

Remove files for all the provided keys in a queue and invoke the completion handler in the main thread when done.

  • NetworkProcess/cache/NetworkCacheStorage.h:
Location:
trunk/Source/WebKit2
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r219242 r219249  
     12017-07-07  Antti Koivisto  <antti@apple.com>
     2
     3        WKWebSiteDataStore.removeDataOfTypes should wait until disk cache files are actually removed before invoking completion handler
     4        https://bugs.webkit.org/show_bug.cgi?id=174224
     5        <rdar://problem/33067545>
     6
     7        Reviewed by Sam Weinig.
     8
     9        Currently we dispatch file deletion operations to a background queue and call the completion
     10        handler without waiting for the I/O to complete.
     11
     12        * NetworkProcess/NetworkProcess.cpp:
     13        (WebKit::clearDiskCacheEntries):
     14
     15            Call a new version of NetworkCache::remove() for bulk deletion.
     16            Note that it is fine to call this with an empty vector.
     17
     18        * NetworkProcess/cache/NetworkCache.cpp:
     19        (WebKit::NetworkCache::Cache::remove):
     20
     21            Bulk deletion with a completion handler.
     22
     23        (WebKit::NetworkCache::Cache::deleteFiles): Added.
     24
     25            Factor to a helper function.
     26
     27        * NetworkProcess/cache/NetworkCache.h:
     28        * NetworkProcess/cache/NetworkCacheStorage.cpp:
     29        (WebKit::NetworkCache::Storage::remove):
     30
     31            Remove files for all the provided keys in a queue and invoke the completion handler in the main thread when done.
     32
     33        * NetworkProcess/cache/NetworkCacheStorage.h:
     34
    1352017-07-06  Chris Dumez  <cdumez@apple.com>
    236
  • trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp

    r219161 r219249  
    450450            }
    451451
    452             for (auto& key : cacheKeysToDelete)
    453                 NetworkCache::singleton().remove(key);
    454 
    455             RunLoop::main().dispatch(WTFMove(completionHandler));
     452            NetworkCache::singleton().remove(cacheKeysToDelete, WTFMove(completionHandler));
    456453            return;
    457454        });
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp

    r218763 r219249  
    504504{
    505505    remove(makeCacheKey(request));
     506}
     507
     508void Cache::remove(const Vector<Key>& keys, Function<void ()>&& completionHandler)
     509{
     510    ASSERT(isEnabled());
     511
     512    m_storage->remove(keys, WTFMove(completionHandler));
    506513}
    507514
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.h

    r215060 r219249  
    122122    void remove(const Key&);
    123123    void remove(const WebCore::ResourceRequest&);
     124    void remove(const Vector<Key>&, Function<void ()>&&);
    124125
    125126    void clear();
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp

    r217724 r219249  
    556556
    557557    serialBackgroundIOQueue().dispatch([this, key] {
    558         WebCore::deleteFile(recordPathForKey(key));
    559         m_blobStorage.remove(blobPathForKey(key));
    560     });
     558        deleteFiles(key);
     559    });
     560}
     561
     562void Storage::remove(const Vector<Key>& keys, Function<void ()>&& completionHandler)
     563{
     564    ASSERT(RunLoop::isMain());
     565
     566    Vector<Key> keysToRemove;
     567    keysToRemove.reserveInitialCapacity(keys.size());
     568
     569    for (auto& key : keys) {
     570        if (!mayContain(key))
     571            continue;
     572        removeFromPendingWriteOperations(key);
     573        keysToRemove.uncheckedAppend(key);
     574    }
     575
     576    serialBackgroundIOQueue().dispatch([this, keysToRemove = WTFMove(keysToRemove), completionHandler = WTFMove(completionHandler)] () mutable {
     577        for (auto& key : keysToRemove)
     578            deleteFiles(key);
     579
     580        if (completionHandler)
     581            RunLoop::main().dispatch(WTFMove(completionHandler));
     582    });
     583}
     584
     585void Storage::deleteFiles(const Key& key)
     586{
     587    ASSERT(!RunLoop::isMain());
     588
     589    WebCore::deleteFile(recordPathForKey(key));
     590    m_blobStorage.remove(blobPathForKey(key));
    561591}
    562592
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h

    r215044 r219249  
    6969
    7070    void remove(const Key&);
     71    void remove(const Vector<Key>&, Function<void ()>&&);
    7172    void clear(const String& type, std::chrono::system_clock::time_point modifiedSinceTime, Function<void ()>&& completionHandler);
    7273
     
    144145
    145146    void addToRecordFilter(const Key&);
     147    void deleteFiles(const Key&);
    146148
    147149    const String m_basePath;
Note: See TracChangeset for help on using the changeset viewer.