Title: [277492] trunk
Revision
277492
Author
[email protected]
Date
2021-05-14 09:10:38 -0700 (Fri, 14 May 2021)

Log Message

Rename FileSystem::getFileSize() to FileSystem::fileSize()
https://bugs.webkit.org/show_bug.cgi?id=225798

Reviewed by Alex Christensen.

Source/_javascript_Core:

Update code path to due to the API change.

* inspector/remote/socket/RemoteInspectorSocket.cpp:
(Inspector::RemoteInspector::backendCommands const):
* jsc.cpp:

Source/WebCore:

Update code path to due to the API change.

* Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
(WebCore::IDBServer::SQLiteIDBBackingStore::databasesSizeForDirectory):
* Modules/webdatabase/DatabaseDetails.h:
(WebCore::DatabaseDetails::DatabaseDetails):
* Modules/webdatabase/DatabaseTracker.cpp:
(WebCore::DatabaseTracker::hasAdequateQuotaForOrigin):
(WebCore::DatabaseTracker::canEstablishDatabase):
(WebCore::DatabaseTracker::retryCanEstablishDatabase):
(WebCore::DatabaseTracker::maximumSize):
(WebCore::DatabaseTracker::detailsForNameAndOrigin):
(WebCore::DatabaseTracker::setDatabaseDetails):
(WebCore::DatabaseTracker::usage):
(WebCore::DatabaseTracker::quotaNoLock):
(WebCore::DatabaseTracker::quota):
(WebCore::DatabaseTracker::setQuota):
(WebCore::isZeroByteFile):
* Modules/webdatabase/DatabaseTracker.h:
* editing/cocoa/WebContentReaderCocoa.mm:
(WebCore::attachmentForFilePath):
* loader/appcache/ApplicationCacheStorage.cpp:
(WebCore::ApplicationCacheStorage::spaceNeeded):
(WebCore::ApplicationCacheStorage::loadCache):
(WebCore::ApplicationCacheStorage::flatFileAreaSize):
* platform/FileStream.cpp:
(WebCore::FileStream::getSize):
* platform/network/FormData.cpp:
(WebCore::FormDataElement::lengthInBytes const):
* platform/network/curl/CurlCacheEntry.cpp:
(WebCore::CurlCacheEntry::loadFileToBuffer):
* platform/network/curl/CurlCacheManager.cpp:
(WebCore::CurlCacheManager::loadIndex):
* platform/sql/SQLiteFileSystem.cpp:
(WebCore::SQLiteFileSystem::databaseFileSize):
* platform/sql/SQLiteFileSystem.h:
* rendering/RenderThemeWin.cpp:
(WebCore::RenderThemeWin::stringWithContentsOfFile):
* workers/service/server/SWScriptStorage.cpp:
(WebCore::shouldUseFileMapping):
(WebCore::SWScriptStorage::retrieve):

Source/WebKit:

Update code path to due to the API change.

* NetworkProcess/WebStorage/LocalStorageDatabase.cpp:
(WebKit::LocalStorageDatabase::setItem):
* NetworkProcess/WebStorage/LocalStorageDatabase.h:
* NetworkProcess/cache/CacheStorageEngine.cpp:
(WebKit::CacheStorage::getDirectorySize):
(WebKit::CacheStorage::Engine::readSizeFile):
* NetworkProcess/cache/NetworkCacheBlobStorage.cpp:
(WebKit::NetworkCache::BlobStorage::synchronize):
* NetworkProcess/cache/NetworkCacheData.cpp:
(WebKit::NetworkCache::mapFile):
* NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp:
(WebKit::NetworkCache::IOChannel::read):
* Shared/PersistencyUtils.cpp:
(WebKit::createForFile):
* UIProcess/DeviceIdHashSaltStorage.cpp:
(WebKit::DeviceIdHashSaltStorage::loadStorageFromDisk):

Source/WebKitLegacy:

Update code path to due to the API change.

* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin):
* Storage/StorageTracker.h:

Source/WTF:

Rename FileSystem::getFileSize() to FileSystem::fileSize() as we usually avoid the "get"
prefix in WebKit. It is also more consistent with the std::filesystem::file_size() the
implementation relies on.

Also have it return an Optional<uint64_t> instead of taking a long long out-parameter, as
this is more modern.

* wtf/FileSystem.cpp:
(WTF::FileSystemImpl::fileSize):
* wtf/FileSystem.h:
* wtf/glib/FileSystemGlib.cpp:
(WTF::FileSystemImpl::fileSize):
* wtf/posix/FileSystemPOSIX.cpp:
(WTF::FileSystemImpl::fileSize):
* wtf/win/FileSystemWin.cpp:
(WTF::FileSystemImpl::getFileSizeFromByHandleFileInformationStructure):
(WTF::FileSystemImpl::fileSize):
(WTF::FileSystemImpl::MappedFileData::mapFileHandle):

Tools:

Update code path to due to the API change.

* TestWebKitAPI/Tests/WTF/FileSystem.cpp:
(TestWebKitAPI::TEST_F):
* TestWebKitAPI/Tests/WebCore/cocoa/DatabaseTrackerTest.mm:
(TestWebKitAPI::TEST):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (277491 => 277492)


--- trunk/Source/_javascript_Core/ChangeLog	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/_javascript_Core/ChangeLog	2021-05-14 16:10:38 UTC (rev 277492)
@@ -1,3 +1,16 @@
+2021-05-14  Chris Dumez  <[email protected]>
+
+        Rename FileSystem::getFileSize() to FileSystem::fileSize()
+        https://bugs.webkit.org/show_bug.cgi?id=225798
+
+        Reviewed by Alex Christensen.
+
+        Update code path to due to the API change.
+
+        * inspector/remote/socket/RemoteInspectorSocket.cpp:
+        (Inspector::RemoteInspector::backendCommands const):
+        * jsc.cpp:
+
 2021-05-13  Darin Adler  <[email protected]>
 
         Follow-up fix for: Remove StringBuilder::appendNumber

Modified: trunk/Source/_javascript_Core/inspector/remote/socket/RemoteInspectorSocket.cpp (277491 => 277492)


--- trunk/Source/_javascript_Core/inspector/remote/socket/RemoteInspectorSocket.cpp	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/_javascript_Core/inspector/remote/socket/RemoteInspectorSocket.cpp	2021-05-14 16:10:38 UTC (rev 277492)
@@ -268,10 +268,9 @@
         return { };
 
     String result;
-    long long size;
-    if (FileSystem::getFileSize(handle, size)) {
-        Vector<LChar> buffer(size);
-        if (FileSystem::readFromFile(handle, reinterpret_cast<char*>(buffer.data()), size) == size)
+    if (auto size = FileSystem::fileSize(handle)) {
+        Vector<LChar> buffer(*size);
+        if (FileSystem::readFromFile(handle, reinterpret_cast<char*>(buffer.data()), *size) == *size)
             result = String::adopt(WTFMove(buffer));
     }
     FileSystem::closeFile(handle);

Modified: trunk/Source/_javascript_Core/jsc.cpp (277491 => 277492)


--- trunk/Source/_javascript_Core/jsc.cpp	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/_javascript_Core/jsc.cpp	2021-05-14 16:10:38 UTC (rev 277492)
@@ -1049,12 +1049,12 @@
             FileSystem::unlockAndCloseFile(fd);
         });
 
-        long long fileSize;
-        if (!FileSystem::getFileSize(fd, fileSize))
+        auto fileSize = FileSystem::fileSize(fd);
+        if (!fileSize)
             return;
 
         size_t cacheFileSize;
