[webkit-changes] [WebKit/WebKit] 24bcf0: Make more service worker classes ref-counted

Chris Dumez noreply at github.com
Thu Jan 18 11:39:39 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 24bcf01c94b38587227ec24c11c1afeccbf415cf
      https://github.com/WebKit/WebKit/commit/24bcf01c94b38587227ec24c11c1afeccbf415cf
  Author: Chris Dumez <cdumez at apple.com>
  Date:   2024-01-18 (Thu, 18 Jan 2024)

  Changed paths:
    M Source/WebCore/workers/service/server/SWServer.cpp
    M Source/WebCore/workers/service/server/SWServer.h
    M Source/WebCore/workers/service/server/SWServerJobQueue.cpp
    M Source/WebCore/workers/service/server/SWServerJobQueue.h
    M Source/WebCore/workers/service/server/SWServerRegistration.cpp
    M Source/WebCore/workers/service/server/SWServerRegistration.h
    M Source/WebCore/workers/service/server/SWServerToContextConnection.cpp
    M Source/WebCore/workers/service/server/SWServerToContextConnection.h
    M Source/WebCore/workers/service/server/SWServerWorker.cpp
    M Source/WebCore/workers/service/server/SWServerWorker.h
    M Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp
    M Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h
    M Source/WebKit/NetworkProcess/NetworkResourceLoader.h
    M Source/WebKit/NetworkProcess/NetworkSession.cpp
    M Source/WebKit/NetworkProcess/NetworkSession.h
    M Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp
    M Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.h
    M Source/WebKit/NetworkProcess/ServiceWorker/WebSWRegistrationStore.cpp
    M Source/WebKit/NetworkProcess/ServiceWorker/WebSWRegistrationStore.h
    M Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.cpp
    M Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.h
    M Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp
    M Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h

  Log Message:
  -----------
  Make more service worker classes ref-counted
https://bugs.webkit.org/show_bug.cgi?id=267707

Reviewed by Geoffrey Garen.

I recently did smart adoption of smart pointers in service worker code. In
doing so I had to use CheckedPtr a lot because many of the classes were not
ref-counted and I had no way to "protect" an object before calling a member
function on it. It was then pointed out to me that we could make those classes
ref-counted instead. I gave it a try and I think the code looks a lot safer. It
is also a lot less likely to introduce new crashes (since it decreases the use
of CheckedPtr).

