Title: [291842] trunk
Revision
291842
Author
cdu...@apple.com
Date
2022-03-24 19:05:10 -0700 (Thu, 24 Mar 2022)

Log Message

FileSystem::pathByAppendingComponent() should take in StringViews instead of Strings
https://bugs.webkit.org/show_bug.cgi?id=238344

Reviewed by Geoff Garen.

Source/_javascript_Core:

* jsc.cpp:

Source/WebCore:

* Modules/indexeddb/IDBDatabaseIdentifier.cpp:
(WebCore::IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot const):
(WebCore::IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot):
* Modules/indexeddb/IDBDatabaseIdentifier.h:
* Modules/indexeddb/server/IDBServer.cpp:
(WebCore::IDBServer::IDBServer::getAllDatabaseNamesAndVersions):
(WebCore::IDBServer::IDBServer::diskUsage):
(WebCore::IDBServer::IDBServer::upgradedDatabaseDirectory):
* Modules/webdatabase/OriginLock.cpp:
(WebCore::lockFileNameForPath):
* platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
(WebCore::CDMInstanceFairPlayStreamingAVFObjC::setStorageDirectory):
* platform/network/curl/CurlCacheManager.cpp:
(WebCore::CurlCacheManager::loadIndex):

Source/WebKit:

* NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
(WebKit::ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore):
* NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.cpp:
(WebKit::PCM::Database::Database):
* NetworkProcess/cache/CacheStorageEngine.cpp:
(WebKit::CacheStorage::Engine::storagePath):
(WebKit::CacheStorage::Engine::initialize):
* NetworkProcess/cache/CacheStorageEngineCaches.cpp:
(WebKit::CacheStorage::cachesListFilename):
(WebKit::CacheStorage::cachesOriginFilename):
(WebKit::CacheStorage::Caches::cachesSizeFilename):
* NetworkProcess/cache/NetworkCacheBlobStorage.cpp:
(WebKit::NetworkCache::BlobStorage::blobPathForHash const):
* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::makeCachePath):
* NetworkProcess/storage/IDBStorageManager.cpp:
(WebKit::IDBStorageManager::idbStorageOriginDirectory):
* UIProcess/Inspector/win/InspectorResourceURLSchemeHandler.cpp:
(WebKit::InspectorResourceURLSchemeHandler::platformStartTask):

Source/WebKitLegacy/mac:

* Storage/WebDatabaseProvider.mm:
(WebDatabaseProvider::indexedDatabaseDirectoryPath):
* WebView/WebView.mm:
(-[WebView _commonInitializationWithFrameName:groupName:]):

Source/WTF:

FileSystem::pathByAppendingComponent() should take in StringViews instead of Strings, to avoid
unnecessary String constructor in many instances.

* wtf/FileSystem.cpp:
(WTF::FileSystemImpl::pathByAppendingComponent):
* wtf/FileSystem.h:
* wtf/posix/FileSystemPOSIX.cpp:
(WTF::FileSystemImpl::pathByAppendingComponent):

Tools:

* TestWebKitAPI/Tests/WTF/FileSystem.cpp:
(TestWebKitAPI::TEST_F):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (291841 => 291842)


--- trunk/Source/_javascript_Core/ChangeLog	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Source/_javascript_Core/ChangeLog	2022-03-25 02:05:10 UTC (rev 291842)
@@ -1,5 +1,14 @@
 2022-03-24  Chris Dumez  <cdu...@apple.com>
 
+        FileSystem::pathByAppendingComponent() should take in StringViews instead of Strings
+        https://bugs.webkit.org/show_bug.cgi?id=238344
+
+        Reviewed by Geoff Garen.
+
+        * jsc.cpp:
+
+2022-03-24  Chris Dumez  <cdu...@apple.com>
+
         String's startsWith() / endsWith() / replace() should take in a StringView instead of a String
         https://bugs.webkit.org/show_bug.cgi?id=238333
 

Modified: trunk/Source/_javascript_Core/jsc.cpp (291841 => 291842)


--- trunk/Source/_javascript_Core/jsc.cpp	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Source/_javascript_Core/jsc.cpp	2022-03-25 02:05:10 UTC (rev 291842)
@@ -1096,7 +1096,7 @@
             return { };
         const char* cachePath = Options::diskCachePath();
         String filename = FileSystem::encodeForFileName(FileSystem::lastComponentOfPathIgnoringTrailingSlash(sourceOrigin().url().fileSystemPath()));
-        return FileSystem::pathByAppendingComponent(String { cachePath }, makeString(source().toString().hash(), '-', filename, ".bytecode-cache"));
+        return FileSystem::pathByAppendingComponent(cachePath, makeString(source().toString().hash(), '-', filename, ".bytecode-cache"));
     }
 
     void loadBytecode() const