-        if (!WTF::convertSafely(fileSize, cacheFileSize) || cacheFileSize != m_cachedBytecode->size()) {
+        if (!WTF::convertSafely(*fileSize, cacheFileSize) || cacheFileSize != m_cachedBytecode->size()) {
             // The bytecode cache has already been updated
             return;
         }

Modified: trunk/Source/WTF/ChangeLog (277491 => 277492)


--- trunk/Source/WTF/ChangeLog	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WTF/ChangeLog	2021-05-14 16:10:38 UTC (rev 277492)
@@ -1,5 +1,31 @@
 2021-05-14  Chris Dumez  <[email protected]>
 
+        Rename FileSystem::getFileSize() to FileSystem::fileSize()
+        https://bugs.webkit.org/show_bug.cgi?id=225798
+
+        Reviewed by Alex Christensen.
+
+        Rename FileSystem::getFileSize() to FileSystem::fileSize() as we usually avoid the "get"
+        prefix in WebKit. It is also more consistent with the std::filesystem::file_size() the
+        implementation relies on.
+
+        Also have it return an Optional<uint64_t> instead of taking a long long out-parameter, as
+        this is more modern.
+
+        * wtf/FileSystem.cpp:
+        (WTF::FileSystemImpl::fileSize):
+        * wtf/FileSystem.h:
+        * wtf/glib/FileSystemGlib.cpp:
+        (WTF::FileSystemImpl::fileSize):
+        * wtf/posix/FileSystemPOSIX.cpp:
+        (WTF::FileSystemImpl::fileSize):
+        * wtf/win/FileSystemWin.cpp:
+        (WTF::FileSystemImpl::getFileSizeFromByHandleFileInformationStructure):
+        (WTF::FileSystemImpl::fileSize):
+        (WTF::FileSystemImpl::MappedFileData::mapFileHandle):
+
+2021-05-14  Chris Dumez  <[email protected]>
+
         Rename FileSystem::pathGetFileName() to FileSystem::pathFileName()
         https://bugs.webkit.org/show_bug.cgi?id=225806
 

Modified: trunk/Source/WTF/wtf/FileSystem.cpp (277491 => 277492)


--- trunk/Source/WTF/wtf/FileSystem.cpp	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WTF/wtf/FileSystem.cpp	2021-05-14 16:10:38 UTC (rev 277492)
@@ -597,14 +597,13 @@
     return std::filesystem::remove_all(fsOldPath, ec);
 }
 
-bool getFileSize(const String& path, long long& result)
+Optional<uint64_t> fileSize(const String& path)
 {
     std::error_code ec;
     auto size = std::filesystem::file_size(toStdFileSystemPath(path), ec);
     if (ec)
-        return false;
-    result = size;
-    return true;
+        return WTF::nullopt;
+    return size;
 }
 
 bool isDirectory(const String& path)

Modified: trunk/Source/WTF/wtf/FileSystem.h (277491 => 277492)


--- trunk/Source/WTF/wtf/FileSystem.h	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WTF/wtf/FileSystem.h	2021-05-14 16:10:38 UTC (rev 277492)
@@ -111,8 +111,8 @@
 WTF_EXPORT_PRIVATE bool deleteFile(const String&);
 WTF_EXPORT_PRIVATE bool deleteEmptyDirectory(const String&);
 WTF_EXPORT_PRIVATE bool moveFile(const String& oldPath, const String& newPath);
-WTF_EXPORT_PRIVATE bool getFileSize(const String&, long long& result);
-WTF_EXPORT_PRIVATE bool getFileSize(PlatformFileHandle, long long& result);
+WTF_EXPORT_PRIVATE Optional<uint64_t> fileSize(const String&);
+WTF_EXPORT_PRIVATE Optional<uint64_t> fileSize(PlatformFileHandle);
 WTF_EXPORT_PRIVATE Optional<WallTime> getFileModificationTime(const String&);
 WTF_EXPORT_PRIVATE Optional<WallTime> getFileCreationTime(const String&); // Not all platforms store file creation time.
 WTF_EXPORT_PRIVATE Optional<FileMetadata> fileMetadata(const String& path);

Modified: trunk/Source/WTF/wtf/glib/FileSystemGlib.cpp (277491 => 277492)


--- trunk/Source/WTF/wtf/glib/FileSystemGlib.cpp	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WTF/wtf/glib/FileSystemGlib.cpp	2021-05-14 16:10:38 UTC (rev 277492)
@@ -120,14 +120,13 @@
 #endif
 }
 
-bool getFileSize(PlatformFileHandle handle, long long& resultSize)
+Optional<uint64_t> fileSize(PlatformFileHandle handle)
 {
     GRefPtr<GFileInfo> info = adoptGRef(g_file_io_stream_query_info(handle, G_FILE_ATTRIBUTE_STANDARD_SIZE, nullptr, nullptr));
     if (!info)
-        return false;
+        return WTF::nullopt;
 
-    resultSize = g_file_info_get_size(info.get());
-    return true;
+    return g_file_info_get_size(info.get());
 }
 
 Optional<WallTime> getFileCreationTime(const String&)

Modified: trunk/Source/WTF/wtf/posix/FileSystemPOSIX.cpp (277491 => 277492)


--- trunk/Source/WTF/wtf/posix/FileSystemPOSIX.cpp	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WTF/wtf/posix/FileSystemPOSIX.cpp	2021-05-14 16:10:38 UTC (rev 277492)
@@ -156,14 +156,13 @@
 }
 #endif
 
-bool getFileSize(PlatformFileHandle handle, long long& result)
+Optional<uint64_t> fileSize(PlatformFileHandle handle)
 {
     struct stat fileInfo;
     if (fstat(handle, &fileInfo))
-        return false;
+        return WTF::nullopt;
 
-    result = fileInfo.st_size;
-    return true;
+    return fileInfo.st_size;
 }
 
 Optional<WallTime> getFileCreationTime(const String& path)

Modified: trunk/Source/WTF/wtf/win/FileSystemWin.cpp (277491 => 277492)


--- trunk/Source/WTF/wtf/win/FileSystemWin.cpp	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WTF/wtf/win/FileSystemWin.cpp	2021-05-14 16:10:38 UTC (rev 277492)
@@ -71,7 +71,7 @@
     return true;
 }
 
-static bool getFileSizeFromByHandleFileInformationStructure(const BY_HANDLE_FILE_INFORMATION& fileInformation, long long& size)
+static Optional<uint64_t> getFileSizeFromByHandleFileInformationStructure(const BY_HANDLE_FILE_INFORMATION& fileInformation)
 {
     ULARGE_INTEGER fileSize;
     fileSize.HighPart = fileInformation.nFileSizeHigh;
@@ -78,10 +78,9 @@
     fileSize.LowPart = fileInformation.nFileSizeLow;
 
     if (fileSize.QuadPart > static_cast<ULONGLONG>(std::numeric_limits<long long>::max()))
-        return false;
+        return WTF::nullopt;
 
-    size = fileSize.QuadPart;
-    return true;
+    return fileSize.QuadPart;
 }
 
 static void getFileCreationTimeFromFindData(const WIN32_FIND_DATAW& findData, time_t& time)
@@ -105,13 +104,13 @@
     time = fileTime.QuadPart / 10000000 - kSecondsFromFileTimeToTimet;
 }
 
-bool getFileSize(PlatformFileHandle fileHandle, long long& size)
+Optional<uint64_t> fileSize(PlatformFileHandle fileHandle)
 {
     BY_HANDLE_FILE_INFORMATION fileInformation;
     if (!::GetFileInformationByHandle(fileHandle, &fileInformation))
-        return false;
+        return WTF::nullopt;
 
-    return getFileSizeFromByHandleFileInformationStructure(fileInformation, size);
+    return getFileSizeFromByHandleFileInformationStructure(fileInformation);
 }
 
 Optional<WallTime> getFileCreationTime(const String& path)
@@ -403,12 +402,12 @@
     if (!isHandleValid(handle))
         return false;
 
