Title: [252264] trunk/Source/WebKit
Revision
252264
Author
[email protected]
Date
2019-11-08 15:01:40 -0800 (Fri, 08 Nov 2019)

Log Message

Use separate cache directory for development WebKit on Mac
https://bugs.webkit.org/show_bug.cgi?id=204015

Reviewed by Youenn Fablet.

Replace the NetworkCache::lastStableVersion scheme with a completely separate directory.
This way potential bugs in development WebKit can't end up affecting system WebKit cache.
This also removes the need to keep lastStableVersion updated.

* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::makeCachePath):

Add '/Development' to cache path if this is not system WebKit.

(WebKit::NetworkCache::Storage::open):
(WebKit::NetworkCache::Storage::deleteOldVersions):

No need to avoid deleting lastStableVersion anymore.

* NetworkProcess/cache/NetworkCacheStorage.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (252263 => 252264)


--- trunk/Source/WebKit/ChangeLog	2019-11-08 22:10:58 UTC (rev 252263)
+++ trunk/Source/WebKit/ChangeLog	2019-11-08 23:01:40 UTC (rev 252264)
@@ -1,3 +1,26 @@
+2019-11-08  Antti Koivisto  <[email protected]>
+
+        Use separate cache directory for development WebKit on Mac
+        https://bugs.webkit.org/show_bug.cgi?id=204015
+
+        Reviewed by Youenn Fablet.
+
+        Replace the NetworkCache::lastStableVersion scheme with a completely separate directory.
+        This way potential bugs in development WebKit can't end up affecting system WebKit cache.
+        This also removes the need to keep lastStableVersion updated.
+
+        * NetworkProcess/cache/NetworkCacheStorage.cpp:
+        (WebKit::NetworkCache::makeCachePath):
+
+        Add '/Development' to cache path if this is not system WebKit.
+
+        (WebKit::NetworkCache::Storage::open):
+        (WebKit::NetworkCache::Storage::deleteOldVersions):
+
+        No need to avoid deleting lastStableVersion anymore.
+
+        * NetworkProcess/cache/NetworkCacheStorage.h:
+
 2019-11-08  Per Arne Vollan  <[email protected]>
 
         [macOS] [iOS] Add logging and telemetry to mach lookup rules

Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp (252263 => 252264)


--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp	2019-11-08 22:10:58 UTC (rev 252263)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp	2019-11-08 23:01:40 UTC (rev 252264)
@@ -143,6 +143,16 @@
     unsigned activeCount { 0 };
 };
 
+static String makeCachePath(const String& baseCachePath)
+{
+#if PLATFORM(MAC)
+    // Put development cache to a different directory to avoid affecting the system cache.
+    if (!AuxiliaryProcess::isSystemWebKit())
+        return FileSystem::pathByAppendingComponent(baseCachePath, "Development"_s);
+#endif
+    return baseCachePath;
+}
+
 static String makeVersionedDirectoryPath(const String& baseDirectoryPath)
 {
     String versionSubdirectory = makeString(versionDirectoryPrefix, Storage::version);
@@ -164,15 +174,19 @@
     return FileSystem::pathByAppendingComponent(makeVersionedDirectoryPath(baseDirectoryPath), saltFileName);
 }
 
-RefPtr<Storage> Storage::open(const String& cachePath, Mode mode)
+RefPtr<Storage> Storage::open(const String& baseCachePath, Mode mode)
 {
     ASSERT(RunLoop::isMain());
 
+    auto cachePath = makeCachePath(baseCachePath);
+
     if (!FileSystem::makeAllDirectories(makeVersionedDirectoryPath(cachePath)))
         return nullptr;
+
     auto salt = readOrMakeSalt(makeSaltFilePath(cachePath));
     if (!salt)
         return nullptr;
+
     return adoptRef(new Storage(cachePath, mode, *salt));
 }
 
@@ -1122,10 +1136,6 @@
                 return;
             if (directoryVersion >= version)
                 return;
-#if PLATFORM(MAC)
-            if (!AuxiliaryProcess::isSystemWebKit() && directoryVersion == lastStableVersion)
-                return;
-#endif
 
             auto oldVersionPath = FileSystem::pathByAppendingComponent(cachePath, subdirName);
             LOG(NetworkCacheStorage, "(NetworkProcess) deleting old cache version, path %s", oldVersionPath.utf8().data());

Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.h (252263 => 252264)


--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.h	2019-11-08 22:10:58 UTC (rev 252263)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.h	2019-11-08 23:01:40 UTC (rev 252264)
@@ -108,10 +108,6 @@
 
     // Incrementing this number will delete all existing cache content for everyone. Do you really need to do it?
     static const unsigned version = 15;
-#if PLATFORM(MAC)
-    /// Allow the last stable version of the cache to co-exist with the latest development one.
-    static const unsigned lastStableVersion = 13;
-#endif
 
     String basePathIsolatedCopy() const;
     String versionPath() const;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to