-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add API to trigger background fetch click event #10856
Add API to trigger background fetch click event #10856
Conversation
EWS run on previous version of this PR (hash 8083876) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these SPIs only added for test runner, or it could be used for clients?
(If they will be used for WebKit clients I think we might want them to be more formal and performant. For example, in current version, it seems getting background identifiers will create origin managers for all origins and import background fetch data for all origins, which seems can lead to abandoned memory (i.e. the data may never be used by web clients))
Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp
Outdated
Show resolved
Hide resolved
Source/WebKit/NetworkProcess/storage/BackgroundFetchStoreImpl.cpp
Outdated
Show resolved
Hide resolved
In the future, it would be clients.
That is correct. That said, we may want to optimise this in the future. |
8083876
to
af26af6
Compare
EWS run on previous version of this PR (hash af26af6) |
af26af6
to
10b9abd
Compare
EWS run on previous version of this PR (hash 10b9abd) |
10b9abd
to
b488ab6
Compare
EWS run on previous version of this PR (hash b488ab6) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me with comments, overall looks good
LayoutTests/http/wpt/background-fetch/background-fetch-abort.window.js
Outdated
Show resolved
Hide resolved
Source/WebCore/workers/service/background-fetch/BackgroundFetchEngine.cpp
Outdated
Show resolved
Hide resolved
Source/WebKit/NetworkProcess/storage/BackgroundFetchStoreImpl.cpp
Outdated
Show resolved
Hide resolved
@@ -61,22 +66,35 @@ String BackgroundFetchStoreImpl::getFilename(const ServiceWorkerRegistrationKey& | |||
return iterator->value.fetchToFilenames.get(std::make_pair(key.scope().string(), identifier)); | |||
} | |||
|
|||
void BackgroundFetchStoreImpl::initializeFetches(BackgroundFetchEngine& engine, const ServiceWorkerRegistrationKey& key, CompletionHandler<void()>&& callback) | |||
void BackgroundFetchStoreImpl::registerFetch(const ClientOrigin& origin, const ServiceWorkerRegistrationKey& key, const String& backgroundFetchIdentifier, String&& fetchStorageIdentifier) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems we will need to add unregisterFetch
function, otherwise the map will just keep growing as long as the session lives
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An unregisterFetch method is clearer than doing the work in clearFetch/clearAllFetches.
I'll update the patch accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An unregisterFetch is also less efficient, since for clearFetch/clearAllFetches, we are already doing the find.
Also, m_perClientOriginFetches is growing so that, if we initialize once, we do not try again to reinitialize.
b488ab6
to
4f43c5b
Compare
EWS run on current version of this PR (hash 4f43c5b) |
https://bugs.webkit.org/show_bug.cgi?id=253072 rdar://problem/106026054 Reviewed by Sihui Liu. Expose new WebsiteDataStore API to get a list of background fetch identifiers, click, abort, pause and resume them. Each call sends IPC to network process to do the actual work. The work is done through BackgroundFetchStoreImpl that will identify the background fetch registration from the background fetch identifier. The background fetch identifier is the filename of the persisted background fetch. Once identified, we send the order to the BackgroundFetchEngine. This patch only implements abort and click in BackgroundFetchEngine. We add testRunner API to trigger click, abort, resume and suspend actions. * LayoutTests/http/wpt/background-fetch/background-fetch-abort.window-expected.txt: Added. * LayoutTests/http/wpt/background-fetch/background-fetch-abort.window.html: Added. * LayoutTests/http/wpt/background-fetch/background-fetch-abort.window.js: Added. (promise_test.async t): * LayoutTests/http/wpt/background-fetch/background-fetch-click.window-expected.txt: Added. * LayoutTests/http/wpt/background-fetch/background-fetch-click.window.html: Added. * LayoutTests/http/wpt/background-fetch/background-fetch-click.window.js: Added. (promise_test.async t): * LayoutTests/http/wpt/background-fetch/sw.js: (onmessage): (onbackgroundfetchclick): (onbackgroundfetchabort): * Source/WebCore/workers/service/background-fetch/BackgroundFetchEngine.cpp: (WebCore::BackgroundFetchEngine::startBackgroundFetch): (WebCore::BackgroundFetchEngine::backgroundFetchInformation): (WebCore::BackgroundFetchEngine::backgroundFetchIdentifiers): (WebCore::BackgroundFetchEngine::abortBackgroundFetch): (WebCore::BackgroundFetchEngine::matchBackgroundFetch): (WebCore::BackgroundFetchEngine::pauseBackgroundFetch): (WebCore::BackgroundFetchEngine::resumeBackgroundFetch): (WebCore::BackgroundFetchEngine::clickBackgroundFetch): * Source/WebCore/workers/service/background-fetch/BackgroundFetchEngine.h: * Source/WebCore/workers/service/background-fetch/BackgroundFetchStore.h: * Source/WebCore/workers/service/context/SWContextManager.cpp: (WebCore::SWContextManager::fireBackgroundFetchClickEvent): * Source/WebCore/workers/service/context/SWContextManager.h: * Source/WebCore/workers/service/context/ServiceWorkerThread.cpp: (WebCore::ServiceWorkerThread::queueTaskToFireBackgroundFetchClickEvent): * Source/WebCore/workers/service/context/ServiceWorkerThread.h: * Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp: (WebCore::ServiceWorkerThreadProxy::fireBackgroundFetchClickEvent): * Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.h: * Source/WebCore/workers/service/server/SWServer.cpp: (WebCore::SWServer::fireBackgroundFetchEvent): (WebCore::SWServer::fireBackgroundFetchClickEvent): * Source/WebCore/workers/service/server/SWServer.h: * Source/WebCore/workers/service/server/SWServerDelegate.h: * Source/WebCore/workers/service/server/SWServerToContextConnection.h: * Source/WebKit/NetworkProcess/NetworkProcess.cpp: (WebKit::NetworkProcess::allBackgroundFetches): (WebKit::NetworkProcess::abortBackgroundFetch): (WebKit::NetworkProcess::pauseBackgroundFetch): (WebKit::NetworkProcess::resumeBackgroundFetch): (WebKit::NetworkProcess::clickBackgroundFetch): * Source/WebKit/NetworkProcess/NetworkProcess.h: * Source/WebKit/NetworkProcess/NetworkProcess.messages.in: * Source/WebKit/NetworkProcess/NetworkSession.cpp: (WebKit::NetworkSession::createBackgroundFetchStore): (WebKit::NetworkSession::ensureBackgroundFetchStore): (WebKit::NetworkSession::allBackgroundFetches): (WebKit::NetworkSession::abortBackgroundFetch): (WebKit::NetworkSession::pauseBackgroundFetch): (WebKit::NetworkSession::resumeBackgroundFetch): (WebKit::NetworkSession::clickBackgroundFetch): * Source/WebKit/NetworkProcess/NetworkSession.h: * Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp: (WebKit::WebSWServerToContextConnection::fireBackgroundFetchClickEvent): * Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h: * Source/WebKit/NetworkProcess/storage/BackgroundFetchStoreImpl.cpp: (WebKit::BackgroundFetchStoreImpl::BackgroundFetchStoreImpl): (WebKit::BackgroundFetchStoreImpl::registerFetch): (WebKit::BackgroundFetchStoreImpl::initializeFetches): (WebKit::BackgroundFetchStoreImpl::storeFetch): (WebKit::BackgroundFetchStoreImpl::fetchInformationFromFilename): (WebKit::BackgroundFetchStoreImpl::loadAllFetches): (WebKit::BackgroundFetchStoreImpl::allBackgroundFetches): (WebKit::BackgroundFetchStoreImpl::abortBackgroundFetch): (WebKit::BackgroundFetchStoreImpl::pauseBackgroundFetch): (WebKit::BackgroundFetchStoreImpl::resumeBackgroundFetch): (WebKit::BackgroundFetchStoreImpl::clickBackgroundFetch): * Source/WebKit/NetworkProcess/storage/BackgroundFetchStoreImpl.h: (WebKit::BackgroundFetchStoreImpl::create): * Source/WebKit/NetworkProcess/storage/NetworkStorageManager.cpp: (WebKit::NetworkStorageManager::close): (WebKit::NetworkStorageManager::writeOriginToFileIfNecessary): (WebKit::NetworkStorageManager::originStorageManager): (WebKit::NetworkStorageManager::removeOriginStorageManagerIfPossible): (WebKit::NetworkStorageManager::persisted): (WebKit::NetworkStorageManager::persist): (WebKit::NetworkStorageManager::estimate): (WebKit::NetworkStorageManager::resetStoragePersistedState): (WebKit::NetworkStorageManager::clearStorageForWebPage): (WebKit::NetworkStorageManager::cloneSessionStorageForWebPage): (WebKit::NetworkStorageManager::didIncreaseQuota): (WebKit::NetworkStorageManager::getAllOrigins): (WebKit::NetworkStorageManager::suspend): (WebKit::NetworkStorageManager::handleLowMemoryWarning): (WebKit::NetworkStorageManager::syncLocalStorage): (WebKit::NetworkStorageManager::resetQuotaForTesting): (WebKit::NetworkStorageManager::resetQuotaUpdatedBasedOnUsageForTesting): (WebKit::NetworkStorageManager::cancelConnectToStorageArea): (WebKit::NetworkStorageManager::cloneSessionStorageNamespace): (WebKit::NetworkStorageManager::cacheStorageClearMemoryRepresentation): * Source/WebKit/NetworkProcess/storage/NetworkStorageManager.h: * Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm: (-[WKWebsiteDataStore _getAllBackgroundFetches:]): (-[WKWebsiteDataStore _abortBackgroundFetch:]): (-[WKWebsiteDataStore _pauseBackgroundFetch:]): (-[WKWebsiteDataStore _resumeBackgroundFetch:]): (-[WKWebsiteDataStore _clickBackgroundFetch:]): * Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h: * Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp: (WebKit::NetworkProcessProxy::allBackgroundFetches): (WebKit::NetworkProcessProxy::abortBackgroundFetch): (WebKit::NetworkProcessProxy::pauseBackgroundFetch): (WebKit::NetworkProcessProxy::resumeBackgroundFetch): (WebKit::NetworkProcessProxy::clickBackgroundFetch): * Source/WebKit/UIProcess/Network/NetworkProcessProxy.h: * Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::fireBackgroundFetchClickEvent): * Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h: * Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in: * Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: * Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp: (WTR::InjectedBundle::getBackgroundFetchIdentifier): * Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h: * Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp: (WTR::TestRunner::getBackgroundFetchIdentifier): (WTR::TestRunner::abortBackgroundFetch): (WTR::TestRunner::pauseBackgroundFetch): (WTR::TestRunner::resumeBackgroundFetch): (WTR::TestRunner::simulateClickBackgroundFetch): * Tools/WebKitTestRunner/InjectedBundle/TestRunner.h: * Tools/WebKitTestRunner/TestController.cpp: (WTR::TestController::getBackgroundFetchIdentifier): (WTR::TestController::abortBackgroundFetch): (WTR::TestController::pauseBackgroundFetch): (WTR::TestController::resumeBackgroundFetch): (WTR::TestController::simulateClickBackgroundFetch): * Tools/WebKitTestRunner/TestController.h: * Tools/WebKitTestRunner/TestInvocation.cpp: (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle): * Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm: (WTR::TestController::getBackgroundFetchIdentifier): (WTR::TestController::abortBackgroundFetch): (WTR::TestController::pauseBackgroundFetch): (WTR::TestController::resumeBackgroundFetch): (WTR::TestController::simulateClickBackgroundFetch): Canonical link: https://commits.webkit.org/261136@main
4f43c5b
to
4a7cad9
Compare
Committed 261136@main (4a7cad9): https://commits.webkit.org/261136@main Reviewed commits have been landed. Closing PR #10856 and removing active labels. |
4a7cad9
4f43c5b
π wpeπ§ͺ ios-wk2π§ͺ api-macπ§ͺ api-iosπ§ͺ gtk-wk2π tvπ§ͺ mac-wk2π§ͺ api-gtkπ§ͺ mac-AS-debug-wk2