-    long long size;
-    if (!getFileSize(handle, size) || size > std::numeric_limits<size_t>::max() || size > std::numeric_limits<decltype(m_fileSize)>::max()) {
+    auto size = fileSize(handle);
+    if (!size || *size > std::numeric_limits<size_t>::max() || *size > std::numeric_limits<decltype(m_fileSize)>::max()) {
         return false;
     }
 
-    if (!size) {
+    if (!*size) {
         return true;
     }
 
@@ -433,11 +432,11 @@
     if (!mapping)
         return false;
 
-    m_fileData = MapViewOfFile(mapping, desiredAccess, 0, 0, size);
+    m_fileData = MapViewOfFile(mapping, desiredAccess, 0, 0, *size);
     CloseHandle(mapping);
     if (!m_fileData)
         return false;
-    m_fileSize = size;
+    m_fileSize = *size;
     return true;
 }
 

Modified: trunk/Source/WebCore/ChangeLog (277491 => 277492)


--- trunk/Source/WebCore/ChangeLog	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WebCore/ChangeLog	2021-05-14 16:10:38 UTC (rev 277492)
@@ -1,5 +1,54 @@
 2021-05-14  Chris Dumez  <[email protected]>
 
+        Rename FileSystem::getFileSize() to FileSystem::fileSize()
+        https://bugs.webkit.org/show_bug.cgi?id=225798
+
+        Reviewed by Alex Christensen.
+
+        Update code path to due to the API change.
+
+        * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
+        (WebCore::IDBServer::SQLiteIDBBackingStore::databasesSizeForDirectory):
+        * Modules/webdatabase/DatabaseDetails.h:
+        (WebCore::DatabaseDetails::DatabaseDetails):
+        * Modules/webdatabase/DatabaseTracker.cpp:
+        (WebCore::DatabaseTracker::hasAdequateQuotaForOrigin):
+        (WebCore::DatabaseTracker::canEstablishDatabase):
+        (WebCore::DatabaseTracker::retryCanEstablishDatabase):
+        (WebCore::DatabaseTracker::maximumSize):
+        (WebCore::DatabaseTracker::detailsForNameAndOrigin):
+        (WebCore::DatabaseTracker::setDatabaseDetails):
+        (WebCore::DatabaseTracker::usage):
+        (WebCore::DatabaseTracker::quotaNoLock):
+        (WebCore::DatabaseTracker::quota):
+        (WebCore::DatabaseTracker::setQuota):
+        (WebCore::isZeroByteFile):
+        * Modules/webdatabase/DatabaseTracker.h:
+        * editing/cocoa/WebContentReaderCocoa.mm:
+        (WebCore::attachmentForFilePath):
+        * loader/appcache/ApplicationCacheStorage.cpp:
+        (WebCore::ApplicationCacheStorage::spaceNeeded):
+        (WebCore::ApplicationCacheStorage::loadCache):
+        (WebCore::ApplicationCacheStorage::flatFileAreaSize):
+        * platform/FileStream.cpp:
+        (WebCore::FileStream::getSize):
+        * platform/network/FormData.cpp:
+        (WebCore::FormDataElement::lengthInBytes const):
+        * platform/network/curl/CurlCacheEntry.cpp:
+        (WebCore::CurlCacheEntry::loadFileToBuffer):
+        * platform/network/curl/CurlCacheManager.cpp:
+        (WebCore::CurlCacheManager::loadIndex):
+        * platform/sql/SQLiteFileSystem.cpp:
+        (WebCore::SQLiteFileSystem::databaseFileSize):
+        * platform/sql/SQLiteFileSystem.h:
+        * rendering/RenderThemeWin.cpp:
+        (WebCore::RenderThemeWin::stringWithContentsOfFile):
+        * workers/service/server/SWScriptStorage.cpp:
+        (WebCore::shouldUseFileMapping):
+        (WebCore::SWScriptStorage::retrieve):
+
+2021-05-14  Chris Dumez  <[email protected]>
+
         Rename FileSystem::pathGetFileName() to FileSystem::pathFileName()
         https://bugs.webkit.org/show_bug.cgi?id=225806
 

Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp (277491 => 277492)


--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp	2021-05-14 16:10:38 UTC (rev 277492)
@@ -1284,7 +1284,7 @@
         auto dbDirectoryPath = FileSystem::pathByAppendingComponent(directory, dbDirectoryName);
         for (auto& fileName : FileSystem::listDirectory(dbDirectoryPath)) {
             if (fileName.endsWith(".sqlite3"))
-                diskUsage += SQLiteFileSystem::getDatabaseFileSize(FileSystem::pathByAppendingComponent(dbDirectoryPath, fileName));
+                diskUsage += SQLiteFileSystem::databaseFileSize(FileSystem::pathByAppendingComponent(dbDirectoryPath, fileName));
         }
     }
     return diskUsage;

Modified: trunk/Source/WebCore/Modules/webdatabase/DatabaseDetails.h (277491 => 277492)


--- trunk/Source/WebCore/Modules/webdatabase/DatabaseDetails.h	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WebCore/Modules/webdatabase/DatabaseDetails.h	2021-05-14 16:10:38 UTC (rev 277492)
@@ -66,7 +66,7 @@
         return *this;
     }
 
-    DatabaseDetails(const String& databaseName, const String& displayName, unsigned long long expectedUsage, unsigned long long currentUsage, Optional<WallTime> creationTime, Optional<WallTime> modificationTime)
+    DatabaseDetails(const String& databaseName, const String& displayName, uint64_t expectedUsage, uint64_t currentUsage, Optional<WallTime> creationTime, Optional<WallTime> modificationTime)
         : m_name(databaseName)
         , m_displayName(displayName)
         , m_expectedUsage(expectedUsage)

Modified: trunk/Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp (277491 => 277492)


--- trunk/Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp	2021-05-14 16:10:38 UTC (rev 277492)
@@ -141,13 +141,13 @@
     }
 }
 
