Storage::deleteOldVersions does not need to retain Storage
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 29 Apr 2019 20:32:47 +0000 (20:32 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 29 Apr 2019 20:32:47 +0000 (20:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197336
<rdar://problem/48679972>

Reviewed by Darin Adler.

* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::Storage::deleteOldVersions):
Something is wrong with the lifetime of Storage, but we only need a String, not the whole Storage.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244750 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp

index 1e3f589..1b376a7 100644 (file)
@@ -1,3 +1,15 @@
+2019-04-29  Alex Christensen  <achristensen@webkit.org>
+
+        Storage::deleteOldVersions does not need to retain Storage
+        https://bugs.webkit.org/show_bug.cgi?id=197336
+        <rdar://problem/48679972>
+
+        Reviewed by Darin Adler.
+
+        * NetworkProcess/cache/NetworkCacheStorage.cpp:
+        (WebKit::NetworkCache::Storage::deleteOldVersions):
+        Something is wrong with the lifetime of Storage, but we only need a String, not the whole Storage.
+
 2019-04-29  Brent Fulgham  <bfulgham@apple.com>
 
         [Cocoa] Move common sandbox files from Shared/mac to Shared/Cocoa
index 06a813d..0f5a9fe 100644 (file)
@@ -1109,9 +1109,8 @@ void Storage::shrink()
 
 void Storage::deleteOldVersions()
 {
-    backgroundIOQueue().dispatch([this, protectedThis = makeRef(*this)] () mutable {
-        auto cachePath = basePath();
-        traverseDirectory(cachePath, [&cachePath](const String& subdirName, DirectoryEntryType type) {
+    backgroundIOQueue().dispatch([cachePath = basePath()] () mutable {
+        traverseDirectory(cachePath, [cachePath = WTFMove(cachePath)](const String& subdirName, DirectoryEntryType type) {
             if (type != DirectoryEntryType::Directory)
                 return;
             if (!subdirName.startsWith(versionDirectoryPrefix))