WebKit Bugzilla
Attachment 369273 Details for
Bug 196289
: [WinCairo] storage/indexeddb tests are timing out
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-196289-20190507195239.patch (text/plain), 25.31 KB, created by
Fujii Hironori
on 2019-05-07 03:52:40 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Fujii Hironori
Created:
2019-05-07 03:52:40 PDT
Size:
25.31 KB
patch
obsolete
>Subversion Revision: 244999 >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index c6d49c940bb4441967e375afd1995bdb9b4653e6..3ba0ee2a7a9ec305191f161bf3b46945cb722b06 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,18 @@ >+2019-05-06 Fujii Hironori <Hironori.Fujii@sony.com> >+ >+ [WinCairo] storage/indexeddb tests are timing out >+ https://bugs.webkit.org/show_bug.cgi?id=196289 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * wtf/FileSystem.h: Added hardLink. >+ * wtf/glib/FileSystemGlib.cpp: >+ (WTF::FileSystemImpl::hardLink): Added. >+ * wtf/posix/FileSystemPOSIX.cpp: >+ (WTF::FileSystemImpl::hardLink): Added. >+ * wtf/win/FileSystemWin.cpp: >+ (WTF::FileSystemImpl::hardLink): Added. >+ > 2019-05-06 Christopher Reid <chris.reid@sony.com> > > [JSC] Respect already defined USE_LLINT_EMBEDDED_OPCODE_ID compiler variable. >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 0afee79f38ad66a9e90f5c2b3111cd7eb74d79cf..2af6bede190bd1f33952500630b4ea2254b87469 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,56 @@ >+2019-05-06 Fujii Hironori <Hironori.Fujii@sony.com> >+ >+ [WinCairo] storage/indexeddb tests are timing out >+ https://bugs.webkit.org/show_bug.cgi?id=196289 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ storage/indexeddb tests were timing out for WinCairo port because >+ WebKit::NetworkCache classes were not implemented yet for Windows. >+ >+ Implement WebKit::NetworkCache classes by using WTF::FileSystem >+ functions. >+ >+ * NetworkProcess/cache/CacheStorageEngine.cpp: >+ (WebKit::CacheStorage::Engine::readFile): Use >+ IOChannel::isOpened() to check the channel is opened instead of >+ checking the file descriptor. >+ * NetworkProcess/cache/NetworkCacheBlobStorage.cpp: >+ (WebKit::NetworkCache::BlobStorage::add): >+ (WebKit::NetworkCache::BlobStorage::remove): >+ * NetworkProcess/cache/NetworkCacheData.cpp: >+ (WebKit::NetworkCache::Data::mapToFile const): >+ (WebKit::NetworkCache::mapFile): >+ (WebKit::NetworkCache::adoptAndMapFile): >+ (WebKit::NetworkCache::makeSalt): >+ (WebKit::NetworkCache::readOrMakeSalt): >+ * NetworkProcess/cache/NetworkCacheData.h: >+ (WebKit::NetworkCache::Data::isEmpty const): >+ (WebKit::NetworkCache::Data::size const): >+ * NetworkProcess/cache/NetworkCacheDataCurl.cpp: >+ (WebKit::NetworkCache::Data::Data): >+ (WebKit::NetworkCache::Data::empty): >+ (WebKit::NetworkCache::Data::data const): >+ (WebKit::NetworkCache::Data::isNull const): >+ (WebKit::NetworkCache::Data::apply const): >+ (WebKit::NetworkCache::Data::subrange const): >+ (WebKit::NetworkCache::concatenate): >+ (WebKit::NetworkCache::Data::adoptMap): Deleted. >+ * NetworkProcess/cache/NetworkCacheFileSystem.cpp: >+ (WebKit::NetworkCache::traverseDirectory): >+ (WebKit::NetworkCache::fileTimes): >+ (WebKit::NetworkCache::updateFileModificationTimeIfNeeded): >+ (WebKit::NetworkCache::isSafeToUseMemoryMapForPath): >+ * NetworkProcess/cache/NetworkCacheIOChannel.h: >+ (WebKit::NetworkCache::IOChannel::isOpened const): >+ (WebKit::NetworkCache::IOChannel::fileDescriptor const): Deleted. >+ * NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp: >+ (WebKit::NetworkCache::IOChannel::IOChannel): >+ (WebKit::NetworkCache::IOChannel::~IOChannel): >+ (WebKit::NetworkCache::runTaskInQueue): >+ (WebKit::NetworkCache::IOChannel::read): >+ (WebKit::NetworkCache::IOChannel::write): >+ > 2019-05-06 Tim Horton <timothy_horton@apple.com> > > _overrideViewportWithArguments does not work when called before loading >diff --git a/Source/WTF/wtf/FileSystem.h b/Source/WTF/wtf/FileSystem.h >index 0ac8961fd84b6f777250daaf8b6ad4ba7f064cc3..32fe76df400072cfb7499b7fd48a3a3b148b2a4a 100644 >--- a/Source/WTF/wtf/FileSystem.h >+++ b/Source/WTF/wtf/FileSystem.h >@@ -151,6 +151,7 @@ WTF_EXPORT_PRIVATE void unlockAndCloseFile(PlatformFileHandle); > // Returns true if the write was successful, false if it was not. > WTF_EXPORT_PRIVATE bool appendFileContentsToFileHandle(const String& path, PlatformFileHandle&); > >+WTF_EXPORT_PRIVATE bool hardLink(const String& source, const String& destination); > // Hard links a file if possible, copies it if not. > WTF_EXPORT_PRIVATE bool hardLinkOrCopyFile(const String& source, const String& destination); > >diff --git a/Source/WTF/wtf/glib/FileSystemGlib.cpp b/Source/WTF/wtf/glib/FileSystemGlib.cpp >index 0bf12b0c9db275d20feef208e0608a3748061454..58f26d5fe66011c38a0f7f4c2ff422007a1a0c00 100644 >--- a/Source/WTF/wtf/glib/FileSystemGlib.cpp >+++ b/Source/WTF/wtf/glib/FileSystemGlib.cpp >@@ -429,6 +429,23 @@ bool moveFile(const String& oldPath, const String& newPath) > return g_file_move(oldFile.get(), newFile.get(), G_FILE_COPY_OVERWRITE, nullptr, nullptr, nullptr, nullptr); > } > >+bool hardLink(const String& source, const String& destination) >+{ >+#if OS(WINDOWS) >+ return CreateHardLink(destination.wideCharacters().data(), source.wideCharacters().data(), nullptr); >+#else >+ auto sourceFilename = fileSystemRepresentation(source); >+ if (!validRepresentation(sourceFilename)) >+ return false; >+ >+ auto destinationFilename = fileSystemRepresentation(destination); >+ if (!validRepresentation(destinationFilename)) >+ return false; >+ >+ return !link(sourceFilename.data(), destinationFilename.data()); >+#endif >+} >+ > bool hardLinkOrCopyFile(const String& source, const String& destination) > { > #if OS(WINDOWS) >diff --git a/Source/WTF/wtf/posix/FileSystemPOSIX.cpp b/Source/WTF/wtf/posix/FileSystemPOSIX.cpp >index 70d2f98e4d72c2cd15994e9fa7f7a9bc4bf0af56..904f1fe982eb9729dae93ef00c080cf7aefa3302 100644 >--- a/Source/WTF/wtf/posix/FileSystemPOSIX.cpp >+++ b/Source/WTF/wtf/posix/FileSystemPOSIX.cpp >@@ -444,6 +444,22 @@ end: > } > #endif // !PLATFORM(COCOA) > >+bool hardLink(const String& source, const String& destination) >+{ >+ if (source.isEmpty() || destination.isEmpty()) >+ return false; >+ >+ auto fsSource = fileSystemRepresentation(source); >+ if (!fsSource.data()) >+ return false; >+ >+ auto fsDestination = fileSystemRepresentation(destination); >+ if (!fsDestination.data()) >+ return false; >+ >+ return link(fsSource.data(), fsDestination.data()) != -1; >+} >+ > bool hardLinkOrCopyFile(const String& source, const String& destination) > { > if (source.isEmpty() || destination.isEmpty()) >diff --git a/Source/WTF/wtf/win/FileSystemWin.cpp b/Source/WTF/wtf/win/FileSystemWin.cpp >index cf46a509b9e98d932dd9dc94a9126b88b3738dca..f7cf0703ad55945775928ca0b20b7b628d67c7f9 100644 >--- a/Source/WTF/wtf/win/FileSystemWin.cpp >+++ b/Source/WTF/wtf/win/FileSystemWin.cpp >@@ -496,6 +496,11 @@ int readFromFile(PlatformFileHandle handle, char* data, int length) > return static_cast<int>(bytesRead); > } > >+bool hardLink(const String& source, const String& destination) >+{ >+ return CreateHardLink(destination.wideCharacters().data(), source.wideCharacters().data(), nullptr); >+} >+ > bool hardLinkOrCopyFile(const String& source, const String& destination) > { > return !!::CopyFile(source.wideCharacters().data(), destination.wideCharacters().data(), TRUE); >diff --git a/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp b/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp >index d90c70fb0acfaeba53496c033f852210d5d77ed5..4cc67f82ca84e32eed88b22de18569fe2c58afa7 100644 >--- a/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp >+++ b/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp >@@ -423,7 +423,7 @@ void Engine::readFile(const String& filename, CompletionHandler<void(const Netwo > m_pendingReadCallbacks.add(++m_pendingCallbacksCounter, WTFMove(callback)); > m_ioQueue->dispatch([this, weakThis = makeWeakPtr(this), identifier = m_pendingCallbacksCounter, filename = filename.isolatedCopy()]() mutable { > auto channel = IOChannel::open(filename, IOChannel::Type::Read); >- if (channel->fileDescriptor() < 0) { >+ if (!channel->isOpened()) { > RunLoop::main().dispatch([this, weakThis = WTFMove(weakThis), identifier]() mutable { > if (!weakThis) > return; >diff --git a/Source/WebKit/NetworkProcess/cache/NetworkCacheBlobStorage.cpp b/Source/WebKit/NetworkProcess/cache/NetworkCacheBlobStorage.cpp >index cf55b00573879a2c51ab591ffc79b8af312b0a6b..72b77bd4cfc91546072a0dbd50a3c13f09cdd605 100644 >--- a/Source/WebKit/NetworkProcess/cache/NetworkCacheBlobStorage.cpp >+++ b/Source/WebKit/NetworkProcess/cache/NetworkCacheBlobStorage.cpp >@@ -86,46 +86,40 @@ String BlobStorage::blobPathForHash(const SHA1::Digest& hash) const > > BlobStorage::Blob BlobStorage::add(const String& path, const Data& data) > { >-#if !OS(WINDOWS) > ASSERT(!RunLoop::isMain()); > > auto hash = computeSHA1(data, m_salt); > if (data.isEmpty()) > return { data, hash }; > >- String blobPathString = blobPathForHash(hash); >+ String blobPath = blobPathForHash(hash); > >- auto blobPath = FileSystem::fileSystemRepresentation(blobPathString); >- auto linkPath = FileSystem::fileSystemRepresentation(path); >- unlink(linkPath.data()); >+ FileSystem::deleteFile(path); > >- bool blobExists = access(blobPath.data(), F_OK) != -1; >+ bool blobExists = FileSystem::fileExists(blobPath); > if (blobExists) { >- FileSystem::makeSafeToUseMemoryMapForPath(blobPathString); >- auto existingData = mapFile(blobPath.data()); >+ FileSystem::makeSafeToUseMemoryMapForPath(blobPath); >+ auto existingData = mapFile(blobPath); > if (bytesEqual(existingData, data)) { >- if (link(blobPath.data(), linkPath.data()) == -1) >- WTFLogAlways("Failed to create hard link from %s to %s", blobPath.data(), linkPath.data()); >+ if (!FileSystem::hardLink(path, blobPath)) >+ WTFLogAlways("Failed to create hard link from %s to %s", blobPath.utf8().data(), path.utf8().data()); > return { existingData, hash }; > } >- unlink(blobPath.data()); >+ FileSystem::deleteFile(blobPath); > } > >- auto mappedData = data.mapToFile(blobPath.data()); >+ auto mappedData = data.mapToFile(blobPath); > if (mappedData.isNull()) > return { }; > >- FileSystem::makeSafeToUseMemoryMapForPath(blobPathString); >+ FileSystem::makeSafeToUseMemoryMapForPath(blobPath); > >- if (link(blobPath.data(), linkPath.data()) == -1) >- WTFLogAlways("Failed to create hard link from %s to %s", blobPath.data(), linkPath.data()); >+ if (!FileSystem::hardLink(path, blobPath)) >+ WTFLogAlways("Failed to create hard link from %s to %s", blobPath.utf8().data(), path.utf8().data()); > > m_approximateSize += mappedData.size(); > > return { mappedData, hash }; >-#else >- return { Data(), computeSHA1(data, m_salt) }; >-#endif > } > > BlobStorage::Blob BlobStorage::get(const String& path) >@@ -142,8 +136,7 @@ void BlobStorage::remove(const String& path) > { > ASSERT(!RunLoop::isMain()); > >- auto linkPath = FileSystem::fileSystemRepresentation(path); >- unlink(linkPath.data()); >+ FileSystem::deleteFile(path); > } > > unsigned BlobStorage::shareCount(const String& path) >diff --git a/Source/WebKit/NetworkProcess/cache/NetworkCacheData.cpp b/Source/WebKit/NetworkProcess/cache/NetworkCacheData.cpp >index 1a32aa9a0e53b46957aa8eb3bb23856f0a899f31..ae0c66dac3e567c3054d2bfefe908a81cf14b29f 100644 >--- a/Source/WebKit/NetworkProcess/cache/NetworkCacheData.cpp >+++ b/Source/WebKit/NetworkProcess/cache/NetworkCacheData.cpp >@@ -39,10 +39,10 @@ > namespace WebKit { > namespace NetworkCache { > >-Data Data::mapToFile(const char* path) const >-{ > #if !OS(WINDOWS) >- int fd = open(path, O_CREAT | O_EXCL | O_RDWR , S_IRUSR | S_IWUSR); >+Data Data::mapToFile(const String& path) const >+{ >+ int fd = open(FileSystem::fileSystemRepresentation(path).data(), O_CREAT | O_EXCL | O_RDWR , S_IRUSR | S_IWUSR); > if (fd < 0) > return { }; > >@@ -71,14 +71,22 @@ Data Data::mapToFile(const char* path) const > msync(map, m_size, MS_ASYNC); > > return Data::adoptMap(map, m_size, fd); >+} > #else >- return Data(); >-#endif >+Data Data::mapToFile(const String& path) const >+{ >+ auto file = FileSystem::openFile(path, FileSystem::FileOpenMode::Write); >+ if (!FileSystem::isHandleValid(file)) >+ return { }; >+ if (FileSystem::writeToFile(file, reinterpret_cast<const char*>(data()), size()) < 0) >+ return { }; >+ return Data(Vector<uint8_t>(m_buffer)); > } >+#endif > >+#if !OS(WINDOWS) > Data mapFile(const char* path) > { >-#if !OS(WINDOWS) > int fd = open(path, O_RDONLY, 0); > if (fd < 0) > return { }; >@@ -94,14 +102,27 @@ Data mapFile(const char* path) > } > > return adoptAndMapFile(fd, 0, size); >+} >+#endif >+ >+Data mapFile(const String& path) >+{ >+#if !OS(WINDOWS) >+ return mapFile(FileSystem::fileSystemRepresentation(path).data()); > #else >- return Data(); >+ auto file = FileSystem::openFile(path, FileSystem::FileOpenMode::Read); >+ if (!FileSystem::isHandleValid(file)) >+ return { }; >+ long long size; >+ if (!FileSystem::getFileSize(file, size)) >+ return { }; >+ return adoptAndMapFile(file, 0, size); > #endif > } > >+#if !OS(WINDOWS) > Data adoptAndMapFile(int fd, size_t offset, size_t size) > { >-#if !OS(WINDOWS) > if (!size) { > close(fd); > return Data::empty(); >@@ -114,10 +135,13 @@ Data adoptAndMapFile(int fd, size_t offset, size_t size) > } > > return Data::adoptMap(map, size, fd); >+} > #else >- return Data(); >-#endif >+Data adoptAndMapFile(FileSystem::PlatformFileHandle file, size_t offset, size_t size) >+{ >+ return Data(file, offset, size); > } >+#endif > > SHA1::Digest computeSHA1(const Data& data, const Salt& salt) > { >@@ -142,7 +166,6 @@ bool bytesEqual(const Data& a, const Data& b) > return !memcmp(a.data(), b.data(), a.size()); > } > >-#if !OS(WINDOWS) > static Salt makeSalt() > { > Salt salt; >@@ -151,7 +174,6 @@ static Salt makeSalt() > *reinterpret_cast<uint32_t*>(&salt[4]) = cryptographicallyRandomNumber(); > return salt; > } >-#endif > > Optional<Salt> readOrMakeSalt(const String& path) > { >@@ -173,7 +195,21 @@ Optional<Salt> readOrMakeSalt(const String& path) > } > return salt; > #else >- return Salt(); >+ auto file = FileSystem::openFile(path, FileSystem::FileOpenMode::Read); >+ Salt salt; >+ auto bytesRead = FileSystem::readFromFile(file, reinterpret_cast<char*>(salt.data()), salt.size()); >+ FileSystem::closeFile(file); >+ if (bytesRead != salt.size()) { >+ salt = makeSalt(); >+ >+ FileSystem::deleteFile(path); >+ file = FileSystem::openFile(path, FileSystem::FileOpenMode::Write); >+ bool success = FileSystem::writeToFile(file, reinterpret_cast<char*>(salt.data()), salt.size()) == salt.size(); >+ FileSystem::closeFile(file); >+ if (!success) >+ return { }; >+ } >+ return salt; > #endif > } > >diff --git a/Source/WebKit/NetworkProcess/cache/NetworkCacheData.h b/Source/WebKit/NetworkProcess/cache/NetworkCacheData.h >index 5559c35ba7fcf6cf9e059bb93d4b9d21b5240883..0e30c0a86762b09907c08a55f3da761a290c8cdb 100644 >--- a/Source/WebKit/NetworkProcess/cache/NetworkCacheData.h >+++ b/Source/WebKit/NetworkProcess/cache/NetworkCacheData.h >@@ -25,6 +25,7 @@ > > #pragma once > >+#include <wtf/FileSystem.h> > #include <wtf/FunctionDispatcher.h> > #include <wtf/SHA1.h> > #include <wtf/ThreadSafeRefCounted.h> >@@ -52,7 +53,9 @@ public: > ~Data() { } > > static Data empty(); >+#if !OS(WINDOWS) > static Data adoptMap(void* map, size_t, int fd); >+#endif > > #if PLATFORM(COCOA) > enum class Backing { Buffer, Map }; >@@ -60,20 +63,31 @@ public: > #endif > #if USE(SOUP) > Data(GRefPtr<SoupBuffer>&&, int fd = -1); >+#elif OS(WINDOWS) >+ explicit Data(Vector<uint8_t>&&); >+ Data(FileSystem::PlatformFileHandle, size_t offset, size_t); > #endif > bool isNull() const; >+#if !OS(WINDOWS) > bool isEmpty() const { return !m_size; } >+#else >+ bool isEmpty() const { return m_buffer.isEmpty(); } >+#endif > > const uint8_t* data() const; >+#if !OS(WINDOWS) > size_t size() const { return m_size; } > bool isMap() const { return m_isMap; } >+#else >+ size_t size() const { return m_buffer.size(); } >+#endif > RefPtr<SharedMemory> tryCreateSharedMemory() const; > > Data subrange(size_t offset, size_t) const; > > bool apply(const Function<bool (const uint8_t*, size_t)>&) const; > >- Data mapToFile(const char* path) const; >+ Data mapToFile(const String& path) const; > > #if PLATFORM(COCOA) > dispatch_data_t dispatchData() const { return m_dispatchData.get(); } >@@ -90,18 +104,29 @@ private: > mutable GRefPtr<SoupBuffer> m_buffer; > int m_fileDescriptor { -1 }; > #endif >+#if OS(WINDOWS) >+ Vector<uint8_t> m_buffer; >+#else > mutable const uint8_t* m_data { nullptr }; > size_t m_size { 0 }; > bool m_isMap { false }; >+#endif > }; > > Data concatenate(const Data&, const Data&); > bool bytesEqual(const Data&, const Data&); >-Data adoptAndMapFile(int fd, size_t offset, size_t); >+#if !OS(WINDOWS) >+Data adoptAndMapFile(int, size_t offset, size_t); >+#else >+Data adoptAndMapFile(FileSystem::PlatformFileHandle, size_t offset, size_t); >+#endif > #if USE(GLIB) && !PLATFORM(WIN) > Data adoptAndMapFile(GFileIOStream*, size_t offset, size_t); > #endif >+#if !OS(WINDOWS) > Data mapFile(const char* path); >+#endif >+Data mapFile(const String& path); > > using Salt = std::array<uint8_t, 8>; > >diff --git a/Source/WebKit/NetworkProcess/cache/NetworkCacheDataCurl.cpp b/Source/WebKit/NetworkProcess/cache/NetworkCacheDataCurl.cpp >index 690c5f9a4c548d07c05f3991d8b085af3b4378ba..95de110dd7b0245a4b084bbf7118e70578be3184 100644 >--- a/Source/WebKit/NetworkProcess/cache/NetworkCacheDataCurl.cpp >+++ b/Source/WebKit/NetworkProcess/cache/NetworkCacheDataCurl.cpp >@@ -26,55 +26,62 @@ > #include "config.h" > #include "NetworkCacheData.h" > >-#include <WebCore/NotImplemented.h> >- > namespace WebKit { > namespace NetworkCache { > > Data::Data(const uint8_t* data, size_t size) > { >- notImplemented(); >+ m_buffer.resize(size); >+ memcpy(m_buffer.data(), data, size); >+} >+ >+Data::Data(FileSystem::PlatformFileHandle file, size_t offset, size_t size) >+{ >+ m_buffer.resize(size); >+ FileSystem::seekFile(file, offset, FileSystem::FileSeekOrigin::Beginning); >+ FileSystem::readFromFile(file, reinterpret_cast<char*>(m_buffer.data()), size); >+ FileSystem::closeFile(file); >+} >+ >+Data::Data(Vector<uint8_t>&& buffer) >+ : m_buffer(WTFMove(buffer)) >+{ > } > > Data Data::empty() > { >- notImplemented(); > return { }; > } > > const uint8_t* Data::data() const > { >- notImplemented(); >- return nullptr; >+ return m_buffer.data(); > } > > bool Data::isNull() const > { >- notImplemented(); >- return true; >+ return m_buffer.isEmpty(); > } > > bool Data::apply(const Function<bool(const uint8_t*, size_t)>& applier) const > { >- notImplemented(); >- return false; >+ if (isEmpty()) >+ return false; >+ >+ return applier(reinterpret_cast<const uint8_t*>(m_buffer.data()), m_buffer.size()); > } > > Data Data::subrange(size_t offset, size_t size) const > { >- return { }; >+ return { m_buffer.data() + offset, size }; > } > > Data concatenate(const Data& a, const Data& b) > { >- notImplemented(); >- return { }; >-} >- >-Data Data::adoptMap(void* map, size_t size, int fd) >-{ >- notImplemented(); >- return { }; >+ Vector<uint8_t> buffer(a.size() + b.size()); >+ memcpy(buffer.data(), a.data(), a.size()); >+ memcpy(buffer.data() + a.size(), b.data(), b.size()); >+ return Data(WTFMove(buffer)); > } > > } // namespace NetworkCache >diff --git a/Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp b/Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp >index 75a26654ec06afa52bdb12ab26320c7e63b2561b..99d41de204c912306fdd1f2b30f6ec95cc98486c 100644 >--- a/Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp >+++ b/Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp >@@ -87,7 +87,11 @@ void traverseDirectory(const String& path, const Function<void (const String&, D > } > closedir(dir); > #else >- function(String(), DirectoryEntryType::File); >+ auto entries = FileSystem::listDirectory(path); >+ for (auto& entry : entries) { >+ auto type = FileSystem::fileIsDirectory(entry, FileSystem::ShouldFollowSymbolicLinks::No) ? DirectoryEntryType::Directory : DirectoryEntryType::File; >+ function(entry, type); >+ } > #endif > } > >@@ -127,7 +131,9 @@ FileTimes fileTimes(const String& path) > return { WallTime::fromRawSeconds(g_ascii_strtoull(birthtimeString, nullptr, 10)), > WallTime::fromRawSeconds(g_file_info_get_attribute_uint64(fileInfo.get(), "time::modified")) }; > #elif OS(WINDOWS) >- return FileTimes(); >+ auto createTime = FileSystem::getFileCreationTime(path); >+ auto modifyTime = FileSystem::getFileModificationTime(path); >+ return { createTime.valueOr(WallTime()), modifyTime.valueOr(WallTime()) }; > #endif > } > >@@ -142,6 +148,14 @@ void updateFileModificationTimeIfNeeded(const String& path) > #if !OS(WINDOWS) > // This really updates both the access time and the modification time. > utimes(FileSystem::fileSystemRepresentation(path).data(), nullptr); >+#else >+ FILETIME time; >+ GetSystemTimeAsFileTime(&time); >+ auto file = CreateFile(path.wideCharacters().data(), GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); >+ if (file == INVALID_HANDLE_VALUE) >+ return; >+ SetFileTime(file, &time, &time, &time); >+ CloseHandle(file); > #endif > } > >diff --git a/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannel.h b/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannel.h >index b47d13d5f7d6c808e0a304bad60a25aa5d657cb1..5767f930800001d12dd9352b74b1d1adbde8490a 100644 >--- a/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannel.h >+++ b/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannel.h >@@ -52,7 +52,11 @@ public: > const String& path() const { return m_path; } > Type type() const { return m_type; } > >- int fileDescriptor() const { return m_fileDescriptor; } >+#if !USE(SOUP) >+ bool isOpened() const { return FileSystem::isHandleValid(m_fileDescriptor); } >+#else >+ bool isOpened() const { return true; } >+#endif > > ~IOChannel(); > >@@ -66,7 +70,9 @@ private: > String m_path; > Type m_type; > >- int m_fileDescriptor { 0 }; >+#if !USE(SOUP) >+ FileSystem::PlatformFileHandle m_fileDescriptor { FileSystem::invalidPlatformFileHandle }; >+#endif > std::atomic<bool> m_wasDeleted { false }; // Try to narrow down a crash, https://bugs.webkit.org/show_bug.cgi?id=165659 > #if PLATFORM(COCOA) > OSObjectPtr<dispatch_io_t> m_dispatchIO; >diff --git a/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp b/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp >index daf8905c58135a80f3e6d20d4ea38ee87780fbbd..db49e653d6d2e8802f1db69bd1dfdf3064a84b52 100644 >--- a/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp >+++ b/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp >@@ -26,20 +26,33 @@ > #include "config.h" > #include "NetworkCacheIOChannel.h" > >-#include <WebCore/NotImplemented.h> >+#include <wtf/RunLoop.h> > > namespace WebKit { > namespace NetworkCache { > > IOChannel::IOChannel(const String& filePath, Type type) >- : m_path{filePath} >- , m_type{type} >+ : m_path(filePath) >+ , m_type(type) > { >- notImplemented(); >+ FileSystem::FileOpenMode mode; >+ switch (type) { >+ case Type::Read: >+ mode = FileSystem::FileOpenMode::Read; >+ break; >+ case Type::Write: >+ mode = FileSystem::FileOpenMode::Write; >+ break; >+ case Type::Create: >+ mode = FileSystem::FileOpenMode::Write; >+ break; >+ } >+ m_fileDescriptor = FileSystem::openFile(filePath, mode); > } > > IOChannel::~IOChannel() > { >+ FileSystem::closeFile(m_fileDescriptor); > } > > Ref<IOChannel> IOChannel::open(const String& filePath, IOChannel::Type type) >@@ -47,14 +60,37 @@ Ref<IOChannel> IOChannel::open(const String& filePath, IOChannel::Type type) > return adoptRef(*new IOChannel(filePath, type)); > } > >+static inline void runTaskInQueue(Function<void()>&& task, WorkQueue* queue) >+{ >+ if (queue) { >+ queue->dispatch(WTFMove(task)); >+ return; >+ } >+ >+ // Using nullptr as queue submits the result to the main context. >+ RunLoop::main().dispatch(WTFMove(task)); >+} >+ > void IOChannel::read(size_t offset, size_t size, WorkQueue* queue, Function<void(Data&, int error)>&& completionHandler) > { >- notImplemented(); >+ runTaskInQueue([this, protectedThis = makeRef(*this), offset, size, completionHandler = WTFMove(completionHandler)] { >+ Vector<uint8_t> buffer(size); >+ FileSystem::seekFile(m_fileDescriptor, offset, FileSystem::FileSeekOrigin::Beginning); >+ int err = FileSystem::readFromFile(m_fileDescriptor, reinterpret_cast<char*>(buffer.data()), size); >+ err = err < 0 ? err : 0; >+ auto data = Data(WTFMove(buffer)); >+ completionHandler(data, err); >+ }, queue); > } > > void IOChannel::write(size_t offset, const Data& data, WorkQueue* queue, Function<void(int error)>&& completionHandler) > { >- notImplemented(); >+ runTaskInQueue([this, protectedThis = makeRef(*this), offset, data, completionHandler = WTFMove(completionHandler)] { >+ FileSystem::seekFile(m_fileDescriptor, offset, FileSystem::FileSeekOrigin::Beginning); >+ int err = FileSystem::writeToFile(m_fileDescriptor, reinterpret_cast<const char*>(data.data()), data.size()); >+ err = err < 0 ? err : 0; >+ completionHandler(err); >+ }, queue); > } > > } // namespace NetworkCache
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 196289
:
366805
|
367027
|
367926
|
367983
|
368006
|
369239
|
369244
|
369248
|
369250
|
369256
|
369260
|
369271
|
369273
|
369276
|
369278
|
369288
|
369358
|
369457
|
369539