Modified: trunk/Source/WTF/ChangeLog (291841 => 291842)


--- trunk/Source/WTF/ChangeLog	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Source/WTF/ChangeLog	2022-03-25 02:05:10 UTC (rev 291842)
@@ -1,5 +1,21 @@
 2022-03-24  Chris Dumez  <cdu...@apple.com>
 
+        FileSystem::pathByAppendingComponent() should take in StringViews instead of Strings
+        https://bugs.webkit.org/show_bug.cgi?id=238344
+
+        Reviewed by Geoff Garen.
+
+        FileSystem::pathByAppendingComponent() should take in StringViews instead of Strings, to avoid
+        unnecessary String constructor in many instances.
+
+        * wtf/FileSystem.cpp:
+        (WTF::FileSystemImpl::pathByAppendingComponent):
+        * wtf/FileSystem.h:
+        * wtf/posix/FileSystemPOSIX.cpp:
+        (WTF::FileSystemImpl::pathByAppendingComponent):
+
+2022-03-24  Chris Dumez  <cdu...@apple.com>
+
         String's startsWith() / endsWith() / replace() should take in a StringView instead of a String
         https://bugs.webkit.org/show_bug.cgi?id=238333
 

Modified: trunk/Source/WTF/wtf/FileSystem.cpp (291841 => 291842)


--- trunk/Source/WTF/wtf/FileSystem.cpp	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Source/WTF/wtf/FileSystem.cpp	2022-03-25 02:05:10 UTC (rev 291842)
@@ -821,7 +821,7 @@
     return !ec;
 }
 
-String pathByAppendingComponent(const String& path, const String& component)
+String pathByAppendingComponent(StringView path, StringView component)
 {
     return fromStdFileSystemPath(toStdFileSystemPath(path) / toStdFileSystemPath(component));
 }

Modified: trunk/Source/WTF/wtf/FileSystem.h (291841 => 291842)


--- trunk/Source/WTF/wtf/FileSystem.h	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Source/WTF/wtf/FileSystem.h	2022-03-25 02:05:10 UTC (rev 291842)
@@ -117,7 +117,7 @@
 WTF_EXPORT_PRIVATE bool updateFileModificationTime(const String& path); // Sets modification time to now.
 WTF_EXPORT_PRIVATE std::optional<WallTime> fileCreationTime(const String&); // Not all platforms store file creation time.
 WTF_EXPORT_PRIVATE bool isHiddenFile(const String&);
-WTF_EXPORT_PRIVATE String pathByAppendingComponent(const String& path, const String& component);
+WTF_EXPORT_PRIVATE String pathByAppendingComponent(StringView path, StringView component);
 WTF_EXPORT_PRIVATE String pathByAppendingComponents(StringView path, const Vector<StringView>& components);
 WTF_EXPORT_PRIVATE String lastComponentOfPathIgnoringTrailingSlash(const String& path);
 WTF_EXPORT_PRIVATE bool makeAllDirectories(const String& path);

Modified: trunk/Source/WTF/wtf/posix/FileSystemPOSIX.cpp (291841 => 291842)


--- trunk/Source/WTF/wtf/posix/FileSystemPOSIX.cpp	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Source/WTF/wtf/posix/FileSystemPOSIX.cpp	2022-03-25 02:05:10 UTC (rev 291842)
@@ -298,11 +298,11 @@
     return true;
 }
 
-String pathByAppendingComponent(const String& path, const String& component)
+String pathByAppendingComponent(StringView path, StringView component)
 {
     if (path.endsWith('/'))
-        return path + component;
-    return path + "/" + component;
+        return makeString(path, component);
+    return makeString(path, '/', component);
 }
 
 String pathByAppendingComponents(StringView path, const Vector<StringView>& components)

Modified: trunk/Source/WTF/wtf/win/FileSystemWin.cpp (291841 => 291842)


--- trunk/Source/WTF/wtf/win/FileSystemWin.cpp	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Source/WTF/wtf/win/FileSystemWin.cpp	2022-03-25 02:05:10 UTC (rev 291842)
@@ -169,7 +169,7 @@
     buffer.shrink(wcslen(wcharFrom(buffer.data())));
     String directory = String::adopt(WTFMove(buffer));
 
-    directory = pathByAppendingComponent(directory, "Apple Computer\\" + bundleName());
+    directory = pathByAppendingComponent(directory, makeString("Apple Computer\\", bundleName()));
     if (!makeAllDirectories(directory))
         return String();
 
@@ -211,7 +211,7 @@
 
         ASSERT(wcslen(tempFile) == WTF_ARRAY_LENGTH(tempFile) - 1);
 