-ExceptionOr<void> DatabaseTracker::hasAdequateQuotaForOrigin(const SecurityOriginData& origin, unsigned long long estimatedSize)
+ExceptionOr<void> DatabaseTracker::hasAdequateQuotaForOrigin(const SecurityOriginData& origin, uint64_t estimatedSize)
 {
     ASSERT(!m_databaseGuard.tryLock());
     auto usage = this->usage(origin);
 
     // If the database will fit, allow its creation.
-    auto requirement = usage + std::max<unsigned long long>(1, estimatedSize);
+    auto requirement = usage + std::max<uint64_t>(1u, estimatedSize);
     if (requirement < usage) {
         // The estimated size is so big it causes an overflow; don't allow creation.
         return Exception { SecurityError };
@@ -157,7 +157,7 @@
     return { };
 }
 
-ExceptionOr<void> DatabaseTracker::canEstablishDatabase(DatabaseContext& context, const String& name, unsigned long long estimatedSize)
+ExceptionOr<void> DatabaseTracker::canEstablishDatabase(DatabaseContext& context, const String& name, uint64_t estimatedSize)
 {
     LockHolder lockDatabase(m_databaseGuard);
 
@@ -205,7 +205,7 @@
 // hasAdequateQuotaForOrigin() simple and correct (i.e. bug free), and just
 // re-use it. Also note that the path for opening a database involves IO, and
 // hence should not be a performance critical path anyway. 
-ExceptionOr<void> DatabaseTracker::retryCanEstablishDatabase(DatabaseContext& context, const String& name, unsigned long long estimatedSize)
+ExceptionOr<void> DatabaseTracker::retryCanEstablishDatabase(DatabaseContext& context, const String& name, uint64_t estimatedSize)
 {
     LockHolder lockDatabase(m_databaseGuard);
 
@@ -267,7 +267,7 @@
     return statement.step() == SQLITE_ROW;
 }
 
-unsigned long long DatabaseTracker::maximumSize(Database& database)
+uint64_t DatabaseTracker::maximumSize(Database& database)
 {
     // The maximum size for a database is the full quota for its origin, minus the current usage within the origin,
     // plus the current usage of the given database
@@ -274,9 +274,9 @@
     LockHolder lockDatabase(m_databaseGuard);
     auto origin = database.securityOrigin();
 
-    unsigned long long quota = quotaNoLock(origin);
-    unsigned long long diskUsage = usage(origin);
-    unsigned long long databaseFileSize = SQLiteFileSystem::getDatabaseFileSize(database.fileNameIsolatedCopy());
+    auto quota = quotaNoLock(origin);
+    auto diskUsage = usage(origin);
+    auto databaseFileSize = SQLiteFileSystem::databaseFileSize(database.fileNameIsolatedCopy());
     ASSERT(databaseFileSize <= diskUsage);
 
     if (diskUsage > quota)
@@ -286,7 +286,7 @@
     // have allowed this database to exceed our cached estimate of the origin
     // disk usage. Don't multiply that error through integer underflow, or the
     // effective quota will permanently become 2^64.
-    unsigned long long maxSize = quota - diskUsage + databaseFileSize;
+    uint64_t maxSize = quota - diskUsage + databaseFileSize;
     if (maxSize > quota)
         maxSize = databaseFileSize;
     return maxSize;
@@ -461,10 +461,10 @@
     String path = fullPathForDatabase(origin, name, false);
     if (path.isEmpty())
         return DatabaseDetails(name, displayName, expectedUsage, 0, WTF::nullopt, WTF::nullopt);
-    return DatabaseDetails(name, displayName, expectedUsage, SQLiteFileSystem::getDatabaseFileSize(path), SQLiteFileSystem::databaseCreationTime(path), SQLiteFileSystem::databaseModificationTime(path));
+    return DatabaseDetails(name, displayName, expectedUsage, SQLiteFileSystem::databaseFileSize(path), SQLiteFileSystem::databaseCreationTime(path), SQLiteFileSystem::databaseModificationTime(path));
 }
 
-void DatabaseTracker::setDatabaseDetails(const SecurityOriginData& origin, const String& name, const String& displayName, unsigned long long estimatedSize)
+void DatabaseTracker::setDatabaseDetails(const SecurityOriginData& origin, const String& name, const String& displayName, uint64_t estimatedSize)
 {
     String originIdentifier = origin.databaseIdentifier();
     int64_t guid = 0;
@@ -651,21 +651,21 @@
     OriginLock::deleteLockFile(originPath(origin));
 }
 
-unsigned long long DatabaseTracker::usage(const SecurityOriginData& origin)
+uint64_t DatabaseTracker::usage(const SecurityOriginData& origin)
 {
     String originPath = this->originPath(origin);
-    unsigned long long diskUsage = 0;
+    uint64_t diskUsage = 0;
     for (auto& fileName : FileSystem::listDirectory(originPath)) {
         if (fileName.endsWith(".db"))
-            diskUsage += SQLiteFileSystem::getDatabaseFileSize(FileSystem::pathByAppendingComponent(originPath, fileName));
+            diskUsage += SQLiteFileSystem::databaseFileSize(FileSystem::pathByAppendingComponent(originPath, fileName));
     }
     return diskUsage;
 }
 
-unsigned long long DatabaseTracker::quotaNoLock(const SecurityOriginData& origin)
+uint64_t DatabaseTracker::quotaNoLock(const SecurityOriginData& origin)
 {
     ASSERT(!m_databaseGuard.tryLock());
-    unsigned long long quota = 0;
+    uint64_t quota = 0;
 
     openTrackerDatabase(DontCreateIfDoesNotExist);
     if (!m_database.isOpen())
@@ -684,13 +684,13 @@
     return quota;
 }
 
-unsigned long long DatabaseTracker::quota(const SecurityOriginData& origin)
+uint64_t DatabaseTracker::quota(const SecurityOriginData& origin)
 {
     LockHolder lockDatabase(m_databaseGuard);
     return quotaNoLock(origin);
 }
 
-void DatabaseTracker::setQuota(const SecurityOriginData& origin, unsigned long long quota)
+void DatabaseTracker::setQuota(const SecurityOriginData& origin, uint64_t quota)
 {
     LockHolder lockDatabase(m_databaseGuard);
 
@@ -1243,8 +1243,8 @@
     
 static bool isZeroByteFile(const String& path)
 {
-    long long size = 0;
-    return FileSystem::getFileSize(path, size) && !size;
+    auto size = FileSystem::fileSize(path);
+    return size && !*size;
 }
     
 bool DatabaseTracker::deleteDatabaseFileIfEmpty(const String& path)

Modified: trunk/Source/WebCore/Modules/webdatabase/DatabaseTracker.h (277491 => 277492)


--- trunk/Source/WebCore/Modules/webdatabase/DatabaseTracker.h	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WebCore/Modules/webdatabase/DatabaseTracker.h	2021-05-14 16:10:38 UTC (rev 277492)
@@ -67,10 +67,10 @@
     // m_databaseGuard and m_openDatabaseMapGuard currently don't overlap.
     // notificationMutex() is currently independent of the other locks.
 
-    ExceptionOr<void> canEstablishDatabase(DatabaseContext&, const String& name, unsigned long long estimatedSize);
-    ExceptionOr<void> retryCanEstablishDatabase(DatabaseContext&, const String& name, unsigned long long estimatedSize);
+    ExceptionOr<void> canEstablishDatabase(DatabaseContext&, const String& name, uint64_t estimatedSize);
+    ExceptionOr<void> retryCanEstablishDatabase(DatabaseContext&, const String& name, uint64_t estimatedSize);
 
-    void setDatabaseDetails(const SecurityOriginData&, const String& name, const String& displayName, unsigned long long estimatedSize);
+    void setDatabaseDetails(const SecurityOriginData&, const String& name, const String& displayName, uint64_t estimatedSize);
     WEBCORE_EXPORT String fullPathForDatabase(const SecurityOriginData&, const String& name, bool createIfDoesNotExist);
 
     Vector<Ref<Database>> openDatabases();
@@ -77,7 +77,7 @@
     void addOpenDatabase(Database&);
     void removeOpenDatabase(Database&);
 
-    unsigned long long maximumSize(Database&);
+    uint64_t maximumSize(Database&);
 
     WEBCORE_EXPORT void closeAllDatabases(CurrentQueryBehavior = CurrentQueryBehavior::RunToCompletion);
 
@@ -86,9 +86,9 @@
 
     DatabaseDetails detailsForNameAndOrigin(const String&, const SecurityOriginData&);
 
-    WEBCORE_EXPORT unsigned long long usage(const SecurityOriginData&);
-    WEBCORE_EXPORT unsigned long long quota(const SecurityOriginData&);
-    WEBCORE_EXPORT void setQuota(const SecurityOriginData&, unsigned long long);
+    WEBCORE_EXPORT uint64_t usage(const SecurityOriginData&);
+    WEBCORE_EXPORT uint64_t quota(const SecurityOriginData&);
+    WEBCORE_EXPORT void setQuota(const SecurityOriginData&, uint64_t);
     RefPtr<OriginLock> originLockFor(const SecurityOriginData&);
 
     WEBCORE_EXPORT void deleteAllDatabasesImmediately();
@@ -119,12 +119,12 @@
 private:
     explicit DatabaseTracker(const String& databasePath);
 
-    ExceptionOr<void> hasAdequateQuotaForOrigin(const SecurityOriginData&, unsigned long long estimatedSize);
+    ExceptionOr<void> hasAdequateQuotaForOrigin(const SecurityOriginData&, uint64_t estimatedSize);
 
     bool hasEntryForOriginNoLock(const SecurityOriginData&);
     String fullPathForDatabaseNoLock(const SecurityOriginData&, const String& name, bool createIfDoesNotExist);
     Vector<String> databaseNamesNoLock(const SecurityOriginData&);
-    unsigned long long quotaNoLock(const SecurityOriginData&);
+    uint64_t quotaNoLock(const SecurityOriginData&);
 
     String trackerDatabasePath() const;
 

Modified: trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm (277491 => 277492)


--- trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm	2021-05-14 16:10:38 UTC (rev 277492)
@@ -727,11 +727,8 @@
     }
 
     Optional<uint64_t> fileSizeForDisplay;
-    if (!isDirectory) {
-        long long fileSize;
-        FileSystem::getFileSize(path, fileSize);
-        fileSizeForDisplay = fileSize;
-    }
+    if (!isDirectory)
+        fileSizeForDisplay = FileSystem::fileSize(path).valueOr(0);
 
     frame.editor().registerAttachmentIdentifier(attachment->ensureUniqueIdentifier(), contentType, path);
 

Modified: trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp (277491 => 277492)


--- trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp	2021-05-14 16:10:38 UTC (rev 277492)
@@ -369,11 +369,11 @@
 int64_t ApplicationCacheStorage::spaceNeeded(int64_t cacheToSave)
 {
     int64_t spaceNeeded = 0;
-    long long fileSize = 0;
-    if (!FileSystem::getFileSize(m_cacheFile, fileSize))
+    auto fileSize = FileSystem::fileSize(m_cacheFile);
+    if (!fileSize)
         return 0;
 
-    int64_t currentSize = fileSize + flatFileAreaSize();
+    int64_t currentSize = *fileSize + flatFileAreaSize();
 
     // Determine the amount of free space we have available.
     int64_t totalAvailableSize = 0;
@@ -1126,7 +1126,7 @@
             size = data->size();
         else {
             path = FileSystem::pathByAppendingComponent(flatFileDirectory, path);
-            FileSystem::getFileSize(path, size);
+            size = FileSystem::fileSize(path).valueOr(0);
         }
         
         String mimeType = cacheStatement.getColumnText(3);
@@ -1456,12 +1456,8 @@
     long long totalSize = 0;
     String flatFileDirectory = FileSystem::pathByAppendingComponent(m_cacheDirectory, m_flatFileSubdirectoryName);
     while (selectPaths.step() == SQLITE_ROW) {
-        String path = selectPaths.getColumnText(0);
-        String fullPath = FileSystem::pathByAppendingComponent(flatFileDirectory, path);
-        long long pathSize = 0;
-        if (!FileSystem::getFileSize(fullPath, pathSize))
-            continue;
-        totalSize += pathSize;
+        auto fullPath = FileSystem::pathByAppendingComponent(flatFileDirectory, selectPaths.getColumnText(0));
+        totalSize += FileSystem::fileSize(fullPath).valueOr(0);
     }
     
     return totalSize;

Modified: trunk/Source/WebCore/platform/FileStream.cpp (277491 => 277492)


--- trunk/Source/WebCore/platform/FileStream.cpp	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WebCore/platform/FileStream.cpp	2021-05-14 16:10:38 UTC (rev 277492)
@@ -59,11 +59,11 @@
     }
 
     // Now get the file size.
-    long long length;
-    if (!FileSystem::getFileSize(path, length))
+    auto length = FileSystem::fileSize(path);
+    if (!length)
         return -1;
 
-    return length;
+    return *length;
 }
 
 bool FileStream::openForRead(const String& path, long long offset, long long length)

Modified: trunk/Source/WebCore/platform/network/FormData.cpp (277491 => 277492)


--- trunk/Source/WebCore/platform/network/FormData.cpp	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WebCore/platform/network/FormData.cpp	2021-05-14 16:10:38 UTC (rev 277492)
@@ -131,10 +131,7 @@
         }, [] (const FormDataElement::EncodedFileData& fileData) {
             if (fileData.fileLength != BlobDataItem::toEndOfFile)
                 return static_cast<uint64_t>(fileData.fileLength);
-            long long fileSize;
-            if (FileSystem::getFileSize(fileData.filename, fileSize))
-                return static_cast<uint64_t>(fileSize);
-            return static_cast<uint64_t>(0);
+            return FileSystem::fileSize(fileData.filename).valueOr(0);
         }, [&blobSize] (const FormDataElement::EncodedBlobData& blobData) {
             return blobSize(blobData.url);
         }

