Title: [277514] trunk
Revision
277514
Author
[email protected]
Date
2021-05-14 16:08:03 -0700 (Fri, 14 May 2021)

Log Message

Rename FileSystem::getVolumeFreeSpace() to FileSystem::volumeFreeSpace()
https://bugs.webkit.org/show_bug.cgi?id=225811

Reviewed by Darin Adler.

Source/WebKit:

Update code base due to API change.

* NetworkProcess/cache/NetworkCache.cpp:
(WebKit::NetworkCache::computeCapacity):

Source/WTF:

Rename FileSystem::getVolumeFreeSpace() to FileSystem::volumeFreeSpace() given that we
avoid the "get" prefix in WebKit. Also modernize the function by returning an
Optional<uint64_t> instead of using an out-parameter.

* wtf/FileSystem.cpp:
(WTF::FileSystemImpl::volumeFreeSpace):
* wtf/FileSystem.h:

Tools:

Update code base due to API change.

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

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (277513 => 277514)


--- trunk/Source/WTF/ChangeLog	2021-05-14 22:32:03 UTC (rev 277513)
+++ trunk/Source/WTF/ChangeLog	2021-05-14 23:08:03 UTC (rev 277514)
@@ -1,3 +1,18 @@
+2021-05-14  Chris Dumez  <[email protected]>
+
+        Rename FileSystem::getVolumeFreeSpace() to FileSystem::volumeFreeSpace()
+        https://bugs.webkit.org/show_bug.cgi?id=225811
+
+        Reviewed by Darin Adler.
+
+        Rename FileSystem::getVolumeFreeSpace() to FileSystem::volumeFreeSpace() given that we
+        avoid the "get" prefix in WebKit. Also modernize the function by returning an
+        Optional<uint64_t> instead of using an out-parameter.
+
+        * wtf/FileSystem.cpp:
+        (WTF::FileSystemImpl::volumeFreeSpace):
+        * wtf/FileSystem.h:
+
 2021-05-14  Devin Rousso  <[email protected]>
 
         Promote `-[WKWebView _pageExtendedBackgroundColor]` SPI to `-[WKWebView underPageBackgroundColor]` API

Modified: trunk/Source/WTF/wtf/FileSystem.cpp (277513 => 277514)


--- trunk/Source/WTF/wtf/FileSystem.cpp	2021-05-14 22:32:03 UTC (rev 277513)
+++ trunk/Source/WTF/wtf/FileSystem.cpp	2021-05-14 23:08:03 UTC (rev 277514)
@@ -625,14 +625,13 @@
     return !ec;
 }
 
-bool getVolumeFreeSpace(const String& path, uint64_t& freeSpace)
+Optional<uint64_t> volumeFreeSpace(const String& path)
 {
     std::error_code ec;
     auto spaceInfo = std::filesystem::space(toStdFileSystemPath(path), ec);
     if (ec)
-        return false;
-    freeSpace = spaceInfo.available;
-    return true;
+        return WTF::nullopt;
+    return spaceInfo.available;
 }
 
 bool createSymbolicLink(const String& targetPath, const String& symbolicLinkPath)

Modified: trunk/Source/WTF/wtf/FileSystem.h (277513 => 277514)


--- trunk/Source/WTF/wtf/FileSystem.h	2021-05-14 22:32:03 UTC (rev 277513)
+++ trunk/Source/WTF/wtf/FileSystem.h	2021-05-14 23:08:03 UTC (rev 277514)
@@ -126,7 +126,7 @@
 WTF_EXPORT_PRIVATE bool makeAllDirectories(const String& path);
 WTF_EXPORT_PRIVATE String pathFileName(const String&);
 WTF_EXPORT_PRIVATE String parentPath(const String&);
-WTF_EXPORT_PRIVATE bool getVolumeFreeSpace(const String&, uint64_t&);
+WTF_EXPORT_PRIVATE Optional<uint64_t> volumeFreeSpace(const String&);
 WTF_EXPORT_PRIVATE Optional<int32_t> getFileDeviceId(const CString&);
 WTF_EXPORT_PRIVATE bool createSymbolicLink(const String& targetPath, const String& symbolicLinkPath);
 WTF_EXPORT_PRIVATE String createTemporaryZipArchive(const String& directory);