-        proposedPath = pathByAppendingComponent(tempPath, tempFile);
+        proposedPath = pathByAppendingComponent(String(tempPath), String(tempFile));
         if (proposedPath.isEmpty())
             break;
     } while (!action(proposedPath));

Modified: trunk/Source/WebCore/ChangeLog (291841 => 291842)


--- trunk/Source/WebCore/ChangeLog	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Source/WebCore/ChangeLog	2022-03-25 02:05:10 UTC (rev 291842)
@@ -1,3 +1,25 @@
+2022-03-24  Chris Dumez  <cdu...@apple.com>
+
+        FileSystem::pathByAppendingComponent() should take in StringViews instead of Strings
+        https://bugs.webkit.org/show_bug.cgi?id=238344
+
+        Reviewed by Geoff Garen.
+
+        * Modules/indexeddb/IDBDatabaseIdentifier.cpp:
+        (WebCore::IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot const):
+        (WebCore::IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot):
+        * Modules/indexeddb/IDBDatabaseIdentifier.h:
+        * Modules/indexeddb/server/IDBServer.cpp:
+        (WebCore::IDBServer::IDBServer::getAllDatabaseNamesAndVersions):
+        (WebCore::IDBServer::IDBServer::diskUsage):
+        (WebCore::IDBServer::IDBServer::upgradedDatabaseDirectory):
+        * Modules/webdatabase/OriginLock.cpp:
+        (WebCore::lockFileNameForPath):
+        * platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm:
+        (WebCore::CDMInstanceFairPlayStreamingAVFObjC::setStorageDirectory):
+        * platform/network/curl/CurlCacheManager.cpp:
+        (WebCore::CurlCacheManager::loadIndex):
+
 2022-03-24  Nikolaos Mouchtaris  <nmouchta...@apple.com>
 
         calc(): Handle finite value with infinite step in round()

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.cpp (291841 => 291842)


--- trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.cpp	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.cpp	2022-03-25 02:05:10 UTC (rev 291842)
@@ -60,14 +60,14 @@
     return identifier;
 }
 
-String IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(const String& rootDirectory, const String& versionString) const
+String IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(const String& rootDirectory, ASCIILiteral versionString) const
 {
     return databaseDirectoryRelativeToRoot(m_origin, rootDirectory, versionString);
 }
 
-String IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(const ClientOrigin& origin, const String& rootDirectory, const String& versionString)
+String IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(const ClientOrigin& origin, const String& rootDirectory, ASCIILiteral versionString)
 {
-    String versionDirectory = FileSystem::pathByAppendingComponent(rootDirectory, versionString);
+    String versionDirectory = FileSystem::pathByAppendingComponent(rootDirectory, StringView { versionString });
     String mainFrameDirectory = FileSystem::pathByAppendingComponent(versionDirectory, origin.topOrigin.databaseIdentifier());
 
     // If the opening origin and main frame origins are the same, there is no partitioning.

Modified: trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.h (291841 => 291842)


--- trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.h	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.h	2022-03-25 02:05:10 UTC (rev 291842)
@@ -70,8 +70,8 @@
     const ClientOrigin& origin() const { return m_origin; }
     bool isTransient() const { return m_isTransient; }
 
-    String databaseDirectoryRelativeToRoot(const String& rootDirectory, const String& versionString="v1") const;
-    WEBCORE_EXPORT static String databaseDirectoryRelativeToRoot(const ClientOrigin&, const String& rootDirectory, const String& versionString);
+    String databaseDirectoryRelativeToRoot(const String& rootDirectory, ASCIILiteral versionString = "v1"_s) const;
+    WEBCORE_EXPORT static String databaseDirectoryRelativeToRoot(const ClientOrigin&, const String& rootDirectory, ASCIILiteral versionString);
 
     template<class Encoder> void encode(Encoder&) const;
     template<class Decoder> static std::optional<IDBDatabaseIdentifier> decode(Decoder&);

Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp (291841 => 291842)


--- trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp	2022-03-25 02:05:10 UTC (rev 291842)
@@ -530,10 +530,10 @@
             result.append(WTFMove(*nameAndVersion));
     }
 
-    auto oldDirectory = IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(origin, m_databaseDirectoryPath, "v0");
+    auto oldDirectory = IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(origin, m_databaseDirectoryPath, "v0"_s);
     getDatabaseNameAndVersionFromOriginDirectory(oldDirectory, visitedDatabasePaths, result);
 
-    auto directory = IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(origin, m_databaseDirectoryPath, "v1");
+    auto directory = IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(origin, m_databaseDirectoryPath, "v1"_s);
     getDatabaseNameAndVersionFromOriginDirectory(directory, visitedDatabasePaths, result);
 
     auto connection = m_connectionMap.get(serverConnectionIdentifier);