* Source/WebCore/workers/service/server/SWServer.cpp:
(WebCore::SWServer::create):
(WebCore::SWServer::activeWorkerFromRegistrationID):
(WebCore::SWServer::getRegistration):
(WebCore::SWServer::addRegistrationFromStore):
(WebCore::SWServer::addRegistration):
(WebCore::SWServer::removeRegistration):
(WebCore::SWServer::getRegistrations):
(WebCore::SWServer::clearAll):
(WebCore::SWServer::clearInternal):
(WebCore::SWServer::Connection::finishFetchingScriptInServer):
(WebCore::SWServer::Connection::didResolveRegistrationPromise):
(WebCore::SWServer::Connection::doRegistrationMatching):
(WebCore::SWServer::Connection::addServiceWorkerRegistrationInServer):
(WebCore::SWServer::Connection::removeServiceWorkerRegistrationInServer):
(WebCore::SWServer::SWServer):
(WebCore::SWServer::validateRegistrationDomain):
(WebCore::SWServer::scheduleJob):
(WebCore::SWServer::startScriptFetch):
(WebCore::SWServer::refreshImportedScripts):
(WebCore::SWServer::terminatePreinstallationWorker):
(WebCore::SWServer::didFinishActivation):
(WebCore::SWServer::claim):
(WebCore::SWServer::addClientServiceWorkerRegistration):
(WebCore::SWServer::removeClientServiceWorkerRegistration):
(WebCore::SWServer::installContextData):
(WebCore::SWServer::runServiceWorkerIfNecessary):
(WebCore::SWServer::removeConnection):
(WebCore::SWServer::doRegistrationMatching):
(WebCore::SWServer::registerServiceWorkerClient):
(WebCore::SWServer::unregisterServiceWorkerClient):
(WebCore::SWServer::Connection::whenRegistrationReady):
(WebCore::SWServer::Connection::storeRegistrationsOnDisk):
(WebCore::SWServer::getAllOrigins):
(WebCore::SWServer::createContextConnection):
(WebCore::SWServer::processPushMessage):
(WebCore::SWServer::processNotificationEvent):
(WebCore::SWServer::fireFunctionalEvent):
(WebCore::SWServer::Connection::startBackgroundFetch):
(WebCore::SWServer::Connection::backgroundFetchInformation):
(WebCore::SWServer::Connection::backgroundFetchIdentifiers):
(WebCore::SWServer::Connection::abortBackgroundFetch):
(WebCore::SWServer::Connection::matchBackgroundFetch):
(WebCore::SWServer::Connection::retrieveRecordResponse):
(WebCore::SWServer::Connection::retrieveRecordResponseBody):
* Source/WebCore/workers/service/server/SWServer.h:
(WebCore::SWServer::Connection::protectedServer const):
(WebCore::SWServer::Connection::doRegistrationMatching): Deleted.
(WebCore::SWServer::Connection::checkedServer const): Deleted.
(WebCore::SWServer::getRegistration): Deleted.
* Source/WebCore/workers/service/server/SWServerJobQueue.cpp:
(WebCore::SWServerJobQueue::scriptFetchFinished):
(WebCore::SWServerJobQueue::importedScriptsFetchFinished):
(WebCore::SWServerJobQueue::scriptAndImportedScriptsFetchFinished):
(WebCore::SWServerJobQueue::scriptContextFailedToStart):
(WebCore::SWServerJobQueue::scriptContextStarted):
(WebCore::SWServerJobQueue::install):
(WebCore::SWServerJobQueue::didResolveRegistrationPromise):
(WebCore::SWServerJobQueue::didFinishInstall):
(WebCore::SWServerJobQueue::runRegisterJob):
(WebCore::SWServerJobQueue::runUnregisterJob):
(WebCore::SWServerJobQueue::runUpdateJob):
(WebCore::SWServerJobQueue::rejectCurrentJob):
* Source/WebCore/workers/service/server/SWServerJobQueue.h:
(WebCore::SWServerJobQueue::protectedServer const):
(WebCore::SWServerJobQueue::checkedServer const): Deleted.
* Source/WebCore/workers/service/server/SWServerRegistration.cpp:
(WebCore::SWServerRegistration::create):
(WebCore::SWServerRegistration::forEachConnection):
(WebCore::SWServerRegistration::notifyClientsOfControllerChange):
(WebCore::SWServerRegistration::clear):
(WebCore::SWServerRegistration::activate):
(WebCore::SWServerRegistration::isUnregistered const):
(WebCore::SWServerRegistration::controlClient):
(WebCore::SWServerRegistration::softUpdate):
(WebCore::SWServerRegistration::enableNavigationPreload):
(WebCore::SWServerRegistration::disableNavigationPreload):
(WebCore::SWServerRegistration::setNavigationPreloadHeaderValue):
* Source/WebCore/workers/service/server/SWServerRegistration.h:
(WebCore::SWServerRegistration::protectedServer const):
(WebCore::SWServerRegistration::checkedServer const): Deleted.
* Source/WebCore/workers/service/server/SWServerToContextConnection.cpp:
(WebCore::SWServerToContextConnection::protectedServer const):
(WebCore::SWServerToContextConnection::claim):
(WebCore::SWServerToContextConnection::terminateWhenPossible):
* Source/WebCore/workers/service/server/SWServerToContextConnection.h:
* Source/WebCore/workers/service/server/SWServerWorker.cpp:
(WebCore::m_lastNavigationWasAppInitiated):
(WebCore::SWServerWorker::protectedServer const):
(WebCore::SWServerWorker::startTermination):
(WebCore::SWServerWorker::contextConnection):
(WebCore::SWServerWorker::scriptContextFailedToStart):
(WebCore::SWServerWorker::scriptContextStarted):
(WebCore::SWServerWorker::didFinishInstall):
(WebCore::SWServerWorker::didFinishActivation):
(WebCore::SWServerWorker::contextTerminated):
(WebCore::SWServerWorker::findClientByIdentifier const):
(WebCore::SWServerWorker::findClientByVisibleIdentifier):
(WebCore::SWServerWorker::matchAll):
(WebCore::SWServerWorker::userAgent const):
(WebCore::SWServerWorker::setHasPendingEvents):
(WebCore::SWServerWorker::setState):
(WebCore::SWServerWorker::workerThreadMode const):
(WebCore::SWServerWorker::shouldBeTerminated const):
(WebCore::SWServerWorker::terminationIfPossibleTimerFired):
(WebCore::SWServerWorker::isClientActiveServiceWorker const):
(WebCore::SWServerWorker::checkedServer const): Deleted.
* Source/WebCore/workers/service/server/SWServerWorker.h:
* Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::createFetchTask):
* Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h:
* Source/WebKit/NetworkProcess/NetworkResourceLoader.h:
* Source/WebKit/NetworkProcess/NetworkSession.cpp:
(WebKit::NetworkSession::navigationPreloaderTaskFromFetchIdentifier):
(WebKit::NetworkSession::ensureSWServer):
* Source/WebKit/NetworkProcess/NetworkSession.h:
* Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.cpp:
(WebKit::ServiceWorkerFetchTask::create):
(WebKit::ServiceWorkerFetchTask::fromNavigationPreloader):
(WebKit::ServiceWorkerFetchTask::ServiceWorkerFetchTask):
(WebKit::ServiceWorkerFetchTask::cannotHandle):
(WebKit::ServiceWorkerFetchTask::softUpdateIfNeeded):
(WebKit::ServiceWorkerFetchTask::loadResponseFromPreloader):
(WebKit::ServiceWorkerFetchTask::loadBodyFromPreloader):
* Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerFetchTask.h:
* Source/WebKit/NetworkProcess/ServiceWorker/WebSWRegistrationStore.cpp:
(WebKit::WebSWRegistrationStore::protectedServer const):
(WebKit::WebSWRegistrationStore::updateToStorage):
(WebKit::WebSWRegistrationStore::checkedServer const): Deleted.
* Source/WebKit/NetworkProcess/ServiceWorker/WebSWRegistrationStore.h:
* Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.cpp:
(WebKit::WebSWServerConnection::~WebSWServerConnection):
(WebKit::WebSWServerConnection::createFetchTask):
(WebKit::WebSWServerConnection::startFetch):
(WebKit::WebSWServerConnection::postMessageToServiceWorker):
(WebKit::WebSWServerConnection::scheduleJobInServer):
(WebKit::WebSWServerConnection::clientURLFromIdentifier):
(WebKit::WebSWServerConnection::scheduleUnregisterJobInServer):
(WebKit::WebSWServerConnection::postMessageToServiceWorkerClient):
(WebKit::WebSWServerConnection::matchRegistration):
(WebKit::WebSWServerConnection::getRegistrations):
(WebKit::WebSWServerConnection::registerServiceWorkerClientInternal):
(WebKit::WebSWServerConnection::unregisterServiceWorkerClient):
(WebKit::WebSWServerConnection::computeThrottleState const):
(WebKit::WebSWServerConnection::updateThrottleState):
(WebKit::WebSWServerConnection::subscribeToPushService):
(WebKit::WebSWServerConnection::unsubscribeFromPushService):
(WebKit::WebSWServerConnection::getPushSubscription):
(WebKit::WebSWServerConnection::getPushPermissionState):
(WebKit::WebSWServerConnection::fetchTaskTimedOut):
(WebKit::WebSWServerConnection::enableNavigationPreload):
(WebKit::WebSWServerConnection::disableNavigationPreload):
(WebKit::WebSWServerConnection::setNavigationPreloadHeaderValue):
(WebKit::WebSWServerConnection::getNavigationPreloadState):
(WebKit::WebSWServerConnection::gatherClientData):
* Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.h:
* Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp:
(WebKit::WebSWServerToContextConnection::~WebSWServerToContextConnection):
(WebKit::WebSWServerToContextConnection::postMessageToServiceWorkerClient):
(WebKit::WebSWServerToContextConnection::openWindow):
(WebKit::WebSWServerToContextConnection::reportConsoleMessage):
(WebKit::WebSWServerToContextConnection::focus):
* Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h:

Canonical link: https://commits.webkit.org/273187@main




More information about the webkit-changes mailing list