Modified: trunk/Source/WebKit/ChangeLog (277513 => 277514)


--- trunk/Source/WebKit/ChangeLog	2021-05-14 22:32:03 UTC (rev 277513)
+++ trunk/Source/WebKit/ChangeLog	2021-05-14 23:08:03 UTC (rev 277514)
@@ -1,3 +1,15 @@
+2021-05-14  Chris Dumez  <[email protected]>
+
+        Rename FileSystem::getVolumeFreeSpace() to FileSystem::volumeFreeSpace()
+        https://bugs.webkit.org/show_bug.cgi?id=225811
+
+        Reviewed by Darin Adler.
+
+        Update code base due to API change.
+
+        * NetworkProcess/cache/NetworkCache.cpp:
+        (WebKit::NetworkCache::computeCapacity):
+
 2021-05-14  Wenson Hsieh  <[email protected]>
 
         Replace -[WKContentView _hasPendingImageExtraction] with a monotonically increasing ID

Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp (277513 => 277514)


--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp	2021-05-14 22:32:03 UTC (rev 277513)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp	2021-05-14 23:08:03 UTC (rev 277514)
@@ -66,12 +66,11 @@
 {
     unsigned urlCacheMemoryCapacity = 0;
     uint64_t urlCacheDiskCapacity = 0;
-    uint64_t diskFreeSize = 0;
-    if (FileSystem::getVolumeFreeSpace(cachePath, diskFreeSize)) {
+    if (auto diskFreeSize = FileSystem::volumeFreeSpace(cachePath)) {
         // As a fudge factor, use 1000 instead of 1024, in case the reported byte
         // count doesn't align exactly to a megabyte boundary.
-        diskFreeSize /= KB * 1000;
-        calculateURLCacheSizes(cacheModel, diskFreeSize, urlCacheMemoryCapacity, urlCacheDiskCapacity);
+        *diskFreeSize /= KB * 1000;
+        calculateURLCacheSizes(cacheModel, *diskFreeSize, urlCacheMemoryCapacity, urlCacheDiskCapacity);
     }
     return urlCacheDiskCapacity;
 }

Modified: trunk/Tools/ChangeLog (277513 => 277514)


--- trunk/Tools/ChangeLog	2021-05-14 22:32:03 UTC (rev 277513)
+++ trunk/Tools/ChangeLog	2021-05-14 23:08:03 UTC (rev 277514)
@@ -1,3 +1,15 @@
+2021-05-14  Chris Dumez  <[email protected]>
+
+        Rename FileSystem::getVolumeFreeSpace() to FileSystem::volumeFreeSpace()
+        https://bugs.webkit.org/show_bug.cgi?id=225811
+
+        Reviewed by Darin Adler.
+
+        Update code base due to API change.
+
+        * TestWebKitAPI/Tests/WTF/FileSystem.cpp:
+        (TestWebKitAPI::TEST_F):
+
 2021-05-14  Jean-Yves Avenard  <[email protected]>
 
         TestWebKitAPI.Fullscreen.WKViewDelegate is timing out

Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp (277513 => 277514)


--- trunk/Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp	2021-05-14 22:32:03 UTC (rev 277513)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp	2021-05-14 23:08:03 UTC (rev 277514)
@@ -543,14 +543,14 @@
     EXPECT_FALSE(FileSystem::fileExists(subFolderPath));
 }
 
-TEST_F(FileSystemTest, getVolumeFreeSpace)
+TEST_F(FileSystemTest, volumeFreeSpace)
 {
-    uint64_t freeSpace = 0;
-    EXPECT_TRUE(FileSystem::getVolumeFreeSpace(tempFilePath(), freeSpace));
-    EXPECT_GT(freeSpace, 0U);
+    auto freeSpace = FileSystem::volumeFreeSpace(tempFilePath());
+    ASSERT_TRUE(freeSpace);
+    EXPECT_GT(*freeSpace, 0U);
 
     String fileThatDoesNotExist = FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "does-not-exist"_s);
-    EXPECT_FALSE(FileSystem::getVolumeFreeSpace(fileThatDoesNotExist, freeSpace));
+    EXPECT_FALSE(FileSystem::volumeFreeSpace(fileThatDoesNotExist));
 }
 
 TEST_F(FileSystemTest, createSymbolicLink)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to