Diff
Modified: trunk/Source/_javascript_Core/Configurations/_javascript_Core.xcconfig (277356 => 277357)
--- trunk/Source/_javascript_Core/Configurations/_javascript_Core.xcconfig 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Source/_javascript_Core/Configurations/_javascript_Core.xcconfig 2021-05-12 05:55:23 UTC (rev 277357)
@@ -27,7 +27,7 @@
MODULEMAP_FILE = $(SRCROOT)/_javascript_Core.modulemap;
// Prevent C++ standard library operator new, delete and their related exception types from being exported as weak symbols.
-OTHER_LDFLAGS_HIDE_SYMBOLS = -Wl,-unexported_symbol,__ZTISt9bad_alloc -Wl,-unexported_symbol,__ZTISt9exception -Wl,-unexported_symbol,__ZTSSt9bad_alloc -Wl,-unexported_symbol,__ZTSSt9exception -Wl,-unexported_symbol,__ZdlPvS_ -Wl,-unexported_symbol,__ZnwmPv -Wl,-unexported_symbol,__ZNKSt3__18functionIFvvEEclEv -Wl,-unexported_symbol,__ZNSt3__18functionIFvvEEC1EOS2_ -Wl,-unexported_symbol,__ZNSt3__18functionIFvvEEC2EOS2_ -Wl,-unexported_symbol,__ZNKSt3__18functionIFvRN3JSC17BytecodeGeneratorEPNS1_10RegisterIDEEEclES3_S5_ -Wl,-unexported_symbol,__ZNSt3__18functionIFvRN3JSC17BytecodeGeneratorEPNS1_10RegisterIDEEED1Ev -Wl,-unexported_symbol,__ZNSt3__18functionIFvRN3JSC17BytecodeGeneratorEPNS1_10RegisterIDEEED2Ev -Wl,-unexported_symbol,__ZNSt3__18functionIFvvEED1Ev -Wl,-unexported_symbol,__ZNSt3__18functionIFvvEED2Ev -Wl,-unexported_symbol,__ZTVNSt3__117bad_function_callE -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem24__is_pathable_char_arrayIPKcS4_cLb1EE11__range_endES4
_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem24__is_pathable_char_arrayIPKcS4_cLb1EE13__range_beginES4_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem8_PathCVTIcE14__append_rangeIPKcEENS_9enable_ifIXsr27__is_cpp17_forward_iteratorIT_EE5valueEvE4typeERNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEES8_S8_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem8_PathCVTIcE15__append_sourceIPKcEEvRNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEERKT_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem8_PathCVTIcE14__append_rangeIPKcEENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueEvE4typeERNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEES8_S8_ -Wl,-unexported_symbol,__ZNKSt3__14__fs10filesystem18directory_iteratordeEv -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem18directory_iteratorppEv -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem24__is_pathable_char_arrayIA10_cPccLb1EE11__range_endEPKc -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem2
4__is_pathable_char_arrayIA10_cPccLb1EE13__range_beginEPKc -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem4pathdVERKS2_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem8_PathCVTIcE15__append_sourceIA10_cEEvRNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEERKT_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem24__throw_filesystem_errorIJRPKcRKNS1_4pathERKNS_10error_codeEEEEvDpOT_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem14__is_separatorIcEENS_9enable_ifIXsr18__can_convert_charIT_EE5valueEbE4typeES4_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem24__is_pathable_char_arrayIPKcS4_cLb1EE15__first_or_nullES4_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem4path20__source_is_absoluteIcEEbT_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem4path6appendIPKcEENS_9enable_ifIXsr13__is_pathableIT_EE5valueERS2_E4typeERKS7_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem6u8pathIPKcEENS_9enable_ifIXsr13__is_pathableIT_EE5valueENS1_4pathEE4typeERKS6_;
+OTHER_LDFLAGS_HIDE_SYMBOLS = -Wl,-unexported_symbol,__ZTISt9bad_alloc -Wl,-unexported_symbol,__ZTISt9exception -Wl,-unexported_symbol,__ZTSSt9bad_alloc -Wl,-unexported_symbol,__ZTSSt9exception -Wl,-unexported_symbol,__ZdlPvS_ -Wl,-unexported_symbol,__ZnwmPv -Wl,-unexported_symbol,__ZNKSt3__18functionIFvvEEclEv -Wl,-unexported_symbol,__ZNSt3__18functionIFvvEEC1EOS2_ -Wl,-unexported_symbol,__ZNSt3__18functionIFvvEEC2EOS2_ -Wl,-unexported_symbol,__ZNKSt3__18functionIFvRN3JSC17BytecodeGeneratorEPNS1_10RegisterIDEEEclES3_S5_ -Wl,-unexported_symbol,__ZNSt3__18functionIFvRN3JSC17BytecodeGeneratorEPNS1_10RegisterIDEEED1Ev -Wl,-unexported_symbol,__ZNSt3__18functionIFvRN3JSC17BytecodeGeneratorEPNS1_10RegisterIDEEED2Ev -Wl,-unexported_symbol,__ZNSt3__18functionIFvvEED1Ev -Wl,-unexported_symbol,__ZNSt3__18functionIFvvEED2Ev -Wl,-unexported_symbol,__ZTVNSt3__117bad_function_callE -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem24__is_pathable_char_arrayIPKcS4_cLb1EE11__range_endES4_
-Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem24__is_pathable_char_arrayIPKcS4_cLb1EE13__range_beginES4_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem8_PathCVTIcE14__append_rangeIPKcEENS_9enable_ifIXsr27__is_cpp17_forward_iteratorIT_EE5valueEvE4typeERNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEES8_S8_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem8_PathCVTIcE15__append_sourceIPKcEEvRNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEERKT_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem8_PathCVTIcE14__append_rangeIPKcEENS_9enable_ifIXsr21__is_forward_iteratorIT_EE5valueEvE4typeERNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEES8_S8_ -Wl,-unexported_symbol,__ZNKSt3__14__fs10filesystem18directory_iteratordeEv -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem18directory_iteratorppEv -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem24__is_pathable_char_arrayIA10_cPccLb1EE11__range_endEPKc -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem24
__is_pathable_char_arrayIA10_cPccLb1EE13__range_beginEPKc -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem4pathdVERKS2_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem8_PathCVTIcE15__append_sourceIA10_cEEvRNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEERKT_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem24__throw_filesystem_errorIJRPKcRKNS1_4pathERKNS_10error_codeEEEEvDpOT_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem14__is_separatorIcEENS_9enable_ifIXsr18__can_convert_charIT_EE5valueEbE4typeES4_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem24__is_pathable_char_arrayIPKcS4_cLb1EE15__first_or_nullES4_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem4path20__source_is_absoluteIcEEbT_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem4path6appendIPKcEENS_9enable_ifIXsr13__is_pathableIT_EE5valueERS2_E4typeERKS7_ -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem6u8pathIPKcEENS_9enable_ifIXsr13__is_pathableIT_EE5valueENS1_4pathEE4typeERKS6_ -Wl,-unexported
_symbol,__ZNKSt3__14__fs10filesystem18directory_iteratorptEv -Wl,-unexported_symbol,__ZNSt3__14__fs10filesystem18directory_iterator9incrementERNS_10error_codeE;
OTHER_LDFLAGS_BASE = $(OTHER_LDFLAGS_HIDE_SYMBOLS) -force_load "$(BUILT_PRODUCTS_DIR)/DerivedSources/_javascript_Core/libWTF.a";
OTHER_LDFLAGS[sdk=embedded*] = $(inherited) $(OTHER_LDFLAGS_BASE);
Modified: trunk/Source/WTF/ChangeLog (277356 => 277357)
--- trunk/Source/WTF/ChangeLog 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Source/WTF/ChangeLog 2021-05-12 05:55:23 UTC (rev 277357)
@@ -1,3 +1,22 @@
+2021-05-11 Chris Dumez <cdu...@apple.com>
+
+ Port WTF::FileSystem::listDirectory to std::filesystem
+ https://bugs.webkit.org/show_bug.cgi?id=225633
+
+ Reviewed by Darin Adler.
+
+ Port WTF::FileSystem::listDirectory to std::filesystem with the following 2 changes:
+ - The function no longer takes a (blob-style) filter parameter
+ - The function now returns file names instead of file paths, allowing the call sites
+ to more easily filter based on prefixes.
+
+ * wtf/FileSystem.cpp:
+ (WTF::FileSystemImpl::listDirectory):
+ * wtf/FileSystem.h:
+ * wtf/glib/FileSystemGlib.cpp:
+ * wtf/posix/FileSystemPOSIX.cpp:
+ * wtf/win/FileSystemWin.cpp:
+
2021-05-11 Darin Adler <da...@apple.com>
Remove the String::toInt family of functions
Modified: trunk/Source/WTF/wtf/FileSystem.cpp (277356 => 277357)
--- trunk/Source/WTF/wtf/FileSystem.cpp 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Source/WTF/wtf/FileSystem.cpp 2021-05-12 05:55:23 UTC (rev 277357)
@@ -562,8 +562,9 @@
#if PLATFORM(MAC)
bool containsSingleDSStoreFile = false;
- for (auto& entry : std::filesystem::directory_iterator(fsPath, ec)) {
- if (entry.path().filename() == ".DS_Store")
+ auto entries = std::filesystem::directory_iterator(fsPath, ec);
+ for (auto it = std::filesystem::begin(entries), end = std::filesystem::end(entries); !ec && it != end; it.increment(ec)) {
+ if (it->path().filename() == ".DS_Store")
containsSingleDSStoreFile = true;
else {
containsSingleDSStoreFile = false;
@@ -752,5 +753,18 @@
return fromStdFileSystemPath(fsPath);
}
+Vector<String> listDirectory(const String& path)
+{
+ Vector<String> fileNames;
+ std::error_code ec;
+ auto entries = std::filesystem::directory_iterator(toStdFileSystemPath(path), ec);
+ for (auto it = std::filesystem::begin(entries), end = std::filesystem::end(entries); !ec && it != end; it.increment(ec)) {
+ auto fileName = fromStdFileSystemPath(it->path().filename());
+ if (!fileName.isNull())
+ fileNames.append(WTFMove(fileName));
+ }
+ return fileNames;
+}
+
} // namespace FileSystemImpl
} // namespace WTF
Modified: trunk/Source/WTF/wtf/FileSystem.h (277356 => 277357)
--- trunk/Source/WTF/wtf/FileSystem.h 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Source/WTF/wtf/FileSystem.h 2021-05-12 05:55:23 UTC (rev 277357)
@@ -137,7 +137,7 @@
bool canExcludeFromBackup(); // Returns true if any file can ever be excluded from backup.
bool excludeFromBackup(const String&); // Returns true if successful.
-WTF_EXPORT_PRIVATE Vector<String> listDirectory(const String& path, const String& filter);
+WTF_EXPORT_PRIVATE Vector<String> listDirectory(const String& path); // Returns file names, not full paths.
WTF_EXPORT_PRIVATE CString fileSystemRepresentation(const String&);
WTF_EXPORT_PRIVATE String stringFromFileSystemRepresentation(const char*);
Modified: trunk/Source/WTF/wtf/glib/FileSystemGlib.cpp (277356 => 277357)
--- trunk/Source/WTF/wtf/glib/FileSystemGlib.cpp 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Source/WTF/wtf/glib/FileSystemGlib.cpp 2021-05-12 05:55:23 UTC (rev 277357)
@@ -141,30 +141,6 @@
return stringFromFileSystemRepresentation(g_get_home_dir());
}
-Vector<String> listDirectory(const String& path, const String& filter)
-{
- Vector<String> entries;
-
- auto filename = fileSystemRepresentation(path);
- if (!validRepresentation(filename))
- return entries;
-
- GUniquePtr<GDir> dir(g_dir_open(filename.data(), 0, nullptr));
- if (!dir)
- return entries;
-
- GUniquePtr<GPatternSpec> pspec(g_pattern_spec_new((filter.utf8()).data()));
- while (const char* name = g_dir_read_name(dir.get())) {
- if (!g_pattern_match_string(pspec.get(), name))
- continue;
-
- GUniquePtr<gchar> entry(g_build_filename(filename.data(), name, nullptr));
- entries.append(stringFromFileSystemRepresentation(entry.get()));
- }
-
- return entries;
-}
-
String openTemporaryFile(const String& prefix, PlatformFileHandle& handle, const String& suffix)
{
// FIXME: Suffix is not supported, but OK for now since the code using it is macOS-port-only.
Modified: trunk/Source/WTF/wtf/posix/FileSystemPOSIX.cpp (277356 => 277357)
--- trunk/Source/WTF/wtf/posix/FileSystemPOSIX.cpp 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Source/WTF/wtf/posix/FileSystemPOSIX.cpp 2021-05-12 05:55:23 UTC (rev 277357)
@@ -186,36 +186,6 @@
#endif
}
-Vector<String> listDirectory(const String& path, const String& filter)
-{
- Vector<String> entries;
- CString cpath = fileSystemRepresentation(path);
- CString cfilter = fileSystemRepresentation(filter);
- DIR* dir = opendir(cpath.data());
- if (dir) {
- struct dirent* dp;
- while ((dp = readdir(dir))) {
- const char* name = dp->d_name;
- if (!strcmp(name, ".") || !strcmp(name, ".."))
- continue;
- if (fnmatch(cfilter.data(), name, 0))
- continue;
- char filePath[PATH_MAX];
- if (static_cast<int>(sizeof(filePath) - 1) < snprintf(filePath, sizeof(filePath), "%s/%s", cpath.data(), name))
- continue; // buffer overflow
-
- auto string = stringFromFileSystemRepresentation(filePath);
-
- // Some file system representations cannot be represented as a UTF-16 string,
- // so this string might be null.
- if (!string.isNull())
- entries.append(WTFMove(string));
- }
- closedir(dir);
- }
- return entries;
-}
-
#if !USE(CF)
String stringFromFileSystemRepresentation(const char* path)
{
Modified: trunk/Source/WTF/wtf/win/FileSystemWin.cpp (277356 => 277357)
--- trunk/Source/WTF/wtf/win/FileSystemWin.cpp 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Source/WTF/wtf/win/FileSystemWin.cpp 2021-05-12 05:55:23 UTC (rev 277357)
@@ -364,25 +364,6 @@
return cachedStorageDirectory(CSIDL_APPDATA);
}
-Vector<String> listDirectory(const String& directory, const String& filter)
-{
- Vector<String> entries;
-
- PathWalker walker(directory, filter);
- if (!walker.isValid())
- return entries;
-
- do {
- if (walker.data().dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY
- && (!wcscmp(walker.data().cFileName, L".") || !wcscmp(walker.data().cFileName, L"..")))
- continue;
-
- entries.append(directory + "\\" + reinterpret_cast<const UChar*>(walker.data().cFileName));
- } while (walker.step());
-
- return entries;
-}
-
Optional<int32_t> getFileDeviceId(const CString& fsFile)
{
auto handle = openFile(fsFile.data(), FileOpenMode::Read);
Modified: trunk/Source/WebCore/ChangeLog (277356 => 277357)
--- trunk/Source/WebCore/ChangeLog 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Source/WebCore/ChangeLog 2021-05-12 05:55:23 UTC (rev 277357)
@@ -1,5 +1,41 @@
2021-05-11 Chris Dumez <cdu...@apple.com>
+ Port WTF::FileSystem::listDirectory to std::filesystem
+ https://bugs.webkit.org/show_bug.cgi?id=225633
+
+ Reviewed by Darin Adler.
+
+ Update FileSystem::listDirectory() call sites to deal with the fact that:
+ - The function now returns file names instead of full file paths
+ - The callers now have to do filtering by themselves if they need it
+
+ * Modules/entriesapi/DOMFileSystem.cpp:
+ (WebCore::listDirectoryWithMetadata):
+ * Modules/indexeddb/server/IDBServer.cpp:
+ (WebCore::IDBServer::IDBServer::getAllDatabaseNamesAndVersions):
+ (WebCore::IDBServer::collectOriginsForVersion):
+ (WebCore::IDBServer::removeAllDatabasesForFullOriginPath):
+ (WebCore::IDBServer::removeAllDatabasesForOriginPath):
+ (WebCore::IDBServer::IDBServer::removeDatabasesModifiedSinceForVersion):
+ (WebCore::IDBServer::IDBServer::removeDatabasesWithOriginsForVersion):
+ * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
+ (WebCore::IDBServer::SQLiteIDBBackingStore::fullDatabaseDirectoryWithUpgrade):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::databasesSizeForDirectory):
+ * Modules/webdatabase/DatabaseTracker.cpp:
+ (WebCore::DatabaseTracker::usage):
+ (WebCore::DatabaseTracker::deleteOrigin):
+ * html/DirectoryFileListCreator.cpp:
+ (WebCore::appendDirectoryFiles):
+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+ (WebCore::MediaPlayerPrivateGStreamer::uriDecodeBinElementAddedCallback):
+ (WebCore::MediaPlayerPrivateGStreamer::purgeOldDownloadFiles):
+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
+ * platform/text/hyphen/HyphenationLibHyphen.cpp:
+ (WebCore::extractLocaleFromDictionaryFileName):
+ (WebCore::scanDirectoryForDictionaries):
+
+2021-05-11 Chris Dumez <cdu...@apple.com>
+
Add SPI to suspend / resume a WKWebView
https://bugs.webkit.org/show_bug.cgi?id=225333
<rdar://77462543>
Modified: trunk/Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp (277356 => 277357)
--- trunk/Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp 2021-05-12 05:55:23 UTC (rev 277357)
@@ -54,14 +54,14 @@
if (!FileSystem::fileIsDirectory(fullPath, FileSystem::ShouldFollowSymbolicLinks::No))
return Exception { NotFoundError, "Path no longer exists or is no longer a directory" };
- auto childPaths = FileSystem::listDirectory(fullPath, "*");
+ auto childNames = FileSystem::listDirectory(fullPath);
Vector<ListedChild> listedChildren;
- listedChildren.reserveInitialCapacity(childPaths.size());
- for (auto& childPath : childPaths) {
- auto metadata = FileSystem::fileMetadata(childPath);
+ listedChildren.reserveInitialCapacity(childNames.size());
+ for (auto& childName : childNames) {
+ auto metadata = FileSystem::fileMetadata(FileSystem::pathByAppendingComponent(fullPath, childName));
if (!metadata || metadata.value().isHidden)
continue;
- listedChildren.uncheckedAppend(ListedChild { FileSystem::pathGetFileName(childPath), metadata.value().type });
+ listedChildren.uncheckedAppend(ListedChild { childName, metadata.value().type });
}
return listedChildren;
}
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp (277356 => 277357)
--- trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp 2021-05-12 05:55:23 UTC (rev 277357)
@@ -514,18 +514,18 @@
ASSERT(m_lock.isHeld());
String oldDirectory = IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(origin.topOrigin, origin.clientOrigin, m_databaseDirectoryPath, "v0");
- Vector<String> files = FileSystem::listDirectory(oldDirectory, "*"_s);
+ Vector<String> fileNames = FileSystem::listDirectory(oldDirectory);
Vector<IDBDatabaseNameAndVersion> databases;
- for (auto& file : files) {
- auto databaseTuple = SQLiteIDBBackingStore::databaseNameAndVersionFromFile(SQLiteIDBBackingStore::fullDatabasePathForDirectory(file));
+ for (auto& fileName : fileNames) {
+ auto databaseTuple = SQLiteIDBBackingStore::databaseNameAndVersionFromFile(SQLiteIDBBackingStore::fullDatabasePathForDirectory(FileSystem::pathByAppendingComponent(oldDirectory, fileName)));
if (databaseTuple)
databases.append(WTFMove(*databaseTuple));
}
String directory = IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(origin.topOrigin, origin.clientOrigin, m_databaseDirectoryPath, "v1");
- files = FileSystem::listDirectory(directory, "*"_s);
- for (auto& file : files) {
- auto databaseTuple = SQLiteIDBBackingStore::databaseNameAndVersionFromFile(SQLiteIDBBackingStore::fullDatabasePathForDirectory(file));
+ fileNames = FileSystem::listDirectory(directory);
+ for (auto& fileName : fileNames) {
+ auto databaseTuple = SQLiteIDBBackingStore::databaseNameAndVersionFromFile(SQLiteIDBBackingStore::fullDatabasePathForDirectory(FileSystem::pathByAppendingComponent(directory, fileName)));
if (databaseTuple)
databases.append(WTFMove(*databaseTuple));
}
@@ -539,13 +539,11 @@
static void collectOriginsForVersion(const String& versionPath, HashSet<WebCore::SecurityOriginData>& securityOrigins)
{
- for (auto& topOriginPath : FileSystem::listDirectory(versionPath, "*")) {
- auto databaseIdentifier = FileSystem::pathGetFileName(topOriginPath);
+ for (auto& databaseIdentifier : FileSystem::listDirectory(versionPath)) {
if (auto securityOrigin = SecurityOriginData::fromDatabaseIdentifier(databaseIdentifier)) {
securityOrigins.add(WTFMove(*securityOrigin));
- for (auto& originPath : FileSystem::listDirectory(topOriginPath, "*")) {
- databaseIdentifier = FileSystem::pathGetFileName(originPath);
+ for (auto& databaseIdentifier : FileSystem::listDirectory(FileSystem::pathByAppendingComponent(versionPath, databaseIdentifier))) {
if (auto securityOrigin = SecurityOriginData::fromDatabaseIdentifier(databaseIdentifier))
securityOrigins.add(WTFMove(*securityOrigin));
}
@@ -628,9 +626,10 @@
static void removeAllDatabasesForFullOriginPath(const String& originPath, WallTime modifiedSince)
{
LOG(IndexedDB, "removeAllDatabasesForOriginPath with originPath %s", originPath.utf8().data());
- Vector<String> databasePaths = FileSystem::listDirectory(originPath, "*");
+ Vector<String> databaseNames = FileSystem::listDirectory(originPath);
- for (auto& databasePath : databasePaths) {
+ for (auto& databaseName : databaseNames) {
+ auto databasePath = FileSystem::pathByAppendingComponent(originPath, databaseName);
String databaseFile = FileSystem::pathByAppendingComponent(databasePath, "IndexedDB.sqlite3");
if (modifiedSince > -WallTime::infinity() && FileSystem::fileExists(databaseFile)) {
auto modificationTime = FileSystem::getFileModificationTime(databaseFile);
@@ -649,34 +648,25 @@
//
// To be conservative, we should *not* try to delete files that are unexpected;
// We should only delete files we think we put there.
- //
- // IndexedDB blob files are named "N.blob" where N is a decimal integer,
- // so those are the only blob files we should be trying to delete.
- for (auto& blobPath : FileSystem::listDirectory(databasePath, "[0-9]*.blob")) {
- // Globbing can't give us only filenames starting with 1-or-more digits.
- // The above globbing gives us files that start with a digit and ends with ".blob", but there might be non-digits in between.
- // We need to validate that each filename contains only digits before deleting it, as any other files are not ones we put there.
- String filename = FileSystem::pathGetFileName(blobPath);
- auto filenameLength = filename.length();
-
- ASSERT(filenameLength >= 6);
- ASSERT(filename.endsWith(".blob"));
-
- if (filename.length() < 6)
+ for (auto& fileName : FileSystem::listDirectory(databasePath)) {
+ // IndexedDB blob files are named "N.blob" where N is a decimal integer,
+ // so those are the only blob files we should be trying to delete.
+ auto fileNameLength = fileName.length();
+ if (fileNameLength < 6)
continue;
- if (!filename.endsWith(".blob"))
+ if (!fileName.endsWith(".blob"))
continue;
- bool validFilename = true;
- for (unsigned i = 0; i < filenameLength - 5; ++i) {
- if (!isASCIIDigit(filename[i])) {
- validFilename = false;
+ bool validFileName = true;
+ for (unsigned i = 0; i < fileNameLength - 5; ++i) {
+ if (!isASCIIDigit(fileName[i])) {
+ validFileName = false;
break;
}
}
- if (validFilename)
- FileSystem::deleteFile(blobPath);
+ if (validFileName)
+ FileSystem::deleteFile(FileSystem::pathByAppendingComponent(databasePath, fileName));
}
// Now delete IndexedDB.sqlite3 and related SQLite files.
@@ -696,11 +686,10 @@
if (!SecurityOriginData::fromDatabaseIdentifier(databaseIdentifier))
return;
- auto directories = FileSystem::listDirectory(originPath, "*"_s);
- for (auto& directory : directories) {
- String databaseIdentifier = FileSystem::lastComponentOfPathIgnoringTrailingSlash(directory);
+ auto directoryNames = FileSystem::listDirectory(originPath);
+ for (auto& databaseIdentifier : directoryNames) {
if (auto securityOrigin = SecurityOriginData::fromDatabaseIdentifier(databaseIdentifier))
- removeAllDatabasesForFullOriginPath(directory, modifiedSince);
+ removeAllDatabasesForFullOriginPath(FileSystem::pathByAppendingComponent(originPath, databaseIdentifier), modifiedSince);
}
removeAllDatabasesForFullOriginPath(originPath, modifiedSince);
@@ -709,10 +698,9 @@
void IDBServer::removeDatabasesModifiedSinceForVersion(WallTime modifiedSince, const String& version)
{
String versionPath = FileSystem::pathByAppendingComponent(m_databaseDirectoryPath, version);
- for (auto& originPath : FileSystem::listDirectory(versionPath, "*")) {
- String databaseIdentifier = FileSystem::lastComponentOfPathIgnoringTrailingSlash(originPath);
+ for (auto& databaseIdentifier : FileSystem::listDirectory(versionPath)) {
if (auto securityOrigin = SecurityOriginData::fromDatabaseIdentifier(databaseIdentifier))
- removeAllDatabasesForOriginPath(originPath, modifiedSince);
+ removeAllDatabasesForOriginPath(FileSystem::pathByAppendingComponent(versionPath, databaseIdentifier), modifiedSince);
}
}
@@ -723,7 +711,8 @@
String originPath = FileSystem::pathByAppendingComponent(versionPath, origin.databaseIdentifier());
removeAllDatabasesForOriginPath(originPath, -WallTime::infinity());
- for (auto& topOriginPath : FileSystem::listDirectory(versionPath, "*")) {
+ for (auto& topOrigin : FileSystem::listDirectory(versionPath)) {
+ auto topOriginPath = FileSystem::pathByAppendingComponent(versionPath, topOrigin);
originPath = FileSystem::pathByAppendingComponent(topOriginPath, origin.databaseIdentifier());
removeAllDatabasesForOriginPath(originPath, -WallTime::infinity());
}
Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp (277356 => 277357)
--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp 2021-05-12 05:55:23 UTC (rev 277357)
@@ -1182,7 +1182,6 @@
String oldDatabaseDirectory = FileSystem::pathByAppendingComponent(oldOriginDirectory, filenameForDatabaseName());
String newOriginDirectory = m_identifier.databaseDirectoryRelativeToRoot(m_databaseRootDirectory, "v1");
String fileNameHash = SQLiteFileSystem::computeHashForFileName(m_identifier.databaseName());
- Vector<String> directoriesWithSameHash = FileSystem::listDirectory(newOriginDirectory, fileNameHash + "*");
String newDatabaseDirectory = FileSystem::pathByAppendingComponent(newOriginDirectory, fileNameHash);
FileSystem::makeAllDirectories(newDatabaseDirectory);
@@ -1281,10 +1280,11 @@
uint64_t SQLiteIDBBackingStore::databasesSizeForDirectory(const String& directory)
{
uint64_t diskUsage = 0;
- for (auto& dbDirectory : FileSystem::listDirectory(directory, "*")) {
- for (auto& file : FileSystem::listDirectory(dbDirectory, "*.sqlite3"_s)) {
- auto fileSize = SQLiteFileSystem::getDatabaseFileSize(file);
- diskUsage += fileSize;
+ for (auto& dbDirectoryName : FileSystem::listDirectory(directory)) {
+ auto dbDirectoryPath = FileSystem::pathByAppendingComponent(directory, dbDirectoryName);
+ for (auto& fileName : FileSystem::listDirectory(dbDirectoryPath)) {
+ if (fileName.endsWith(".sqlite3"))
+ diskUsage += SQLiteFileSystem::getDatabaseFileSize(FileSystem::pathByAppendingComponent(dbDirectoryPath, fileName));
}
}
return diskUsage;
Modified: trunk/Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp (277356 => 277357)
--- trunk/Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp 2021-05-12 05:55:23 UTC (rev 277357)
@@ -655,8 +655,10 @@
{
String originPath = this->originPath(origin);
unsigned long long diskUsage = 0;
- for (auto& fileName : FileSystem::listDirectory(originPath, "*.db"_s))
- diskUsage += SQLiteFileSystem::getDatabaseFileSize(fileName);
+ for (auto& fileName : FileSystem::listDirectory(originPath)) {
+ if (fileName.endsWith(".db"))
+ diskUsage += SQLiteFileSystem::getDatabaseFileSize(FileSystem::pathByAppendingComponent(originPath, fileName));
+ }
return diskUsage;
}
@@ -855,8 +857,9 @@
#if PLATFORM(COCOA)
RELEASE_LOG_ERROR(DatabaseTracker, "Unable to retrieve list of database names for origin");
#endif
- for (const auto& file : FileSystem::listDirectory(originPath(origin), "*")) {
- if (!FileSystem::deleteFile(file))
+ auto originPath = this->originPath(origin);
+ for (const auto& fileName : FileSystem::listDirectory(originPath)) {
+ if (!FileSystem::deleteFile(FileSystem::pathByAppendingComponent(originPath, fileName)))
failedToDeleteAnyDatabaseFile = true;
}
}
Modified: trunk/Source/WebCore/html/DirectoryFileListCreator.cpp (277356 => 277357)
--- trunk/Source/WebCore/html/DirectoryFileListCreator.cpp 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Source/WebCore/html/DirectoryFileListCreator.cpp 2021-05-12 05:55:23 UTC (rev 277357)
@@ -54,7 +54,8 @@
static void appendDirectoryFiles(const String& directory, const String& relativePath, Vector<FileInformation>& files)
{
ASSERT(!isMainThread());
- for (auto& childPath : FileSystem::listDirectory(directory, "*")) {
+ for (auto& childName : FileSystem::listDirectory(directory)) {
+ auto childPath = FileSystem::pathByAppendingComponent(directory, childName);
auto metadata = FileSystem::fileMetadata(childPath);
if (!metadata)
continue;
@@ -62,7 +63,7 @@
if (metadata.value().isHidden)
continue;
- String childRelativePath = relativePath + "/" + FileSystem::pathGetFileName(childPath);
+ String childRelativePath = relativePath + "/" + childName;
if (metadata.value().type == FileMetadata::Type::Directory)
appendDirectoryFiles(childPath, childRelativePath, files);
else if (metadata.value().type == FileMetadata::Type::File)
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp (277356 => 277357)
--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp 2021-05-12 05:55:23 UTC (rev 277357)
@@ -2181,7 +2181,8 @@
g_object_set(element, "temp-template", newDownloadTemplate.get(), nullptr);
GST_DEBUG_OBJECT(player->pipeline(), "Reconfigured file download template from '%s' to '%s'", oldDownloadTemplate.get(), newDownloadTemplate.get());
- player->purgeOldDownloadFiles(oldDownloadTemplate.get());
+ String newDownloadPrefixPath = newDownloadTemplate.get();
+ player->purgeOldDownloadFiles(newDownloadPrefixPath.replace("XXXXXX", ""));
}
void MediaPlayerPrivateGStreamer::downloadBufferFileCreatedCallback(MediaPlayerPrivateGStreamer* player)
@@ -2202,16 +2203,18 @@
GST_DEBUG_OBJECT(player->pipeline(), "Unlinked media temporary file %s after creation", downloadFile.get());
}
-void MediaPlayerPrivateGStreamer::purgeOldDownloadFiles(const char* downloadFileTemplate)
+void MediaPlayerPrivateGStreamer::purgeOldDownloadFiles(const String& downloadFilePrefixPath)
{
- if (!downloadFileTemplate)
+ if (downloadFilePrefixPath.isEmpty())
return;
- GUniquePtr<char> templatePath(g_path_get_dirname(downloadFileTemplate));
- GUniquePtr<char> templateFile(g_path_get_basename(downloadFileTemplate));
- String templatePattern = String(templateFile.get()).replace("X", "?");
+ auto templateDirectory = FileSystem::directoryName(downloadFilePrefixPath);
+ auto templatePrefix = FileSystem::pathGetFileName(downloadFilePrefixPath);
+ for (auto& fileName : FileSystem::listDirectory(templateDirectory)) {
+ if (!fileName.startsWith(templatePrefix))
+ continue;
- for (auto& filePath : FileSystem::listDirectory(templatePath.get(), templatePattern)) {
+ auto filePath = FileSystem::pathByAppendingComponent(templateDirectory, fileName);
if (UNLIKELY(!FileSystem::deleteFile(filePath))) {
GST_WARNING("Couldn't unlink legacy media temporary file: %s", filePath.utf8().data());
continue;
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h (277356 => 277357)
--- trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h 2021-05-12 05:55:23 UTC (rev 277357)
@@ -437,7 +437,7 @@
bool didPassCORSAccessCheck() const override;
bool canSaveMediaData() const override;
- void purgeOldDownloadFiles(const char*);
+ void purgeOldDownloadFiles(const String& downloadFilePrefixPath);
static void uriDecodeBinElementAddedCallback(GstBin*, GstElement*, MediaPlayerPrivateGStreamer*);
static void downloadBufferFileCreatedCallback(MediaPlayerPrivateGStreamer*);
Modified: trunk/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp (277356 => 277357)
--- trunk/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Source/WebCore/platform/text/hyphen/HyphenationLibHyphen.cpp 2021-05-12 05:55:23 UTC (rev 277357)
@@ -52,21 +52,26 @@
"/usr/local/share/hyphen",
};
-static String extractLocaleFromDictionaryFilePath(const String& filePath)
+static String extractLocaleFromDictionaryFileName(const String& fileName)
{
+ if (!fileName.startsWith("hyph_") || !fileName.endsWith(".dic"))
+ return { };
+
// Dictionary files always have the form "hyph_<locale name>.dic"
// so we strip everything except the locale.
- String fileName = FileSystem::pathGetFileName(filePath);
- static const int prefixLength = 5;
- static const int suffixLength = 4;
- return fileName.substring(prefixLength, fileName.length() - prefixLength - suffixLength);
+ constexpr int prefixLength = 5;
+ constexpr int suffixLength = 4;
+ return fileName.substring(prefixLength, fileName.length() - prefixLength - suffixLength).convertToASCIILowercase();
}
static void scanDirectoryForDictionaries(const char* directoryPath, HashMap<AtomString, Vector<String>>& availableLocales)
{
- for (auto& filePath : FileSystem::listDirectory(directoryPath, "hyph_*.dic")) {
- String locale = extractLocaleFromDictionaryFilePath(filePath).convertToASCIILowercase();
+ for (auto& fileName : FileSystem::listDirectory(directoryPath)) {
+ String locale = extractLocaleFromDictionaryFileName(fileName);
+ if (locale.isEmpty())
+ continue;
+ auto filePath = FileSystem::pathByAppendingComponent(directoryPath, fileName);
char normalizedPath[PATH_MAX];
if (!realpath(FileSystem::fileSystemRepresentation(filePath).data(), normalizedPath))
continue;
Modified: trunk/Source/WebKit/ChangeLog (277356 => 277357)
--- trunk/Source/WebKit/ChangeLog 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Source/WebKit/ChangeLog 2021-05-12 05:55:23 UTC (rev 277357)
@@ -1,5 +1,40 @@
2021-05-11 Chris Dumez <cdu...@apple.com>
+ Port WTF::FileSystem::listDirectory to std::filesystem
+ https://bugs.webkit.org/show_bug.cgi?id=225633
+
+ Reviewed by Darin Adler.
+
+ Update FileSystem::listDirectory() call sites to deal with the fact that:
+ - The function now returns file names instead of full file paths
+ - The callers now have to do filtering by themselves if they need it
+
+ * NetworkProcess/WebStorage/LocalStorageDatabaseTracker.cpp:
+ (WebKit::LocalStorageDatabaseTracker::origins const):
+ * NetworkProcess/cache/CacheStorageEngine.cpp:
+ (WebKit::CacheStorage::getDirectorySize):
+ (WebKit::CacheStorage::Engine::getDirectories):
+ (WebKit::CacheStorage::Engine::clearAllCachesFromDisk):
+ * NetworkProcess/cache/NetworkCacheFileSystem.cpp:
+ (WebKit::NetworkCache::traverseDirectory):
+ * UIProcess/API/APIContentRuleListStore.cpp:
+ (API::ContentRuleListStore::getAvailableContentRuleListIdentifiers):
+ (API::ContentRuleListStore::synchronousRemoveAllContentRuleLists):
+ * UIProcess/DeviceIdHashSaltStorage.cpp:
+ (WebKit::DeviceIdHashSaltStorage::loadStorageFromDisk):
+ * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+ (WebKit::WebsiteDataStore::mediaKeyOrigins):
+ (WebKit::WebsiteDataStore::removeMediaKeys):
+ * WebProcess/InjectedBundle/API/glib/WebKitExtensionManager.cpp:
+ (WebKit::WebKitExtensionManager::scanModules):
+ * WebProcess/MediaCache/WebMediaKeyStorageManager.cpp:
+ (WebKit::WebMediaKeyStorageManager::getMediaKeyOrigins):
+ (WebKit::removeAllMediaKeyStorageForOriginPath):
+ (WebKit::WebMediaKeyStorageManager::deleteMediaKeyEntriesModifiedBetweenDates):
+ (WebKit::WebMediaKeyStorageManager::deleteAllMediaKeyEntries):
+
+2021-05-11 Chris Dumez <cdu...@apple.com>
+
Add SPI to suspend / resume a WKWebView
https://bugs.webkit.org/show_bug.cgi?id=225333
<rdar://77462543>
Modified: trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabaseTracker.cpp (277356 => 277357)
--- trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabaseTracker.cpp 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Source/WebKit/NetworkProcess/WebStorage/LocalStorageDatabaseTracker.cpp 2021-05-12 05:55:23 UTC (rev 277357)
@@ -104,9 +104,7 @@
Vector<SecurityOriginData> LocalStorageDatabaseTracker::origins() const
{
Vector<SecurityOriginData> databaseOrigins;
- auto paths = FileSystem::listDirectory(localStorageDirectory(), "*.localstorage");
-
- for (const auto& path : paths) {
+ for (auto& path : FileSystem::listDirectory(localStorageDirectory())) {
auto filename = FileSystem::pathGetFileName(path);
auto originIdentifier = filename.substring(0, filename.length() - strlen(".localstorage"));
auto origin = SecurityOriginData::fromDatabaseIdentifier(originIdentifier);
Modified: trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp (277356 => 277357)
--- trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp 2021-05-12 05:55:23 UTC (rev 277357)
@@ -208,13 +208,12 @@
while (!paths.isEmpty()) {
auto path = paths.takeFirst();
if (FileSystem::fileIsDirectory(path, FileSystem::ShouldFollowSymbolicLinks::No)) {
- auto newPaths = FileSystem::listDirectory(path, "*"_s);
- for (auto& newPath : newPaths) {
+ auto fileNames = FileSystem::listDirectory(path);
+ for (auto& fileName : fileNames) {
// Files in /Blobs directory are hard link.
- auto fileName = FileSystem::lastComponentOfPathIgnoringTrailingSlash(newPath);
if (fileName == "Blobs")
continue;
- paths.append(newPath);
+ paths.append(FileSystem::pathByAppendingComponent(path, fileName));
}
continue;
}
@@ -615,9 +614,10 @@
{
m_ioQueue->dispatch([path = m_rootPath.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable {
Vector<String> folderPaths;
- for (auto& filename : FileSystem::listDirectory(path, "*")) {
- if (FileSystem::fileIsDirectory(filename, FileSystem::ShouldFollowSymbolicLinks::No))
- folderPaths.append(filename.isolatedCopy());
+ for (auto& fileName : FileSystem::listDirectory(path)) {
+ auto filePath = FileSystem::pathByAppendingComponent(path, fileName);
+ if (FileSystem::fileIsDirectory(filePath, FileSystem::ShouldFollowSymbolicLinks::No))
+ folderPaths.append(filePath.isolatedCopy());
}
RunLoop::main().dispatch([folderPaths = WTFMove(folderPaths), completionHandler = WTFMove(completionHandler)]() mutable {
@@ -702,9 +702,10 @@
m_ioQueue->dispatch([path = m_rootPath.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable {
LockHolder locker(globalSizeFileLock);
- for (auto& filename : FileSystem::listDirectory(path, "*")) {
- if (FileSystem::fileIsDirectory(filename, FileSystem::ShouldFollowSymbolicLinks::No))
- FileSystem::deleteNonEmptyDirectory(filename);
+ for (auto& fileName : FileSystem::listDirectory(path)) {
+ auto filePath = FileSystem::pathByAppendingComponent(path, fileName);
+ if (FileSystem::fileIsDirectory(filePath, FileSystem::ShouldFollowSymbolicLinks::No))
+ FileSystem::deleteNonEmptyDirectory(filePath);
}
RunLoop::main().dispatch(WTFMove(completionHandler));
});
Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp (277356 => 277357)
--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp 2021-05-12 05:55:23 UTC (rev 277357)
@@ -55,10 +55,11 @@
void traverseDirectory(const String& path, const Function<void (const String&, DirectoryEntryType)>& function)
{
- auto entries = FileSystem::listDirectory(path, "*"_s);
+ auto entries = FileSystem::listDirectory(path);
for (auto& entry : entries) {
- auto type = FileSystem::fileIsDirectory(entry, FileSystem::ShouldFollowSymbolicLinks::No) ? DirectoryEntryType::Directory : DirectoryEntryType::File;
- function(FileSystem::pathGetFileName(entry), type);
+ auto entryPath = FileSystem::pathByAppendingComponent(path, entry);
+ auto type = FileSystem::fileIsDirectory(entryPath, FileSystem::ShouldFollowSymbolicLinks::No) ? DirectoryEntryType::Directory : DirectoryEntryType::File;
+ function(entry, type);
}
}
Modified: trunk/Source/WebKit/UIProcess/API/APIContentRuleListStore.cpp (277356 => 277357)
--- trunk/Source/WebKit/UIProcess/API/APIContentRuleListStore.cpp 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Source/WebKit/UIProcess/API/APIContentRuleListStore.cpp 2021-05-12 05:55:23 UTC (rev 277357)
@@ -89,11 +89,6 @@
return prefix;
}
-static const WTF::String constructedPathFilter(bool legacyFilename)
-{
- return makeString(constructedPathPrefix(legacyFilename), '*');
-}
-
static WTF::String constructedPath(const WTF::String& base, const WTF::String& identifier, bool legacyFilename)
{
return pathByAppendingComponent(base, makeString(constructedPathPrefix(legacyFilename), encodeForFileName(identifier)));
@@ -500,17 +495,18 @@
{
ASSERT(RunLoop::isMain());
m_readQueue->dispatch([protectedThis = makeRef(*this), storePath = m_storePath.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable {
+ auto prefix = constructedPathPrefix(false /*legacy*/);
+ auto prefixLength = prefix.length();
+ auto legacyPrefix = constructedPathPrefix(true /*legacy*/);
+ auto legacyPrefixLength = legacyPrefix.length();
- Vector<WTF::String> fullPaths = listDirectory(storePath, constructedPathFilter(false));
- Vector<WTF::String> legacyFullPaths = listDirectory(storePath, constructedPathFilter(true));
Vector<WTF::String> identifiers;
- identifiers.reserveInitialCapacity(fullPaths.size() + legacyFullPaths.size());
- const auto prefixLength = constructedPathPrefix(false).length();
- const auto legacyPrefixLength = constructedPathPrefix(true).length();
- for (const auto& path : fullPaths)
- identifiers.uncheckedAppend(decodeFromFilename(path.substring(path.reverseFind('/') + 1 + prefixLength)));
- for (const auto& path : legacyFullPaths)
- identifiers.uncheckedAppend(decodeFromFilename(path.substring(path.reverseFind('/') + 1 + legacyPrefixLength)));
+ for (auto& fileName : listDirectory(storePath)) {
+ if (fileName.startsWith(prefix))
+ identifiers.append(decodeFromFilename(fileName.substring(prefixLength)));
+ else if (fileName.startsWith(legacyPrefix))
+ identifiers.append(decodeFromFilename(fileName.substring(legacyPrefixLength)));
+ }
RunLoop::main().dispatch([protectedThis = WTFMove(protectedThis), completionHandler = WTFMove(completionHandler), identifiers = WTFMove(identifiers)]() mutable {
completionHandler(WTFMove(identifiers));
@@ -568,8 +564,8 @@
void ContentRuleListStore::synchronousRemoveAllContentRuleLists()
{
- for (const auto& path : listDirectory(m_storePath, "*"))
- deleteFile(path);
+ for (const auto& fileName : listDirectory(m_storePath))
+ deleteFile(FileSystem::pathByAppendingComponent(m_storePath, fileName));
}
void ContentRuleListStore::invalidateContentRuleListVersion(const WTF::String& identifier)
Modified: trunk/Source/WebKit/UIProcess/DeviceIdHashSaltStorage.cpp (277356 => 277357)
--- trunk/Source/WebKit/UIProcess/DeviceIdHashSaltStorage.cpp 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Source/WebKit/UIProcess/DeviceIdHashSaltStorage.cpp 2021-05-12 05:55:23 UTC (rev 277357)
@@ -115,7 +115,8 @@
FileSystem::makeAllDirectories(m_deviceIdHashSaltStorageDirectory);
HashMap<String, std::unique_ptr<HashSaltForOrigin>> deviceIdHashSaltForOrigins;
- for (auto& originPath : FileSystem::listDirectory(m_deviceIdHashSaltStorageDirectory, "*")) {
+ for (auto& origin : FileSystem::listDirectory(m_deviceIdHashSaltStorageDirectory)) {
+ auto originPath = FileSystem::pathByAppendingComponent(m_deviceIdHashSaltStorageDirectory, origin);
auto deviceIdHashSalt = URL::fileURLWithFileSystemPath(originPath).lastPathComponent().toString();
if (hashSaltSize != deviceIdHashSalt.length()) {
Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (277356 => 277357)
--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2021-05-12 05:55:23 UTC (rev 277357)
@@ -1672,13 +1672,12 @@
Vector<WebCore::SecurityOriginData> origins;
- for (const auto& originPath : FileSystem::listDirectory(mediaKeysStorageDirectory, "*")) {
+ for (const auto& mediaKeyIdentifier : FileSystem::listDirectory(mediaKeysStorageDirectory)) {
+ auto originPath = FileSystem::pathByAppendingComponent(mediaKeysStorageDirectory, mediaKeyIdentifier);
auto mediaKeyFile = computeMediaKeyFile(originPath);
if (!FileSystem::fileExists(mediaKeyFile))
continue;
- auto mediaKeyIdentifier = FileSystem::pathGetFileName(originPath);
-
if (auto securityOrigin = WebCore::SecurityOriginData::fromDatabaseIdentifier(mediaKeyIdentifier))
origins.append(*securityOrigin);
}
@@ -1690,7 +1689,8 @@
{
ASSERT(!mediaKeysStorageDirectory.isEmpty());
- for (const auto& mediaKeyDirectory : FileSystem::listDirectory(mediaKeysStorageDirectory, "*")) {
+ for (const auto& directoryName : FileSystem::listDirectory(mediaKeysStorageDirectory)) {
+ auto mediaKeyDirectory = FileSystem::pathByAppendingComponent(mediaKeysStorageDirectory, directoryName);
auto mediaKeyFile = computeMediaKeyFile(mediaKeyDirectory);
auto modificationTime = FileSystem::getFileModificationTime(mediaKeyFile);
Modified: trunk/Source/WebKit/WebProcess/InjectedBundle/API/glib/WebKitExtensionManager.cpp (277356 => 277357)
--- trunk/Source/WebKit/WebProcess/InjectedBundle/API/glib/WebKitExtensionManager.cpp 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Source/WebKit/WebProcess/InjectedBundle/API/glib/WebKitExtensionManager.cpp 2021-05-12 05:55:23 UTC (rev 277357)
@@ -41,10 +41,14 @@
void WebKitExtensionManager::scanModules(const String& webExtensionsDirectory, Vector<String>& modules)
{
- Vector<String> modulePaths = FileSystem::listDirectory(webExtensionsDirectory, String("*.so"));
- for (size_t i = 0; i < modulePaths.size(); ++i) {
- if (FileSystem::fileExists(modulePaths[i]))
- modules.append(modulePaths[i]);
+ auto moduleNames = FileSystem::listDirectory(webExtensionsDirectory);
+ for (auto& moduleName : moduleNames) {
+ if (!moduleName.endsWith(".so"))
+ continue;
+
+ auto modulePath = FileSystem::pathByAppendingComponent(webExtensionsDirectory, moduleName);
+ if (FileSystem::fileExists(modulePath))
+ modules.append(modulePath);
}
}
Modified: trunk/Source/WebKit/WebProcess/MediaCache/WebMediaKeyStorageManager.cpp (277356 => 277357)
--- trunk/Source/WebKit/WebProcess/MediaCache/WebMediaKeyStorageManager.cpp 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Source/WebKit/WebProcess/MediaCache/WebMediaKeyStorageManager.cpp 2021-05-12 05:55:23 UTC (rev 277357)
@@ -60,8 +60,7 @@
if (m_mediaKeyStorageDirectory.isEmpty())
return results;
- for (auto& originPath : FileSystem::listDirectory(m_mediaKeyStorageDirectory, "*")) {
- auto identifier = URL::fileURLWithFileSystemPath(originPath).lastPathComponent().toString();
+ for (auto& identifier : FileSystem::listDirectory(m_mediaKeyStorageDirectory)) {
if (auto securityOrigin = SecurityOriginData::fromDatabaseIdentifier(identifier))
results.append(*securityOrigin);
}
@@ -71,9 +70,10 @@
static void removeAllMediaKeyStorageForOriginPath(const String& originPath, WallTime startDate, WallTime endDate)
{
- Vector<String> mediaKeyPaths = FileSystem::listDirectory(originPath, "*");
+ Vector<String> mediaKeyNames = FileSystem::listDirectory(originPath);
- for (const auto& mediaKeyPath : mediaKeyPaths) {
+ for (const auto& mediaKeyName : mediaKeyNames) {
+ auto mediaKeyPath = FileSystem::pathByAppendingComponent(originPath, mediaKeyName);
String mediaKeyFile = FileSystem::pathByAppendingComponent(mediaKeyPath, "SecureStop.plist");
if (!FileSystem::fileExists(mediaKeyFile))
@@ -106,9 +106,9 @@
if (m_mediaKeyStorageDirectory.isEmpty())
return;
- Vector<String> originPaths = FileSystem::listDirectory(m_mediaKeyStorageDirectory, "*");
- for (auto& originPath : originPaths)
- removeAllMediaKeyStorageForOriginPath(originPath, startDate, endDate);
+ Vector<String> originNames = FileSystem::listDirectory(m_mediaKeyStorageDirectory);
+ for (auto& originName : originNames)
+ removeAllMediaKeyStorageForOriginPath(FileSystem::pathByAppendingComponent(m_mediaKeyStorageDirectory, originName), startDate, endDate);
}
void WebMediaKeyStorageManager::deleteAllMediaKeyEntries()
@@ -116,9 +116,9 @@
if (m_mediaKeyStorageDirectory.isEmpty())
return;
- Vector<String> originPaths = FileSystem::listDirectory(m_mediaKeyStorageDirectory, "*");
- for (auto& originPath : originPaths)
- removeAllMediaKeyStorageForOriginPath(originPath, -WallTime::infinity(), WallTime::infinity());
+ Vector<String> originNames = FileSystem::listDirectory(m_mediaKeyStorageDirectory);
+ for (auto& originName : originNames)
+ removeAllMediaKeyStorageForOriginPath(FileSystem::pathByAppendingComponent(m_mediaKeyStorageDirectory, originName), -WallTime::infinity(), WallTime::infinity());
}
}
Modified: trunk/Source/WebKitLegacy/ChangeLog (277356 => 277357)
--- trunk/Source/WebKitLegacy/ChangeLog 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Source/WebKitLegacy/ChangeLog 2021-05-12 05:55:23 UTC (rev 277357)
@@ -1,3 +1,17 @@
+2021-05-11 Chris Dumez <cdu...@apple.com>
+
+ Port WTF::FileSystem::listDirectory to std::filesystem
+ https://bugs.webkit.org/show_bug.cgi?id=225633
+
+ Reviewed by Darin Adler.
+
+ Update FileSystem::listDirectory() call sites to deal with the fact that:
+ - The function now returns file names instead of full file paths
+ - The callers now have to do filtering by themselves if they need it
+
+ * Storage/StorageTracker.cpp:
+ (WebKit::StorageTracker::syncFileSystemAndTrackerDatabase):
+
2021-05-04 Alex Christensen <achristen...@webkit.org>
Remove unused references to PageGroup from WebKitLegacy
Modified: trunk/Source/WebKitLegacy/Storage/StorageTracker.cpp (277356 => 277357)
--- trunk/Source/WebKitLegacy/Storage/StorageTracker.cpp 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Source/WebKitLegacy/Storage/StorageTracker.cpp 2021-05-12 05:55:23 UTC (rev 277357)
@@ -236,10 +236,10 @@
ASSERT(m_isActive);
- Vector<String> paths;
+ Vector<String> fileNames;
{
LockHolder locker(m_databaseMutex);
- paths = FileSystem::listDirectory(m_storageDirectoryPath, "*.localstorage");
+ fileNames = FileSystem::listDirectory(m_storageDirectoryPath);
}
// Use a copy of m_originSet to find expired entries and to schedule their
@@ -255,17 +255,16 @@
OriginSet foundOrigins;
String fileExtension = ".localstorage"_s;
- for (Vector<String>::const_iterator it = paths.begin(), end = paths.end(); it != end; ++it) {
- const String& path = *it;
+ for (auto& fileName : fileNames) {
+ if (fileName.length() <= fileExtension.length() || !fileName.endsWith(fileExtension))
+ continue;
- if (path.length() > fileExtension.length() && path.endsWith(fileExtension)) {
- String file = FileSystem::pathGetFileName(path);
- String originIdentifier = file.substring(0, file.length() - fileExtension.length());
- if (!originSetCopy.contains(originIdentifier))
- syncSetOriginDetails(originIdentifier, path);
+ auto filePath = FileSystem::pathByAppendingComponent(m_storageDirectoryPath, fileName);
+ String originIdentifier = fileName.substring(0, fileName.length() - fileExtension.length());
+ if (!originSetCopy.contains(originIdentifier))
+ syncSetOriginDetails(originIdentifier, filePath);
- foundOrigins.add(originIdentifier);
- }
+ foundOrigins.add(originIdentifier);
}
// Delete stale StorageTracker records.
Modified: trunk/Source/WebKitLegacy/win/ChangeLog (277356 => 277357)
--- trunk/Source/WebKitLegacy/win/ChangeLog 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Source/WebKitLegacy/win/ChangeLog 2021-05-12 05:55:23 UTC (rev 277357)
@@ -1,3 +1,17 @@
+2021-05-11 Chris Dumez <cdu...@apple.com>
+
+ Port WTF::FileSystem::listDirectory to std::filesystem
+ https://bugs.webkit.org/show_bug.cgi?id=225633
+
+ Reviewed by Darin Adler.
+
+ Update FileSystem::listDirectory() call sites to deal with the fact that:
+ - The function now returns file names instead of full file paths
+ - The callers now have to do filtering by themselves if they need it
+
+ * Plugins/PluginDatabase.cpp:
+ (WebCore::PluginDatabase::getPluginPathsInDirectories const):
+
2021-05-10 Wenson Hsieh <wenson_hs...@apple.com>
Make WebCore::HitTestRequest::RequestType an enum class
Modified: trunk/Source/WebKitLegacy/win/Plugins/PluginDatabase.cpp (277356 => 277357)
--- trunk/Source/WebKitLegacy/win/Plugins/PluginDatabase.cpp 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Source/WebKitLegacy/win/Plugins/PluginDatabase.cpp 2021-05-12 05:55:23 UTC (rev 277357)
@@ -399,19 +399,13 @@
void PluginDatabase::getPluginPathsInDirectories(HashSet<String>& paths) const
{
// FIXME: This should be a case insensitive set.
- HashSet<String> uniqueFilenames;
-
- String fileNameFilter("");
-
- auto dirsEnd = m_pluginDirectories.end();
- for (auto dIt = m_pluginDirectories.begin(); dIt != dirsEnd; ++dIt) {
- Vector<String> pluginPaths = FileSystem::listDirectory(*dIt, fileNameFilter);
- auto pluginsEnd = pluginPaths.end();
- for (auto pIt = pluginPaths.begin(); pIt != pluginsEnd; ++pIt) {
- if (!fileExistsAndIsNotDisabled(*pIt))
+ for (auto& pluginDirectory : m_pluginDirectories) {
+ for (auto& pluginName : FileSystem::listDirectory(pluginDirectory)) {
+ auto pluginPath = FileSystem::pathByAppendingComponent(pluginDirectory, pluginName);
+ if (!fileExistsAndIsNotDisabled(pluginPath))
continue;
- paths.add(*pIt);
+ paths.add(pluginPath);
}
}
}
Modified: trunk/Tools/ChangeLog (277356 => 277357)
--- trunk/Tools/ChangeLog 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Tools/ChangeLog 2021-05-12 05:55:23 UTC (rev 277357)
@@ -1,5 +1,20 @@
2021-05-11 Chris Dumez <cdu...@apple.com>
+ Port WTF::FileSystem::listDirectory to std::filesystem
+ https://bugs.webkit.org/show_bug.cgi?id=225633
+
+ Reviewed by Darin Adler.
+
+ Add API test coverage.
+
+ * TestWebKitAPI/Tests/WTF/FileSystem.cpp:
+ (TestWebKitAPI::createTestFile):
+ (TestWebKitAPI::TEST_F):
+ * TestWebKitAPI/Tests/WebCore/cocoa/DatabaseTrackerTest.mm:
+ (TestWebKitAPI::removeDirectoryAndAllContents):
+
+2021-05-11 Chris Dumez <cdu...@apple.com>
+
Add SPI to suspend / resume a WKWebView
https://bugs.webkit.org/show_bug.cgi?id=225333
<rdar://77462543>
Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp (277356 => 277357)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp 2021-05-12 05:55:23 UTC (rev 277357)
@@ -37,6 +37,14 @@
const char* FileSystemTestData = "This is a test";
+static void createTestFile(const String& path)
+{
+ auto fileHandle = FileSystem::openFile(path, FileSystem::FileOpenMode::Write);
+ EXPECT_TRUE(FileSystem::isHandleValid(fileHandle));
+ FileSystem::writeToFile(fileHandle, FileSystemTestData, strlen(FileSystemTestData));
+ FileSystem::closeFile(fileHandle);
+};
+
// FIXME: Refactor FileSystemTest and SharedBufferTest as a single class.
class FileSystemTest : public testing::Test {
public:
@@ -249,13 +257,6 @@
TEST_F(FileSystemTest, deleteNonEmptyDirectory)
{
- auto createTestTile = [](const String& path) {
- auto fileHandle = FileSystem::openFile(path, FileSystem::FileOpenMode::Write);
- EXPECT_TRUE(FileSystem::isHandleValid(fileHandle));
- FileSystem::writeToFile(fileHandle, FileSystemTestData, strlen(FileSystemTestData));
- FileSystem::closeFile(fileHandle);
- };
-
FileSystem::PlatformFileHandle temporaryFile;
auto temporaryTestFolder = FileSystem::openTemporaryFile("deleteNonEmptyDirectoryTest", temporaryFile);
FileSystem::closeFile(temporaryFile);
@@ -262,10 +263,10 @@
EXPECT_TRUE(FileSystem::deleteFile(temporaryTestFolder));
EXPECT_TRUE(FileSystem::makeAllDirectories(FileSystem::pathByAppendingComponents(temporaryTestFolder, { "subfolder" })));
- createTestTile(FileSystem::pathByAppendingComponent(temporaryTestFolder, "file1.txt"));
- createTestTile(FileSystem::pathByAppendingComponent(temporaryTestFolder, "file2.txt"));
- createTestTile(FileSystem::pathByAppendingComponents(temporaryTestFolder, { "subfolder", "file3.txt" }));
- createTestTile(FileSystem::pathByAppendingComponents(temporaryTestFolder, { "subfolder", "file4.txt" }));
+ createTestFile(FileSystem::pathByAppendingComponent(temporaryTestFolder, "file1.txt"));
+ createTestFile(FileSystem::pathByAppendingComponent(temporaryTestFolder, "file2.txt"));
+ createTestFile(FileSystem::pathByAppendingComponents(temporaryTestFolder, { "subfolder", "file3.txt" }));
+ createTestFile(FileSystem::pathByAppendingComponents(temporaryTestFolder, { "subfolder", "file4.txt" }));
EXPECT_FALSE(FileSystem::deleteEmptyDirectory(temporaryTestFolder));
EXPECT_TRUE(FileSystem::fileExists(temporaryTestFolder));
EXPECT_TRUE(FileSystem::deleteNonEmptyDirectory(temporaryTestFolder));
@@ -780,4 +781,38 @@
#endif
}
+TEST_F(FileSystemTest, listDirectory)
+{
+ createTestFile(FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "a.txt"));
+ createTestFile(FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "b.txt"));
+ createTestFile(FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "bar.png"));
+ createTestFile(FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "foo.png"));
+ FileSystem::makeAllDirectories(FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "subfolder"));
+ createTestFile(FileSystem::pathByAppendingComponents(tempEmptyFolderPath(), { "subfolder", "c.txt" }));
+ createTestFile(FileSystem::pathByAppendingComponents(tempEmptyFolderPath(), { "subfolder", "d.txt" }));
+
+ auto matches = FileSystem::listDirectory(tempEmptyFolderPath());
+ ASSERT_EQ(matches.size(), 5U);
+ std::sort(matches.begin(), matches.end(), WTF::codePointCompareLessThan);
+ EXPECT_STREQ(matches[0].utf8().data(), "a.txt");
+ EXPECT_STREQ(matches[1].utf8().data(), "b.txt");
+ EXPECT_STREQ(matches[2].utf8().data(), "bar.png");
+ EXPECT_STREQ(matches[3].utf8().data(), "foo.png");
+ EXPECT_STREQ(matches[4].utf8().data(), "subfolder");
+
+ matches = FileSystem::listDirectory(FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "subfolder"));
+ ASSERT_EQ(matches.size(), 2U);
+ std::sort(matches.begin(), matches.end(), WTF::codePointCompareLessThan);
+ EXPECT_STREQ(matches[0].utf8().data(), "c.txt");
+ EXPECT_STREQ(matches[1].utf8().data(), "d.txt");
+
+ matches = FileSystem::listDirectory(FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "does-not-exist"));
+ ASSERT_EQ(matches.size(), 0U);
+
+ matches = FileSystem::listDirectory(FileSystem::pathByAppendingComponent(tempEmptyFolderPath(), "a.txt"));
+ ASSERT_EQ(matches.size(), 0U);
+
+ EXPECT_TRUE(FileSystem::deleteNonEmptyDirectory(tempEmptyFolderPath()));
+}
+
} // namespace TestWebKitAPI
Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/cocoa/DatabaseTrackerTest.mm (277356 => 277357)
--- trunk/Tools/TestWebKitAPI/Tests/WebCore/cocoa/DatabaseTrackerTest.mm 2021-05-12 05:53:13 UTC (rev 277356)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/cocoa/DatabaseTrackerTest.mm 2021-05-12 05:55:23 UTC (rev 277357)
@@ -78,8 +78,8 @@
static void removeDirectoryAndAllContents(const String& directoryPath)
{
- for (const auto& file : FileSystem::listDirectory(directoryPath, "*"))
- EXPECT_TRUE(FileSystem::deleteFile(file));
+ for (auto& fileName : FileSystem::listDirectory(directoryPath))
+ EXPECT_TRUE(FileSystem::deleteFile(FileSystem::pathByAppendingComponent(directoryPath, fileName)));
if (FileSystem::fileExists(directoryPath))
EXPECT_TRUE(FileSystem::deleteEmptyDirectory(directoryPath));