Modified: trunk/Source/WebCore/platform/network/curl/CurlCacheEntry.cpp (277491 => 277492)


--- trunk/Source/WebCore/platform/network/curl/CurlCacheEntry.cpp	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WebCore/platform/network/curl/CurlCacheEntry.cpp	2021-05-14 16:10:38 UTC (rev 277492)
@@ -232,8 +232,8 @@
         return false;
     }
 
-    long long filesize = -1;
-    if (!FileSystem::getFileSize(filepath, filesize)) {
+    auto filesize = FileSystem::fileSize(filepath);
+    if (!filesize) {
         LOG(Network, "Cache Error: Could not get file size of %s\n", filepath.latin1().data());
         FileSystem::closeFile(inputFile);
         return false;
@@ -240,13 +240,13 @@
     }
 
     // Load the file content into buffer
-    buffer.resize(filesize);
+    buffer.resize(*filesize);
     int bufferPosition = 0;
     int bufferReadSize = 4096;
     int bytesRead = 0;
-    while (filesize > bufferPosition) {
-        if (filesize - bufferPosition < bufferReadSize)
-            bufferReadSize = filesize - bufferPosition;
+    while (*filesize > bufferPosition) {
+        if (*filesize - bufferPosition < bufferReadSize)
+            bufferReadSize = *filesize - bufferPosition;
 
         bytesRead = FileSystem::readFromFile(inputFile, buffer.data() + bufferPosition, bufferReadSize);
         if (bytesRead != bufferReadSize) {
@@ -330,19 +330,18 @@
 size_t CurlCacheEntry::entrySize()
 {
     if (!m_entrySize) {
-        long long headerFileSize;
-        long long contentFileSize;
-
-        if (!FileSystem::getFileSize(m_headerFilename, headerFileSize)) {
+        auto headerFileSize = FileSystem::fileSize(m_headerFilename);
+        if (!headerFileSize) {
             LOG(Network, "Cache Error: Could not get file size of %s\n", m_headerFilename.latin1().data());
             return m_entrySize;
         }
-        if (!FileSystem::getFileSize(m_contentFilename, contentFileSize)) {
+        auto contentFileSize = FileSystem::fileSize(m_contentFilename);
+        if (!contentFileSize) {
             LOG(Network, "Cache Error: Could not get file size of %s\n", m_contentFilename.latin1().data());
             return m_entrySize;
         }
 
-        m_entrySize = headerFileSize + contentFileSize;
+        m_entrySize = *headerFileSize + *contentFileSize;
     }
 
     return m_entrySize;

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


--- trunk/Source/WebCore/platform/network/curl/CurlCacheManager.cpp	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WebCore/platform/network/curl/CurlCacheManager.cpp	2021-05-14 16:10:38 UTC (rev 277492)
@@ -109,8 +109,8 @@
         return;
     }
 
-    long long filesize = -1;
-    if (!FileSystem::getFileSize(indexFilePath, filesize)) {
+    auto filesize = FileSystem::fileSize(indexFilePath);
+    if (!filesize) {
         LOG(Network, "Cache Error: Could not get file size of %s\n", indexFilePath.latin1().data());
         FileSystem::closeFile(indexFile);
         return;
@@ -118,12 +118,12 @@
 
     // Load the file content into buffer
     Vector<char> buffer;
-    buffer.resize(filesize);
+    buffer.resize(*filesize);
     int bufferPosition = 0;
     int bufferReadSize = IO_BUFFERSIZE;
-    while (filesize > bufferPosition) {
-        if (filesize - bufferPosition < bufferReadSize)
-            bufferReadSize = filesize - bufferPosition;
+    while (*filesize > bufferPosition) {
+        if (*filesize - bufferPosition < bufferReadSize)
+            bufferReadSize = *filesize - bufferPosition;
 
         FileSystem::readFromFile(indexFile, buffer.data() + bufferPosition, bufferReadSize);
         bufferPosition += bufferReadSize;

Modified: trunk/Source/WebCore/platform/sql/SQLiteFileSystem.cpp (277491 => 277492)


--- trunk/Source/WebCore/platform/sql/SQLiteFileSystem.cpp	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WebCore/platform/sql/SQLiteFileSystem.cpp	2021-05-14 16:10:38 UTC (rev 277492)
@@ -98,19 +98,18 @@
 }
 #endif
     
-long long SQLiteFileSystem::getDatabaseFileSize(const String& fileName)
+uint64_t SQLiteFileSystem::databaseFileSize(const String& fileName)
 {        
-    long long fileSize = 0;
-    long long totalSize = 0;
+    uint64_t totalSize = 0;
 
-    if (FileSystem::getFileSize(fileName, fileSize))
-        totalSize += fileSize;
+    if (auto fileSize = FileSystem::fileSize(fileName))
+        totalSize += *fileSize;
 
-    if (FileSystem::getFileSize(makeString(fileName, "-wal"_s), fileSize))
-        totalSize += fileSize;
+    if (auto fileSize = FileSystem::fileSize(makeString(fileName, "-wal"_s)))
+        totalSize += *fileSize;
 
-    if (FileSystem::getFileSize(makeString(fileName, "-shm"_s), fileSize))
-        totalSize += fileSize;
+    if (auto fileSize = FileSystem::fileSize(makeString(fileName, "-shm"_s)))
+        totalSize += *fileSize;
 
     return totalSize;
 }

Modified: trunk/Source/WebCore/platform/sql/SQLiteFileSystem.h (277491 => 277492)


--- trunk/Source/WebCore/platform/sql/SQLiteFileSystem.h	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WebCore/platform/sql/SQLiteFileSystem.h	2021-05-14 16:10:38 UTC (rev 277492)
@@ -89,7 +89,7 @@
     static bool truncateDatabaseFile(sqlite3* database);
 #endif
     
-    WEBCORE_EXPORT static long long getDatabaseFileSize(const String& fileName);
+    WEBCORE_EXPORT static uint64_t databaseFileSize(const String& fileName);
     WEBCORE_EXPORT static Optional<WallTime> databaseCreationTime(const String& fileName);
     WEBCORE_EXPORT static Optional<WallTime> databaseModificationTime(const String& fileName);
 

Modified: trunk/Source/WebCore/rendering/RenderThemeWin.cpp (277491 => 277492)


--- trunk/Source/WebCore/rendering/RenderThemeWin.cpp	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WebCore/rendering/RenderThemeWin.cpp	2021-05-14 16:10:38 UTC (rev 277492)
@@ -1052,17 +1052,17 @@
     if (!FileSystem::isHandleValid(requestedFileHandle))
         return String();
 
-    long long filesize = -1;
-    if (!FileSystem::getFileSize(requestedFileHandle, filesize)) {
+    auto filesize = FileSystem::fileSize(requestedFileHandle);
+    if (!filesize) {
         FileSystem::closeFile(requestedFileHandle);
         return String();
     }
 
     Vector<char> fileContents;
-    fillBufferWithContentsOfFile(requestedFileHandle, filesize, fileContents);
+    fillBufferWithContentsOfFile(requestedFileHandle, *filesize, fileContents);
     FileSystem::closeFile(requestedFileHandle);
 
-    return String(fileContents.data(), static_cast<size_t>(filesize));
+    return String(fileContents.data(), *filesize);
 #else
     return emptyString();
 #endif

Modified: trunk/Source/WebCore/workers/service/server/SWScriptStorage.cpp (277491 => 277492)


--- trunk/Source/WebCore/workers/service/server/SWScriptStorage.cpp	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WebCore/workers/service/server/SWScriptStorage.cpp	2021-05-14 16:10:38 UTC (rev 277492)
@@ -37,7 +37,7 @@
 
 namespace WebCore {
 
-static bool shouldUseFileMapping(size_t fileSize)
+static bool shouldUseFileMapping(uint64_t fileSize)
 {
     return fileSize >= pageSize();
 }
@@ -120,14 +120,14 @@
     ASSERT(!isMainThread());
 
     auto scriptPath = this->scriptPath(registrationKey, scriptURL);
-    long long fileSize = 0;
-    if (!FileSystem::getFileSize(scriptPath, fileSize)) {
-        RELEASE_LOG_ERROR(ServiceWorker, "SWScriptStorage::retrieve: Failure to retrieve %s, FileSystem::getFileSize() failed", scriptPath.utf8().data());
+    auto fileSize = FileSystem::fileSize(scriptPath);
+    if (!fileSize) {
+        RELEASE_LOG_ERROR(ServiceWorker, "SWScriptStorage::retrieve: Failure to retrieve %s, FileSystem::fileSize() failed", scriptPath.utf8().data());
         return { };
     }
 
     // FIXME: Do we need to disable file mapping in more cases to avoid having too many file descriptors open?
-    return SharedBuffer::createWithContentsOfFile(scriptPath, FileSystem::MappedFileMode::Private, shouldUseFileMapping(fileSize) ? SharedBuffer::MayUseFileMapping::Yes : SharedBuffer::MayUseFileMapping::No);
+    return SharedBuffer::createWithContentsOfFile(scriptPath, FileSystem::MappedFileMode::Private, shouldUseFileMapping(*fileSize) ? SharedBuffer::MayUseFileMapping::Yes : SharedBuffer::MayUseFileMapping::No);
 }
 
 void SWScriptStorage::clear(const ServiceWorkerRegistrationKey& registrationKey)

Modified: trunk/Source/WebKit/ChangeLog (277491 => 277492)


--- trunk/Source/WebKit/ChangeLog	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WebKit/ChangeLog	2021-05-14 16:10:38 UTC (rev 277492)
@@ -1,5 +1,31 @@
 2021-05-14  Chris Dumez  <[email protected]>
 
+        Rename FileSystem::getFileSize() to FileSystem::fileSize()
+        https://bugs.webkit.org/show_bug.cgi?id=225798
+
+        Reviewed by Alex Christensen.
+
+        Update code path to due to the API change.
+
+        * NetworkProcess/WebStorage/LocalStorageDatabase.cpp:
+        (WebKit::LocalStorageDatabase::setItem):
+        * NetworkProcess/WebStorage/LocalStorageDatabase.h:
+        * NetworkProcess/cache/CacheStorageEngine.cpp:
+        (WebKit::CacheStorage::getDirectorySize):
+        (WebKit::CacheStorage::Engine::readSizeFile):
+        * NetworkProcess/cache/NetworkCacheBlobStorage.cpp:
+        (WebKit::NetworkCache::BlobStorage::synchronize):
+        * NetworkProcess/cache/NetworkCacheData.cpp:
+        (WebKit::NetworkCache::mapFile):
+        * NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp:
+        (WebKit::NetworkCache::IOChannel::read):
+        * Shared/PersistencyUtils.cpp:
+        (WebKit::createForFile):
+        * UIProcess/DeviceIdHashSaltStorage.cpp:
+        (WebKit::DeviceIdHashSaltStorage::loadStorageFromDisk):
+
+2021-05-14  Chris Dumez  <[email protected]>
+
         Rename FileSystem::pathGetFileName() to FileSystem::pathFileName()
         https://bugs.webkit.org/show_bug.cgi?id=225806
 

Modified: trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.cpp (277491 => 277492)


--- trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.cpp	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.cpp	2021-05-14 16:10:38 UTC (rev 277492)
@@ -224,8 +224,8 @@
 
     if (m_quotaInBytes != WebCore::StorageMap::noQuota) {
         if (!m_databaseSize)
-            m_databaseSize = SQLiteFileSystem::getDatabaseFileSize(m_databasePath);
-        CheckedUint32 newDatabaseSize = *m_databaseSize;
+            m_databaseSize = SQLiteFileSystem::databaseFileSize(m_databasePath);
+        CheckedUint64 newDatabaseSize = *m_databaseSize;
         newDatabaseSize -= oldValue.sizeInBytes();
         newDatabaseSize += value.sizeInBytes();
         if (oldValue.isNull())

Modified: trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.h (277491 => 277492)


--- trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.h	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabase.h	2021-05-14 16:10:38 UTC (rev 277492)
@@ -68,7 +68,7 @@
     mutable WebCore::SQLiteDatabase m_database;
     const unsigned m_quotaInBytes { 0 };
     bool m_isClosed { false };
-    Optional<unsigned> m_databaseSize;
+    Optional<uint64_t> m_databaseSize;
 
     mutable std::unique_ptr<WebCore::SQLiteStatement> m_clearStatement;
     mutable std::unique_ptr<WebCore::SQLiteStatement> m_insertStatement;

Modified: trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp (277491 => 277492)


--- trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp	2021-05-14 16:10:38 UTC (rev 277492)
@@ -217,10 +217,7 @@
             }
             continue;
         }
-
-        long long fileSize = 0;
-        FileSystem::getFileSize(path, fileSize);
-        directorySize += fileSize;
+        directorySize += FileSystem::fileSize(path).valueOr(0);
     }
     return directorySize;
 }
@@ -566,8 +563,8 @@
     if (!FileSystem::isHandleValid(fileHandle))
         return WTF::nullopt;
 
-    long long fileSize = 0;
-    if (!FileSystem::getFileSize(path, fileSize) || !fileSize)
+    auto fileSize = FileSystem::fileSize(path).valueOr(0);
+    if (!fileSize)
         return WTF::nullopt;
 
     unsigned bytesToRead;

Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheBlobStorage.cpp (277491 => 277492)


--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheBlobStorage.cpp	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheBlobStorage.cpp	2021-05-14 16:10:38 UTC (rev 277492)
@@ -69,11 +69,8 @@
         // No clients left for this blob.
         if (linkCount && *linkCount == 1)
             FileSystem::deleteFile(path);
-        else {
-            long long fileSize = 0;
-            FileSystem::getFileSize(path, fileSize);
-            m_approximateSize += fileSize;
-        }
+        else
+            m_approximateSize += FileSystem::fileSize(path).valueOr(0);
     });
 
     LOG(NetworkCacheStorage, "(NetworkProcess) blob synchronization completed approximateSize=%zu", approximateSize());

Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheData.cpp (277491 => 277492)


--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheData.cpp	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheData.cpp	2021-05-14 16:10:38 UTC (rev 277492)
@@ -54,12 +54,12 @@
     auto file = FileSystem::openFile(path, FileSystem::FileOpenMode::Read);
     if (!FileSystem::isHandleValid(file))
         return { };
-    long long size;
-    if (!FileSystem::getFileSize(file, size)) {
+    auto size = FileSystem::fileSize(file);
+    if (!size) {
         FileSystem::closeFile(file);
         return { };
     }
-    return adoptAndMapFile(file, 0, size);
+    return adoptAndMapFile(file, 0, *size);
 }
 
 Data mapFile(const String& path)

Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp (277491 => 277492)


--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp	2021-05-14 16:10:38 UTC (rev 277492)
@@ -58,13 +58,13 @@
 void IOChannel::read(size_t offset, size_t size, WorkQueue& queue, Function<void(Data&, int error)>&& completionHandler)
 {
     queue.dispatch([this, protectedThis = makeRef(*this), offset, size, completionHandler = WTFMove(completionHandler)] {
-        long long fileSize;
-        if (!FileSystem::getFileSize(m_fileDescriptor, fileSize) || fileSize > std::numeric_limits<size_t>::max()) {
+        auto fileSize = FileSystem::fileSize(m_fileDescriptor);
+        if (!fileSize || *fileSize > std::numeric_limits<size_t>::max()) {
             Data data;
             completionHandler(data, -1);
             return;
         }
-        size_t readSize = fileSize;
+        size_t readSize = *fileSize;
         readSize = std::min(size, readSize);
         Vector<uint8_t> buffer(readSize);
         FileSystem::seekFile(m_fileDescriptor, offset, FileSystem::FileSeekOrigin::Beginning);

Modified: trunk/Source/WebKit/Shared/PersistencyUtils.cpp (277491 => 277492)


--- trunk/Source/WebKit/Shared/PersistencyUtils.cpp	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WebKit/Shared/PersistencyUtils.cpp	2021-05-14 16:10:38 UTC (rev 277492)
@@ -43,8 +43,8 @@
     if (handle == FileSystem::invalidPlatformFileHandle)
         return nullptr;
 
-    long long fileSize = 0;
-    if (!FileSystem::getFileSize(handle, fileSize) || !fileSize) {
+    auto fileSize = FileSystem::fileSize(handle).valueOr(0);
+    if (!fileSize) {
         FileSystem::unlockAndCloseFile(handle);
         return nullptr;
     }

Modified: trunk/Source/WebKit/UIProcess/DeviceIdHashSaltStorage.cpp (277491 => 277492)


--- trunk/Source/WebKit/UIProcess/DeviceIdHashSaltStorage.cpp	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WebKit/UIProcess/DeviceIdHashSaltStorage.cpp	2021-05-14 16:10:38 UTC (rev 277492)
@@ -124,8 +124,7 @@
                 continue;
             }
 
-            long long fileSize = 0;
-            if (!FileSystem::getFileSize(originPath, fileSize)) {
+            if (!FileSystem::fileSize(originPath)) {
                 RELEASE_LOG_ERROR(DiskPersistency, "DeviceIdHashSaltStorage: Impossible to get the file size of: '%s'", originPath.utf8().data());
                 continue;
             }

Modified: trunk/Source/WebKitLegacy/ChangeLog (277491 => 277492)


--- trunk/Source/WebKitLegacy/ChangeLog	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WebKitLegacy/ChangeLog	2021-05-14 16:10:38 UTC (rev 277492)
@@ -1,3 +1,16 @@
+2021-05-14  Chris Dumez  <[email protected]>
+
+        Rename FileSystem::getFileSize() to FileSystem::fileSize()
+        https://bugs.webkit.org/show_bug.cgi?id=225798
+
+        Reviewed by Alex Christensen.
+
+        Update code path to due to the API change.
+
+        * Storage/StorageTracker.cpp:
+        (WebKit::StorageTracker::diskUsageForOrigin):
+        * Storage/StorageTracker.h:
+
 2021-05-13  Chris Dumez  <[email protected]>
 
         Rename FileSystem::directoryName() to FileSystem::parentPath()

Modified: trunk/Source/WebKitLegacy/Storage/StorageTracker.cpp (277491 => 277492)


--- trunk/Source/WebKitLegacy/Storage/StorageTracker.cpp	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WebKitLegacy/Storage/StorageTracker.cpp	2021-05-14 16:10:38 UTC (rev 277492)
@@ -627,7 +627,7 @@
     return pathStatement.getColumnText(0);
 }
     
-long long StorageTracker::diskUsageForOrigin(SecurityOrigin* origin)
+uint64_t StorageTracker::diskUsageForOrigin(SecurityOrigin* origin)
 {
     if (!m_isActive)
         return 0;
@@ -638,8 +638,7 @@
     if (path.isEmpty())
         return 0;
 
-    long long size;
-    return FileSystem::getFileSize(path, size) ? size : 0;
+    return FileSystem::fileSize(path).valueOr(0);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebKitLegacy/Storage/StorageTracker.h (277491 => 277492)


--- trunk/Source/WebKitLegacy/Storage/StorageTracker.h	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Source/WebKitLegacy/Storage/StorageTracker.h	2021-05-14 16:10:38 UTC (rev 277492)
@@ -54,7 +54,7 @@
     void deleteOrigin(const WebCore::SecurityOriginData&);
     void deleteOriginWithIdentifier(const String& originIdentifier);
     Vector<WebCore::SecurityOriginData> origins();
-    long long diskUsageForOrigin(WebCore::SecurityOrigin*);
+    uint64_t diskUsageForOrigin(WebCore::SecurityOrigin*);
     
     void cancelDeletingOrigin(const String& originIdentifier);
     

Modified: trunk/Tools/ChangeLog (277491 => 277492)


--- trunk/Tools/ChangeLog	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Tools/ChangeLog	2021-05-14 16:10:38 UTC (rev 277492)
@@ -1,5 +1,19 @@
 2021-05-14  Chris Dumez  <[email protected]>
 
+        Rename FileSystem::getFileSize() to FileSystem::fileSize()
+        https://bugs.webkit.org/show_bug.cgi?id=225798
+
+        Reviewed by Alex Christensen.
+
+        Update code path to due to the API change.
+
+        * TestWebKitAPI/Tests/WTF/FileSystem.cpp:
+        (TestWebKitAPI::TEST_F):
+        * TestWebKitAPI/Tests/WebCore/cocoa/DatabaseTrackerTest.mm:
+        (TestWebKitAPI::TEST):
+
+2021-05-14  Chris Dumez  <[email protected]>
+
         Rename FileSystem::pathGetFileName() to FileSystem::pathFileName()
         https://bugs.webkit.org/show_bug.cgi?id=225806
 

Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp (277491 => 277492)


--- trunk/Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp	2021-05-14 16:10:38 UTC (rev 277492)
@@ -443,20 +443,21 @@
     EXPECT_TRUE(FileSystem::fileExists(tempFilePath()));
     EXPECT_TRUE(FileSystem::fileExists(tempEmptyFilePath()));
 
-    long long fileSize = 0;
-    EXPECT_TRUE(FileSystem::getFileSize(tempFilePath(), fileSize));
-    EXPECT_GT(fileSize, 0);
+    auto fileSize = FileSystem::fileSize(tempFilePath());
+    ASSERT_TRUE(fileSize);
+    EXPECT_GT(*fileSize, 0U);
 
-    EXPECT_TRUE(FileSystem::getFileSize(tempEmptyFilePath(), fileSize));
-    EXPECT_TRUE(!fileSize);
+    fileSize = FileSystem::fileSize(tempEmptyFilePath());
+    ASSERT_TRUE(fileSize);
+    EXPECT_EQ(*fileSize, 0U);
 
     EXPECT_TRUE(FileSystem::moveFile(tempFilePath(), tempEmptyFilePath()));
     EXPECT_FALSE(FileSystem::fileExists(tempFilePath()));
     EXPECT_TRUE(FileSystem::fileExists(tempEmptyFilePath()));
 
-    fileSize = 0;
-    EXPECT_TRUE(FileSystem::getFileSize(tempEmptyFilePath(), fileSize));
-    EXPECT_GT(fileSize, 0);
+    fileSize = FileSystem::fileSize(tempEmptyFilePath());
+    ASSERT_TRUE(fileSize);
+    EXPECT_GT(*fileSize, 0U);
 }
 
 TEST_F(FileSystemTest, moveDirectory)
@@ -485,21 +486,21 @@
     EXPECT_TRUE(FileSystem::fileExists(destinationPath));
 }
 
-TEST_F(FileSystemTest, getFileSize)
+TEST_F(FileSystemTest, fileSize)
 {
     EXPECT_TRUE(FileSystem::fileExists(tempFilePath()));
     EXPECT_TRUE(FileSystem::fileExists(tempEmptyFilePath()));
 
-    long long fileSize = 0;
-    EXPECT_TRUE(FileSystem::getFileSize(tempFilePath(), fileSize));
-    EXPECT_GT(fileSize, 0);
+    auto fileSize = FileSystem::fileSize(tempFilePath());
+    ASSERT_TRUE(fileSize);
+    EXPECT_GT(*fileSize, 0U);
 
-    EXPECT_TRUE(FileSystem::getFileSize(tempEmptyFilePath(), fileSize));
-    EXPECT_TRUE(!fileSize);
+    fileSize = FileSystem::fileSize(tempEmptyFilePath());
+    ASSERT_TRUE(fileSize);
+    EXPECT_EQ(*fileSize, 0U);
 
-    fileSize = 0;
     String fileThatDoesNotExist = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "does-not-exist"_s);
-    EXPECT_FALSE(FileSystem::getFileSize(fileThatDoesNotExist, fileSize));
+    fileSize = FileSystem::fileSize(fileThatDoesNotExist);
     EXPECT_TRUE(!fileSize);
 }
 
@@ -604,20 +605,20 @@
     auto hardlinkPath = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "tempFile-hardlink");
     EXPECT_FALSE(FileSystem::fileExists(hardlinkPath));
 
-    long long fileSize = 0;
-    EXPECT_TRUE(FileSystem::getFileSize(tempFilePath(), fileSize));
-    EXPECT_GT(fileSize, 0);
+    auto fileSize = FileSystem::fileSize(tempFilePath());
+    ASSERT_TRUE(fileSize);
+    EXPECT_GT(*fileSize, 0U);
 
     EXPECT_TRUE(FileSystem::hardLink(tempFilePath(), hardlinkPath));
 
     EXPECT_TRUE(FileSystem::fileExists(hardlinkPath));
 
-    long long linkFileSize = 0;
-    EXPECT_TRUE(FileSystem::getFileSize(hardlinkPath, linkFileSize));
-    EXPECT_EQ(linkFileSize, fileSize);
+    auto linkFileSize = FileSystem::fileSize(hardlinkPath);
+    ASSERT_TRUE(linkFileSize);
+    EXPECT_EQ(*linkFileSize, *fileSize);
 
     auto hardlinkMetadata = FileSystem::fileMetadata(hardlinkPath);
-    EXPECT_TRUE(!!hardlinkMetadata);
+    ASSERT_TRUE(!!hardlinkMetadata);
     EXPECT_EQ(hardlinkMetadata->type, FileMetadata::Type::File);
 
     EXPECT_TRUE(FileSystem::deleteFile(tempFilePath()));
@@ -624,9 +625,9 @@
     EXPECT_FALSE(FileSystem::fileExists(tempFilePath()));
     EXPECT_TRUE(FileSystem::fileExists(hardlinkPath));
 
-    linkFileSize = 0;
-    EXPECT_TRUE(FileSystem::getFileSize(hardlinkPath, linkFileSize));
-    EXPECT_EQ(linkFileSize, fileSize);
+    linkFileSize = FileSystem::fileSize(hardlinkPath);
+    ASSERT_TRUE(linkFileSize);
+    EXPECT_EQ(*linkFileSize, *fileSize);
 }
 
 TEST_F(FileSystemTest, createHardLinkOrCopyFile)
@@ -634,17 +635,17 @@
     auto hardlinkPath = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "tempFile-hardlink");
     EXPECT_FALSE(FileSystem::fileExists(hardlinkPath));
 
-    long long fileSize = 0;
-    EXPECT_TRUE(FileSystem::getFileSize(tempFilePath(), fileSize));
-    EXPECT_GT(fileSize, 0);
+    auto fileSize = FileSystem::fileSize(tempFilePath());
+    ASSERT_TRUE(fileSize);
+    EXPECT_GT(*fileSize, 0U);
 
     EXPECT_TRUE(FileSystem::hardLinkOrCopyFile(tempFilePath(), hardlinkPath));
 
     EXPECT_TRUE(FileSystem::fileExists(hardlinkPath));
 
-    long long linkFileSize = 0;
-    EXPECT_TRUE(FileSystem::getFileSize(hardlinkPath, linkFileSize));
-    EXPECT_EQ(linkFileSize, fileSize);
+    auto linkFileSize = FileSystem::fileSize(hardlinkPath);
+    ASSERT_TRUE(linkFileSize);
+    EXPECT_EQ(*linkFileSize, *fileSize);
 
     auto hardlinkMetadata = FileSystem::fileMetadata(hardlinkPath);
     EXPECT_TRUE(!!hardlinkMetadata);
@@ -654,9 +655,9 @@
     EXPECT_FALSE(FileSystem::fileExists(tempFilePath()));
     EXPECT_TRUE(FileSystem::fileExists(hardlinkPath));
 
-    linkFileSize = 0;
-    EXPECT_TRUE(FileSystem::getFileSize(hardlinkPath, linkFileSize));
-    EXPECT_EQ(linkFileSize, fileSize);
+    linkFileSize = FileSystem::fileSize(hardlinkPath);
+    ASSERT_TRUE(linkFileSize);
+    EXPECT_EQ(*linkFileSize, *fileSize);
 }
 
 TEST_F(FileSystemTest, hardLinkCount)

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/cocoa/DatabaseTrackerTest.mm (277491 => 277492)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/cocoa/DatabaseTrackerTest.mm	2021-05-14 16:01:00 UTC (rev 277491)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/cocoa/DatabaseTrackerTest.mm	2021-05-14 16:10:38 UTC (rev 277492)
@@ -44,9 +44,8 @@
     String databaseFilePath = FileSystem::openTemporaryFile("tempEmptyDatabase", handle);
     FileSystem::closeFile(handle);
 
-    long long fileSize;
-    FileSystem::getFileSize(databaseFilePath, fileSize);
-    EXPECT_EQ(0, fileSize);
+    auto fileSize = FileSystem::fileSize(databaseFilePath).valueOr(0);
+    EXPECT_EQ(0U, fileSize);
 
     EXPECT_TRUE(DatabaseTracker::deleteDatabaseFileIfEmpty(databaseFilePath));
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to