Diff
Modified: trunk/Source/WebCore/ChangeLog (287155 => 287156)
--- trunk/Source/WebCore/ChangeLog 2021-12-16 21:20:10 UTC (rev 287155)
+++ trunk/Source/WebCore/ChangeLog 2021-12-16 22:00:44 UTC (rev 287156)
@@ -1,3 +1,53 @@
+2021-12-16 Sihui Liu <[email protected]>
+
+ REGRESSION (r286601): storage/filesystemaccess/sync-access-handle-read-write-worker.html and file-system-access/sandboxed_FileSystemSyncAccessHandle-truncate.https.tentative.worker.html are consistently failing
+ https://bugs.webkit.org/show_bug.cgi?id=234271
+ <rdar://problem/86434111>
+
+ Reviewed by Youenn Fablet.
+
+ When context stops, FileSystemHandle sets its state to closed. A closed FileSystemHandle will return early on
+ operations including closing sync access handle (asking backend to close handle and releasing lock). If backend
+ thinks existing access handle is not closed, it will prevent new access handle from being created, and this
+ leads to the test failure.
+
+ The problem is that backend isn't notified about the close of a handle: we only set the close state in
+ FileSystemHandle. To fix the issue, let's make sure FileSystemStorageConnection::closeHandle is called when
+ context stops and when FileSystemHandle is detroyed.
+
+ * Headers.cmake:
+ * Modules/filesystemaccess/FileSystemDirectoryHandle.cpp:
+ (WebCore::FileSystemDirectoryHandle::getFileHandle):
+ (WebCore::FileSystemDirectoryHandle::getDirectoryHandle):
+ (WebCore::FileSystemDirectoryHandle::getHandle):
+ * Modules/filesystemaccess/FileSystemFileHandle.cpp:
+ (WebCore::FileSystemFileHandle::createSyncAccessHandle):
+ (WebCore::FileSystemFileHandle::closeSyncAccessHandle):
+ (WebCore::FileSystemFileHandle::close): Deleted.
+ * Modules/filesystemaccess/FileSystemFileHandle.h:
+ * Modules/filesystemaccess/FileSystemHandle.cpp:
+ (WebCore::FileSystemHandle::~FileSystemHandle):
+ (WebCore::FileSystemHandle::close):
+ (WebCore::FileSystemHandle::stop):
+ * Modules/filesystemaccess/FileSystemHandle.h:
+ * Modules/filesystemaccess/FileSystemHandleCloseScope.h: Added.
+ (WebCore::FileSystemHandleCloseScope::create):
+ (WebCore::FileSystemHandleCloseScope::~FileSystemHandleCloseScope):
+ (WebCore::FileSystemHandleCloseScope::release):
+ (WebCore::FileSystemHandleCloseScope::FileSystemHandleCloseScope):
+ * Modules/filesystemaccess/FileSystemStorageConnection.h:
+ * Modules/filesystemaccess/FileSystemSyncAccessHandle.cpp:
+ (WebCore::FileSystemSyncAccessHandle::closeBackend):
+ * Modules/filesystemaccess/WorkerFileSystemStorageConnection.cpp:
+ (WebCore::WorkerFileSystemStorageConnection::getFileHandle):
+ (WebCore::WorkerFileSystemStorageConnection::getDirectoryHandle):
+ (WebCore::WorkerFileSystemStorageConnection::didGetHandle):
+ (WebCore::WorkerFileSystemStorageConnection::closeSyncAccessHandle):
+ (WebCore::WorkerFileSystemStorageConnection::getHandle):
+ (WebCore::WorkerFileSystemStorageConnection::close): Deleted.
+ * Modules/filesystemaccess/WorkerFileSystemStorageConnection.h:
+ * WebCore.xcodeproj/project.pbxproj:
+
2021-12-16 Adrian Perez de Castro <[email protected]>
Non-unified build fixes, late-ish December 2021 edition
Modified: trunk/Source/WebCore/Headers.cmake (287155 => 287156)
--- trunk/Source/WebCore/Headers.cmake 2021-12-16 21:20:10 UTC (rev 287155)
+++ trunk/Source/WebCore/Headers.cmake 2021-12-16 22:00:44 UTC (rev 287156)
@@ -172,6 +172,7 @@
Modules/filesystemaccess/FileSystemDirectoryHandle.h
Modules/filesystemaccess/FileSystemFileHandle.h
Modules/filesystemaccess/FileSystemHandle.h
+ Modules/filesystemaccess/FileSystemHandleCloseScope.h
Modules/filesystemaccess/FileSystemHandleIdentifier.h
Modules/filesystemaccess/FileSystemStorageConnection.h
Modules/filesystemaccess/FileSystemSyncAccessHandle.h
Modified: trunk/Source/WebCore/Modules/filesystemaccess/FileSystemDirectoryHandle.cpp (287155 => 287156)
--- trunk/Source/WebCore/Modules/filesystemaccess/FileSystemDirectoryHandle.cpp 2021-12-16 21:20:10 UTC (rev 287155)
+++ trunk/Source/WebCore/Modules/filesystemaccess/FileSystemDirectoryHandle.cpp 2021-12-16 22:00:44 UTC (rev 287156)
@@ -26,6 +26,7 @@
#include "config.h"
#include "FileSystemDirectoryHandle.h"
+#include "FileSystemHandleCloseScope.h"
#include "FileSystemStorageConnection.h"
#include "JSDOMPromiseDeferred.h"
#include "JSFileSystemDirectoryHandle.h"
@@ -56,14 +57,13 @@
if (result.hasException())
return promise.reject(result.releaseException());
- auto identifier = result.returnValue();
auto* context = weakThis ? weakThis->scriptExecutionContext() : nullptr;
- if (!context) {
- connection->closeHandle(identifier);
+ if (!context)
return promise.reject(Exception { InvalidStateError, "Context has stopped"_s });
- }
- promise.resolve(FileSystemFileHandle::create(*context, String { name }, result.returnValue(), WTFMove(connection)));
+ auto [identifier, isDirectory] = result.returnValue()->release();
+ ASSERT(!isDirectory);
+ promise.resolve(FileSystemFileHandle::create(*context, String { name }, identifier, WTFMove(connection)));
});
}
@@ -77,13 +77,12 @@
if (result.hasException())
return promise.reject(result.releaseException());
- auto identifier = result.returnValue();
auto* context = weakThis ? weakThis->scriptExecutionContext() : nullptr;
- if (!context) {
- connection->closeHandle(identifier);
+ if (!context)
return promise.reject(Exception { InvalidStateError, "Context has stopped"_s });
- }
+ auto [identifier, isDirectory] = result.returnValue()->release();
+ ASSERT(isDirectory);
promise.resolve(FileSystemDirectoryHandle::create(*context, String { name }, identifier, WTFMove(connection)));
});
}
@@ -126,12 +125,10 @@
if (result.hasException())
return completionHandler(result.releaseException());
- auto [identifier, isDirectory] = result.releaseReturnValue();
+ auto [identifier, isDirectory] = result.returnValue()->release();
auto* context = weakThis ? weakThis->scriptExecutionContext() : nullptr;
- if (!context) {
- connection->closeHandle(identifier);
+ if (!context)
return completionHandler(Exception { InvalidStateError, "Context has stopped"_s });
- }
if (isDirectory) {
Ref<FileSystemHandle> handle = FileSystemDirectoryHandle::create(*context, String { name }, identifier, WTFMove(connection));
Modified: trunk/Source/WebCore/Modules/filesystemaccess/FileSystemFileHandle.cpp (287155 => 287156)
--- trunk/Source/WebCore/Modules/filesystemaccess/FileSystemFileHandle.cpp 2021-12-16 21:20:10 UTC (rev 287155)
+++ trunk/Source/WebCore/Modules/filesystemaccess/FileSystemFileHandle.cpp 2021-12-16 22:00:44 UTC (rev 287156)
@@ -27,6 +27,7 @@
#include "FileSystemFileHandle.h"
#include "File.h"
+#include "FileSystemHandleCloseScope.h"
#include "FileSystemStorageConnection.h"
#include "FileSystemSyncAccessHandle.h"
#include "JSDOMPromiseDeferred.h"
@@ -82,7 +83,7 @@
auto* context = protectedThis->scriptExecutionContext();
if (!context) {
FileSystem::closeFile(file);
- protectedThis->close(identifier, { });
+ protectedThis->closeSyncAccessHandle(identifier, { });
return promise.reject(Exception { InvalidStateError, "Context has stopped"_s });
}
@@ -90,12 +91,12 @@
});
}
-void FileSystemFileHandle::close(FileSystemSyncAccessHandleIdentifier accessHandleIdentifier, CompletionHandler<void(ExceptionOr<void>&&)>&& completionHandler)
+void FileSystemFileHandle::closeSyncAccessHandle(FileSystemSyncAccessHandleIdentifier accessHandleIdentifier, CompletionHandler<void(ExceptionOr<void>&&)>&& completionHandler)
{
if (isClosed())
return completionHandler(Exception { InvalidStateError, "Handle is closed"_s });
- connection().close(identifier(), accessHandleIdentifier, WTFMove(completionHandler));
+ connection().closeSyncAccessHandle(identifier(), accessHandleIdentifier, WTFMove(completionHandler));
}
void FileSystemFileHandle::registerSyncAccessHandle(FileSystemSyncAccessHandleIdentifier identifier, FileSystemSyncAccessHandle& handle)
Modified: trunk/Source/WebCore/Modules/filesystemaccess/FileSystemFileHandle.h (287155 => 287156)
--- trunk/Source/WebCore/Modules/filesystemaccess/FileSystemFileHandle.h 2021-12-16 21:20:10 UTC (rev 287155)
+++ trunk/Source/WebCore/Modules/filesystemaccess/FileSystemFileHandle.h 2021-12-16 22:00:44 UTC (rev 287156)
@@ -41,7 +41,7 @@
void getFile(DOMPromiseDeferred<IDLInterface<File>>&&);
void createSyncAccessHandle(DOMPromiseDeferred<IDLInterface<FileSystemSyncAccessHandle>>&&);
- void close(FileSystemSyncAccessHandleIdentifier, CompletionHandler<void(ExceptionOr<void>&&)>&&);
+ void closeSyncAccessHandle(FileSystemSyncAccessHandleIdentifier, CompletionHandler<void(ExceptionOr<void>&&)>&&);
void registerSyncAccessHandle(FileSystemSyncAccessHandleIdentifier, FileSystemSyncAccessHandle&);
void unregisterSyncAccessHandle(FileSystemSyncAccessHandleIdentifier);
Modified: trunk/Source/WebCore/Modules/filesystemaccess/FileSystemHandle.cpp (287155 => 287156)
--- trunk/Source/WebCore/Modules/filesystemaccess/FileSystemHandle.cpp 2021-12-16 21:20:10 UTC (rev 287155)
+++ trunk/Source/WebCore/Modules/filesystemaccess/FileSystemHandle.cpp 2021-12-16 22:00:44 UTC (rev 287156)
@@ -44,8 +44,20 @@
suspendIfNeeded();
}
-FileSystemHandle::~FileSystemHandle() = default;
+FileSystemHandle::~FileSystemHandle()
+{
+ close();
+}
+void FileSystemHandle::close()
+{
+ if (m_isClosed)
+ return;
+
+ m_isClosed = true;
+ m_connection->closeHandle(m_identifier);
+}
+
void FileSystemHandle::isSameEntry(FileSystemHandle& handle, DOMPromiseDeferred<IDLBoolean>&& promise) const
{
if (isClosed())
@@ -82,7 +94,7 @@
void FileSystemHandle::stop()
{
- m_isClosed = true;
+ close();
}
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/filesystemaccess/FileSystemHandle.h (287155 => 287156)
--- trunk/Source/WebCore/Modules/filesystemaccess/FileSystemHandle.h 2021-12-16 21:20:10 UTC (rev 287155)
+++ trunk/Source/WebCore/Modules/filesystemaccess/FileSystemHandle.h 2021-12-16 22:00:44 UTC (rev 287156)
@@ -36,7 +36,7 @@
class FileSystemStorageConnection;
-class FileSystemHandle : public ActiveDOMObject, public CanMakeWeakPtr<FileSystemHandle>, public RefCounted<FileSystemHandle> {
+class FileSystemHandle : public ActiveDOMObject, public CanMakeWeakPtr<FileSystemHandle>, public ThreadSafeRefCounted<FileSystemHandle> {
WTF_MAKE_ISO_ALLOCATED(FileSystemHandle);
public:
virtual ~FileSystemHandle();
@@ -49,6 +49,7 @@
const String& name() const { return m_name; }
FileSystemHandleIdentifier identifier() const { return m_identifier; }
bool isClosed() const { return m_isClosed; }
+ void close();
void isSameEntry(FileSystemHandle&, DOMPromiseDeferred<IDLBoolean>&&) const;
void move(FileSystemHandle&, const String& newName, DOMPromiseDeferred<void>&&);
Copied: trunk/Source/WebCore/Modules/filesystemaccess/FileSystemHandleCloseScope.h (from rev 287154, trunk/Source/WebCore/Modules/filesystemaccess/FileSystemHandle.h) (0 => 287156)
--- trunk/Source/WebCore/Modules/filesystemaccess/FileSystemHandleCloseScope.h (rev 0)
+++ trunk/Source/WebCore/Modules/filesystemaccess/FileSystemHandleCloseScope.h 2021-12-16 22:00:44 UTC (rev 287156)
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "FileSystemStorageConnection.h"
+#include <wtf/RunLoop.h>
+
+namespace WebCore {
+
+class FileSystemHandleCloseScope : public ThreadSafeRefCounted<FileSystemHandleCloseScope, WTF::DestructionThread::MainRunLoop> {
+public:
+ static Ref<FileSystemHandleCloseScope> create(FileSystemHandleIdentifier identifier, bool isDirectory, FileSystemStorageConnection& connection)
+ {
+ return adoptRef(*new FileSystemHandleCloseScope(identifier, isDirectory, connection));
+ }
+
+ ~FileSystemHandleCloseScope()
+ {
+ ASSERT(RunLoop::isMain());
+
+ if (m_identifier.isValid())
+ m_connection->closeHandle(m_identifier);
+ }
+
+ std::pair<FileSystemHandleIdentifier, bool> release()
+ {
+ Locker locker { m_lock };
+ ASSERT_WITH_MESSAGE(m_identifier.isValid(), "FileSystemHandleCloseScope should not be released more than once");
+ return { std::exchange(m_identifier, { }), m_isDirectory };
+ }
+
+private:
+ FileSystemHandleCloseScope(FileSystemHandleIdentifier identifer, bool isDirectory, FileSystemStorageConnection& connection)
+ : m_identifier(identifer)
+ , m_isDirectory(isDirectory)
+ , m_connection(Ref { connection })
+ {
+ ASSERT(RunLoop::isMain());
+ }
+
+ Lock m_lock;
+ FileSystemHandleIdentifier m_identifier WTF_GUARDED_BY_LOCK(m_lock);
+ bool m_isDirectory;
+ Ref<FileSystemStorageConnection> m_connection;
+};
+
+} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/filesystemaccess/FileSystemStorageConnection.h (287155 => 287156)
--- trunk/Source/WebCore/Modules/filesystemaccess/FileSystemStorageConnection.h 2021-12-16 21:20:10 UTC (rev 287155)
+++ trunk/Source/WebCore/Modules/filesystemaccess/FileSystemStorageConnection.h 2021-12-16 22:00:44 UTC (rev 287156)
@@ -37,6 +37,7 @@
class FileSystemDirectoryHandle;
class FileSystemFileHandle;
+class FileSystemHandleCloseScope;
class FileSystemSyncAccessHandle;
template<typename> class ExceptionOr;
@@ -45,7 +46,7 @@
virtual ~FileSystemStorageConnection() { }
using SameEntryCallback = CompletionHandler<void(ExceptionOr<bool>&&)>;
- using GetHandleCallback = CompletionHandler<void(ExceptionOr<FileSystemHandleIdentifier>&&)>;
+ using GetHandleCallback = CompletionHandler<void(ExceptionOr<Ref<FileSystemHandleCloseScope>>&&)>;
using ResolveCallback = CompletionHandler<void(ExceptionOr<Vector<String>>&&)>;
using GetAccessHandleCallback = CompletionHandler<void(ExceptionOr<std::pair<FileSystemSyncAccessHandleIdentifier, FileSystem::PlatformFileHandle>>&&)>;
using VoidCallback = CompletionHandler<void(ExceptionOr<void>&&)>;
@@ -63,12 +64,12 @@
virtual void resolve(FileSystemHandleIdentifier, FileSystemHandleIdentifier, ResolveCallback&&) = 0;
virtual void getFile(FileSystemHandleIdentifier, StringCallback&&) = 0;
virtual void createSyncAccessHandle(FileSystemHandleIdentifier, GetAccessHandleCallback&&) = 0;
- virtual void close(FileSystemHandleIdentifier, FileSystemSyncAccessHandleIdentifier, VoidCallback&&) = 0;
+ virtual void closeSyncAccessHandle(FileSystemHandleIdentifier, FileSystemSyncAccessHandleIdentifier, VoidCallback&&) = 0;
virtual void registerSyncAccessHandle(FileSystemSyncAccessHandleIdentifier, ScriptExecutionContextIdentifier) = 0;
virtual void unregisterSyncAccessHandle(FileSystemSyncAccessHandleIdentifier) = 0;
virtual void invalidateAccessHandle(WebCore::FileSystemSyncAccessHandleIdentifier) = 0;
virtual void getHandleNames(FileSystemHandleIdentifier, GetHandleNamesCallback&&) = 0;
- virtual void getHandle(FileSystemHandleIdentifier, const String& name, GetHandleWithTypeCallback&&) = 0;
+ virtual void getHandle(FileSystemHandleIdentifier, const String& name, GetHandleCallback&&) = 0;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/filesystemaccess/FileSystemSyncAccessHandle.cpp (287155 => 287156)
--- trunk/Source/WebCore/Modules/filesystemaccess/FileSystemSyncAccessHandle.cpp 2021-12-16 21:20:10 UTC (rev 287155)
+++ trunk/Source/WebCore/Modules/filesystemaccess/FileSystemSyncAccessHandle.cpp 2021-12-16 22:00:44 UTC (rev 287156)
@@ -181,13 +181,13 @@
return;
if (mode == CloseMode::Async) {
- m_source->close(m_identifier, [this, protectedThis = Ref { *this }](auto result) mutable {
+ m_source->closeSyncAccessHandle(m_identifier, [this, protectedThis = Ref { *this }](auto result) mutable {
didCloseBackend(WTFMove(result));
});
return;
}
- m_source->close(m_identifier, [](auto) { });
+ m_source->closeSyncAccessHandle(m_identifier, [](auto) { });
didCloseBackend({ });
}
Modified: trunk/Source/WebCore/Modules/filesystemaccess/WorkerFileSystemStorageConnection.cpp (287155 => 287156)
--- trunk/Source/WebCore/Modules/filesystemaccess/WorkerFileSystemStorageConnection.cpp 2021-12-16 21:20:10 UTC (rev 287155)
+++ trunk/Source/WebCore/Modules/filesystemaccess/WorkerFileSystemStorageConnection.cpp 2021-12-16 22:00:44 UTC (rev 287156)
@@ -26,6 +26,7 @@
#include "config.h"
#include "WorkerFileSystemStorageConnection.h"
+#include "FileSystemHandleCloseScope.h"
#include "FileSystemSyncAccessHandle.h"
#include "WorkerGlobalScope.h"
#include "WorkerLoaderProxy.h"
@@ -128,7 +129,8 @@
callOnMainThread([callbackIdentifier, workerThread = Ref { m_scope->thread() }, mainThreadConnection = m_mainThreadConnection, identifier, name = name.isolatedCopy(), createIfNecessary]() mutable {
auto mainThreadCallback = [callbackIdentifier, workerThread = WTFMove(workerThread)](auto result) mutable {
- workerThread->runLoop().postTaskForMode([callbackIdentifier, result = crossThreadCopy(result)] (auto& scope) mutable {
+ auto crossThreadResult = result.hasException() ? ExceptionOr<Ref<FileSystemHandleCloseScope>> { crossThreadCopy(result.exception()) } : ExceptionOr<Ref<FileSystemHandleCloseScope>> { result.releaseReturnValue() };
+ workerThread->runLoop().postTaskForMode([callbackIdentifier, result = WTFMove(crossThreadResult)] (auto& scope) mutable {
if (auto connection = downcast<WorkerGlobalScope>(scope).fileSystemStorageConnection())
connection->didGetHandle(callbackIdentifier, WTFMove(result));
}, WorkerRunLoop::defaultMode());
@@ -148,7 +150,8 @@
callOnMainThread([callbackIdentifier, workerThread = Ref { m_scope->thread() }, mainThreadConnection = m_mainThreadConnection, identifier, name = name.isolatedCopy(), createIfNecessary]() mutable {
auto mainThreadCallback = [callbackIdentifier, workerThread = WTFMove(workerThread)](auto result) mutable {
- workerThread->runLoop().postTaskForMode([callbackIdentifier, result = crossThreadCopy(result)] (auto& scope) mutable {
+ auto crossThreadResult = result.hasException() ? ExceptionOr<Ref<FileSystemHandleCloseScope>> { crossThreadCopy(result.exception()) } : ExceptionOr<Ref<FileSystemHandleCloseScope>> { result.releaseReturnValue() };
+ workerThread->runLoop().postTaskForMode([callbackIdentifier, result = WTFMove(crossThreadResult)] (auto& scope) mutable {
if (auto connection = downcast<WorkerGlobalScope>(scope).fileSystemStorageConnection())
connection->didGetHandle(callbackIdentifier, WTFMove(result));
}, WorkerRunLoop::defaultMode());
@@ -158,7 +161,7 @@
});
}
-void WorkerFileSystemStorageConnection::didGetHandle(CallbackIdentifier callbackIdentifier, ExceptionOr<FileSystemHandleIdentifier>&& result)
+void WorkerFileSystemStorageConnection::didGetHandle(CallbackIdentifier callbackIdentifier, ExceptionOr<Ref<FileSystemHandleCloseScope>>&& result)
{
if (auto callback = m_getHandleCallbacks.take(callbackIdentifier))
callback(WTFMove(result));
@@ -271,7 +274,7 @@
});
}
-void WorkerFileSystemStorageConnection::close(FileSystemHandleIdentifier identifier, FileSystemSyncAccessHandleIdentifier accessHandleIdentifier, FileSystemStorageConnection::VoidCallback&& callback)
+void WorkerFileSystemStorageConnection::closeSyncAccessHandle(FileSystemHandleIdentifier identifier, FileSystemSyncAccessHandleIdentifier accessHandleIdentifier, FileSystemStorageConnection::VoidCallback&& callback)
{
if (!m_scope)
return callback(Exception { InvalidStateError });
@@ -287,7 +290,7 @@
}, WorkerRunLoop::defaultMode());
};
- mainThreadConnection->close(identifier, accessHandleIdentifier, WTFMove(mainThreadCallback));
+ mainThreadConnection->closeSyncAccessHandle(identifier, accessHandleIdentifier, WTFMove(mainThreadCallback));
});
}
@@ -342,19 +345,20 @@
callback(WTFMove(result));
}
-void WorkerFileSystemStorageConnection::getHandle(FileSystemHandleIdentifier identifier, const String& name, GetHandleWithTypeCallback&& callback)
+void WorkerFileSystemStorageConnection::getHandle(FileSystemHandleIdentifier identifier, const String& name, GetHandleCallback&& callback)
{
if (!m_scope)
return callback(Exception { InvalidStateError });
auto callbackIdentifier = CallbackIdentifier::generateThreadSafe();
- m_getHandleWithTypeCallbacks.add(callbackIdentifier, WTFMove(callback));
+ m_getHandleCallbacks.add(callbackIdentifier, WTFMove(callback));
callOnMainThread([callbackIdentifier, workerThread = Ref { m_scope->thread() }, mainThreadConnection = m_mainThreadConnection, identifier, name = name.isolatedCopy()]() mutable {
auto mainThreadCallback = [callbackIdentifier, workerThread = WTFMove(workerThread)](auto result) mutable {
- workerThread->runLoop().postTaskForMode([callbackIdentifier, result = crossThreadCopy(result)] (auto& scope) mutable {
+ auto crossThreadResult = result.hasException() ? ExceptionOr<Ref<FileSystemHandleCloseScope>> { crossThreadCopy(result.exception()) } : ExceptionOr<Ref<FileSystemHandleCloseScope>> { result.releaseReturnValue() };
+ workerThread->runLoop().postTaskForMode([callbackIdentifier, result = WTFMove(crossThreadResult)] (auto& scope) mutable {
if (auto connection = downcast<WorkerGlobalScope>(scope).fileSystemStorageConnection())
- connection->didGetHandleWithType(callbackIdentifier, WTFMove(result));
+ connection->didGetHandle(callbackIdentifier, WTFMove(result));
}, WorkerRunLoop::defaultMode());
};
Modified: trunk/Source/WebCore/Modules/filesystemaccess/WorkerFileSystemStorageConnection.h (287155 => 287156)
--- trunk/Source/WebCore/Modules/filesystemaccess/WorkerFileSystemStorageConnection.h 2021-12-16 21:20:10 UTC (rev 287155)
+++ trunk/Source/WebCore/Modules/filesystemaccess/WorkerFileSystemStorageConnection.h 2021-12-16 22:00:44 UTC (rev 287156)
@@ -47,7 +47,7 @@
void registerSyncAccessHandle(FileSystemSyncAccessHandleIdentifier, FileSystemSyncAccessHandle&);
using CallbackIdentifier = WorkerFileSystemStorageConnectionCallbackIdentifier;
void didIsSameEntry(CallbackIdentifier, ExceptionOr<bool>&&);
- void didGetHandle(CallbackIdentifier, ExceptionOr<FileSystemHandleIdentifier>&&);
+ void didGetHandle(CallbackIdentifier, ExceptionOr<Ref<FileSystemHandleCloseScope>>&&);
void didResolve(CallbackIdentifier, ExceptionOr<Vector<String>>&&);
void completeStringCallback(CallbackIdentifier, ExceptionOr<String>&&);
void didCreateSyncAccessHandle(CallbackIdentifier, ExceptionOr<std::pair<FileSystemSyncAccessHandleIdentifier, FileSystem::PlatformFileHandle>>&&);
@@ -68,10 +68,10 @@
void removeEntry(FileSystemHandleIdentifier, const String& name, bool deleteRecursively, FileSystemStorageConnection::VoidCallback&&) final;
void resolve(FileSystemHandleIdentifier, FileSystemHandleIdentifier, FileSystemStorageConnection::ResolveCallback&&) final;
void getHandleNames(FileSystemHandleIdentifier, GetHandleNamesCallback&&) final;
- void getHandle(FileSystemHandleIdentifier, const String& name, GetHandleWithTypeCallback&&) final;
+ void getHandle(FileSystemHandleIdentifier, const String& name, GetHandleCallback&&) final;
void getFile(FileSystemHandleIdentifier, StringCallback&&) final;
void createSyncAccessHandle(FileSystemHandleIdentifier, FileSystemStorageConnection::GetAccessHandleCallback&&) final;
- void close(FileSystemHandleIdentifier, FileSystemSyncAccessHandleIdentifier, FileSystemStorageConnection::VoidCallback&&) final;
+ void closeSyncAccessHandle(FileSystemHandleIdentifier, FileSystemSyncAccessHandleIdentifier, FileSystemStorageConnection::VoidCallback&&) final;
void registerSyncAccessHandle(FileSystemSyncAccessHandleIdentifier, ScriptExecutionContextIdentifier) final { };
void unregisterSyncAccessHandle(FileSystemSyncAccessHandleIdentifier) final;
void invalidateAccessHandle(FileSystemSyncAccessHandleIdentifier) final;
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (287155 => 287156)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-12-16 21:20:10 UTC (rev 287155)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-12-16 22:00:44 UTC (rev 287156)
@@ -2901,6 +2901,7 @@
93443E8626E995BD0058538F /* FileSystemDirectoryHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 932C9BD426DD625A0053B3DB /* FileSystemDirectoryHandle.h */; settings = {ATTRIBUTES = (Private, ); }; };
93443E8726E995C00058538F /* FileSystemFileHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 932C9BD626DD625C0053B3DB /* FileSystemFileHandle.h */; settings = {ATTRIBUTES = (Private, ); }; };
93443E8826E995C40058538F /* FileSystemHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 932C9BDA26DD62610053B3DB /* FileSystemHandle.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 93445084276A6357001F712B /* FileSystemHandleCloseScope.h in Headers */ = {isa = PBXBuildFile; fileRef = 93445082276A6356001F712B /* FileSystemHandleCloseScope.h */; settings = {ATTRIBUTES = (Private, ); }; };
934907E4125BBBC8007F23A0 /* GraphicsContextCG.h in Headers */ = {isa = PBXBuildFile; fileRef = 934907E3125BBBC8007F23A0 /* GraphicsContextCG.h */; settings = {ATTRIBUTES = (Private, ); }; };
934950CD253943610099F171 /* SpeechRecognition.h in Headers */ = {isa = PBXBuildFile; fileRef = 934950B1253943480099F171 /* SpeechRecognition.h */; };
934950CE253943650099F171 /* SpeechRecognitionAlternative.h in Headers */ = {isa = PBXBuildFile; fileRef = 934950BC2539434E0099F171 /* SpeechRecognitionAlternative.h */; };
@@ -12585,6 +12586,7 @@
93442C9F0D2B336000338FF9 /* HTMLTableRowsCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLTableRowsCollection.cpp; sourceTree = "<group>"; };
93443E7B26E8A6BC0058538F /* StorageManager+FileSystemAccess.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = "StorageManager+FileSystemAccess.idl"; sourceTree = "<group>"; };
93443E7D26E8A6BC0058538F /* StorageManagerFileSystemAccess.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StorageManagerFileSystemAccess.h; sourceTree = "<group>"; };
+ 93445082276A6356001F712B /* FileSystemHandleCloseScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileSystemHandleCloseScope.h; sourceTree = "<group>"; };
934907E3125BBBC8007F23A0 /* GraphicsContextCG.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsContextCG.h; sourceTree = "<group>"; };
934950AD253943460099F171 /* SpeechRecognition.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = SpeechRecognition.idl; sourceTree = "<group>"; };
934950AF253943470099F171 /* SpeechRecognitionErrorCode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SpeechRecognitionErrorCode.h; sourceTree = "<group>"; };
@@ -25012,6 +25014,7 @@
932C9BD026DD62550053B3DB /* FileSystemHandle.cpp */,
932C9BDA26DD62610053B3DB /* FileSystemHandle.h */,
932C9BD926DD62600053B3DB /* FileSystemHandle.idl */,
+ 93445082276A6356001F712B /* FileSystemHandleCloseScope.h */,
935424272703BC88005CA72C /* FileSystemHandleIdentifier.h */,
935424292703BCAD005CA72C /* FileSystemStorageConnection.h */,
93E269A0270A5D5C002C4FF0 /* FileSystemSyncAccessHandle.cpp */,
@@ -34296,6 +34299,7 @@
83FB33751F508A5B00986E54 /* FileSystemFileEntry.h in Headers */,
93443E8726E995C00058538F /* FileSystemFileHandle.h in Headers */,
93443E8826E995C40058538F /* FileSystemHandle.h in Headers */,
+ 93445084276A6357001F712B /* FileSystemHandleCloseScope.h in Headers */,
9354242F2703CA51005CA72C /* FileSystemHandleIdentifier.h in Headers */,
935424302703CB86005CA72C /* FileSystemStorageConnection.h in Headers */,
93E269A2270A5D5D002C4FF0 /* FileSystemSyncAccessHandle.h in Headers */,
Modified: trunk/Source/WebKit/ChangeLog (287155 => 287156)
--- trunk/Source/WebKit/ChangeLog 2021-12-16 21:20:10 UTC (rev 287155)
+++ trunk/Source/WebKit/ChangeLog 2021-12-16 22:00:44 UTC (rev 287156)
@@ -1,3 +1,30 @@
+2021-12-16 Sihui Liu <[email protected]>
+
+ REGRESSION (r286601): storage/filesystemaccess/sync-access-handle-read-write-worker.html and file-system-access/sandboxed_FileSystemSyncAccessHandle-truncate.https.tentative.worker.html are consistently failing
+ https://bugs.webkit.org/show_bug.cgi?id=234271
+ <rdar://problem/86434111>
+
+ Reviewed by Youenn Fablet.
+
+ * NetworkProcess/storage/FileSystemStorageHandle.cpp:
+ (WebKit::FileSystemStorageHandle::close):
+ (WebKit::FileSystemStorageHandle::closeSyncAccessHandle):
+ * NetworkProcess/storage/FileSystemStorageHandle.h:
+ * NetworkProcess/storage/FileSystemStorageManager.cpp:
+ (WebKit::FileSystemStorageManager::closeHandle):
+ * NetworkProcess/storage/NetworkStorageManager.cpp:
+ (WebKit::NetworkStorageManager::closeSyncAccessHandle):
+ (WebKit::NetworkStorageManager::closeAccessHandle): Deleted.
+ * NetworkProcess/storage/NetworkStorageManager.h:
+ * NetworkProcess/storage/NetworkStorageManager.messages.in:
+ * WebProcess/WebCoreSupport/WebFileSystemStorageConnection.cpp:
+ (WebKit::WebFileSystemStorageConnection::getFileHandle):
+ (WebKit::WebFileSystemStorageConnection::getDirectoryHandle):
+ (WebKit::WebFileSystemStorageConnection::closeSyncAccessHandle):
+ (WebKit::WebFileSystemStorageConnection::getHandle):
+ (WebKit::WebFileSystemStorageConnection::close): Deleted.
+ * WebProcess/WebCoreSupport/WebFileSystemStorageConnection.h:
+
2021-12-16 Adrian Perez de Castro <[email protected]>
Non-unified build fixes, late-ish December 2021 edition
Modified: trunk/Source/WebKit/NetworkProcess/storage/FileSystemStorageHandle.cpp (287155 => 287156)
--- trunk/Source/WebKit/NetworkProcess/storage/FileSystemStorageHandle.cpp 2021-12-16 21:20:10 UTC (rev 287155)
+++ trunk/Source/WebKit/NetworkProcess/storage/FileSystemStorageHandle.cpp 2021-12-16 22:00:44 UTC (rev 287156)
@@ -68,6 +68,8 @@
if (!m_manager)
return;
+ if (m_activeSyncAccessHandle)
+ closeSyncAccessHandle(*m_activeSyncAccessHandle);
m_manager->closeHandle(*this);
}
@@ -181,7 +183,7 @@
return std::pair { *m_activeSyncAccessHandle, WTFMove(*ipcHandle) };
}
-std::optional<FileSystemStorageError> FileSystemStorageHandle::close(WebCore::FileSystemSyncAccessHandleIdentifier accessHandleIdentifier)
+std::optional<FileSystemStorageError> FileSystemStorageHandle::closeSyncAccessHandle(WebCore::FileSystemSyncAccessHandleIdentifier accessHandleIdentifier)
{
if (!m_activeSyncAccessHandle || *m_activeSyncAccessHandle != accessHandleIdentifier)
return FileSystemStorageError::Unknown;
Modified: trunk/Source/WebKit/NetworkProcess/storage/FileSystemStorageHandle.h (287155 => 287156)
--- trunk/Source/WebKit/NetworkProcess/storage/FileSystemStorageHandle.h 2021-12-16 21:20:10 UTC (rev 287155)
+++ trunk/Source/WebKit/NetworkProcess/storage/FileSystemStorageHandle.h 2021-12-16 22:00:44 UTC (rev 287156)
@@ -61,7 +61,7 @@
using AccessHandleInfo = std::pair<WebCore::FileSystemSyncAccessHandleIdentifier, IPC::SharedFileHandle>;
Expected<AccessHandleInfo, FileSystemStorageError> createSyncAccessHandle();
- std::optional<FileSystemStorageError> close(WebCore::FileSystemSyncAccessHandleIdentifier);
+ std::optional<FileSystemStorageError> closeSyncAccessHandle(WebCore::FileSystemSyncAccessHandleIdentifier);
std::optional<WebCore::FileSystemSyncAccessHandleIdentifier> activeSyncAccessHandle() const { return m_activeSyncAccessHandle; }
private:
Modified: trunk/Source/WebKit/NetworkProcess/storage/FileSystemStorageManager.cpp (287155 => 287156)
--- trunk/Source/WebKit/NetworkProcess/storage/FileSystemStorageManager.cpp 2021-12-16 21:20:10 UTC (rev 287155)
+++ trunk/Source/WebKit/NetworkProcess/storage/FileSystemStorageManager.cpp 2021-12-16 22:00:44 UTC (rev 287156)
@@ -99,6 +99,10 @@
auto identifier = handle.identifier();
auto takenHandle = m_handles.take(identifier);
ASSERT(takenHandle.get() == &handle);
+ for (auto& handles : m_handlesByConnection.values()) {
+ if (handles.remove(identifier))
+ break;
+ }
m_registry.unregisterHandle(identifier);
}
Modified: trunk/Source/WebKit/NetworkProcess/storage/NetworkStorageManager.cpp (287155 => 287156)
--- trunk/Source/WebKit/NetworkProcess/storage/NetworkStorageManager.cpp 2021-12-16 21:20:10 UTC (rev 287155)
+++ trunk/Source/WebKit/NetworkProcess/storage/NetworkStorageManager.cpp 2021-12-16 22:00:44 UTC (rev 287156)
@@ -379,7 +379,7 @@
fileHandle.close();
}
-void NetworkStorageManager::closeAccessHandle(WebCore::FileSystemHandleIdentifier identifier, WebCore::FileSystemSyncAccessHandleIdentifier accessHandleIdentifier, CompletionHandler<void(std::optional<FileSystemStorageError>)>&& completionHandler)
+void NetworkStorageManager::closeSyncAccessHandle(WebCore::FileSystemHandleIdentifier identifier, WebCore::FileSystemSyncAccessHandleIdentifier accessHandleIdentifier, CompletionHandler<void(std::optional<FileSystemStorageError>)>&& completionHandler)
{
ASSERT(!RunLoop::isMain());
@@ -387,7 +387,7 @@
if (!handle)
return completionHandler(FileSystemStorageError::Unknown);
- completionHandler(handle->close(accessHandleIdentifier));
+ completionHandler(handle->closeSyncAccessHandle(accessHandleIdentifier));
}
void NetworkStorageManager::getHandleNames(WebCore::FileSystemHandleIdentifier identifier, CompletionHandler<void(Expected<Vector<String>, FileSystemStorageError>)>&& completionHandler)
Modified: trunk/Source/WebKit/NetworkProcess/storage/NetworkStorageManager.h (287155 => 287156)
--- trunk/Source/WebKit/NetworkProcess/storage/NetworkStorageManager.h 2021-12-16 21:20:10 UTC (rev 287155)
+++ trunk/Source/WebKit/NetworkProcess/storage/NetworkStorageManager.h 2021-12-16 22:00:44 UTC (rev 287156)
@@ -103,7 +103,7 @@
void getFile(WebCore::FileSystemHandleIdentifier, CompletionHandler<void(Expected<String, FileSystemStorageError>)>&&);
using AccessHandleInfo = std::pair<WebCore::FileSystemSyncAccessHandleIdentifier, IPC::SharedFileHandle>;
void createSyncAccessHandle(WebCore::FileSystemHandleIdentifier, CompletionHandler<void(Expected<AccessHandleInfo, FileSystemStorageError>)>&&);
- void closeAccessHandle(WebCore::FileSystemHandleIdentifier, WebCore::FileSystemSyncAccessHandleIdentifier, CompletionHandler<void(std::optional<FileSystemStorageError>)>&&);
+ void closeSyncAccessHandle(WebCore::FileSystemHandleIdentifier, WebCore::FileSystemSyncAccessHandleIdentifier, CompletionHandler<void(std::optional<FileSystemStorageError>)>&&);
void getHandleNames(WebCore::FileSystemHandleIdentifier, CompletionHandler<void(Expected<Vector<String>, FileSystemStorageError>)>&&);
void getHandle(IPC::Connection&, WebCore::FileSystemHandleIdentifier, String&& name, CompletionHandler<void(Expected<std::pair<WebCore::FileSystemHandleIdentifier, bool>, FileSystemStorageError>)>&&);
Modified: trunk/Source/WebKit/NetworkProcess/storage/NetworkStorageManager.messages.in (287155 => 287156)
--- trunk/Source/WebKit/NetworkProcess/storage/NetworkStorageManager.messages.in 2021-12-16 21:20:10 UTC (rev 287155)
+++ trunk/Source/WebKit/NetworkProcess/storage/NetworkStorageManager.messages.in 2021-12-16 22:00:44 UTC (rev 287156)
@@ -36,7 +36,7 @@
Move(WebCore::FileSystemHandleIdentifier identifier, WebCore::FileSystemHandleIdentifier destinationIdentifier, String newName) -> (std::optional<WebKit::FileSystemStorageError> result) Async
GetFile(WebCore::FileSystemHandleIdentifier identifier) -> (Expected<String, WebKit::FileSystemStorageError> result) Async
CreateSyncAccessHandle(WebCore::FileSystemHandleIdentifier identifier) -> (Expected<std::pair<WebCore::FileSystemSyncAccessHandleIdentifier, IPC::SharedFileHandle>, WebKit::FileSystemStorageError> result) Async
- CloseAccessHandle(WebCore::FileSystemHandleIdentifier identifier, WebCore::FileSystemSyncAccessHandleIdentifier accessHandleIdentifier) -> (std::optional<WebKit::FileSystemStorageError> result) Async
+ CloseSyncAccessHandle(WebCore::FileSystemHandleIdentifier identifier, WebCore::FileSystemSyncAccessHandleIdentifier accessHandleIdentifier) -> (std::optional<WebKit::FileSystemStorageError> result) Async
GetHandleNames(WebCore::FileSystemHandleIdentifier identifier) -> (Expected<Vector<String>, WebKit::FileSystemStorageError> result) Async
GetHandle(WebCore::FileSystemHandleIdentifier identifier, String name) -> (Expected<std::pair<WebCore::FileSystemHandleIdentifier, bool>, WebKit::FileSystemStorageError> result) Async WantsConnection
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFileSystemStorageConnection.cpp (287155 => 287156)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFileSystemStorageConnection.cpp 2021-12-16 21:20:10 UTC (rev 287155)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFileSystemStorageConnection.cpp 2021-12-16 22:00:44 UTC (rev 287156)
@@ -30,6 +30,7 @@
#include <WebCore/ExceptionOr.h>
#include <WebCore/FileSystemDirectoryHandle.h>
#include <WebCore/FileSystemFileHandle.h>
+#include <WebCore/FileSystemHandleCloseScope.h>
#include <WebCore/ScriptExecutionContext.h>
#include <WebCore/WorkerFileSystemStorageConnection.h>
#include <WebCore/WorkerGlobalScope.h>
@@ -78,13 +79,13 @@
if (!m_connection)
return completionHandler(WebCore::Exception { WebCore::UnknownError, "Connection is lost" });
- m_connection->sendWithAsyncReply(Messages::NetworkStorageManager::GetFileHandle(identifier, name, createIfNecessary), [name, completionHandler = WTFMove(completionHandler)](auto result) mutable {
+ m_connection->sendWithAsyncReply(Messages::NetworkStorageManager::GetFileHandle(identifier, name, createIfNecessary), [this, protectedThis = Ref { *this }, name, completionHandler = WTFMove(completionHandler)](auto result) mutable {
if (!result)
return completionHandler(convertToException(result.error()));
auto identifier = result.value();
ASSERT(identifier.isValid());
- completionHandler(WTFMove(identifier));
+ completionHandler(WebCore::FileSystemHandleCloseScope::create(identifier, false, *this));
});
}
@@ -93,13 +94,13 @@
if (!m_connection)
return completionHandler(WebCore::Exception { WebCore::UnknownError, "Connection is lost" });
- m_connection->sendWithAsyncReply(Messages::NetworkStorageManager::GetDirectoryHandle(identifier, name, createIfNecessary), [name, completionHandler = WTFMove(completionHandler)](auto result) mutable {
+ m_connection->sendWithAsyncReply(Messages::NetworkStorageManager::GetDirectoryHandle(identifier, name, createIfNecessary), [this, protectedThis = Ref { *this }, name, completionHandler = WTFMove(completionHandler)](auto result) mutable {
if (!result)
return completionHandler(convertToException(result.error()));
auto identifier = result.value();
ASSERT(identifier.isValid());
- completionHandler(WTFMove(identifier));
+ completionHandler(WebCore::FileSystemHandleCloseScope::create(identifier, true, *this));
});
}
@@ -153,12 +154,12 @@
});
}
-void WebFileSystemStorageConnection::close(WebCore::FileSystemHandleIdentifier identifier, WebCore::FileSystemSyncAccessHandleIdentifier accessHandleIdentifier, VoidCallback&& completionHandler)
+void WebFileSystemStorageConnection::closeSyncAccessHandle(WebCore::FileSystemHandleIdentifier identifier, WebCore::FileSystemSyncAccessHandleIdentifier accessHandleIdentifier, VoidCallback&& completionHandler)
{
if (!m_connection)
return completionHandler(WebCore::Exception { WebCore::UnknownError, "Connection is lost" });
- m_connection->sendWithAsyncReply(Messages::NetworkStorageManager::CloseAccessHandle(identifier, accessHandleIdentifier), [completionHandler = WTFMove(completionHandler)](auto error) mutable {
+ m_connection->sendWithAsyncReply(Messages::NetworkStorageManager::CloseSyncAccessHandle(identifier, accessHandleIdentifier), [completionHandler = WTFMove(completionHandler)](auto error) mutable {
completionHandler(convertToExceptionOr(error));
});
}
@@ -176,16 +177,18 @@
});
}
-void WebFileSystemStorageConnection::getHandle(WebCore::FileSystemHandleIdentifier identifier, const String& name, FileSystemStorageConnection::GetHandleWithTypeCallback&& completionHandler)
+void WebFileSystemStorageConnection::getHandle(WebCore::FileSystemHandleIdentifier identifier, const String& name, FileSystemStorageConnection::GetHandleCallback&& completionHandler)
{
if (!m_connection)
return completionHandler(WebCore::Exception { WebCore::UnknownError, "Connection is lost" });
- m_connection->sendWithAsyncReply(Messages::NetworkStorageManager::GetHandle(identifier, name), [completionHandler = WTFMove(completionHandler)](auto result) mutable {
+ m_connection->sendWithAsyncReply(Messages::NetworkStorageManager::GetHandle(identifier, name), [this, protectedThis = Ref { *this }, completionHandler = WTFMove(completionHandler)](auto result) mutable {
if (!result)
return completionHandler(convertToException(result.error()));
-
- completionHandler(WTFMove(result.value()));
+
+ auto [identifier, isDirectory] = result.value();
+ ASSERT(identifier.isValid());
+ completionHandler(WebCore::FileSystemHandleCloseScope::create(identifier, isDirectory, *this));
});
}
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFileSystemStorageConnection.h (287155 => 287156)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFileSystemStorageConnection.h 2021-12-16 21:20:10 UTC (rev 287155)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebFileSystemStorageConnection.h 2021-12-16 22:00:44 UTC (rev 287156)
@@ -81,11 +81,11 @@
void removeEntry(WebCore::FileSystemHandleIdentifier, const String& name, bool deleteRecursively, WebCore::FileSystemStorageConnection::VoidCallback&&) final;
void resolve(WebCore::FileSystemHandleIdentifier, WebCore::FileSystemHandleIdentifier, WebCore::FileSystemStorageConnection::ResolveCallback&&) final;
void getHandleNames(WebCore::FileSystemHandleIdentifier, FileSystemStorageConnection::GetHandleNamesCallback&&) final;
- void getHandle(WebCore::FileSystemHandleIdentifier, const String& name, FileSystemStorageConnection::GetHandleWithTypeCallback&&) final;
+ void getHandle(WebCore::FileSystemHandleIdentifier, const String& name, FileSystemStorageConnection::GetHandleCallback&&) final;
void getFile(WebCore::FileSystemHandleIdentifier, StringCallback&&) final;
void createSyncAccessHandle(WebCore::FileSystemHandleIdentifier, WebCore::FileSystemStorageConnection::GetAccessHandleCallback&&) final;
- void close(WebCore::FileSystemHandleIdentifier, WebCore::FileSystemSyncAccessHandleIdentifier, WebCore::FileSystemStorageConnection::VoidCallback&&) final;
+ void closeSyncAccessHandle(WebCore::FileSystemHandleIdentifier, WebCore::FileSystemSyncAccessHandleIdentifier, WebCore::FileSystemStorageConnection::VoidCallback&&) final;
void registerSyncAccessHandle(WebCore::FileSystemSyncAccessHandleIdentifier, WebCore::ScriptExecutionContextIdentifier) final;
void unregisterSyncAccessHandle(WebCore::FileSystemSyncAccessHandleIdentifier) final;
void invalidateAccessHandle(WebCore::FileSystemSyncAccessHandleIdentifier) final;