Changeset 245186 in webkit
- Timestamp:
- May 10, 2019 12:01:54 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r245177 r245186 1 2019-05-10 Fujii Hironori <Hironori.Fujii@sony.com> 2 3 [WinCairo] storage/indexeddb tests are timing out 4 https://bugs.webkit.org/show_bug.cgi?id=196289 5 6 Reviewed by Alex Christensen. 7 8 * wtf/FileSystem.h: Added hardLink. 9 * wtf/glib/FileSystemGlib.cpp: 10 (WTF::FileSystemImpl::hardLink): 11 (WTF::FileSystemImpl::hardLinkOrCopyFile): 12 * wtf/posix/FileSystemPOSIX.cpp: 13 (WTF::FileSystemImpl::hardLink): 14 (WTF::FileSystemImpl::hardLinkOrCopyFile): 15 * wtf/win/FileSystemWin.cpp: 16 (WTF::FileSystemImpl::hardLink): 17 (WTF::FileSystemImpl::hardLinkOrCopyFile): 18 Added hardLink. Let hardLinkOrCopyFile use the hardLink. 19 1 20 2019-05-10 Yusuke Suzuki <ysuzuki@apple.com> 2 21 -
trunk/Source/WTF/wtf/FileSystem.h
r244921 r245186 152 152 WTF_EXPORT_PRIVATE bool appendFileContentsToFileHandle(const String& path, PlatformFileHandle&); 153 153 154 WTF_EXPORT_PRIVATE bool hardLink(const String& source, const String& destination); 154 155 // Hard links a file if possible, copies it if not. 155 156 WTF_EXPORT_PRIVATE bool hardLinkOrCopyFile(const String& source, const String& destination); -
trunk/Source/WTF/wtf/glib/FileSystemGlib.cpp
r240969 r245186 430 430 } 431 431 432 bool hardLink OrCopyFile(const String& source, const String& destination)432 bool hardLink(const String& source, const String& destination) 433 433 { 434 434 #if OS(WINDOWS) 435 return !!::CopyFile(source.charactersWithNullTermination().data(), destination.charactersWithNullTermination().data(), TRUE);435 return CreateHardLink(destination.wideCharacters().data(), source.wideCharacters().data(), nullptr); 436 436 #else 437 437 auto sourceFilename = fileSystemRepresentation(source); … … 443 443 return false; 444 444 445 if (!link(sourceFilename.data(), destinationFilename.data())) 445 return !link(sourceFilename.data(), destinationFilename.data()); 446 #endif 447 } 448 449 bool hardLinkOrCopyFile(const String& source, const String& destination) 450 { 451 if (hardLink(source, destination)) 446 452 return true; 447 453 448 454 // Hard link failed. Perform a copy instead. 455 #if OS(WINDOWS) 456 return !!::CopyFile(source.wideCharacters().data(), destination.wideCharacters().data(), TRUE); 457 #else 458 auto sourceFilename = fileSystemRepresentation(source); 459 if (!validRepresentation(sourceFilename)) 460 return false; 461 462 auto destinationFilename = fileSystemRepresentation(destination); 463 if (!validRepresentation(destinationFilename)) 464 return false; 465 449 466 GRefPtr<GFile> sourceFile = adoptGRef(g_file_new_for_path(sourceFilename.data())); 450 467 GRefPtr<GFile> destinationFile = adoptGRef(g_file_new_for_path(destinationFilename.data())); -
trunk/Source/WTF/wtf/posix/FileSystemPOSIX.cpp
r241654 r245186 445 445 #endif // !PLATFORM(COCOA) 446 446 447 bool hardLink(const String& source, const String& destination) 448 { 449 if (source.isEmpty() || destination.isEmpty()) 450 return false; 451 452 auto fsSource = fileSystemRepresentation(source); 453 if (!fsSource.data()) 454 return false; 455 456 auto fsDestination = fileSystemRepresentation(destination); 457 if (!fsDestination.data()) 458 return false; 459 460 return !link(fsSource.data(), fsDestination.data()); 461 } 462 447 463 bool hardLinkOrCopyFile(const String& source, const String& destination) 448 464 { 465 if (hardLink(source, destination)) 466 return true; 467 468 // Hard link failed. Perform a copy instead. 449 469 if (source.isEmpty() || destination.isEmpty()) 450 470 return false; 451 471 452 CStringfsSource = fileSystemRepresentation(source);472 auto fsSource = fileSystemRepresentation(source); 453 473 if (!fsSource.data()) 454 474 return false; 455 475 456 CStringfsDestination = fileSystemRepresentation(destination);476 auto fsDestination = fileSystemRepresentation(destination); 457 477 if (!fsDestination.data()) 458 478 return false; 459 479 460 if (!link(fsSource.data(), fsDestination.data()))461 return true;462 463 // Hard link failed. Perform a copy instead.464 480 auto handle = open(fsDestination.data(), O_WRONLY | O_CREAT | O_EXCL, 0666); 465 481 if (handle == -1) -
trunk/Source/WTF/wtf/win/FileSystemWin.cpp
r242592 r245186 497 497 } 498 498 499 bool hardLink(const String& source, const String& destination) 500 { 501 return CreateHardLink(destination.wideCharacters().data(), source.wideCharacters().data(), nullptr); 502 } 503 499 504 bool hardLinkOrCopyFile(const String& source, const String& destination) 500 505 { 506 if (hardLink(source, destination)) 507 return true; 508 509 // Hard link failed. Perform a copy instead. 501 510 return !!::CopyFile(source.wideCharacters().data(), destination.wideCharacters().data(), TRUE); 502 511 } -
trunk/Source/WebKit/ChangeLog
r245185 r245186 1 2019-05-10 Fujii Hironori <Hironori.Fujii@sony.com> 2 3 [WinCairo] storage/indexeddb tests are timing out 4 https://bugs.webkit.org/show_bug.cgi?id=196289 5 6 Reviewed by Alex Christensen. 7 8 storage/indexeddb tests were timing out for WinCairo port because 9 WebKit::NetworkCache classes were not implemented yet for Windows. 10 11 Implement WebKit::NetworkCache classes by using WTF::FileSystem 12 functions. 13 14 * NetworkProcess/cache/CacheStorageEngine.cpp: 15 (WebKit::CacheStorage::Engine::readFile): Use 16 IOChannel::isOpened() to check the channel is opened instead of 17 checking the file descriptor. 18 * NetworkProcess/cache/NetworkCacheBlobStorage.cpp: 19 (WebKit::NetworkCache::BlobStorage::add): 20 (WebKit::NetworkCache::BlobStorage::remove): 21 * NetworkProcess/cache/NetworkCacheData.cpp: 22 (WebKit::NetworkCache::Data::mapToFile const): 23 (WebKit::NetworkCache::mapFile): 24 (WebKit::NetworkCache::adoptAndMapFile): 25 (WebKit::NetworkCache::makeSalt): 26 (WebKit::NetworkCache::readOrMakeSalt): 27 * NetworkProcess/cache/NetworkCacheData.h: 28 (WebKit::NetworkCache::Data::isEmpty const): 29 (WebKit::NetworkCache::Data::size const): 30 * NetworkProcess/cache/NetworkCacheDataCurl.cpp: 31 (WebKit::NetworkCache::Data::Data): 32 (WebKit::NetworkCache::Data::empty): 33 (WebKit::NetworkCache::Data::data const): 34 (WebKit::NetworkCache::Data::isNull const): 35 (WebKit::NetworkCache::Data::apply const): 36 (WebKit::NetworkCache::Data::subrange const): 37 (WebKit::NetworkCache::concatenate): 38 (WebKit::NetworkCache::Data::adoptMap): Deleted. 39 * NetworkProcess/cache/NetworkCacheFileSystem.cpp: 40 (WebKit::NetworkCache::traverseDirectory): 41 (WebKit::NetworkCache::fileTimes): 42 (WebKit::NetworkCache::updateFileModificationTimeIfNeeded): 43 (WebKit::NetworkCache::isSafeToUseMemoryMapForPath): 44 * NetworkProcess/cache/NetworkCacheIOChannel.h: 45 (WebKit::NetworkCache::IOChannel::isOpened const): 46 (WebKit::NetworkCache::IOChannel::fileDescriptor const): Deleted. 47 * NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp: 48 (WebKit::NetworkCache::IOChannel::IOChannel): 49 (WebKit::NetworkCache::IOChannel::~IOChannel): 50 (WebKit::NetworkCache::runTaskInQueue): 51 (WebKit::NetworkCache::IOChannel::read): 52 (WebKit::NetworkCache::IOChannel::write): 53 1 54 2019-05-10 Chris Dumez <cdumez@apple.com> 2 55 -
trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp
r244364 r245186 424 424 m_ioQueue->dispatch([this, weakThis = makeWeakPtr(this), identifier = m_pendingCallbacksCounter, filename = filename.isolatedCopy()]() mutable { 425 425 auto channel = IOChannel::open(filename, IOChannel::Type::Read); 426 if ( channel->fileDescriptor() < 0) {426 if (!channel->isOpened()) { 427 427 RunLoop::main().dispatch([this, weakThis = WTFMove(weakThis), identifier]() mutable { 428 428 if (!weakThis) -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheBlobStorage.cpp
r244997 r245186 87 87 BlobStorage::Blob BlobStorage::add(const String& path, const Data& data) 88 88 { 89 #if !OS(WINDOWS)90 89 ASSERT(!RunLoop::isMain()); 91 90 … … 94 93 return { data, hash }; 95 94 96 String blobPath String= blobPathForHash(hash);95 String blobPath = blobPathForHash(hash); 97 96 98 auto blobPath = FileSystem::fileSystemRepresentation(blobPathString); 99 auto linkPath = FileSystem::fileSystemRepresentation(path); 100 unlink(linkPath.data()); 97 FileSystem::deleteFile(path); 101 98 102 bool blobExists = access(blobPath.data(), F_OK) != -1;99 bool blobExists = FileSystem::fileExists(blobPath); 103 100 if (blobExists) { 104 FileSystem::makeSafeToUseMemoryMapForPath(blobPath String);105 auto existingData = mapFile(blobPath .data());101 FileSystem::makeSafeToUseMemoryMapForPath(blobPath); 102 auto existingData = mapFile(blobPath); 106 103 if (bytesEqual(existingData, data)) { 107 if ( link(blobPath.data(), linkPath.data()) == -1)108 WTFLogAlways("Failed to create hard link from %s to %s", blobPath. data(), linkPath.data());104 if (!FileSystem::hardLink(blobPath, path)) 105 WTFLogAlways("Failed to create hard link from %s to %s", blobPath.utf8().data(), path.utf8().data()); 109 106 return { existingData, hash }; 110 107 } 111 unlink(blobPath.data());108 FileSystem::deleteFile(blobPath); 112 109 } 113 110 114 auto mappedData = data.mapToFile(blobPath .data());111 auto mappedData = data.mapToFile(blobPath); 115 112 if (mappedData.isNull()) 116 113 return { }; 117 114 118 FileSystem::makeSafeToUseMemoryMapForPath(blobPath String);115 FileSystem::makeSafeToUseMemoryMapForPath(blobPath); 119 116 120 if ( link(blobPath.data(), linkPath.data()) == -1)121 WTFLogAlways("Failed to create hard link from %s to %s", blobPath. data(), linkPath.data());117 if (!FileSystem::hardLink(blobPath, path)) 118 WTFLogAlways("Failed to create hard link from %s to %s", blobPath.utf8().data(), path.utf8().data()); 122 119 123 120 m_approximateSize += mappedData.size(); 124 121 125 122 return { mappedData, hash }; 126 #else127 return { Data(), computeSHA1(data, m_salt) };128 #endif129 123 } 130 124 … … 143 137 ASSERT(!RunLoop::isMain()); 144 138 145 auto linkPath = FileSystem::fileSystemRepresentation(path); 146 unlink(linkPath.data()); 139 FileSystem::deleteFile(path); 147 140 } 148 141 -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheData.cpp
r240437 r245186 40 40 namespace NetworkCache { 41 41 42 Data Data::mapToFile(const char* path) const 43 { 44 #if !OS(WINDOWS) 45 int fd = open( path, O_CREAT | O_EXCL | O_RDWR , S_IRUSR | S_IWUSR);42 #if !OS(WINDOWS) 43 Data Data::mapToFile(const String& path) const 44 { 45 int fd = open(FileSystem::fileSystemRepresentation(path).data(), O_CREAT | O_EXCL | O_RDWR , S_IRUSR | S_IWUSR); 46 46 if (fd < 0) 47 47 return { }; … … 72 72 73 73 return Data::adoptMap(map, m_size, fd); 74 #else 75 return Data(); 76 #endif 77 } 78 74 } 75 #else 76 Data Data::mapToFile(const String& path) const 77 { 78 auto file = FileSystem::openFile(path, FileSystem::FileOpenMode::Write); 79 if (!FileSystem::isHandleValid(file)) 80 return { }; 81 if (FileSystem::writeToFile(file, reinterpret_cast<const char*>(data()), size()) < 0) 82 return { }; 83 return Data(Vector<uint8_t>(m_buffer)); 84 } 85 #endif 86 87 #if !OS(WINDOWS) 79 88 Data mapFile(const char* path) 80 89 { 81 #if !OS(WINDOWS)82 90 int fd = open(path, O_RDONLY, 0); 83 91 if (fd < 0) … … 95 103 96 104 return adoptAndMapFile(fd, 0, size); 97 #else 98 return Data(); 99 #endif 100 } 101 105 } 106 #endif 107 108 Data mapFile(const String& path) 109 { 110 #if !OS(WINDOWS) 111 return mapFile(FileSystem::fileSystemRepresentation(path).data()); 112 #else 113 auto file = FileSystem::openFile(path, FileSystem::FileOpenMode::Read); 114 if (!FileSystem::isHandleValid(file)) 115 return { }; 116 long long size; 117 if (!FileSystem::getFileSize(file, size)) 118 return { }; 119 return adoptAndMapFile(file, 0, size); 120 #endif 121 } 122 123 #if !OS(WINDOWS) 102 124 Data adoptAndMapFile(int fd, size_t offset, size_t size) 103 125 { 104 #if !OS(WINDOWS)105 126 if (!size) { 106 127 close(fd); … … 115 136 116 137 return Data::adoptMap(map, size, fd); 117 #else 118 return Data(); 119 #endif 120 } 138 } 139 #else 140 Data adoptAndMapFile(FileSystem::PlatformFileHandle file, size_t offset, size_t size) 141 { 142 return Data(file, offset, size); 143 } 144 #endif 121 145 122 146 SHA1::Digest computeSHA1(const Data& data, const Salt& salt) … … 143 167 } 144 168 145 #if !OS(WINDOWS)146 169 static Salt makeSalt() 147 170 { … … 152 175 return salt; 153 176 } 154 #endif155 177 156 178 Optional<Salt> readOrMakeSalt(const String& path) … … 174 196 return salt; 175 197 #else 176 return Salt(); 198 auto file = FileSystem::openFile(path, FileSystem::FileOpenMode::Read); 199 Salt salt; 200 auto bytesRead = FileSystem::readFromFile(file, reinterpret_cast<char*>(salt.data()), salt.size()); 201 FileSystem::closeFile(file); 202 if (bytesRead != salt.size()) { 203 salt = makeSalt(); 204 205 FileSystem::deleteFile(path); 206 file = FileSystem::openFile(path, FileSystem::FileOpenMode::Write); 207 bool success = FileSystem::writeToFile(file, reinterpret_cast<char*>(salt.data()), salt.size()) == salt.size(); 208 FileSystem::closeFile(file); 209 if (!success) 210 return { }; 211 } 212 return salt; 177 213 #endif 178 214 } -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheData.h
r241283 r245186 26 26 #pragma once 27 27 28 #include <wtf/FileSystem.h> 28 29 #include <wtf/FunctionDispatcher.h> 29 30 #include <wtf/SHA1.h> … … 53 54 54 55 static Data empty(); 56 #if !OS(WINDOWS) 55 57 static Data adoptMap(void* map, size_t, int fd); 58 #endif 56 59 57 60 #if PLATFORM(COCOA) … … 61 64 #if USE(SOUP) 62 65 Data(GRefPtr<SoupBuffer>&&, int fd = -1); 66 #elif OS(WINDOWS) 67 explicit Data(Vector<uint8_t>&&); 68 Data(FileSystem::PlatformFileHandle, size_t offset, size_t); 63 69 #endif 64 70 bool isNull() const; … … 74 80 bool apply(const Function<bool (const uint8_t*, size_t)>&) const; 75 81 76 Data mapToFile(const char*path) const;82 Data mapToFile(const String& path) const; 77 83 78 84 #if PLATFORM(COCOA) … … 91 97 int m_fileDescriptor { -1 }; 92 98 #endif 99 #if OS(WINDOWS) 100 Vector<uint8_t> m_buffer; 101 #endif 93 102 mutable const uint8_t* m_data { nullptr }; 94 103 size_t m_size { 0 }; … … 98 107 Data concatenate(const Data&, const Data&); 99 108 bool bytesEqual(const Data&, const Data&); 100 Data adoptAndMapFile(int fd, size_t offset, size_t); 109 #if !OS(WINDOWS) 110 Data adoptAndMapFile(int, size_t offset, size_t); 111 #else 112 Data adoptAndMapFile(FileSystem::PlatformFileHandle, size_t offset, size_t); 113 #endif 101 114 #if USE(GLIB) && !PLATFORM(WIN) 102 115 Data adoptAndMapFile(GFileIOStream*, size_t offset, size_t); 103 116 #endif 117 #if !OS(WINDOWS) 104 118 Data mapFile(const char* path); 119 #endif 120 Data mapFile(const String& path); 105 121 106 122 using Salt = std::array<uint8_t, 8>; -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheDataCurl.cpp
r226465 r245186 27 27 #include "NetworkCacheData.h" 28 28 29 #include <WebCore/NotImplemented.h>30 31 29 namespace WebKit { 32 30 namespace NetworkCache { … … 34 32 Data::Data(const uint8_t* data, size_t size) 35 33 { 36 notImplemented(); 34 m_buffer.resize(size); 35 m_size = size; 36 memcpy(m_buffer.data(), data, size); 37 } 38 39 Data::Data(FileSystem::PlatformFileHandle file, size_t offset, size_t size) 40 { 41 m_buffer.resize(size); 42 m_size = size; 43 FileSystem::seekFile(file, offset, FileSystem::FileSeekOrigin::Beginning); 44 FileSystem::readFromFile(file, reinterpret_cast<char*>(m_buffer.data()), size); 45 FileSystem::closeFile(file); 46 } 47 48 Data::Data(Vector<uint8_t>&& buffer) 49 : m_buffer(WTFMove(buffer)) 50 { 51 m_size = m_buffer.size(); 37 52 } 38 53 39 54 Data Data::empty() 40 55 { 41 notImplemented();42 56 return { }; 43 57 } … … 45 59 const uint8_t* Data::data() const 46 60 { 47 notImplemented(); 48 return nullptr; 61 return m_buffer.data(); 49 62 } 50 63 51 64 bool Data::isNull() const 52 65 { 53 notImplemented(); 54 return true; 66 return m_buffer.isEmpty(); 55 67 } 56 68 57 69 bool Data::apply(const Function<bool(const uint8_t*, size_t)>& applier) const 58 70 { 59 notImplemented(); 60 return false; 71 if (isEmpty()) 72 return false; 73 74 return applier(reinterpret_cast<const uint8_t*>(m_buffer.data()), m_buffer.size()); 61 75 } 62 76 63 77 Data Data::subrange(size_t offset, size_t size) const 64 78 { 65 return { };79 return { m_buffer.data() + offset, size }; 66 80 } 67 81 68 82 Data concatenate(const Data& a, const Data& b) 69 83 { 70 notImplemented(); 71 return { }; 72 } 73 74 Data Data::adoptMap(void* map, size_t size, int fd) 75 { 76 notImplemented(); 77 return { }; 84 Vector<uint8_t> buffer(a.size() + b.size()); 85 memcpy(buffer.data(), a.data(), a.size()); 86 memcpy(buffer.data() + a.size(), b.data(), b.size()); 87 return Data(WTFMove(buffer)); 78 88 } 79 89 -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp
r244921 r245186 88 88 closedir(dir); 89 89 #else 90 function(String(), DirectoryEntryType::File); 90 auto entries = FileSystem::listDirectory(path); 91 for (auto& entry : entries) { 92 auto type = FileSystem::fileIsDirectory(entry, FileSystem::ShouldFollowSymbolicLinks::No) ? DirectoryEntryType::Directory : DirectoryEntryType::File; 93 function(entry, type); 94 } 91 95 #endif 92 96 } … … 128 132 WallTime::fromRawSeconds(g_file_info_get_attribute_uint64(fileInfo.get(), "time::modified")) }; 129 133 #elif OS(WINDOWS) 130 return FileTimes(); 134 auto createTime = FileSystem::getFileCreationTime(path); 135 auto modifyTime = FileSystem::getFileModificationTime(path); 136 return { createTime.valueOr(WallTime()), modifyTime.valueOr(WallTime()) }; 131 137 #endif 132 138 } … … 143 149 // This really updates both the access time and the modification time. 144 150 utimes(FileSystem::fileSystemRepresentation(path).data(), nullptr); 151 #else 152 FILETIME time; 153 GetSystemTimeAsFileTime(&time); 154 auto file = CreateFile(path.wideCharacters().data(), GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); 155 if (file == INVALID_HANDLE_VALUE) 156 return; 157 SetFileTime(file, &time, &time, &time); 158 CloseHandle(file); 145 159 #endif 146 160 } -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannel.h
r232528 r245186 53 53 Type type() const { return m_type; } 54 54 55 int fileDescriptor() const { return m_fileDescriptor; } 55 #if !USE(SOUP) 56 bool isOpened() const { return FileSystem::isHandleValid(m_fileDescriptor); } 57 #else 58 bool isOpened() const { return true; } 59 #endif 56 60 57 61 ~IOChannel(); … … 67 71 Type m_type; 68 72 69 int m_fileDescriptor { 0 }; 73 #if !USE(SOUP) 74 FileSystem::PlatformFileHandle m_fileDescriptor { FileSystem::invalidPlatformFileHandle }; 75 #endif 70 76 std::atomic<bool> m_wasDeleted { false }; // Try to narrow down a crash, https://bugs.webkit.org/show_bug.cgi?id=165659 71 77 #if PLATFORM(COCOA) -
trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheIOChannelCurl.cpp
r226465 r245186 27 27 #include "NetworkCacheIOChannel.h" 28 28 29 #include < WebCore/NotImplemented.h>29 #include <wtf/RunLoop.h> 30 30 31 31 namespace WebKit { … … 33 33 34 34 IOChannel::IOChannel(const String& filePath, Type type) 35 : m_path {filePath}36 , m_type {type}35 : m_path(filePath) 36 , m_type(type) 37 37 { 38 notImplemented(); 38 FileSystem::FileOpenMode mode; 39 switch (type) { 40 case Type::Read: 41 mode = FileSystem::FileOpenMode::Read; 42 break; 43 case Type::Write: 44 mode = FileSystem::FileOpenMode::Write; 45 break; 46 case Type::Create: 47 mode = FileSystem::FileOpenMode::Write; 48 break; 49 } 50 m_fileDescriptor = FileSystem::openFile(filePath, mode); 39 51 } 40 52 41 53 IOChannel::~IOChannel() 42 54 { 55 FileSystem::closeFile(m_fileDescriptor); 43 56 } 44 57 … … 48 61 } 49 62 63 static inline void runTaskInQueue(Function<void()>&& task, WorkQueue* queue) 64 { 65 if (queue) { 66 queue->dispatch(WTFMove(task)); 67 return; 68 } 69 70 // Using nullptr as queue submits the result to the main context. 71 RunLoop::main().dispatch(WTFMove(task)); 72 } 73 50 74 void IOChannel::read(size_t offset, size_t size, WorkQueue* queue, Function<void(Data&, int error)>&& completionHandler) 51 75 { 52 notImplemented(); 76 runTaskInQueue([this, protectedThis = makeRef(*this), offset, size, completionHandler = WTFMove(completionHandler)] { 77 Vector<uint8_t> buffer(size); 78 FileSystem::seekFile(m_fileDescriptor, offset, FileSystem::FileSeekOrigin::Beginning); 79 int err = FileSystem::readFromFile(m_fileDescriptor, reinterpret_cast<char*>(buffer.data()), size); 80 err = err < 0 ? err : 0; 81 auto data = Data(WTFMove(buffer)); 82 completionHandler(data, err); 83 }, queue); 53 84 } 54 85 55 86 void IOChannel::write(size_t offset, const Data& data, WorkQueue* queue, Function<void(int error)>&& completionHandler) 56 87 { 57 notImplemented(); 88 runTaskInQueue([this, protectedThis = makeRef(*this), offset, data, completionHandler = WTFMove(completionHandler)] { 89 FileSystem::seekFile(m_fileDescriptor, offset, FileSystem::FileSeekOrigin::Beginning); 90 int err = FileSystem::writeToFile(m_fileDescriptor, reinterpret_cast<const char*>(data.data()), data.size()); 91 err = err < 0 ? err : 0; 92 completionHandler(err); 93 }, queue); 58 94 } 59 95
Note: See TracChangeset
for help on using the changeset viewer.