Changeset 284059 in webkit
- Timestamp:
- Oct 12, 2021 4:35:55 PM (9 months ago)
- Location:
- trunk
- Files:
-
- 4 added
- 35 edited
- 4 copied
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemSyncAccessHandle-close.https.tentative.worker-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemSyncAccessHandle-flush.https.tentative.worker-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemSyncAccessHandle-getSize.https.tentative.worker-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemSyncAccessHandle-read-write.https.tentative.worker-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemSyncAccessHandle-truncate.https.tentative.worker-expected.txt (modified) (1 diff)
-
LayoutTests/storage/filesystemaccess/resources/sync-access-handle-read-write.js (added)
-
LayoutTests/storage/filesystemaccess/sync-access-handle-read-write-worker-expected.txt (added)
-
LayoutTests/storage/filesystemaccess/sync-access-handle-read-write-worker.html (added)
-
Source/WTF/ChangeLog (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Modules/filesystemaccess/FileSystemFileHandle.cpp (modified) (1 diff)
-
Source/WebCore/Modules/filesystemaccess/FileSystemFileHandle.h (modified) (1 diff)
-
Source/WebCore/Modules/filesystemaccess/FileSystemStorageConnection.h (modified) (2 diffs)
-
Source/WebCore/Modules/filesystemaccess/FileSystemSyncAccessHandle.cpp (modified) (4 diffs)
-
Source/WebCore/Modules/filesystemaccess/FileSystemSyncAccessHandle.h (modified) (4 diffs)
-
Source/WebCore/Modules/filesystemaccess/FileSystemSyncAccessHandle.idl (modified) (1 diff)
-
Source/WebCore/Modules/filesystemaccess/WorkerFileSystemStorageConnection.cpp (modified) (2 diffs)
-
Source/WebCore/Modules/filesystemaccess/WorkerFileSystemStorageConnection.h (modified) (1 diff)
-
Source/WebCore/PAL/ChangeLog (modified) (1 diff)
-
Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj (modified) (4 diffs)
-
Source/WebCore/PAL/pal/spi/cocoa/FilePortSPI.h (copied) (copied from trunk/Source/WebCore/Modules/filesystemaccess/FileSystemSyncAccessHandle.idl) (1 diff)
-
Source/WebCore/bindings/js/BufferSource.h (modified) (1 diff)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/NetworkProcess/storage/FileSystemStorageError.h (modified) (3 diffs)
-
Source/WebKit/NetworkProcess/storage/FileSystemStorageHandle.cpp (modified) (6 diffs)
-
Source/WebKit/NetworkProcess/storage/FileSystemStorageHandle.h (modified) (3 diffs)
-
Source/WebKit/NetworkProcess/storage/NetworkStorageManager.cpp (modified) (1 diff)
-
Source/WebKit/NetworkProcess/storage/NetworkStorageManager.h (modified) (2 diffs)
-
Source/WebKit/NetworkProcess/storage/NetworkStorageManager.messages.in (modified) (1 diff)
-
Source/WebKit/Platform/IPC/SharedFileHandle.cpp (copied) (copied from trunk/Source/WebCore/Modules/filesystemaccess/FileSystemSyncAccessHandle.idl) (1 diff)
-
Source/WebKit/Platform/IPC/SharedFileHandle.h (copied) (copied from trunk/Source/WebCore/Modules/filesystemaccess/FileSystemSyncAccessHandle.idl) (1 diff)
-
Source/WebKit/Platform/IPC/cocoa/SharedFileHandleCocoa.cpp (copied) (copied from trunk/Source/WebCore/Modules/filesystemaccess/FileSystemSyncAccessHandle.idl) (1 diff)
-
Source/WebKit/Sources.txt (modified) (1 diff)
-
Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm (modified) (1 diff)
-
Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h (modified) (1 diff)
-
Source/WebKit/WebKit.xcodeproj/project.pbxproj (modified) (8 diffs)
-
Source/WebKit/WebProcess/WebCoreSupport/WebFileSystemStorageConnection.cpp (modified) (1 diff)
-
Source/WebKit/WebProcess/com.apple.WebProcess.sb.in (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (modified) (4 diffs)
-
Tools/TestWebKitAPI/Tests/WebKitCocoa/FileSystemAccess.mm (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r284058 r284059 1 2021-10-12 Sihui Liu <sihui_liu@apple.com> 2 3 Implement FileSystemSyncAccessHandle read() and write() 4 https://bugs.webkit.org/show_bug.cgi?id=231466 5 <rdar://problem/84050394> 6 7 Reviewed by Youenn Fablet. 8 9 * storage/filesystemaccess/resources/sync-access-handle-read-write.js: Added. 10 (finishTest): 11 (arrayBufferToString): 12 (stringToArrayBuffer): 13 (write): 14 (read): 15 (async test): 16 * storage/filesystemaccess/sync-access-handle-read-write-worker-expected.txt: Added. 17 * storage/filesystemaccess/sync-access-handle-read-write-worker.html: Added. 18 1 19 2021-10-12 Ayumi Kojima <ayumi_kojima@apple.com> 2 20 -
trunk/LayoutTests/imported/w3c/ChangeLog
r283980 r284059 1 2021-10-12 Sihui Liu <sihui_liu@apple.com> 2 3 Implement FileSystemSyncAccessHandle read() and write() 4 https://bugs.webkit.org/show_bug.cgi?id=231466 5 <rdar://problem/84050394> 6 7 Reviewed by Youenn Fablet. 8 9 * web-platform-tests/file-system-access/sandboxed_FileSystemSyncAccessHandle-close.https.tentative.worker-expected.txt: 10 * web-platform-tests/file-system-access/sandboxed_FileSystemSyncAccessHandle-flush.https.tentative.worker-expected.txt: 11 * web-platform-tests/file-system-access/sandboxed_FileSystemSyncAccessHandle-getSize.https.tentative.worker-expected.txt: 12 * web-platform-tests/file-system-access/sandboxed_FileSystemSyncAccessHandle-read-write.https.tentative.worker-expected.txt: 13 * web-platform-tests/file-system-access/sandboxed_FileSystemSyncAccessHandle-truncate.https.tentative.worker-expected.txt: 14 1 15 2021-10-12 Aditya Keerthi <akeerthi@apple.com> 2 16 -
trunk/LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemSyncAccessHandle-close.https.tentative.worker-expected.txt
r283881 r284059 2 2 FAIL SyncAccessHandle.close is idempotent promise_test: Unhandled rejection with value: object "InvalidStateError: The object is in an invalid state." 3 3 FAIL SyncAccessHandle.close is idempotent when called immediately promise_test: Unhandled rejection with value: object "UnknownError: The operation failed for an unknown transient reason (e.g. out of memory)." 4 FAIL SyncAccessHandle.read fails after SyncAccessHandle.close settles assert_throws_dom: function "() => handle.read(readBuffer, {at: 0})" threw object "TypeError: handle.read is not a function. (In 'handle.read(readBuffer, {at: 0})', 'handle.read' is undefined)" that is not a DOMException InvalidStateError: property "code" is equal to undefined, expected 115 FAIL SyncAccessHandle.read fails immediately after calling SyncAccessHandle.close assert_throws_dom: function "() => handle.read(readBuffer, {at: 0})" threw object "TypeError: handle.read is not a function. (In 'handle.read(readBuffer, {at: 0})', 'handle.read' is undefined)" that is not a DOMException InvalidStateError: property "code" is equal to undefined, expected 116 FAIL SyncAccessHandle.write fails after SyncAccessHandle.close settles assert_throws_dom: function "() => handle.write(writeBuffer, {at: 0})" threw object "TypeError: handle.write is not a function. (In 'handle.write(writeBuffer, {at: 0})', 'handle.write' is undefined)" that is not a DOMException InvalidStateError: property "code" is equal to undefined, expected 117 FAIL SyncAccessHandle.write fails immediately after calling SyncAccessHandle.close assert_throws_dom: function "() => handle.write(writeBuffer, {at: 0})" threw object "TypeError: handle.write is not a function. (In 'handle.write(writeBuffer, {at: 0})', 'handle.write' is undefined)" that is not a DOMException InvalidStateError: property "code" is equal to undefined, expected 114 FAIL SyncAccessHandle.read fails after SyncAccessHandle.close settles promise_test: Unhandled rejection with value: object "InvalidStateError: The object is in an invalid state." 5 FAIL SyncAccessHandle.read fails immediately after calling SyncAccessHandle.close promise_test: Unhandled rejection with value: object "InvalidStateError: The object is in an invalid state." 6 FAIL SyncAccessHandle.write fails after SyncAccessHandle.close settles promise_test: Unhandled rejection with value: object "InvalidStateError: The object is in an invalid state." 7 FAIL SyncAccessHandle.write fails immediately after calling SyncAccessHandle.close promise_test: Unhandled rejection with value: object "InvalidStateError: The object is in an invalid state." 8 8 FAIL SyncAccessHandle.flush fails after SyncAccessHandle.close settles promise_rejects_dom: function "function () { throw e }" threw object "UnknownError: The operation failed for an unknown transient reason (e.g. out of memory)." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11 9 9 FAIL SyncAccessHandle.flush fails immediately after calling SyncAccessHandle.close promise_rejects_dom: function "function () { throw e }" threw object "UnknownError: The operation failed for an unknown transient reason (e.g. out of memory)." that is not a DOMException InvalidStateError: property "code" is equal to 0, expected 11 -
trunk/LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemSyncAccessHandle-flush.https.tentative.worker-expected.txt
r283881 r284059 1 1 2 2 PASS Test flush on an empty file. 3 FAIL SyncAccessHandle.read returns bytes written by SyncAccessHandle.write after SyncAccessHandle.flush promise_test: Unhandled rejection with value: object "TypeError: handle.write is not a function. (In 'handle.write(writeBuffer, {at: 0})', 'handle.write' is undefined)" 4 FAIL SyncAccessHandle.read fails when there is a pending SyncAccessHandle.flush promise_test: Unhandled rejection with value: object "InvalidStateError: The object is in an invalid state." 5 FAIL SyncAccessHandle.write fails when there is a pending SyncAccessHandle.flush promise_test: Unhandled rejection with value: object "InvalidStateError: The object is in an invalid state." 3 PASS SyncAccessHandle.read returns bytes written by SyncAccessHandle.write after SyncAccessHandle.flush 4 PASS SyncAccessHandle.read fails when there is a pending SyncAccessHandle.flush 5 PASS SyncAccessHandle.write fails when there is a pending SyncAccessHandle.flush 6 6 -
trunk/LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemSyncAccessHandle-getSize.https.tentative.worker-expected.txt
r283881 r284059 1 1 2 FAIL test SyncAccessHandle.getSize after SyncAccessHandle.write promise_test: Unhandled rejection with value: object "TypeError: handle.write is not a function. (In 'handle.write(writeBuffer, {at: 0})', 'handle.write' is undefined)" 3 FAIL test createSyncAccessHandle.getSize with pending operation promise_test: Unhandled rejection with value: object "InvalidStateError: The object is in an invalid state."2 PASS test SyncAccessHandle.getSize after SyncAccessHandle.write 3 FAIL test createSyncAccessHandle.getSize with pending operation assert_unreached: Should have rejected: undefined Reached unreachable code 4 4 -
trunk/LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemSyncAccessHandle-read-write.https.tentative.worker-expected.txt
r283881 r284059 1 1 2 FAIL Test reading an empty file through a sync access handle. promise_test: Unhandled rejection with value: object "TypeError: handle.read is not a function. (In 'handle.read(readBuffer, {at: 0})', 'handle.read' is undefined)" 3 FAIL Test writing and reading through a sync access handle. promise_test: Unhandled rejection with value: object "InvalidStateError: The object is in an invalid state." 4 FAIL Test second write that is bigger than the first write promise_test: Unhandled rejection with value: object "InvalidStateError: The object is in an invalid state." 5 FAIL Test second write that is smaller than the first write promise_test: Unhandled rejection with value: object "InvalidStateError: The object is in an invalid state." 6 FAIL Test initial write with an offset promise_test: Unhandled rejection with value: object "InvalidStateError: The object is in an invalid state." 7 FAIL Test overwriting the file at an offset promise_test: Unhandled rejection with value: object "InvalidStateError: The object is in an invalid state." 8 FAIL Test read at an offset promise_test: Unhandled rejection with value: object "InvalidStateError: The object is in an invalid state." 9 FAIL Test reading at a negative offset fails. promise_test: Unhandled rejection with value: object "InvalidStateError: The object is in an invalid state."2 PASS Test reading an empty file through a sync access handle. 3 PASS Test writing and reading through a sync access handle. 4 PASS Test second write that is bigger than the first write 5 PASS Test second write that is smaller than the first write 6 PASS Test initial write with an offset 7 PASS Test overwriting the file at an offset 8 PASS Test read at an offset 9 FAIL Test reading at a negative offset fails. assert_throws_dom: function "() => handle.read(readBuffer, { at: -1 })" threw object "TypeError: Value -1 is outside the range [0, 9007199254740991]" that is not a DOMException NotSupportedError: property "code" is equal to undefined, expected 9 10 10 -
trunk/LayoutTests/imported/w3c/web-platform-tests/file-system-access/sandboxed_FileSystemSyncAccessHandle-truncate.https.tentative.worker-expected.txt
r283881 r284059 2 2 FAIL test createSyncAccessHandle.truncate with pending operation assert_unreached: Should have rejected: undefined Reached unreachable code 3 3 PASS test SyncAccessHandle.truncate with different sizes 4 FAIL test SyncAccessHandle.truncate after SyncAccessHandle.write promise_test: Unhandled rejection with value: object "TypeError: handle.write is not a function. (In 'handle.write(writeBuffer, {at: 0})', 'handle.write' is undefined)" 4 PASS test SyncAccessHandle.truncate after SyncAccessHandle.write 5 5 -
trunk/Source/WTF/ChangeLog
r284057 r284059 1 2021-10-12 Sihui Liu <sihui_liu@apple.com> 2 3 Implement FileSystemSyncAccessHandle read() and write() 4 https://bugs.webkit.org/show_bug.cgi?id=231466 5 <rdar://problem/84050394> 6 7 Reviewed by Youenn Fablet. 8 9 * wtf/PlatformHave.h: 10 1 11 2021-10-12 Chris Dumez <cdumez@apple.com> 2 12 -
trunk/Source/WebCore/ChangeLog
r284057 r284059 1 2021-10-12 Sihui Liu <sihui_liu@apple.com> 2 3 Implement FileSystemSyncAccessHandle read() and write() 4 https://bugs.webkit.org/show_bug.cgi?id=231466 5 <rdar://problem/84050394> 6 7 Reviewed by Youenn Fablet. 8 9 Implement read() and write() according to proposal: 10 https://github.com/WICG/file-system-access/blob/main/AccessHandle.md 11 12 Test: storage/filesystemaccess/sync-access-handle-read-write-worker.html 13 API test: FileSystemAccess.ProcessCrashDuringWrite 14 15 * Modules/filesystemaccess/FileSystemFileHandle.cpp: 16 (WebCore::FileSystemFileHandle::createSyncAccessHandle): 17 (WebCore::FileSystemFileHandle::getSize): 18 (WebCore::FileSystemFileHandle::truncate): 19 (WebCore::FileSystemFileHandle::flush): 20 * Modules/filesystemaccess/FileSystemFileHandle.h: 21 * Modules/filesystemaccess/FileSystemStorageConnection.h: 22 * Modules/filesystemaccess/FileSystemSyncAccessHandle.cpp: 23 (WebCore::FileSystemSyncAccessHandle::create): 24 (WebCore::FileSystemSyncAccessHandle::FileSystemSyncAccessHandle): 25 (WebCore::FileSystemSyncAccessHandle::truncate): 26 (WebCore::FileSystemSyncAccessHandle::getSize): 27 (WebCore::FileSystemSyncAccessHandle::flush): 28 (WebCore::FileSystemSyncAccessHandle::close): 29 (WebCore::FileSystemSyncAccessHandle::read): 30 (WebCore::FileSystemSyncAccessHandle::write): 31 * Modules/filesystemaccess/FileSystemSyncAccessHandle.h: 32 * Modules/filesystemaccess/FileSystemSyncAccessHandle.idl: 33 * Modules/filesystemaccess/WorkerFileSystemStorageConnection.cpp: 34 (WebCore::WorkerFileSystemStorageConnection::didCreateSyncAccessHandle): 35 (WebCore::WorkerFileSystemStorageConnection::createSyncAccessHandle): 36 * Modules/filesystemaccess/WorkerFileSystemStorageConnection.h: 37 * bindings/js/BufferSource.h: 38 (WebCore::BufferSource::mutableData const): 39 1 40 2021-10-12 Chris Dumez <cdumez@apple.com> 2 41 -
trunk/Source/WebCore/Modules/filesystemaccess/FileSystemFileHandle.cpp
r283881 r284059 58 58 return promise.reject(result.releaseException()); 59 59 60 promise.settle(FileSystemSyncAccessHandle::create(protectedThis.get(), result.returnValue())); 60 auto resultValue = result.releaseReturnValue(); 61 promise.settle(FileSystemSyncAccessHandle::create(protectedThis.get(), resultValue.first, resultValue.second)); 61 62 }); 62 63 } 63 64 64 void FileSystemFileHandle::getSize(FileSystemSyncAccessHandleIdentifier accessHandleIdentifier, DOMPromiseDeferred<IDLUnsignedLongLong>&& promise)65 void FileSystemFileHandle::getSize(FileSystemSyncAccessHandleIdentifier accessHandleIdentifier, CompletionHandler<void(ExceptionOr<uint64_t>&&)>&& completionHandler) 65 66 { 66 connection().getSize(identifier(), accessHandleIdentifier, [promise = WTFMove(promise)](auto result) mutable { 67 promise.settle(WTFMove(result)); 68 }); 67 connection().getSize(identifier(), accessHandleIdentifier, WTFMove(completionHandler)); 69 68 } 70 69 71 void FileSystemFileHandle::truncate(FileSystemSyncAccessHandleIdentifier accessHandleIdentifier, unsigned long long size, DOMPromiseDeferred<void>&& promise)70 void FileSystemFileHandle::truncate(FileSystemSyncAccessHandleIdentifier accessHandleIdentifier, unsigned long long size, CompletionHandler<void(ExceptionOr<void>&&)>&& completionHandler) 72 71 { 73 connection().truncate(identifier(), accessHandleIdentifier, size, [promise = WTFMove(promise)](auto result) mutable { 74 promise.settle(WTFMove(result)); 75 }); 72 connection().truncate(identifier(), accessHandleIdentifier, size, WTFMove(completionHandler)); 76 73 } 77 74 78 void FileSystemFileHandle::flush(FileSystemSyncAccessHandleIdentifier accessHandleIdentifier, DOMPromiseDeferred<void>&& promise)75 void FileSystemFileHandle::flush(FileSystemSyncAccessHandleIdentifier accessHandleIdentifier, CompletionHandler<void(ExceptionOr<void>&&)>&& completionHandler) 79 76 { 80 connection().flush(identifier(), accessHandleIdentifier, [promise = WTFMove(promise)](auto result) mutable { 81 promise.settle(WTFMove(result)); 82 }); 77 connection().flush(identifier(), accessHandleIdentifier, WTFMove(completionHandler)); 83 78 } 84 79 -
trunk/Source/WebCore/Modules/filesystemaccess/FileSystemFileHandle.h
r283676 r284059 42 42 43 43 void createSyncAccessHandle(DOMPromiseDeferred<IDLInterface<FileSystemSyncAccessHandle>>&&); 44 void getSize(FileSystemSyncAccessHandleIdentifier, DOMPromiseDeferred<IDLUnsignedLongLong>&&);45 void truncate(FileSystemSyncAccessHandleIdentifier, unsigned long long size, DOMPromiseDeferred<void>&&);46 void flush(FileSystemSyncAccessHandleIdentifier, DOMPromiseDeferred<void>&&);44 void getSize(FileSystemSyncAccessHandleIdentifier, CompletionHandler<void(ExceptionOr<uint64_t>&&)>&&); 45 void truncate(FileSystemSyncAccessHandleIdentifier, unsigned long long size, CompletionHandler<void(ExceptionOr<void>&&)>&&); 46 void flush(FileSystemSyncAccessHandleIdentifier, CompletionHandler<void(ExceptionOr<void>&&)>&&); 47 47 void close(FileSystemSyncAccessHandleIdentifier, CompletionHandler<void(ExceptionOr<void>&&)>&&); 48 48 -
trunk/Source/WebCore/Modules/filesystemaccess/FileSystemStorageConnection.h
r283881 r284059 29 29 #include "FileSystemSyncAccessHandleIdentifier.h" 30 30 #include <wtf/CompletionHandler.h> 31 #include <wtf/FileSystem.h> 31 32 #include <wtf/ThreadSafeRefCounted.h> 32 33 … … 44 45 using GetHandleCallback = CompletionHandler<void(ExceptionOr<FileSystemHandleIdentifier>&&)>; 45 46 using ResolveCallback = CompletionHandler<void(ExceptionOr<Vector<String>>&&)>; 46 using GetAccessHandleCallback = CompletionHandler<void(ExceptionOr< FileSystemSyncAccessHandleIdentifier>&&)>;47 using GetAccessHandleCallback = CompletionHandler<void(ExceptionOr<std::pair<FileSystemSyncAccessHandleIdentifier, FileSystem::PlatformFileHandle>>&&)>; 47 48 using VoidCallback = CompletionHandler<void(ExceptionOr<void>&&)>; 48 49 using IntegerCallback = CompletionHandler<void(ExceptionOr<uint64_t>&&)>; -
trunk/Source/WebCore/Modules/filesystemaccess/FileSystemSyncAccessHandle.cpp
r283676 r284059 35 35 namespace WebCore { 36 36 37 Ref<FileSystemSyncAccessHandle> FileSystemSyncAccessHandle::create(FileSystemFileHandle& source, FileSystemSyncAccessHandleIdentifier identifier )37 Ref<FileSystemSyncAccessHandle> FileSystemSyncAccessHandle::create(FileSystemFileHandle& source, FileSystemSyncAccessHandleIdentifier identifier, FileSystem::PlatformFileHandle file) 38 38 { 39 return adoptRef(*new FileSystemSyncAccessHandle(source, identifier ));39 return adoptRef(*new FileSystemSyncAccessHandle(source, identifier, file)); 40 40 } 41 41 42 FileSystemSyncAccessHandle::FileSystemSyncAccessHandle(FileSystemFileHandle& source, FileSystemSyncAccessHandleIdentifier identifier )42 FileSystemSyncAccessHandle::FileSystemSyncAccessHandle(FileSystemFileHandle& source, FileSystemSyncAccessHandleIdentifier identifier, FileSystem::PlatformFileHandle file) 43 43 : m_source(source) 44 44 , m_identifier(identifier) 45 , m_file(file) 45 46 { 46 47 } … … 54 55 void FileSystemSyncAccessHandle::truncate(unsigned long long size, DOMPromiseDeferred<void>&& promise) 55 56 { 56 m_source->truncate(m_identifier, size, WTFMove(promise)); 57 m_pendingOperationCount++; 58 m_source->truncate(m_identifier, size, [weakThis = makeWeakPtr(*this), promise = WTFMove(promise)](auto result) mutable { 59 if (weakThis) 60 weakThis->m_pendingOperationCount--; 61 62 promise.settle(WTFMove(result)); 63 }); 57 64 } 58 65 59 66 void FileSystemSyncAccessHandle::getSize(DOMPromiseDeferred<IDLUnsignedLongLong>&& promise) 60 67 { 61 m_source->getSize(m_identifier, WTFMove(promise)); 68 m_pendingOperationCount++; 69 m_source->getSize(m_identifier, [weakThis = makeWeakPtr(*this), promise = WTFMove(promise)](auto result) mutable { 70 if (weakThis) 71 weakThis->m_pendingOperationCount--; 72 73 promise.settle(WTFMove(result)); 74 }); 62 75 } 63 76 64 77 void FileSystemSyncAccessHandle::flush(DOMPromiseDeferred<void>&& promise) 65 78 { 66 m_source->flush(m_identifier, WTFMove(promise)); 79 m_pendingOperationCount++; 80 m_source->flush(m_identifier, [weakThis = makeWeakPtr(*this), promise = WTFMove(promise)](auto result) mutable { 81 if (weakThis) 82 weakThis->m_pendingOperationCount--; 83 84 promise.settle(WTFMove(result)); 85 }); 67 86 } 68 87 … … 72 91 return promise.reject(Exception { InvalidStateError }); 73 92 93 m_pendingOperationCount++; 74 94 m_source->close(m_identifier, [weakThis = makeWeakPtr(*this), promise = WTFMove(promise)](auto result) mutable { 75 if (weakThis) 95 if (weakThis) { 96 weakThis->m_pendingOperationCount--; 76 97 weakThis->didClose(); 98 } 77 99 78 100 promise.settle(WTFMove(result)); … … 85 107 } 86 108 109 ExceptionOr<unsigned long long> FileSystemSyncAccessHandle::read(BufferSource&& buffer, FileSystemSyncAccessHandle::FilesystemReadWriteOptions options) 110 { 111 ASSERT(!isMainThread()); 112 113 if (m_file == FileSystem::invalidPlatformFileHandle || m_isClosed) 114 return Exception { InvalidStateError }; 115 116 if (m_pendingOperationCount) 117 return Exception { InvalidStateError, "Access handle has unfinished operation"_s }; 118 119 int result = FileSystem::seekFile(m_file, options.at, FileSystem::FileSeekOrigin::Beginning); 120 if (result == -1) 121 return Exception { InvalidStateError, "Failed to read at offset"_s }; 122 123 result = FileSystem::readFromFile(m_file, buffer.mutableData(), buffer.length()); 124 if (result == -1) 125 return Exception { InvalidStateError, "Failed to read from file"_s }; 126 127 return result; 128 } 129 130 ExceptionOr<unsigned long long> FileSystemSyncAccessHandle::write(BufferSource&& buffer, FileSystemSyncAccessHandle::FilesystemReadWriteOptions options) 131 { 132 ASSERT(!isMainThread()); 133 134 if (m_file == FileSystem::invalidPlatformFileHandle || m_isClosed) 135 return Exception { InvalidStateError }; 136 137 if (m_pendingOperationCount) 138 return Exception { InvalidStateError, "Access handle has unfinished operation"_s }; 139 140 int result = FileSystem::seekFile(m_file, options.at, FileSystem::FileSeekOrigin::Beginning); 141 if (result == -1) 142 return Exception { InvalidStateError, "Failed to write at offset"_s }; 143 144 result = FileSystem::writeToFile(m_file, buffer.data(), buffer.length()); 145 if (result == -1) 146 return Exception { InvalidStateError, "Failed to write to file"_s }; 147 148 return result; 149 } 150 87 151 } // namespace WebCore -
trunk/Source/WebCore/Modules/filesystemaccess/FileSystemSyncAccessHandle.h
r283676 r284059 26 26 #pragma once 27 27 28 #include "BufferSource.h" 28 29 #include "FileSystemSyncAccessHandleIdentifier.h" 29 30 #include "IDLTypes.h" 31 #include <wtf/FileSystem.h> 30 32 #include <wtf/WeakPtr.h> 31 33 … … 34 36 class FileSystemFileHandle; 35 37 template<typename> class DOMPromiseDeferred; 38 template<typename> class ExceptionOr; 36 39 37 40 class FileSystemSyncAccessHandle : public RefCounted<FileSystemSyncAccessHandle>, public CanMakeWeakPtr<FileSystemSyncAccessHandle> { … … 41 44 }; 42 45 43 static Ref<FileSystemSyncAccessHandle> create(FileSystemFileHandle&, FileSystemSyncAccessHandleIdentifier );46 static Ref<FileSystemSyncAccessHandle> create(FileSystemFileHandle&, FileSystemSyncAccessHandleIdentifier, FileSystem::PlatformFileHandle); 44 47 ~FileSystemSyncAccessHandle(); 45 48 … … 49 52 void close(DOMPromiseDeferred<void>&&); 50 53 void didClose(); 54 ExceptionOr<unsigned long long> read(BufferSource&&, FilesystemReadWriteOptions); 55 ExceptionOr<unsigned long long> write(BufferSource&&, FilesystemReadWriteOptions); 51 56 52 57 private: 53 FileSystemSyncAccessHandle(FileSystemFileHandle&, FileSystemSyncAccessHandleIdentifier );58 FileSystemSyncAccessHandle(FileSystemFileHandle&, FileSystemSyncAccessHandleIdentifier, FileSystem::PlatformFileHandle); 54 59 55 60 Ref<FileSystemFileHandle> m_source; 56 61 FileSystemSyncAccessHandleIdentifier m_identifier; 57 62 bool m_isClosed { false }; 63 uint64_t m_pendingOperationCount { 0 }; 64 FileSystem::PlatformFileHandle m_file; 58 65 }; 59 66 -
trunk/Source/WebCore/Modules/filesystemaccess/FileSystemSyncAccessHandle.idl
r283676 r284059 34 34 Promise<undefined> flush(); 35 35 Promise<undefined> close(); 36 unsigned long long read([AllowShared] BufferSource buffer, FilesystemReadWriteOptions options); 37 unsigned long long write([AllowShared] BufferSource buffer, FilesystemReadWriteOptions options); 36 38 }; 37 39 -
trunk/Source/WebCore/Modules/filesystemaccess/WorkerFileSystemStorageConnection.cpp
r284057 r284059 194 194 } 195 195 196 void WorkerFileSystemStorageConnection::didCreateSyncAccessHandle(CallbackIdentifier callbackIdentifier, ExceptionOr< FileSystemSyncAccessHandleIdentifier>&& result)196 void WorkerFileSystemStorageConnection::didCreateSyncAccessHandle(CallbackIdentifier callbackIdentifier, ExceptionOr<std::pair<FileSystemSyncAccessHandleIdentifier, FileSystem::PlatformFileHandle>>&& result) 197 197 { 198 198 if (auto callback = m_getAccessHandlCallbacks.take(callbackIdentifier)) … … 222 222 callOnMainThread([callbackIdentifier, workerThread = Ref { m_scope->thread() }, mainThreadConnection = m_mainThreadConnection, identifier]() mutable { 223 223 auto mainThreadCallback = [callbackIdentifier, workerThread = WTFMove(workerThread)](auto result) mutable { 224 workerThread->runLoop().postTaskForMode([callbackIdentifier, result = crossThreadCopy(result)] (auto& scope) mutable { 224 auto crossThreadResult = result; 225 if (result.hasException()) 226 crossThreadResult = crossThreadCopy(result.exception()); 227 workerThread->runLoop().postTaskForMode([callbackIdentifier, result = WTFMove(crossThreadResult)] (auto& scope) mutable { 225 228 if (auto connection = downcast<WorkerGlobalScope>(scope).fileSystemStorageConnection()) 226 229 connection->didCreateSyncAccessHandle(callbackIdentifier, WTFMove(result)); -
trunk/Source/WebCore/Modules/filesystemaccess/WorkerFileSystemStorageConnection.h
r283881 r284059 48 48 void didGetHandle(CallbackIdentifier, ExceptionOr<FileSystemHandleIdentifier>&&); 49 49 void didResolve(CallbackIdentifier, ExceptionOr<Vector<String>>&&); 50 void didCreateSyncAccessHandle(CallbackIdentifier, ExceptionOr< FileSystemSyncAccessHandleIdentifier>&& result);50 void didCreateSyncAccessHandle(CallbackIdentifier, ExceptionOr<std::pair<FileSystemSyncAccessHandleIdentifier, FileSystem::PlatformFileHandle>>&&); 51 51 void completeVoidCallback(CallbackIdentifier, ExceptionOr<void>&& result); 52 52 void completeIntegerCallback(CallbackIdentifier, ExceptionOr<uint64_t>&& result); -
trunk/Source/WebCore/PAL/ChangeLog
r284009 r284059 1 2021-10-12 Sihui Liu <sihui_liu@apple.com> 2 3 Implement FileSystemSyncAccessHandle read() and write() 4 https://bugs.webkit.org/show_bug.cgi?id=231466 5 <rdar://problem/84050394> 6 7 Reviewed by Youenn Fablet. 8 9 * PAL.xcodeproj/project.pbxproj: 10 * pal/spi/cocoa/FilePortSPI.h: Added. 11 1 12 2021-10-12 Chris Dumez <cdumez@apple.com> 2 13 -
trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj
r282313 r284059 155 155 7A36D0F9223AD9AB00B0522E /* CommonCryptoSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A36D0F8223AD9AB00B0522E /* CommonCryptoSPI.h */; }; 156 156 7A3A6A8020CADB4700317AAE /* NSImageSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A3A6A7F20CADB4600317AAE /* NSImageSPI.h */; }; 157 93468E672714A7CD009983E3 /* FilePortSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 93468E662714A7CD009983E3 /* FilePortSPI.h */; }; 157 158 93B38EBE25821CB600198E63 /* SpeechSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B38EBD25821CB600198E63 /* SpeechSoftLink.h */; }; 158 159 93B38EC025821CD800198E63 /* SpeechSoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93B38EBF25821CD700198E63 /* SpeechSoftLink.mm */; }; … … 377 378 7A36D0F8223AD9AB00B0522E /* CommonCryptoSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CommonCryptoSPI.h; sourceTree = "<group>"; }; 378 379 7A3A6A7F20CADB4600317AAE /* NSImageSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSImageSPI.h; sourceTree = "<group>"; }; 380 93468E662714A7CD009983E3 /* FilePortSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FilePortSPI.h; sourceTree = "<group>"; }; 379 381 93B38EBD25821CB600198E63 /* SpeechSoftLink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpeechSoftLink.h; sourceTree = "<group>"; }; 380 382 93B38EBF25821CD700198E63 /* SpeechSoftLink.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SpeechSoftLink.mm; sourceTree = "<group>"; }; … … 535 537 0C2DA1251F3BEB4900DBC317 /* DataDetectorsCoreSPI.h */, 536 538 1D12CC4A2411BCAE00FDA0A3 /* FeatureFlagsSPI.h */, 539 93468E662714A7CD009983E3 /* FilePortSPI.h */, 537 540 CE5673862151A7B9002F92D7 /* IOKitSPI.h */, 538 541 0C2DA1261F3BEB4900DBC317 /* IOPMLibSPI.h */, … … 901 904 0C2D9E731EEF5AF600DBC317 /* ExportMacros.h in Headers */, 902 905 1D12CC4B2411BCAE00FDA0A3 /* FeatureFlagsSPI.h in Headers */, 906 93468E672714A7CD009983E3 /* FilePortSPI.h in Headers */, 903 907 F44291601FA5261E002CC93E /* FileSizeFormatter.h in Headers */, 904 908 0C5AF91B1F43A4C7002EAC02 /* GraphicsServicesSPI.h in Headers */, -
trunk/Source/WebCore/PAL/pal/spi/cocoa/FilePortSPI.h
r284058 r284059 24 24 */ 25 25 26 [ 27 EnabledBySetting=AccessHandleEnabled, 28 ImplementationLacksVTable, 29 Exposed=DedicatedWorker, 30 SecureContext 31 ] interface FileSystemSyncAccessHandle { 32 Promise<undefined> truncate([EnforceRange] unsigned long long size); 33 Promise<unsigned long long> getSize(); 34 Promise<undefined> flush(); 35 Promise<undefined> close(); 36 }; 26 #pragma once 37 27 38 dictionary FilesystemReadWriteOptions { 39 [EnforceRange] unsigned long long at; 40 }; 28 #if USE(APPLE_INTERNAL_SDK) 29 30 #include <System/sys/fileport.h> 31 32 #else 33 34 extern "C" { 35 int fileport_makeport(int, mach_port_t*); 36 int fileport_makefd(mach_port_t); 37 } 38 39 #endif // #if USE(APPLE_INTERNAL_SDK) 40 -
trunk/Source/WebCore/bindings/js/BufferSource.h
r284016 r284059 50 50 }, m_variant); 51 51 } 52 53 void* mutableData() const 54 { 55 return std::visit([](auto& buffer) -> void* { 56 return buffer->data(); 57 }, m_variant); 58 } 52 59 53 60 size_t length() const -
trunk/Source/WebKit/ChangeLog
r284057 r284059 1 2021-10-12 Sihui Liu <sihui_liu@apple.com> 2 3 Implement FileSystemSyncAccessHandle read() and write() 4 https://bugs.webkit.org/show_bug.cgi?id=231466 5 <rdar://problem/84050394> 6 7 Reviewed by Youenn Fablet. 8 9 Let network process open the file and pass file descriptor to web process, so that web process can read and 10 write the file without sending IPC messages. Currently getting file size, truncating file and syncing file are 11 still performed by network process. 12 13 * NetworkProcess/storage/FileSystemStorageError.h: 14 (WebKit::convertToException): 15 * NetworkProcess/storage/FileSystemStorageHandle.cpp: 16 (WebKit::FileSystemStorageHandle::createSyncAccessHandle): 17 (WebKit::FileSystemStorageHandle::truncate): 18 (WebKit::FileSystemStorageHandle::flush): 19 (WebKit::FileSystemStorageHandle::close): 20 * NetworkProcess/storage/FileSystemStorageHandle.h: 21 * NetworkProcess/storage/NetworkStorageManager.cpp: 22 (WebKit::NetworkStorageManager::createSyncAccessHandle): 23 * NetworkProcess/storage/NetworkStorageManager.h: 24 * NetworkProcess/storage/NetworkStorageManager.messages.in: 25 * Platform/IPC/SharedFileHandle.cpp: Added. 26 (IPC::SharedFileHandle::create): 27 (IPC::SharedFileHandle::encode const): 28 (IPC::SharedFileHandle::decode): 29 * Platform/IPC/SharedFileHandle.h: Added. 30 (IPC::SharedFileHandle::handle): 31 (IPC::SharedFileHandle::SharedFileHandle): 32 * Platform/IPC/cocoa/SharedFileHandleCocoa.cpp: Added. 33 (IPC::SharedFileHandle::create): 34 (IPC::SharedFileHandle::encode const): 35 (IPC::SharedFileHandle::decode): 36 * Sources.txt: 37 * UIProcess/API/Cocoa/WKPreferences.mm: 38 (-[WKPreferences _fileSystemAccessEnabled]): 39 (-[WKPreferences _setFileSystemAccessEnabled:]): 40 (-[WKPreferences _storageAPIEnabled]): 41 (-[WKPreferences _setStorageAPIEnabled:]): 42 (-[WKPreferences _accessHandleEnabled]): 43 (-[WKPreferences _setAccessHandleEnabled:]): 44 * UIProcess/API/Cocoa/WKPreferencesPrivate.h: 45 * WebKit.xcodeproj/project.pbxproj: 46 * WebProcess/WebCoreSupport/WebFileSystemStorageConnection.cpp: 47 (WebKit::WebFileSystemStorageConnection::createSyncAccessHandle): 48 * WebProcess/com.apple.WebProcess.sb.in: 49 1 50 2021-10-12 Chris Dumez <cdumez@apple.com> 2 51 -
trunk/Source/WebKit/NetworkProcess/storage/FileSystemStorageError.h
r283676 r284059 32 32 33 33 enum class FileSystemStorageError : uint8_t { 34 BackendNotSupported, 34 35 FileNotFound, 36 InvalidModification, 35 37 InvalidName, 36 InvalidModification,37 38 InvalidState, 38 39 TypeMismatch, … … 43 44 { 44 45 switch (error) { 46 case FileSystemStorageError::BackendNotSupported: 47 return WebCore::Exception { WebCore::NotSupportedError, "Backend does not support this operation" }; 45 48 case FileSystemStorageError::FileNotFound: 46 49 return WebCore::Exception { WebCore::NotFoundError }; 47 50 case FileSystemStorageError::InvalidModification: 48 51 return WebCore::Exception { WebCore::InvalidModificationError }; 49 case FileSystemStorageError::TypeMismatch:50 return WebCore::Exception { WebCore::TypeError };51 52 case FileSystemStorageError::InvalidName: 52 53 return WebCore::Exception { WebCore::UnknownError, "Name is invalid" }; 53 54 case FileSystemStorageError::InvalidState: 54 55 return WebCore::Exception { WebCore::InvalidStateError }; 56 case FileSystemStorageError::TypeMismatch: 57 return WebCore::Exception { WebCore::TypeError }; 55 58 case FileSystemStorageError::Unknown: 56 59 break; … … 75 78 using values = EnumValues< 76 79 WebKit::FileSystemStorageError, 80 WebKit::FileSystemStorageError::BackendNotSupported, 77 81 WebKit::FileSystemStorageError::FileNotFound, 82 WebKit::FileSystemStorageError::InvalidModification, 78 83 WebKit::FileSystemStorageError::InvalidName, 79 WebKit::FileSystemStorageError::InvalidModification,80 84 WebKit::FileSystemStorageError::InvalidState, 81 85 WebKit::FileSystemStorageError::TypeMismatch, -
trunk/Source/WebKit/NetworkProcess/storage/FileSystemStorageHandle.cpp
r283881 r284059 29 29 #include "FileSystemStorageError.h" 30 30 #include "FileSystemStorageManager.h" 31 #include "SharedFileHandle.h" 31 32 #include <wtf/Scope.h> 32 33 … … 144 145 } 145 146 146 Expected< WebCore::FileSystemSyncAccessHandleIdentifier, FileSystemStorageError> FileSystemStorageHandle::createSyncAccessHandle()147 Expected<FileSystemStorageHandle::AccessHandleInfo, FileSystemStorageError> FileSystemStorageHandle::createSyncAccessHandle() 147 148 { 148 149 if (!m_manager) … … 153 154 return makeUnexpected(FileSystemStorageError::InvalidState); 154 155 156 m_handle = FileSystem::openFile(m_path, FileSystem::FileOpenMode::ReadWrite); 157 if (m_handle == FileSystem::invalidPlatformFileHandle) 158 return makeUnexpected(FileSystemStorageError::Unknown); 159 160 auto ipcHandle = IPC::SharedFileHandle::create(m_handle); 161 if (!ipcHandle) { 162 FileSystem::closeFile(m_handle); 163 m_handle = FileSystem::invalidPlatformFileHandle; 164 return makeUnexpected(FileSystemStorageError::BackendNotSupported); 165 } 166 155 167 ASSERT(!m_activeSyncAccessHandle); 156 168 m_activeSyncAccessHandle = WebCore::FileSystemSyncAccessHandleIdentifier::generateThreadSafe(); 157 return *m_activeSyncAccessHandle;169 return std::pair { *m_activeSyncAccessHandle, WTFMove(*ipcHandle) }; 158 170 } 159 171 … … 181 193 return FileSystemStorageError::Unknown; 182 194 183 auto handle = FileSystem::openFile(m_path, FileSystem::FileOpenMode::ReadWrite); 184 auto closeFileScope = makeScopeExit([&] { 185 FileSystem::closeFile(handle); 186 }); 187 188 auto result = FileSystem::truncateFile(handle, size); 195 ASSERT(m_handle != FileSystem::invalidPlatformFileHandle); 196 auto result = FileSystem::truncateFile(m_handle, size); 189 197 if (!result) 190 198 return FileSystemStorageError::Unknown; … … 201 209 return FileSystemStorageError::Unknown; 202 210 203 // FIXME: when write operation is implemented, perform actual flush here. 211 ASSERT(m_handle != FileSystem::invalidPlatformFileHandle); 212 auto result = FileSystem::flushFile(m_handle); 213 if (!result) 214 return FileSystemStorageError::Unknown; 215 204 216 return std::nullopt; 205 217 } … … 212 224 if (!m_activeSyncAccessHandle || *m_activeSyncAccessHandle != accessHandleIdentifier) 213 225 return FileSystemStorageError::Unknown; 226 227 ASSERT(m_handle != FileSystem::invalidPlatformFileHandle); 228 FileSystem::closeFile(m_handle); 229 m_handle = FileSystem::invalidPlatformFileHandle; 214 230 215 231 m_manager->releaseLockForFile(m_path, m_identifier); -
trunk/Source/WebKit/NetworkProcess/storage/FileSystemStorageHandle.h
r283881 r284059 31 31 #include <wtf/WeakPtr.h> 32 32 33 namespace IPC { 34 class SharedFileHandle; 35 } 36 33 37 namespace WebKit { 34 38 … … 54 58 Expected<std::pair<WebCore::FileSystemHandleIdentifier, bool>, FileSystemStorageError> getHandle(IPC::Connection::UniqueID, String&& name); 55 59 56 Expected<WebCore::FileSystemSyncAccessHandleIdentifier, FileSystemStorageError> createSyncAccessHandle(); 60 using AccessHandleInfo = std::pair<WebCore::FileSystemSyncAccessHandleIdentifier, IPC::SharedFileHandle>; 61 Expected<AccessHandleInfo, FileSystemStorageError> createSyncAccessHandle(); 57 62 Expected<uint64_t, FileSystemStorageError> getSize(WebCore::FileSystemSyncAccessHandleIdentifier); 58 63 std::optional<FileSystemStorageError> truncate(WebCore::FileSystemSyncAccessHandleIdentifier, uint64_t size); … … 69 74 String m_name; 70 75 std::optional<WebCore::FileSystemSyncAccessHandleIdentifier> m_activeSyncAccessHandle; 76 FileSystem::PlatformFileHandle m_handle { FileSystem::invalidPlatformFileHandle }; 71 77 }; 72 78 -
trunk/Source/WebKit/NetworkProcess/storage/NetworkStorageManager.cpp
r283881 r284059 227 227 } 228 228 229 void NetworkStorageManager::createSyncAccessHandle(WebCore::FileSystemHandleIdentifier identifier, CompletionHandler<void(Expected< WebCore::FileSystemSyncAccessHandleIdentifier, FileSystemStorageError>)>&& completionHandler)229 void NetworkStorageManager::createSyncAccessHandle(WebCore::FileSystemHandleIdentifier identifier, CompletionHandler<void(Expected<AccessHandleInfo, FileSystemStorageError>)>&& completionHandler) 230 230 { 231 231 ASSERT(!RunLoop::isMain()); -
trunk/Source/WebKit/NetworkProcess/storage/NetworkStorageManager.h
r283881 r284059 33 33 #include <WebCore/FileSystemSyncAccessHandleIdentifier.h> 34 34 #include <pal/SessionID.h> 35 36 namespace IPC { 37 class SharedFileHandle; 38 } 35 39 36 40 namespace WebCore { … … 71 75 void removeEntry(WebCore::FileSystemHandleIdentifier, const String& name, bool deleteRecursively, CompletionHandler<void(std::optional<FileSystemStorageError>)>&&); 72 76 void resolve(WebCore::FileSystemHandleIdentifier, WebCore::FileSystemHandleIdentifier, CompletionHandler<void(Expected<Vector<String>, FileSystemStorageError>)>&&); 73 void createSyncAccessHandle(WebCore::FileSystemHandleIdentifier, CompletionHandler<void(Expected<WebCore::FileSystemSyncAccessHandleIdentifier, FileSystemStorageError>)>&&); 77 using AccessHandleInfo = std::pair<WebCore::FileSystemSyncAccessHandleIdentifier, IPC::SharedFileHandle>; 78 void createSyncAccessHandle(WebCore::FileSystemHandleIdentifier, CompletionHandler<void(Expected<AccessHandleInfo, FileSystemStorageError>)>&&); 74 79 void getSizeForAccessHandle(WebCore::FileSystemHandleIdentifier, WebCore::FileSystemSyncAccessHandleIdentifier, CompletionHandler<void(Expected<uint64_t, FileSystemStorageError>)>&&); 75 80 void truncateForAccessHandle(WebCore::FileSystemHandleIdentifier, WebCore::FileSystemSyncAccessHandleIdentifier, uint64_t size, CompletionHandler<void(std::optional<FileSystemStorageError>)>&&); -
trunk/Source/WebKit/NetworkProcess/storage/NetworkStorageManager.messages.in
r283881 r284059 34 34 Resolve(WebCore::FileSystemHandleIdentifier identifier, WebCore::FileSystemHandleIdentifier targetIdentifier) -> (Expected<Vector<String>, WebKit::FileSystemStorageError> result) Async 35 35 36 CreateSyncAccessHandle(WebCore::FileSystemHandleIdentifier identifier) -> (Expected< WebCore::FileSystemSyncAccessHandleIdentifier, WebKit::FileSystemStorageError> result) Async36 CreateSyncAccessHandle(WebCore::FileSystemHandleIdentifier identifier) -> (Expected<std::pair<WebCore::FileSystemSyncAccessHandleIdentifier, IPC::SharedFileHandle>, WebKit::FileSystemStorageError> result) Async 37 37 GetSizeForAccessHandle(WebCore::FileSystemHandleIdentifier identifier, WebCore::FileSystemSyncAccessHandleIdentifier accessHandleIdentifier) -> (Expected<uint64_t, WebKit::FileSystemStorageError> result) Async 38 38 TruncateForAccessHandle(WebCore::FileSystemHandleIdentifier identifier, WebCore::FileSystemSyncAccessHandleIdentifier accessHandleIdentifier, uint64_t size) -> (std::optional<WebKit::FileSystemStorageError> result) Async -
trunk/Source/WebKit/Platform/IPC/SharedFileHandle.cpp
r284058 r284059 24 24 */ 25 25 26 [ 27 EnabledBySetting=AccessHandleEnabled, 28 ImplementationLacksVTable, 29 Exposed=DedicatedWorker, 30 SecureContext 31 ] interface FileSystemSyncAccessHandle { 32 Promise<undefined> truncate([EnforceRange] unsigned long long size); 33 Promise<unsigned long long> getSize(); 34 Promise<undefined> flush(); 35 Promise<undefined> close(); 36 }; 26 #include "config.h" 27 #include "SharedFileHandle.h" 37 28 38 dictionary FilesystemReadWriteOptions { 39 [EnforceRange] unsigned long long at; 40 }; 29 namespace IPC { 30 31 #if !PLATFORM(COCOA) 32 33 std::optional<SharedFileHandle> SharedFileHandle::create(FileSystem::PlatformFileHandle) 34 { 35 return std::nullopt; 36 } 37 38 void SharedFileHandle::encode(Encoder&) const 39 { 40 } 41 42 std::optional<SharedFileHandle> SharedFileHandle::decode(Decoder&) 43 { 44 return std::nullopt; 45 } 46 47 #endif 48 49 } // namespace IPC -
trunk/Source/WebKit/Platform/IPC/SharedFileHandle.h
r284058 r284059 24 24 */ 25 25 26 [ 27 EnabledBySetting=AccessHandleEnabled, 28 ImplementationLacksVTable, 29 Exposed=DedicatedWorker, 30 SecureContext 31 ] interface FileSystemSyncAccessHandle { 32 Promise<undefined> truncate([EnforceRange] unsigned long long size); 33 Promise<unsigned long long> getSize(); 34 Promise<undefined> flush(); 35 Promise<undefined> close(); 26 #pragma once 27 28 #include <fcntl.h> 29 #include <wtf/FileSystem.h> 30 31 namespace IPC { 32 33 class Decoder; 34 class Encoder; 35 36 class SharedFileHandle { 37 public: 38 static std::optional<SharedFileHandle> create(FileSystem::PlatformFileHandle); 39 40 SharedFileHandle() = default; 41 FileSystem::PlatformFileHandle handle() { return m_handle; } 42 43 void encode(Encoder&) const; 44 45 static std::optional<SharedFileHandle> decode(Decoder&); 46 47 private: 48 explicit SharedFileHandle(FileSystem::PlatformFileHandle handle) 49 : m_handle(handle) 50 { 51 } 52 53 FileSystem::PlatformFileHandle m_handle { FileSystem::invalidPlatformFileHandle }; 36 54 }; 37 55 38 dictionary FilesystemReadWriteOptions { 39 [EnforceRange] unsigned long long at; 40 }; 56 } // namespace IPC 57 58 -
trunk/Source/WebKit/Platform/IPC/cocoa/SharedFileHandleCocoa.cpp
r284058 r284059 24 24 */ 25 25 26 [ 27 EnabledBySetting=AccessHandleEnabled, 28 ImplementationLacksVTable, 29 Exposed=DedicatedWorker, 30 SecureContext 31 ] interface FileSystemSyncAccessHandle { 32 Promise<undefined> truncate([EnforceRange] unsigned long long size); 33 Promise<unsigned long long> getSize(); 34 Promise<undefined> flush(); 35 Promise<undefined> close(); 36 }; 26 #include "config.h" 27 #include "SharedFileHandle.h" 37 28 38 dictionary FilesystemReadWriteOptions { 39 [EnforceRange] unsigned long long at; 40 }; 29 #include "MachPort.h" 30 #include <pal/spi/cocoa/FilePortSPI.h> 31 32 namespace IPC { 33 34 std::optional<SharedFileHandle> SharedFileHandle::create(FileSystem::PlatformFileHandle handle) 35 { 36 return SharedFileHandle { handle }; 37 } 38 39 void SharedFileHandle::encode(Encoder& encoder) const 40 { 41 mach_port_name_t fileport = MACH_PORT_NULL; 42 if (fileport_makeport(m_handle, &fileport) == -1) { 43 encoder << MachPort(); 44 return; 45 } 46 47 encoder << MachPort(fileport, MACH_MSG_TYPE_MOVE_SEND); 48 } 49 50 std::optional<SharedFileHandle> SharedFileHandle::decode(Decoder& decoder) 51 { 52 MachPort machPort; 53 if (!decoder.decode(machPort)) 54 return std::nullopt; 55 56 int fd = fileport_makefd(machPort.port()); 57 if (fd == -1) 58 return SharedFileHandle { }; 59 60 return SharedFileHandle::create(fileport_makefd(machPort.port())); 61 } 62 63 } // namespace IPC -
trunk/Source/WebKit/Sources.txt
r283941 r284059 174 174 Platform/IPC/StreamConnectionBuffer.cpp @no-unify 175 175 Platform/IPC/StreamConnectionWorkQueue.cpp @no-unify 176 Platform/IPC/SharedFileHandle.cpp @no-unify 176 177 Platform/IPC/StreamServerConnection.cpp @no-unify 177 178 Platform/IPC/StringReference.cpp @no-unify -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm
r280298 r284059 1518 1518 } 1519 1519 1520 - (BOOL)_fileSystemAccessEnabled 1521 { 1522 return _preferences->fileSystemAccessEnabled(); 1523 } 1524 1525 - (void)_setFileSystemAccessEnabled:(BOOL)fileSystemAccessEnabled 1526 { 1527 _preferences->setFileSystemAccessEnabled(fileSystemAccessEnabled); 1528 } 1529 1530 - (BOOL)_storageAPIEnabled 1531 { 1532 return _preferences->storageAPIEnabled(); 1533 } 1534 1535 - (void)_setStorageAPIEnabled:(BOOL)storageAPIEnabled 1536 { 1537 _preferences->setStorageAPIEnabled(storageAPIEnabled); 1538 } 1539 1540 - (BOOL)_accessHandleEnabled 1541 { 1542 return _preferences->accessHandleEnabled(); 1543 } 1544 1545 - (void)_setAccessHandleEnabled:(BOOL)accessHandleEnabled 1546 { 1547 _preferences->setAccessHandleEnabled(accessHandleEnabled); 1548 } 1549 1520 1550 @end 1521 1551 -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h
r280298 r284059 174 174 @property (nonatomic, getter=_isExtensibleSSOEnabled, setter=_setExtensibleSSOEnabled:) BOOL _extensibleSSOEnabled WK_API_AVAILABLE(macos(12.0), ios(15.0)); 175 175 @property (nonatomic, setter=_setRequiresPageVisibilityToPlayAudio:) BOOL _requiresPageVisibilityToPlayAudio WK_API_AVAILABLE(macos(12.0), ios(15.0)); 176 @property (nonatomic, setter=_setFileSystemAccessEnabled:) BOOL _fileSystemAccessEnabled WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 177 @property (nonatomic, setter=_setStorageAPIEnabled:) BOOL _storageAPIEnabled WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 178 @property (nonatomic, setter=_setAccessHandleEnabled:) BOOL _accessHandleEnabled WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA)); 176 179 177 180 #if !TARGET_OS_IPHONE -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r284055 r284059 1473 1473 93085DE026E5BCFD000EC6A7 /* NetworkStorageManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 93085DC426E1BBBD000EC6A7 /* NetworkStorageManager.h */; }; 1474 1474 93085DE126E5BD13000EC6A7 /* NetworkStorageManagerMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 93085DCD26E2E902000EC6A7 /* NetworkStorageManagerMessages.h */; }; 1475 93122C862710CCDF001D819F /* SharedFileHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 93122C852710CCDE001D819F /* SharedFileHandle.h */; }; 1475 1476 9312BAD526F33C2600FDDF5F /* FileSystemStorageManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 931A075026F06310004474CD /* FileSystemStorageManager.h */; }; 1476 1477 9312BAD626F33C2900FDDF5F /* FileSystemStorageHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 931A075326F06AB4004474CD /* FileSystemStorageHandle.h */; }; … … 1485 1486 933E835B23A1B75000DEF289 /* WebIDBServerMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 933E835823A1ADF500DEF289 /* WebIDBServerMessageReceiver.cpp */; }; 1486 1487 9342589A255B535A0059EEDD /* MediaPermissionUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 93425898255B534B0059EEDD /* MediaPermissionUtilities.h */; }; 1488 93468E6B2714AF47009983E3 /* SharedFileHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93468E6A2714AF47009983E3 /* SharedFileHandle.cpp */; }; 1489 93468E6D2714AF88009983E3 /* SharedFileHandleCocoa.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93468E6C2714AF88009983E3 /* SharedFileHandleCocoa.cpp */; }; 1487 1490 934B724419F5B9BE00AE96D6 /* WKActionMenuItemTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 934B724319F5B9BE00AE96D6 /* WKActionMenuItemTypes.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1488 1491 9354242C2703BDCB005CA72C /* WebFileSystemStorageConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 9354242A2703BDCB005CA72C /* WebFileSystemStorageConnection.h */; }; … … 4951 4954 93085DCD26E2E902000EC6A7 /* NetworkStorageManagerMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkStorageManagerMessages.h; sourceTree = "<group>"; }; 4952 4955 93085DCE26E2E902000EC6A7 /* NetworkStorageManagerMessagesReplies.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkStorageManagerMessagesReplies.h; sourceTree = "<group>"; }; 4956 93122C852710CCDE001D819F /* SharedFileHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedFileHandle.h; sourceTree = "<group>"; }; 4953 4957 931A075026F06310004474CD /* FileSystemStorageManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileSystemStorageManager.h; sourceTree = "<group>"; }; 4954 4958 931A075126F06310004474CD /* FileSystemStorageManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FileSystemStorageManager.cpp; sourceTree = "<group>"; }; … … 4969 4973 9342588F2555DCA50059EEDD /* MediaPermissionUtilities.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaPermissionUtilities.mm; sourceTree = "<group>"; }; 4970 4974 93425898255B534B0059EEDD /* MediaPermissionUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaPermissionUtilities.h; sourceTree = "<group>"; }; 4975 93468E6A2714AF47009983E3 /* SharedFileHandle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedFileHandle.cpp; sourceTree = "<group>"; }; 4976 93468E6C2714AF88009983E3 /* SharedFileHandleCocoa.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedFileHandleCocoa.cpp; sourceTree = "<group>"; }; 4971 4977 934B724319F5B9BE00AE96D6 /* WKActionMenuItemTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKActionMenuItemTypes.h; sourceTree = "<group>"; }; 4972 4978 9354242A2703BDCB005CA72C /* WebFileSystemStorageConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebFileSystemStorageConnection.h; sourceTree = "<group>"; }; … … 7360 7366 2DC1855EDBFB850BA0B6D06D /* SharedBufferDataReference.cpp */, 7361 7367 2DC1881ACBCAB5D57C5C6EF0 /* SharedBufferDataReference.h */, 7368 93468E6A2714AF47009983E3 /* SharedFileHandle.cpp */, 7369 93122C852710CCDE001D819F /* SharedFileHandle.h */, 7362 7370 7B73123625CC8524003B2796 /* StreamClientConnection.cpp */, 7363 7371 7B73123325CC8523003B2796 /* StreamClientConnection.h */, … … 11133 11141 1A6D86C01DF75265007745E8 /* MachMessage.h */, 11134 11142 BCC56F771159957D001CCAF9 /* MachPort.h */, 11143 93468E6C2714AF88009983E3 /* SharedFileHandleCocoa.cpp */, 11135 11144 ); 11136 11145 path = cocoa; … … 12657 12666 2DC18FF6EF2A3130C1301767 /* SharedBufferDataReference.h in Headers */, 12658 12667 F4A6D6BC254CA3E900B65FAA /* SharedDisplayListHandle.h in Headers */, 12668 93122C862710CCDF001D819F /* SharedFileHandle.h in Headers */, 12659 12669 1A24BED5120894D100FBB059 /* SharedMemory.h in Headers */, 12660 12670 CD4B4D9D1E765E0000D27092 /* SharedRingBufferStorage.h in Headers */, … … 14619 14629 2DC18FEBF337B9671C88E3CD /* SharedBufferCopy.cpp in Sources */, 14620 14630 2DC181245B549343BC98164C /* SharedBufferDataReference.cpp in Sources */, 14631 93468E6B2714AF47009983E3 /* SharedFileHandle.cpp in Sources */, 14632 93468E6D2714AF88009983E3 /* SharedFileHandleCocoa.cpp in Sources */, 14621 14633 A1ADAFB62368E6A8009CB776 /* SharedMemory.cpp in Sources */, 14622 14634 575B1BB923CE9C0B0020639A /* SimulatedInputDispatcher.cpp in Sources */, -
trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFileSystemStorageConnection.cpp
r283881 r284059 122 122 return completionHandler(convertToException(result.error())); 123 123 124 completionHandler(WTFMove(result.value())); 124 auto resultValue = result.value(); 125 completionHandler(std::pair { resultValue.first, resultValue.second.handle() }); 125 126 }); 126 127 } -
trunk/Source/WebKit/WebProcess/com.apple.WebProcess.sb.in
r283998 r284059 1979 1979 (syscall-number SYS_sendto_nocancel) 1980 1980 (syscall-number SYS_fsgetpath) 1981 (syscall-number SYS_fileport_makefd) 1981 1982 (syscall-number SYS_fileport_makeport) 1982 1983 (syscall-number SYS_guarded_open_np) -
trunk/Tools/ChangeLog
r284055 r284059 1 2021-10-12 Sihui Liu <sihui_liu@apple.com> 2 3 Implement FileSystemSyncAccessHandle read() and write() 4 https://bugs.webkit.org/show_bug.cgi?id=231466 5 <rdar://problem/84050394> 6 7 Reviewed by Youenn Fablet. 8 9 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 10 * TestWebKitAPI/Tests/WebKitCocoa/FileSystemAccess.mm: Added. 11 (-[FileSystemAccessMessageHandler userContentController:didReceiveScriptMessage:]): 12 (test): 13 1 14 2021-10-12 Alex Christensen <achristensen@webkit.org> 2 15 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r283857 r284059 855 855 9342589C255B609B0059EEDD /* SpeechRecognition.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9342589B255B609A0059EEDD /* SpeechRecognition.mm */; }; 856 856 9342589E255B6A120059EEDD /* speechrecognition-user-permission-persistence.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9342589D255B66A00059EEDD /* speechrecognition-user-permission-persistence.html */; }; 857 93468E6F2714B4F2009983E3 /* FileSystemAccess.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93468E6E2714B4F1009983E3 /* FileSystemAccess.mm */; }; 857 858 935786CC20F6A2700000CDFC /* IndexedDB.sqlite3-wal in Copy Resources */ = {isa = PBXBuildFile; fileRef = 934FA5C520F69FED0040DC1B /* IndexedDB.sqlite3-wal */; }; 858 859 935786CD20F6A2910000CDFC /* IndexedDB.sqlite3 in Copy Resources */ = {isa = PBXBuildFile; fileRef = 934FA5C720F69FEE0040DC1B /* IndexedDB.sqlite3 */; }; … … 2583 2584 9342589B255B609A0059EEDD /* SpeechRecognition.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SpeechRecognition.mm; sourceTree = "<group>"; }; 2584 2585 9342589D255B66A00059EEDD /* speechrecognition-user-permission-persistence.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "speechrecognition-user-permission-persistence.html"; sourceTree = "<group>"; }; 2586 93468E6E2714B4F1009983E3 /* FileSystemAccess.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FileSystemAccess.mm; sourceTree = "<group>"; }; 2585 2587 934FA5C520F69FED0040DC1B /* IndexedDB.sqlite3-wal */ = {isa = PBXFileReference; lastKnownFileType = file; path = "IndexedDB.sqlite3-wal"; sourceTree = "<group>"; }; 2586 2588 934FA5C620F69FED0040DC1B /* IndexedDB.sqlite3-shm */ = {isa = PBXFileReference; lastKnownFileType = file; path = "IndexedDB.sqlite3-shm"; sourceTree = "<group>"; }; … … 3511 3513 CDA29B2820FD2A9900F15CED /* ExitFullscreenOnEnterPiP.mm */, 3512 3514 1D12BEBF245BEF85004C0B7A /* ExitPiPOnSuspendVideoElement.mm */, 3515 93468E6E2714B4F1009983E3 /* FileSystemAccess.mm */, 3513 3516 2D8104CB1BEC13E70020DA46 /* FindInPage.mm */, 3514 3517 51242CD42374E61E00EED9C1 /* FindInPageAPI.mm */, … … 5569 5572 579651E7216BFDED006EBFE5 /* FidoHidMessageTest.cpp in Sources */, 5570 5573 7A32D74A1F02151500162C44 /* FileMonitor.cpp in Sources */, 5574 93468E6F2714B4F2009983E3 /* FileSystemAccess.mm in Sources */, 5571 5575 7CCE7EF31A411AE600447C4C /* Find.cpp in Sources */, 5572 5576 7C83E0BB1D0A650000FEBCF3 /* FindInPage.mm in Sources */,
Note: See TracChangeset
for help on using the changeset viewer.