@@ -758,8 +758,8 @@
 {
     ASSERT(!isMainThread());
 
-    auto oldVersionOriginDirectory = IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(origin, rootDirectory, "v0"_str);
-    auto newVersionOriginDirectory = IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(origin, rootDirectory, "v1"_str);
+    auto oldVersionOriginDirectory = IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(origin, rootDirectory, "v0"_s);
+    auto newVersionOriginDirectory = IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(origin, rootDirectory, "v1"_s);
     return SQLiteIDBBackingStore::databasesSizeForDirectory(oldVersionOriginDirectory) + SQLiteIDBBackingStore::databasesSizeForDirectory(newVersionOriginDirectory);
 }
 
@@ -775,9 +775,9 @@
 
 String IDBServer::upgradedDatabaseDirectory(const WebCore::IDBDatabaseIdentifier& identifier)
 {
-    String oldOriginDirectory = identifier.databaseDirectoryRelativeToRoot(m_databaseDirectoryPath, "v0");
+    String oldOriginDirectory = identifier.databaseDirectoryRelativeToRoot(m_databaseDirectoryPath, "v0"_s);
     String oldDatabaseDirectory = FileSystem::pathByAppendingComponent(oldOriginDirectory, SQLiteIDBBackingStore::encodeDatabaseName(identifier.databaseName()));
-    String newOriginDirectory = identifier.databaseDirectoryRelativeToRoot(m_databaseDirectoryPath, "v1");
+    String newOriginDirectory = identifier.databaseDirectoryRelativeToRoot(m_databaseDirectoryPath, "v1"_s);
     String fileNameHash = SQLiteFileSystem::computeHashForFileName(identifier.databaseName());
     String newDatabaseDirectory = FileSystem::pathByAppendingComponent(newOriginDirectory, fileNameHash);
     FileSystem::makeAllDirectories(newDatabaseDirectory);

Modified: trunk/Source/WebCore/Modules/webdatabase/OriginLock.cpp (291841 => 291842)


--- trunk/Source/WebCore/Modules/webdatabase/OriginLock.cpp	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Source/WebCore/Modules/webdatabase/OriginLock.cpp	2022-03-25 02:05:10 UTC (rev 291842)
@@ -30,7 +30,7 @@
 
 static String lockFileNameForPath(const String& originPath)
 {
-    return FileSystem::pathByAppendingComponent(originPath, ".lock"_s);
+    return FileSystem::pathByAppendingComponent(originPath, ".lock");
 }
 
 OriginLock::OriginLock(const String& originPath)

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm (291841 => 291842)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm	2022-03-25 02:05:10 UTC (rev 291842)
@@ -405,8 +405,8 @@
         if (!FileSystem::makeAllDirectories(storageDirectory))
             return;
     } else if (*fileType != FileSystem::FileType::Directory) {
-        auto tempDirectory = FileSystem::createTemporaryDirectory(@"MediaKeys");
-        if (!tempDirectory)
+        String tempDirectory = FileSystem::createTemporaryDirectory(@"MediaKeys");
+        if (tempDirectory.isNull())
             return;
 
         auto tempStoragePath = FileSystem::pathByAppendingComponent(tempDirectory, FileSystem::pathFileName(storagePath));

Modified: trunk/Source/WebCore/platform/network/curl/CurlCacheManager.cpp (291841 => 291842)


--- trunk/Source/WebCore/platform/network/curl/CurlCacheManager.cpp	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Source/WebCore/platform/network/curl/CurlCacheManager.cpp	2022-03-25 02:05:10 UTC (rev 291842)
@@ -101,7 +101,7 @@
     if (m_disabled)
         return;
 
-    String indexFilePath = FileSystem::pathByAppendingComponent(m_cacheDir, "index.dat"_s);
+    String indexFilePath = FileSystem::pathByAppendingComponent(m_cacheDir, "index.dat");
     auto buffer = FileSystem::readEntireFile(indexFilePath);
     if (!buffer) {
         LOG(Network, "Cache Error: Could not read %s\n", indexFilePath.latin1().data());

Modified: trunk/Source/WebKit/ChangeLog (291841 => 291842)


--- trunk/Source/WebKit/ChangeLog	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Source/WebKit/ChangeLog	2022-03-25 02:05:10 UTC (rev 291842)
@@ -1,3 +1,30 @@
+2022-03-24  Chris Dumez  <cdu...@apple.com>
+
+        FileSystem::pathByAppendingComponent() should take in StringViews instead of Strings
+        https://bugs.webkit.org/show_bug.cgi?id=238344
+
+        Reviewed by Geoff Garen.
+
+        * NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp:
+        (WebKit::ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore):
+        * NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.cpp:
+        (WebKit::PCM::Database::Database):
+        * NetworkProcess/cache/CacheStorageEngine.cpp:
+        (WebKit::CacheStorage::Engine::storagePath):
+        (WebKit::CacheStorage::Engine::initialize):
+        * NetworkProcess/cache/CacheStorageEngineCaches.cpp:
+        (WebKit::CacheStorage::cachesListFilename):
+        (WebKit::CacheStorage::cachesOriginFilename):
+        (WebKit::CacheStorage::Caches::cachesSizeFilename):
+        * NetworkProcess/cache/NetworkCacheBlobStorage.cpp:
+        (WebKit::NetworkCache::BlobStorage::blobPathForHash const):
+        * NetworkProcess/cache/NetworkCacheStorage.cpp:
+        (WebKit::NetworkCache::makeCachePath):
+        * NetworkProcess/storage/IDBStorageManager.cpp:
+        (WebKit::IDBStorageManager::idbStorageOriginDirectory):
+        * UIProcess/Inspector/win/InspectorResourceURLSchemeHandler.cpp:
+        (WebKit::InspectorResourceURLSchemeHandler::platformStartTask):
+
 2022-03-24  Don Olmstead  <don.olmst...@sony.com>
 
         [GLib] Add user directories to WTF::FileSystem

Modified: trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp (291841 => 291842)


--- trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsDatabaseStore.cpp	2022-03-25 02:05:10 UTC (rev 291842)
@@ -314,7 +314,7 @@
 
 ResourceLoadStatisticsDatabaseStore::ResourceLoadStatisticsDatabaseStore(WebResourceLoadStatisticsStore& store, SuspendableWorkQueue& workQueue, ShouldIncludeLocalhost shouldIncludeLocalhost, const String& storageDirectoryPath, PAL::SessionID sessionID)
     : ResourceLoadStatisticsStore(store, workQueue, shouldIncludeLocalhost)
-    , DatabaseUtilities(FileSystem::pathByAppendingComponent(storageDirectoryPath, "observations.db"_s))
+    , DatabaseUtilities(FileSystem::pathByAppendingComponent(storageDirectoryPath, "observations.db"))
     , m_sessionID(sessionID)
 {
     ASSERT(!RunLoop::isMain());

Modified: trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.cpp (291841 => 291842)


--- trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.cpp	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Source/WebKit/NetworkProcess/PrivateClickMeasurement/PrivateClickMeasurementDatabase.cpp	2022-03-25 02:05:10 UTC (rev 291842)
@@ -82,7 +82,7 @@
 }
 
 Database::Database(const String& storageDirectory)
-    : DatabaseUtilities(FileSystem::pathByAppendingComponent(storageDirectory, "pcm.db"_s))
+    : DatabaseUtilities(FileSystem::pathByAppendingComponent(storageDirectory, "pcm.db"))
 {
     ASSERT(!RunLoop::isMain());
     openDatabaseAndCreateSchemaIfNecessary();

Modified: trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp (291841 => 291842)


--- trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp	2022-03-25 02:05:10 UTC (rev 291842)
@@ -211,7 +211,7 @@
     if (rootDirectory.isEmpty())
         return emptyString();
 
-    String saltPath = FileSystem::pathByAppendingComponent(rootDirectory, "salt"_s);
+    String saltPath = FileSystem::pathByAppendingComponent(rootDirectory, "salt");
     auto salt = FileSystem::readOrMakeSalt(saltPath);
     if (!salt)
         return emptyString();
@@ -360,7 +360,7 @@
 
     m_ioQueue->dispatch([this, weakThis = WeakPtr { *this }, rootPath = m_rootPath.isolatedCopy()] () mutable {
         FileSystem::makeAllDirectories(rootPath);
-        String saltPath = FileSystem::pathByAppendingComponent(rootPath, "salt"_s);
+        String saltPath = FileSystem::pathByAppendingComponent(rootPath, "salt");
         RunLoop::main().dispatch([this, weakThis = WTFMove(weakThis), salt = FileSystem::readOrMakeSalt(saltPath)]() mutable {
             if (!weakThis)
                 return;

Modified: trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp (291841 => 291842)


--- trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp	2022-03-25 02:05:10 UTC (rev 291842)
@@ -43,17 +43,17 @@
 
 static inline String cachesListFilename(const String& cachesRootPath)
 {
-    return FileSystem::pathByAppendingComponent(cachesRootPath, "cacheslist"_s);
+    return FileSystem::pathByAppendingComponent(cachesRootPath, "cacheslist");
 }
 
 static inline String cachesOriginFilename(const String& cachesRootPath)
 {
-    return FileSystem::pathByAppendingComponent(cachesRootPath, "origin"_s);
+    return FileSystem::pathByAppendingComponent(cachesRootPath, "origin");
 }
 
 String Caches::cachesSizeFilename(const String& cachesRootsPath)
 {
-    return FileSystem::pathByAppendingComponent(cachesRootsPath, "estimatedsize"_s);
+    return FileSystem::pathByAppendingComponent(cachesRootsPath, "estimatedsize");
 }
 
 Ref<Caches> Caches::create(Engine& engine, WebCore::ClientOrigin&& origin, String&& rootPath)

Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheBlobStorage.cpp (291841 => 291842)


--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheBlobStorage.cpp	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheBlobStorage.cpp	2022-03-25 02:05:10 UTC (rev 291842)
@@ -79,7 +79,7 @@
 String BlobStorage::blobPathForHash(const SHA1::Digest& hash) const
 {
     auto hashAsString = SHA1::hexDigest(hash);
-    return FileSystem::pathByAppendingComponent(blobDirectoryPathIsolatedCopy(), String::fromUTF8(hashAsString));
+    return FileSystem::pathByAppendingComponent(blobDirectoryPathIsolatedCopy(), hashAsString.data());
 }
 
 BlobStorage::Blob BlobStorage::add(const String& path, const Data& data)

Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp (291841 => 291842)


--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp	2022-03-25 02:05:10 UTC (rev 291842)
@@ -176,7 +176,7 @@
 #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);
+        return FileSystem::pathByAppendingComponent(baseCachePath, "Development");
 #endif
     return baseCachePath;
 }

Modified: trunk/Source/WebKit/NetworkProcess/storage/IDBStorageManager.cpp (291841 => 291842)


--- trunk/Source/WebKit/NetworkProcess/storage/IDBStorageManager.cpp	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Source/WebKit/NetworkProcess/storage/IDBStorageManager.cpp	2022-03-25 02:05:10 UTC (rev 291842)
@@ -71,8 +71,8 @@
     if (rootDirectory.isEmpty())
         return emptyString();
 
-    auto originDirectory = WebCore::IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(origin, rootDirectory, "v1");
-    auto oldOriginDirectory = WebCore::IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(origin, rootDirectory, "v0");
+    auto originDirectory = WebCore::IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(origin, rootDirectory, "v1"_s);
+    auto oldOriginDirectory = WebCore::IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(origin, rootDirectory, "v0"_s);
     migrateOriginDataImpl(oldOriginDirectory, originDirectory, [](const String& name) {
         return WebCore::SQLiteFileSystem::computeHashForFileName(WebCore::IDBServer::SQLiteIDBBackingStore::decodeDatabaseName(name));
     });

Modified: trunk/Source/WebKit/NetworkProcess/storage/LocalStorageManager.cpp (291841 => 291842)


--- trunk/Source/WebKit/NetworkProcess/storage/LocalStorageManager.cpp	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Source/WebKit/NetworkProcess/storage/LocalStorageManager.cpp	2022-03-25 02:05:10 UTC (rev 291842)
@@ -35,17 +35,17 @@
 
 // Suggested by https://www.w3.org/TR/webstorage/#disk-space
 constexpr unsigned localStorageQuotaInBytes = 5 * MB;
-constexpr auto fileSuffix = ".localstorage"_s;
-constexpr auto fileName = "localstorage.sqlite3"_s;
+constexpr auto s_fileSuffix = ".localstorage"_s;
+constexpr auto s_fileName = "localstorage.sqlite3"_s;
 
 // This is intended to be used for existing files.
 // We should not include origin in file name.
 static std::optional<WebCore::SecurityOriginData> fileNameToOrigin(const String& fileName)
 {
-    if (!fileName.endsWith(StringView { fileSuffix }))
+    if (!fileName.endsWith(StringView { s_fileSuffix }))
         return std::nullopt;
 
-    auto suffixLength = strlen(fileSuffix);
+    auto suffixLength = s_fileSuffix.length();
     auto fileNameLength = fileName.length();
     if (fileNameLength <= suffixLength)
         return std::nullopt;
@@ -86,7 +86,7 @@
     if (directory.isEmpty())
         return emptyString();
 
-    return FileSystem::pathByAppendingComponent(directory, fileName);
+    return FileSystem::pathByAppendingComponent(directory, StringView { s_fileName });
 }
 
 LocalStorageManager::LocalStorageManager(const String& path, StorageAreaRegistry& registry)

Modified: trunk/Source/WebKit/UIProcess/Inspector/win/InspectorResourceURLSchemeHandler.cpp (291841 => 291842)


--- trunk/Source/WebKit/UIProcess/Inspector/win/InspectorResourceURLSchemeHandler.cpp	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Source/WebKit/UIProcess/Inspector/win/InspectorResourceURLSchemeHandler.cpp	2022-03-25 02:05:10 UTC (rev 291842)
@@ -47,7 +47,7 @@
     if (requestPath.startsWith("\\"))
         requestPath.remove(0);
     auto path = URL(adoptCF(CFBundleCopyBundleURL(WebCore::webKitBundle())).get()).fileSystemPath();
-    path = FileSystem::pathByAppendingComponent(path, "WebInspectorUI"_s);
+    path = FileSystem::pathByAppendingComponent(path, "WebInspectorUI");
     path = FileSystem::pathByAppendingComponent(path, requestPath);
     bool success;
     FileSystem::MappedFileData file(path, FileSystem::MappedFileMode::Private, success);

Modified: trunk/Source/WebKit/WebProcess/Model/mac/ARKitInlinePreviewModelPlayerMac.mm (291841 => 291842)


--- trunk/Source/WebKit/WebProcess/Model/mac/ARKitInlinePreviewModelPlayerMac.mm	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Source/WebKit/WebProcess/Model/mac/ARKitInlinePreviewModelPlayerMac.mm	2022-03-25 02:05:10 UTC (rev 291842)
@@ -103,7 +103,7 @@
     }
 
     // We need to support .reality files as well, https://bugs.webkit.org/show_bug.cgi?id=227568.
-    auto fileName = FileSystem::encodeForFileName(createVersion4UUIDString()) + ".usdz";
+    String fileName = FileSystem::encodeForFileName(createVersion4UUIDString()) + ".usdz";
     auto filePath = FileSystem::pathByAppendingComponent(pathToDirectory, fileName);
     auto file = FileSystem::openFile(filePath, FileSystem::FileOpenMode::Write);
     if (file <= 0)

Modified: trunk/Source/WebKitLegacy/Storage/StorageSyncManager.cpp (291841 => 291842)


--- trunk/Source/WebKitLegacy/Storage/StorageSyncManager.cpp	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Source/WebKitLegacy/Storage/StorageSyncManager.cpp	2022-03-25 02:05:10 UTC (rev 291842)
@@ -60,7 +60,7 @@
         return String();
     }
 
-    return FileSystem::pathByAppendingComponent(m_path, databaseIdentifier + ".localstorage");
+    return FileSystem::pathByAppendingComponent(m_path, makeString(databaseIdentifier, ".localstorage"));
 }
 
 void StorageSyncManager::dispatch(Function<void ()>&& function)

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (291841 => 291842)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2022-03-25 02:05:10 UTC (rev 291842)
@@ -1,5 +1,17 @@
 2022-03-24  Chris Dumez  <cdu...@apple.com>
 
+        FileSystem::pathByAppendingComponent() should take in StringViews instead of Strings
+        https://bugs.webkit.org/show_bug.cgi?id=238344
+
+        Reviewed by Geoff Garen.
+
+        * Storage/WebDatabaseProvider.mm:
+        (WebDatabaseProvider::indexedDatabaseDirectoryPath):
+        * WebView/WebView.mm:
+        (-[WebView _commonInitializationWithFrameName:groupName:]):
+
+2022-03-24  Chris Dumez  <cdu...@apple.com>
+
         String's startsWith() / endsWith() / replace() should take in a StringView instead of a String
         https://bugs.webkit.org/show_bug.cgi?id=238333
 

Modified: trunk/Source/WebKitLegacy/mac/Storage/WebDatabaseProvider.mm (291841 => 291842)


--- trunk/Source/WebKitLegacy/mac/Storage/WebDatabaseProvider.mm	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Source/WebKitLegacy/mac/Storage/WebDatabaseProvider.mm	2022-03-25 02:05:10 UTC (rev 291842)
@@ -33,9 +33,9 @@
     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
     NSString *databasesDirectory = [defaults objectForKey:WebDatabaseDirectoryDefaultsKey];
     if (!databasesDirectory || ![databasesDirectory isKindOfClass:[NSString class]])
-        databasesDirectory = FileSystem::pathByAppendingComponent("~/Library/WebKit/Databases/___IndexedDB"_s, [[NSBundle mainBundle] bundleIdentifier]);
+        databasesDirectory = FileSystem::pathByAppendingComponent("~/Library/WebKit/Databases/___IndexedDB", String([[NSBundle mainBundle] bundleIdentifier]));
     else
-        databasesDirectory = FileSystem::pathByAppendingComponent(databasesDirectory, "___IndexedDB"_s);
+        databasesDirectory = FileSystem::pathByAppendingComponent(String(databasesDirectory), "___IndexedDB");
     
     return [databasesDirectory stringByStandardizingPath];
 }

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebView.mm (291841 => 291842)


--- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebView.mm	2022-03-25 02:05:10 UTC (rev 291842)
@@ -1534,7 +1534,7 @@
 #endif
 
 #if ENABLE(VIDEO)
-        WebCore::HTMLMediaElement::setMediaCacheDirectory(FileSystem::pathByAppendingComponent(NSTemporaryDirectory(), "MediaCache/"_s));
+        WebCore::HTMLMediaElement::setMediaCacheDirectory(FileSystem::pathByAppendingComponent(String(NSTemporaryDirectory()), "MediaCache/"));
 #endif
         didOneTimeInitialization = true;
     }

Modified: trunk/Tools/ChangeLog (291841 => 291842)


--- trunk/Tools/ChangeLog	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Tools/ChangeLog	2022-03-25 02:05:10 UTC (rev 291842)
@@ -1,3 +1,13 @@
+2022-03-24  Chris Dumez  <cdu...@apple.com>
+
+        FileSystem::pathByAppendingComponent() should take in StringViews instead of Strings
+        https://bugs.webkit.org/show_bug.cgi?id=238344
+
+        Reviewed by Geoff Garen.
+
+        * TestWebKitAPI/Tests/WTF/FileSystem.cpp:
+        (TestWebKitAPI::TEST_F):
+
 2022-03-24  Aakash Jain  <aakash_j...@apple.com>
 
         [ews] Set bug_title property appropriately

Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp (291841 => 291842)


--- trunk/Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp	2022-03-25 01:03:07 UTC (rev 291841)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp	2022-03-25 02:05:10 UTC (rev 291842)
@@ -264,13 +264,13 @@
     EXPECT_TRUE(FileSystem::fileExists(tempFileSymlinkPath()));
     EXPECT_TRUE(FileSystem::fileExists(tempEmptyFilePath()));
     EXPECT_TRUE(FileSystem::fileExists(tempEmptyFolderPath()));
-    EXPECT_FALSE(FileSystem::fileExists(FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "does-not-exist"_s)));
+    EXPECT_FALSE(FileSystem::fileExists(FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "does-not-exist")));
 }
 
 TEST_F(FileSystemTest, fileExistsBrokenSymlink)
 {
-    auto doesNotExistPath = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "does-not-exist"_s);
-    auto symlinkPath = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "does-not-exist-symlink"_s);
+    auto doesNotExistPath = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "does-not-exist");
+    auto symlinkPath = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "does-not-exist-symlink");
     EXPECT_TRUE(FileSystem::createSymbolicLink(doesNotExistPath, symlinkPath));
     EXPECT_FALSE(FileSystem::fileExists(doesNotExistPath));
     EXPECT_FALSE(FileSystem::fileExists(symlinkPath)); // fileExists() follows symlinks.
