[webkit-changes] [WebKit/WebKit] 43bf0b: Migrate CacheStorageConnection::open to NativePromise
youennf
noreply at github.com
Wed Jan 31 07:14:41 PST 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 43bf0bb142ab5ea9b74e0cd70cbca969aacb8840
https://github.com/WebKit/WebKit/commit/43bf0bb142ab5ea9b74e0cd70cbca969aacb8840
Author: Youenn Fablet <youennf at gmail.com>
Date: 2024-01-31 (Wed, 31 Jan 2024)
Changed paths:
M Source/WTF/wtf/Forward.h
M Source/WTF/wtf/NativePromise.h
M Source/WebCore/Modules/cache/CacheStorageConnection.h
M Source/WebCore/Modules/cache/DOMCacheStorage.cpp
M Source/WebCore/Modules/cache/WorkerCacheStorageConnection.cpp
M Source/WebCore/Modules/cache/WorkerCacheStorageConnection.h
M Source/WebCore/Modules/mediasource/SourceBuffer.h
M Source/WebCore/dom/ScriptExecutionContext.cpp
M Source/WebCore/dom/ScriptExecutionContext.h
M Source/WebCore/page/CacheStorageProvider.h
M Source/WebKit/WebProcess/Cache/WebCacheStorageConnection.cpp
M Source/WebKit/WebProcess/Cache/WebCacheStorageConnection.h
M Tools/TestWebKitAPI/Tests/WTF/NativePromise.cpp
Log Message:
-----------
Migrate CacheStorageConnection::open to NativePromise
https://bugs.webkit.org/show_bug.cgi?id=266568
rdar://119804320
Reviewed by Jean-Yves Avenard.
The goal is first to simplify CacheStorage operations handling from workers.
We should as a follow-up step allow to send/receive IPC out of main thread, which will be made easier with promises.
Given it runs in workers, we need to have a way to register NativePromise callbacks that are guaranteed to be destroyed in workers.
We do this by registering these callbacks in a WorkerGlobalScope so that we can destroy them when WorkerGlobalScope gets stopped.
To do this, we allow a promise to either take a RefCountedGuaranteedSerialFunctionDispatcher or a NativePromiseDispatcher.
The latter is a RefCountedSerialFunctionDispatcher but without any guarantee that the function will be dispatched or not.
To handle this possibility, the NativePromiseDispatcher is responsible to disconnect the NativePromiseCallback that it is given in registerCallback
in the same context as its RefCountedSerialFunctionDispatcher.
* Source/WTF/wtf/Forward.h:
* Source/WTF/wtf/NativePromise.h:
(WTF::NativePromiseRequest::~NativePromiseRequest):
(WTF::NativePromiseRequest::track):
(WTF::NativePromiseRequest::operator bool const):
(WTF::NativePromiseRequest::complete):
(WTF::NativePromiseRequest::disconnect):
* Source/WebCore/Modules/cache/CacheStorageConnection.h:
* Source/WebCore/Modules/cache/DOMCacheStorage.cpp:
(WebCore::DOMCacheStorage::doOpen):
* Source/WebCore/Modules/cache/WorkerCacheStorageConnection.cpp:
(WebCore::WorkerCacheStorageConnection::open):
(WebCore::WorkerCacheStorageConnection::clearPendingRequests):
(WebCore::WorkerCacheStorageConnection::openCompleted): Deleted.
* Source/WebCore/Modules/cache/WorkerCacheStorageConnection.h:
* Source/WebCore/Modules/mediasource/SourceBuffer.h:
* Source/WebCore/dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::stopActiveDOMObjects):
(WebCore::ScriptExecutionContext::nativePromiseDispatcher):
* Source/WebCore/dom/ScriptExecutionContext.h:
(WebCore::ScriptExecutionContext::Task::Task):
(WebCore::ScriptExecutionContext::Task::m_isCleanupTask):
(WebCore::ScriptExecutionContext::enqueueTaskWhenPromiseIsSettled):
(WebCore::ScriptExecutionContext::AddConsoleMessageTask::AddConsoleMessageTask):
* Source/WebCore/page/CacheStorageProvider.h:
* Source/WebKit/WebProcess/Cache/WebCacheStorageConnection.cpp:
(WebKit::WebCacheStorageConnection::open):
* Source/WebKit/WebProcess/Cache/WebCacheStorageConnection.h:
* Tools/TestWebKitAPI/Tests/WTF/NativePromise.cpp:
(TestWebKitAPI::TEST):
Canonical link: https://commits.webkit.org/273828@main
More information about the webkit-changes
mailing list