@@ -281,7 +281,7 @@
 TEST_F(FileSystemTest, fileExistsSymlinkToSymlink)
 {
     // Create a valid symlink to a symlink to a regular file.
-    auto symlinkPath = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "symlink"_s);
+    auto symlinkPath = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "symlink");
     EXPECT_TRUE(FileSystem::createSymbolicLink(tempFileSymlinkPath(), symlinkPath));
     EXPECT_TRUE(FileSystem::fileExists(symlinkPath));
     EXPECT_EQ(FileSystem::fileType(symlinkPath), FileSystem::FileType::SymbolicLink);
@@ -468,7 +468,7 @@
     ASSERT_TRUE(fileSize);
     EXPECT_EQ(*fileSize, 0U);
 
-    String fileThatDoesNotExist = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "does-not-exist"_s);
+    String fileThatDoesNotExist = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "does-not-exist");
     fileSize = FileSystem::fileSize(fileThatDoesNotExist);
     EXPECT_TRUE(!fileSize);
 }
@@ -498,7 +498,7 @@
     ASSERT_TRUE(freeSpace);
     EXPECT_GT(*freeSpace, 0U);
 
-    String fileThatDoesNotExist = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "does-not-exist"_s);
+    String fileThatDoesNotExist = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "does-not-exist");
     EXPECT_FALSE(FileSystem::volumeFreeSpace(fileThatDoesNotExist));
 }
 
@@ -533,10 +533,10 @@
 
 TEST_F(FileSystemTest, createSymbolicLinkFileDoesNotExist)
 {
-    String fileThatDoesNotExist = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "does-not-exist"_s);
+    String fileThatDoesNotExist = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "does-not-exist");
     EXPECT_FALSE(FileSystem::fileExists(fileThatDoesNotExist));
 
-    auto symlinkPath = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "does-not-exist-symlink"_s);
+    auto symlinkPath = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "does-not-exist-symlink");
     EXPECT_FALSE(FileSystem::fileExists(symlinkPath));
     EXPECT_TRUE(FileSystem::createSymbolicLink(fileThatDoesNotExist, symlinkPath));
     EXPECT_FALSE(FileSystem::fileExists(symlinkPath));
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to