haikuwebkit/Source/WTF/wtf/ObjectIdentifier.h

161 lines
5.3 KiB
C
Raw Permalink Normal View History

Use a single identifier type to identify Service Workers https://bugs.webkit.org/show_bug.cgi?id=179192 Reviewed by Brady Eidson. Source/WebCore: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * WebCore.xcodeproj/project.pbxproj: * loader/ResourceLoaderOptions.h: * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::setSelectedServiceWorkerIdentifierIfNeeded): * loader/cache/CachedResourceRequest.h: * workers/service/ServiceWorker.cpp: (WebCore::ServiceWorker::ServiceWorker): * workers/service/ServiceWorker.h: * workers/service/ServiceWorkerClient.cpp: (WebCore::ServiceWorkerClient::postMessage): * workers/service/ServiceWorkerContainer.cpp: (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration): * workers/service/ServiceWorkerContextData.cpp: (WebCore::ServiceWorkerContextData::isolatedCopy const): * workers/service/ServiceWorkerContextData.h: (WebCore::ServiceWorkerContextData::encode const): (WebCore::ServiceWorkerContextData::decode): * workers/service/ServiceWorkerIdentifier.h: Copied from Source/WebCore/workers/service/ServiceWorkerContextData.cpp. * workers/service/ServiceWorkerRegistrationData.h: (WebCore::ServiceWorkerRegistrationData::decode): * workers/service/context/SWContextManager.cpp: (WebCore::SWContextManager::serviceWorkerThreadProxy const): (WebCore::SWContextManager::postMessageToServiceWorkerGlobalScope): * workers/service/context/SWContextManager.h: * workers/service/context/ServiceWorkerThread.cpp: (WebCore::ServiceWorkerThread::ServiceWorkerThread): * workers/service/context/ServiceWorkerThread.h: (WebCore::ServiceWorkerThread::identifier const): * workers/service/context/ServiceWorkerThreadProxy.h: * workers/service/server/SWClientConnection.cpp: (WebCore::SWClientConnection::postMessageToServiceWorkerClient): * workers/service/server/SWClientConnection.h: * workers/service/server/SWServer.cpp: (WebCore::generateServiceWorkerIdentifier): (WebCore::SWServer::Connection::scriptContextFailedToStart): (WebCore::SWServer::Connection::scriptContextStarted): (WebCore::SWServer::scriptContextFailedToStart): (WebCore::SWServer::scriptContextStarted): (WebCore::SWServer::updateWorker): * workers/service/server/SWServer.h: * workers/service/server/SWServerJobQueue.cpp: (WebCore::SWServerJobQueue::scriptContextFailedToStart): (WebCore::SWServerJobQueue::scriptContextStarted): * workers/service/server/SWServerJobQueue.h: * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::setActiveServiceWorkerIdentifier): * workers/service/server/SWServerWorker.cpp: (WebCore::SWServerWorker::SWServerWorker): * workers/service/server/SWServerWorker.h: (WebCore::SWServerWorker::create): (WebCore::SWServerWorker::identifier const): Source/WebKit: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * Scripts/webkit/messages.py: (forward_declarations_and_headers): (forward_declarations_and_headers.templates): * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::startFetch): (WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWServerConnection::postMessageToServiceWorkerClient): * StorageProcess/ServiceWorker/WebSWServerConnection.h: * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in: * StorageProcess/StorageProcess.cpp: (WebKit::StorageProcess::serviceWorkerContextFailedToStart): (WebKit::StorageProcess::serviceWorkerContextStarted): (WebKit::StorageProcess::postMessageToServiceWorkerClient): * StorageProcess/StorageProcess.h: * StorageProcess/StorageProcess.messages.in: * WebProcess/Storage/WebSWClientConnection.cpp: (WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWClientConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWClientConnection.h: * WebProcess/Storage/WebSWClientConnection.messages.in: * WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::updateServiceWorker): (WebKit::WebSWContextManagerConnection::serviceWorkerStartedWithMessage): (WebKit::WebSWContextManagerConnection::startFetch): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWContextManagerConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.messages.in: Source/WTF: Introduce class for strongly typed identifiers. This avoids mixing up different types of identifiers. * WTF.xcodeproj/project.pbxproj: * wtf/ObjectIdentifier.h: Added. (WTF::ObjectIdentifier::encode const): (WTF::ObjectIdentifier::decode): (WTF::ObjectIdentifier::operator== const): (WTF::ObjectIdentifier::operator!= const): (WTF::ObjectIdentifier::ObjectIdentifier): (WTF::makeObjectIdentifier): (WTF::ObjectIdentifierHash::hash): (WTF::ObjectIdentifierHash::equal): (WTF::HashTraits<ObjectIdentifier<T>>::emptyValue): (WTF::HashTraits<ObjectIdentifier<T>>::constructDeletedValue): (WTF::HashTraits<ObjectIdentifier<T>>::isDeletedValue): Canonical link: https://commits.webkit.org/195341@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224403 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-03 16:37:04 +00:00
/*
Make sure WTF::generateObjectIdentifier() internal counter does not get duplicated https://bugs.webkit.org/show_bug.cgi?id=193848 Reviewed by Youenn Fablet. Source/WebCore: * dom/Document.cpp: * dom/MessageChannel.cpp: (WebCore::MessageChannel::MessageChannel): * dom/ScriptExecutionContext.cpp: (WebCore::ScriptExecutionContext::contextIdentifier const): * history/HistoryItem.cpp: (WebCore::HistoryItem::HistoryItem): * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::registerTemporaryServiceWorkerClient): * page/DOMWindow.cpp: (WebCore::DOMWindow::DOMWindow): * platform/Process.cpp: (WebCore::Process::identifier): * workers/service/ServiceWorkerJobData.cpp: (WebCore::ServiceWorkerJobData::ServiceWorkerJobData): * workers/service/server/RegistrationDatabase.cpp: (WebCore::RegistrationDatabase::importRecords): * workers/service/server/SWServer.cpp: (WebCore::SWServer::Connection::Connection): (WebCore::SWServer::updateWorker): * workers/service/server/SWServerRegistration.cpp: (WebCore::generateServiceWorkerRegistrationIdentifier): * workers/service/server/SWServerToContextConnection.cpp: (WebCore::generateServerToContextConnectionIdentifier): Source/WebKit: * Platform/IPC/Connection.cpp: (IPC::Connection::Connection): * UIProcess/ChildProcessProxy.h: * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::WebUserContentControllerProxy): * UIProcess/WebBackForwardList.cpp: (WebKit::WebBackForwardList::restoreFromState): * UIProcess/WebProcessPool.cpp: * WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp: (WebKit::UserMediaPermissionRequestManager::addDeviceChangeObserver): Source/WTF: Move WTF::generateObjectIdentifier()'s internal counter out-of-line so make sure it never gets duplicated at each call site. This has caused some hard-to-debug issues with duplicate identifiers such as Bug 193761. Also move it to ObjectIdentifier and rename it to generate() as this make call sites nicer when they have a typedef for the ObjectIdentifier<T> type. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/ObjectIdentifier.cpp: Copied from Source/WebCore/platform/Process.cpp. (WTF::ObjectIdentifierBase::generateIdentifierInternal): (WTF::ObjectIdentifierBase::generateThreadSafeIdentifierInternal): * wtf/ObjectIdentifier.h: (WTF::ObjectIdentifier::generate): (WTF::ObjectIdentifier::generateThreadSafe): Canonical link: https://commits.webkit.org/208459@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240661 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-29 17:50:53 +00:00
* Copyright (C) 2017-2019 Apple Inc. All rights reserved.
Use a single identifier type to identify Service Workers https://bugs.webkit.org/show_bug.cgi?id=179192 Reviewed by Brady Eidson. Source/WebCore: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * WebCore.xcodeproj/project.pbxproj: * loader/ResourceLoaderOptions.h: * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::setSelectedServiceWorkerIdentifierIfNeeded): * loader/cache/CachedResourceRequest.h: * workers/service/ServiceWorker.cpp: (WebCore::ServiceWorker::ServiceWorker): * workers/service/ServiceWorker.h: * workers/service/ServiceWorkerClient.cpp: (WebCore::ServiceWorkerClient::postMessage): * workers/service/ServiceWorkerContainer.cpp: (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration): * workers/service/ServiceWorkerContextData.cpp: (WebCore::ServiceWorkerContextData::isolatedCopy const): * workers/service/ServiceWorkerContextData.h: (WebCore::ServiceWorkerContextData::encode const): (WebCore::ServiceWorkerContextData::decode): * workers/service/ServiceWorkerIdentifier.h: Copied from Source/WebCore/workers/service/ServiceWorkerContextData.cpp. * workers/service/ServiceWorkerRegistrationData.h: (WebCore::ServiceWorkerRegistrationData::decode): * workers/service/context/SWContextManager.cpp: (WebCore::SWContextManager::serviceWorkerThreadProxy const): (WebCore::SWContextManager::postMessageToServiceWorkerGlobalScope): * workers/service/context/SWContextManager.h: * workers/service/context/ServiceWorkerThread.cpp: (WebCore::ServiceWorkerThread::ServiceWorkerThread): * workers/service/context/ServiceWorkerThread.h: (WebCore::ServiceWorkerThread::identifier const): * workers/service/context/ServiceWorkerThreadProxy.h: * workers/service/server/SWClientConnection.cpp: (WebCore::SWClientConnection::postMessageToServiceWorkerClient): * workers/service/server/SWClientConnection.h: * workers/service/server/SWServer.cpp: (WebCore::generateServiceWorkerIdentifier): (WebCore::SWServer::Connection::scriptContextFailedToStart): (WebCore::SWServer::Connection::scriptContextStarted): (WebCore::SWServer::scriptContextFailedToStart): (WebCore::SWServer::scriptContextStarted): (WebCore::SWServer::updateWorker): * workers/service/server/SWServer.h: * workers/service/server/SWServerJobQueue.cpp: (WebCore::SWServerJobQueue::scriptContextFailedToStart): (WebCore::SWServerJobQueue::scriptContextStarted): * workers/service/server/SWServerJobQueue.h: * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::setActiveServiceWorkerIdentifier): * workers/service/server/SWServerWorker.cpp: (WebCore::SWServerWorker::SWServerWorker): * workers/service/server/SWServerWorker.h: (WebCore::SWServerWorker::create): (WebCore::SWServerWorker::identifier const): Source/WebKit: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * Scripts/webkit/messages.py: (forward_declarations_and_headers): (forward_declarations_and_headers.templates): * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::startFetch): (WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWServerConnection::postMessageToServiceWorkerClient): * StorageProcess/ServiceWorker/WebSWServerConnection.h: * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in: * StorageProcess/StorageProcess.cpp: (WebKit::StorageProcess::serviceWorkerContextFailedToStart): (WebKit::StorageProcess::serviceWorkerContextStarted): (WebKit::StorageProcess::postMessageToServiceWorkerClient): * StorageProcess/StorageProcess.h: * StorageProcess/StorageProcess.messages.in: * WebProcess/Storage/WebSWClientConnection.cpp: (WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWClientConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWClientConnection.h: * WebProcess/Storage/WebSWClientConnection.messages.in: * WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::updateServiceWorker): (WebKit::WebSWContextManagerConnection::serviceWorkerStartedWithMessage): (WebKit::WebSWContextManagerConnection::startFetch): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWContextManagerConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.messages.in: Source/WTF: Introduce class for strongly typed identifiers. This avoids mixing up different types of identifiers. * WTF.xcodeproj/project.pbxproj: * wtf/ObjectIdentifier.h: Added. (WTF::ObjectIdentifier::encode const): (WTF::ObjectIdentifier::decode): (WTF::ObjectIdentifier::operator== const): (WTF::ObjectIdentifier::operator!= const): (WTF::ObjectIdentifier::ObjectIdentifier): (WTF::makeObjectIdentifier): (WTF::ObjectIdentifierHash::hash): (WTF::ObjectIdentifierHash::equal): (WTF::HashTraits<ObjectIdentifier<T>>::emptyValue): (WTF::HashTraits<ObjectIdentifier<T>>::constructDeletedValue): (WTF::HashTraits<ObjectIdentifier<T>>::isDeletedValue): Canonical link: https://commits.webkit.org/195341@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224403 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-03 16:37:04 +00:00
*
* 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
ASSERTION FAILED: registration in WebCore::SWServerJobQueue::scriptContextStarted(ServiceWorkerIdentifier) https://bugs.webkit.org/show_bug.cgi?id=179846 Reviewed by Darin Adler. Source/WebCore: We have seen crashes on the bots in SWServerJobQueue because methods such as scriptContextStarted() can get called after the jobQueue has been cleared. This is because when a jobQueue is cleared, an asynchronous operation may be pending (e.g. script fetch, service worker starting, install event). To address the issue, we now pass the identifier of the job that started the asynchronous operation when calling the methods on SWServerJobQueue. If the identifier does not match the identifier of the current job in the JobQueue, we ignore it. This patch also starts using a strongly typed identifier (ServiceWorkerJobIdentifier) for ServiceWorkerJob, instead of a uint64_t. It also introduces a ServiceWorkerJobDataIdentifier type which contains both a SWServerConnectionIdentifier and a ServiceWorkerJobIdentifier. This is useful because ServiceWorkerJobData is passed to the StorageProcess and it needs a globally unique identifier. ServiceWorkerJobIdentifier is only guaranteed to be unique within a single WebProcess. Augmenting it with the SWServerConnectionIdentifier of the WebProcess makes it globally unique. No new tests, unskipped exiting test. * WebCore.xcodeproj/project.pbxproj: * workers/service/ServiceWorkerContainer.cpp: (WebCore::ServiceWorkerContainer::scheduleJob): (WebCore::ServiceWorkerContainer::startScriptFetchForJob): (WebCore::ServiceWorkerContainer::jobFinishedLoadingScript): (WebCore::ServiceWorkerContainer::jobFailedLoadingScript): (WebCore::ServiceWorkerContainer::jobDidFinish): * workers/service/ServiceWorkerContainer.h: * workers/service/ServiceWorkerContextData.cpp: (WebCore::ServiceWorkerContextData::isolatedCopy const): * workers/service/ServiceWorkerContextData.h: (WebCore::ServiceWorkerContextData::encode const): (WebCore::ServiceWorkerContextData::decode): * workers/service/ServiceWorkerFetchResult.h: (WebCore::ServiceWorkerFetchResult::encode const): (WebCore::ServiceWorkerFetchResult::decode): * workers/service/ServiceWorkerJob.h: (WebCore::ServiceWorkerJob::identifier const): * workers/service/ServiceWorkerJobData.cpp: (WebCore::ServiceWorkerJobData::ServiceWorkerJobData): (WebCore::ServiceWorkerJobData::isolatedCopy const): * workers/service/ServiceWorkerJobData.h: (WebCore::ServiceWorkerJobData::connectionIdentifier const): (WebCore::ServiceWorkerJobData::identifier const): (WebCore::ServiceWorkerJobData::encode const): (WebCore::ServiceWorkerJobData::decode): * workers/service/ServiceWorkerJobDataIdentifier.h: Copied from Source/WebCore/workers/service/ServiceWorkerFetchResult.h. (WebCore::ServiceWorkerJobDataIdentifier::operator== const): (WebCore::ServiceWorkerJobDataIdentifier::loggingString const): (WebCore::ServiceWorkerJobDataIdentifier::encode const): (WebCore::ServiceWorkerJobDataIdentifier::decode): * workers/service/ServiceWorkerTypes.h: * workers/service/context/SWContextManager.cpp: (WebCore::SWContextManager::registerServiceWorkerThreadForInstall): * workers/service/context/SWContextManager.h: * workers/service/context/ServiceWorkerThread.cpp: (WebCore::ServiceWorkerThread::fireInstallEvent): * workers/service/server/SWClientConnection.cpp: (WebCore::SWClientConnection::scheduleJob): (WebCore::SWClientConnection::finishedFetchingScript): (WebCore::SWClientConnection::failedFetchingScript): (WebCore::SWClientConnection::jobRejectedInServer): (WebCore::SWClientConnection::registrationJobResolvedInServer): (WebCore::SWClientConnection::unregistrationJobResolvedInServer): (WebCore::SWClientConnection::startScriptFetchForServer): * workers/service/server/SWClientConnection.h: * workers/service/server/SWServer.cpp: (WebCore::SWServer::Connection::scheduleJobInServer): (WebCore::SWServer::rejectJob): (WebCore::SWServer::resolveRegistrationJob): (WebCore::SWServer::startScriptFetch): (WebCore::SWServer::scriptFetchFinished): (WebCore::SWServer::scriptContextFailedToStart): (WebCore::SWServer::scriptContextStarted): (WebCore::SWServer::didFinishInstall): (WebCore::SWServer::updateWorker): * workers/service/server/SWServer.h: * workers/service/server/SWServerJobQueue.cpp: (WebCore::SWServerJobQueue::isCurrentlyProcessingJob const): (WebCore::SWServerJobQueue::scriptFetchFinished): (WebCore::SWServerJobQueue::scriptContextFailedToStart): (WebCore::SWServerJobQueue::scriptContextStarted): (WebCore::SWServerJobQueue::didFinishInstall): * workers/service/server/SWServerJobQueue.h: * workers/service/server/SWServerToContextConnection.cpp: (WebCore::SWServerToContextConnection::scriptContextFailedToStart): (WebCore::SWServerToContextConnection::scriptContextStarted): (WebCore::SWServerToContextConnection::didFinishInstall): * workers/service/server/SWServerToContextConnection.h: * workers/service/server/SWServerWorker.cpp: (WebCore::SWServerWorker::scriptContextFailedToStart): (WebCore::SWServerWorker::scriptContextStarted): (WebCore::SWServerWorker::didFinishInstall): * workers/service/server/SWServerWorker.h: Source/WebKit: * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::rejectJobInClient): (WebKit::WebSWServerConnection::resolveRegistrationJobInClient): (WebKit::WebSWServerConnection::resolveUnregistrationJobInClient): (WebKit::WebSWServerConnection::startScriptFetchInClient): * StorageProcess/ServiceWorker/WebSWServerConnection.h: * StorageProcess/ServiceWorker/WebSWServerToContextConnection.messages.in: * WebProcess/Storage/WebSWClientConnection.messages.in: * WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::serviceWorkerStartedWithMessage): (WebKit::WebSWContextManagerConnection::didFinishInstall): * WebProcess/Storage/WebSWContextManagerConnection.h: Source/WTF: Add a generateThreadSafeObjectIdentifier() for generating an ObjectIdentifier in a thread-safe manner, using std::atomic. * wtf/ObjectIdentifier.h: (WTF::generateObjectIdentifier): (WTF::generateThreadSafeObjectIdentifier): LayoutTests: Unskip test that use to flakily crash. * platform/mac/TestExpectations: Canonical link: https://commits.webkit.org/195900@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225031 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-19 07:19:00 +00:00
#include <atomic>
#include <mutex>
Use a single identifier type to identify Service Workers https://bugs.webkit.org/show_bug.cgi?id=179192 Reviewed by Brady Eidson. Source/WebCore: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * WebCore.xcodeproj/project.pbxproj: * loader/ResourceLoaderOptions.h: * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::setSelectedServiceWorkerIdentifierIfNeeded): * loader/cache/CachedResourceRequest.h: * workers/service/ServiceWorker.cpp: (WebCore::ServiceWorker::ServiceWorker): * workers/service/ServiceWorker.h: * workers/service/ServiceWorkerClient.cpp: (WebCore::ServiceWorkerClient::postMessage): * workers/service/ServiceWorkerContainer.cpp: (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration): * workers/service/ServiceWorkerContextData.cpp: (WebCore::ServiceWorkerContextData::isolatedCopy const): * workers/service/ServiceWorkerContextData.h: (WebCore::ServiceWorkerContextData::encode const): (WebCore::ServiceWorkerContextData::decode): * workers/service/ServiceWorkerIdentifier.h: Copied from Source/WebCore/workers/service/ServiceWorkerContextData.cpp. * workers/service/ServiceWorkerRegistrationData.h: (WebCore::ServiceWorkerRegistrationData::decode): * workers/service/context/SWContextManager.cpp: (WebCore::SWContextManager::serviceWorkerThreadProxy const): (WebCore::SWContextManager::postMessageToServiceWorkerGlobalScope): * workers/service/context/SWContextManager.h: * workers/service/context/ServiceWorkerThread.cpp: (WebCore::ServiceWorkerThread::ServiceWorkerThread): * workers/service/context/ServiceWorkerThread.h: (WebCore::ServiceWorkerThread::identifier const): * workers/service/context/ServiceWorkerThreadProxy.h: * workers/service/server/SWClientConnection.cpp: (WebCore::SWClientConnection::postMessageToServiceWorkerClient): * workers/service/server/SWClientConnection.h: * workers/service/server/SWServer.cpp: (WebCore::generateServiceWorkerIdentifier): (WebCore::SWServer::Connection::scriptContextFailedToStart): (WebCore::SWServer::Connection::scriptContextStarted): (WebCore::SWServer::scriptContextFailedToStart): (WebCore::SWServer::scriptContextStarted): (WebCore::SWServer::updateWorker): * workers/service/server/SWServer.h: * workers/service/server/SWServerJobQueue.cpp: (WebCore::SWServerJobQueue::scriptContextFailedToStart): (WebCore::SWServerJobQueue::scriptContextStarted): * workers/service/server/SWServerJobQueue.h: * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::setActiveServiceWorkerIdentifier): * workers/service/server/SWServerWorker.cpp: (WebCore::SWServerWorker::SWServerWorker): * workers/service/server/SWServerWorker.h: (WebCore::SWServerWorker::create): (WebCore::SWServerWorker::identifier const): Source/WebKit: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * Scripts/webkit/messages.py: (forward_declarations_and_headers): (forward_declarations_and_headers.templates): * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::startFetch): (WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWServerConnection::postMessageToServiceWorkerClient): * StorageProcess/ServiceWorker/WebSWServerConnection.h: * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in: * StorageProcess/StorageProcess.cpp: (WebKit::StorageProcess::serviceWorkerContextFailedToStart): (WebKit::StorageProcess::serviceWorkerContextStarted): (WebKit::StorageProcess::postMessageToServiceWorkerClient): * StorageProcess/StorageProcess.h: * StorageProcess/StorageProcess.messages.in: * WebProcess/Storage/WebSWClientConnection.cpp: (WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWClientConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWClientConnection.h: * WebProcess/Storage/WebSWClientConnection.messages.in: * WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::updateServiceWorker): (WebKit::WebSWContextManagerConnection::serviceWorkerStartedWithMessage): (WebKit::WebSWContextManagerConnection::startFetch): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWContextManagerConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.messages.in: Source/WTF: Introduce class for strongly typed identifiers. This avoids mixing up different types of identifiers. * WTF.xcodeproj/project.pbxproj: * wtf/ObjectIdentifier.h: Added. (WTF::ObjectIdentifier::encode const): (WTF::ObjectIdentifier::decode): (WTF::ObjectIdentifier::operator== const): (WTF::ObjectIdentifier::operator!= const): (WTF::ObjectIdentifier::ObjectIdentifier): (WTF::makeObjectIdentifier): (WTF::ObjectIdentifierHash::hash): (WTF::ObjectIdentifierHash::equal): (WTF::HashTraits<ObjectIdentifier<T>>::emptyValue): (WTF::HashTraits<ObjectIdentifier<T>>::constructDeletedValue): (WTF::HashTraits<ObjectIdentifier<T>>::isDeletedValue): Canonical link: https://commits.webkit.org/195341@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224403 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-03 16:37:04 +00:00
#include <wtf/HashTraits.h>
ASSERTION FAILED: registration in WebCore::SWServerJobQueue::scriptContextStarted(ServiceWorkerIdentifier) https://bugs.webkit.org/show_bug.cgi?id=179846 Reviewed by Darin Adler. Source/WebCore: We have seen crashes on the bots in SWServerJobQueue because methods such as scriptContextStarted() can get called after the jobQueue has been cleared. This is because when a jobQueue is cleared, an asynchronous operation may be pending (e.g. script fetch, service worker starting, install event). To address the issue, we now pass the identifier of the job that started the asynchronous operation when calling the methods on SWServerJobQueue. If the identifier does not match the identifier of the current job in the JobQueue, we ignore it. This patch also starts using a strongly typed identifier (ServiceWorkerJobIdentifier) for ServiceWorkerJob, instead of a uint64_t. It also introduces a ServiceWorkerJobDataIdentifier type which contains both a SWServerConnectionIdentifier and a ServiceWorkerJobIdentifier. This is useful because ServiceWorkerJobData is passed to the StorageProcess and it needs a globally unique identifier. ServiceWorkerJobIdentifier is only guaranteed to be unique within a single WebProcess. Augmenting it with the SWServerConnectionIdentifier of the WebProcess makes it globally unique. No new tests, unskipped exiting test. * WebCore.xcodeproj/project.pbxproj: * workers/service/ServiceWorkerContainer.cpp: (WebCore::ServiceWorkerContainer::scheduleJob): (WebCore::ServiceWorkerContainer::startScriptFetchForJob): (WebCore::ServiceWorkerContainer::jobFinishedLoadingScript): (WebCore::ServiceWorkerContainer::jobFailedLoadingScript): (WebCore::ServiceWorkerContainer::jobDidFinish): * workers/service/ServiceWorkerContainer.h: * workers/service/ServiceWorkerContextData.cpp: (WebCore::ServiceWorkerContextData::isolatedCopy const): * workers/service/ServiceWorkerContextData.h: (WebCore::ServiceWorkerContextData::encode const): (WebCore::ServiceWorkerContextData::decode): * workers/service/ServiceWorkerFetchResult.h: (WebCore::ServiceWorkerFetchResult::encode const): (WebCore::ServiceWorkerFetchResult::decode): * workers/service/ServiceWorkerJob.h: (WebCore::ServiceWorkerJob::identifier const): * workers/service/ServiceWorkerJobData.cpp: (WebCore::ServiceWorkerJobData::ServiceWorkerJobData): (WebCore::ServiceWorkerJobData::isolatedCopy const): * workers/service/ServiceWorkerJobData.h: (WebCore::ServiceWorkerJobData::connectionIdentifier const): (WebCore::ServiceWorkerJobData::identifier const): (WebCore::ServiceWorkerJobData::encode const): (WebCore::ServiceWorkerJobData::decode): * workers/service/ServiceWorkerJobDataIdentifier.h: Copied from Source/WebCore/workers/service/ServiceWorkerFetchResult.h. (WebCore::ServiceWorkerJobDataIdentifier::operator== const): (WebCore::ServiceWorkerJobDataIdentifier::loggingString const): (WebCore::ServiceWorkerJobDataIdentifier::encode const): (WebCore::ServiceWorkerJobDataIdentifier::decode): * workers/service/ServiceWorkerTypes.h: * workers/service/context/SWContextManager.cpp: (WebCore::SWContextManager::registerServiceWorkerThreadForInstall): * workers/service/context/SWContextManager.h: * workers/service/context/ServiceWorkerThread.cpp: (WebCore::ServiceWorkerThread::fireInstallEvent): * workers/service/server/SWClientConnection.cpp: (WebCore::SWClientConnection::scheduleJob): (WebCore::SWClientConnection::finishedFetchingScript): (WebCore::SWClientConnection::failedFetchingScript): (WebCore::SWClientConnection::jobRejectedInServer): (WebCore::SWClientConnection::registrationJobResolvedInServer): (WebCore::SWClientConnection::unregistrationJobResolvedInServer): (WebCore::SWClientConnection::startScriptFetchForServer): * workers/service/server/SWClientConnection.h: * workers/service/server/SWServer.cpp: (WebCore::SWServer::Connection::scheduleJobInServer): (WebCore::SWServer::rejectJob): (WebCore::SWServer::resolveRegistrationJob): (WebCore::SWServer::startScriptFetch): (WebCore::SWServer::scriptFetchFinished): (WebCore::SWServer::scriptContextFailedToStart): (WebCore::SWServer::scriptContextStarted): (WebCore::SWServer::didFinishInstall): (WebCore::SWServer::updateWorker): * workers/service/server/SWServer.h: * workers/service/server/SWServerJobQueue.cpp: (WebCore::SWServerJobQueue::isCurrentlyProcessingJob const): (WebCore::SWServerJobQueue::scriptFetchFinished): (WebCore::SWServerJobQueue::scriptContextFailedToStart): (WebCore::SWServerJobQueue::scriptContextStarted): (WebCore::SWServerJobQueue::didFinishInstall): * workers/service/server/SWServerJobQueue.h: * workers/service/server/SWServerToContextConnection.cpp: (WebCore::SWServerToContextConnection::scriptContextFailedToStart): (WebCore::SWServerToContextConnection::scriptContextStarted): (WebCore::SWServerToContextConnection::didFinishInstall): * workers/service/server/SWServerToContextConnection.h: * workers/service/server/SWServerWorker.cpp: (WebCore::SWServerWorker::scriptContextFailedToStart): (WebCore::SWServerWorker::scriptContextStarted): (WebCore::SWServerWorker::didFinishInstall): * workers/service/server/SWServerWorker.h: Source/WebKit: * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::rejectJobInClient): (WebKit::WebSWServerConnection::resolveRegistrationJobInClient): (WebKit::WebSWServerConnection::resolveUnregistrationJobInClient): (WebKit::WebSWServerConnection::startScriptFetchInClient): * StorageProcess/ServiceWorker/WebSWServerConnection.h: * StorageProcess/ServiceWorker/WebSWServerToContextConnection.messages.in: * WebProcess/Storage/WebSWClientConnection.messages.in: * WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::serviceWorkerStartedWithMessage): (WebKit::WebSWContextManagerConnection::didFinishInstall): * WebProcess/Storage/WebSWContextManagerConnection.h: Source/WTF: Add a generateThreadSafeObjectIdentifier() for generating an ObjectIdentifier in a thread-safe manner, using std::atomic. * wtf/ObjectIdentifier.h: (WTF::generateObjectIdentifier): (WTF::generateThreadSafeObjectIdentifier): LayoutTests: Unskip test that use to flakily crash. * platform/mac/TestExpectations: Canonical link: https://commits.webkit.org/195900@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225031 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-19 07:19:00 +00:00
#include <wtf/NeverDestroyed.h>
#include <wtf/text/TextStream.h>
Implement "UpdateWorkerState" and use it https://bugs.webkit.org/show_bug.cgi?id=179318 Reviewed by Chris Dumez. LayoutTests/imported/w3c: * web-platform-tests/service-workers/service-worker/update.https-expected.txt: Source/WebCore: No new tests (Existing tests and changes there-to). * workers/service/ServiceWorker.cpp: (WebCore::ServiceWorker::allWorkers): (WebCore::ServiceWorker::mutableAllWorkers): (WebCore::ServiceWorker::ServiceWorker): (WebCore::ServiceWorker::~ServiceWorker): (WebCore::ServiceWorker::updateWorkerState): (WebCore::ServiceWorker::setState): Deleted. * workers/service/ServiceWorker.h: * workers/service/ServiceWorkerContainer.cpp: (WebCore::ServiceWorkerContainer::updateRegistrationState): (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration): * workers/service/ServiceWorkerContainer.h: * workers/service/ServiceWorkerRegistration.cpp: (WebCore::ServiceWorkerRegistration::ServiceWorkerRegistration): (WebCore::ServiceWorkerRegistration::~ServiceWorkerRegistration): (WebCore::ServiceWorkerRegistration::updateStateFromServer): * workers/service/ServiceWorkerRegistrationData.cpp: (WebCore::ServiceWorkerRegistrationData::isolatedCopy const): * workers/service/ServiceWorkerRegistrationData.h: (WebCore::ServiceWorkerRegistrationData::encode const): (WebCore::ServiceWorkerRegistrationData::decode): * workers/service/ServiceWorkerRegistrationKey.cpp: (WebCore::ServiceWorkerRegistrationKey::loggingString const): * workers/service/ServiceWorkerRegistrationKey.h: * workers/service/ServiceWorkerTypes.h: * workers/service/context/SWContextManager.cpp: (WebCore::SWContextManager::registerServiceWorkerThreadForInstall): (WebCore::SWContextManager::registerServiceWorkerThreadForUpdate): Deleted. * workers/service/context/SWContextManager.h: * workers/service/server/SWClientConnection.cpp: (WebCore::SWClientConnection::updateRegistrationState): (WebCore::SWClientConnection::updateWorkerState): * workers/service/server/SWClientConnection.h: * workers/service/server/SWServer.cpp: (WebCore::SWServer::updateWorker): * workers/service/server/SWServer.h: (WebCore::SWServer::workerByID const): * workers/service/server/SWServerJobQueue.cpp: (WebCore::SWServerJobQueue::scriptFetchFinished): (WebCore::SWServerJobQueue::scriptContextStarted): (WebCore::SWServerJobQueue::install): (WebCore::SWServerJobQueue::tryClearRegistration): * workers/service/server/SWServerRegistration.cpp: (WebCore::SWServerRegistration::updateRegistrationState): (WebCore::SWServerRegistration::updateWorkerState): (WebCore::SWServerRegistration::data const): * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::setActiveServiceWorkerIdentifier): Deleted. * workers/service/server/SWServerWorker.h: (WebCore::SWServerWorker::state const): (WebCore::SWServerWorker::setState): Source/WebKit: * Scripts/webkit/messages.py: (headers_for_type): * Shared/WebCoreArgumentCoders.h: * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::updateWorkerStateInClient): (WebKit::WebSWServerConnection::installServiceWorkerContext): (WebKit::WebSWServerConnection::setContextConnection): (WebKit::WebSWServerConnection::updateServiceWorkerContext): Deleted. * StorageProcess/ServiceWorker/WebSWServerConnection.h: * WebProcess/Storage/WebSWClientConnection.messages.in: * WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::installServiceWorker): (WebKit::WebSWContextManagerConnection::updateServiceWorker): Deleted. * WebProcess/Storage/WebSWContextManagerConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.messages.in: Source/WTF: * wtf/ObjectIdentifier.h: (WTF::ObjectIdentifier::loggingString const): Canonical link: https://commits.webkit.org/195461@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224553 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-07 23:06:55 +00:00
#include <wtf/text/WTFString.h>
Use a single identifier type to identify Service Workers https://bugs.webkit.org/show_bug.cgi?id=179192 Reviewed by Brady Eidson. Source/WebCore: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * WebCore.xcodeproj/project.pbxproj: * loader/ResourceLoaderOptions.h: * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::setSelectedServiceWorkerIdentifierIfNeeded): * loader/cache/CachedResourceRequest.h: * workers/service/ServiceWorker.cpp: (WebCore::ServiceWorker::ServiceWorker): * workers/service/ServiceWorker.h: * workers/service/ServiceWorkerClient.cpp: (WebCore::ServiceWorkerClient::postMessage): * workers/service/ServiceWorkerContainer.cpp: (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration): * workers/service/ServiceWorkerContextData.cpp: (WebCore::ServiceWorkerContextData::isolatedCopy const): * workers/service/ServiceWorkerContextData.h: (WebCore::ServiceWorkerContextData::encode const): (WebCore::ServiceWorkerContextData::decode): * workers/service/ServiceWorkerIdentifier.h: Copied from Source/WebCore/workers/service/ServiceWorkerContextData.cpp. * workers/service/ServiceWorkerRegistrationData.h: (WebCore::ServiceWorkerRegistrationData::decode): * workers/service/context/SWContextManager.cpp: (WebCore::SWContextManager::serviceWorkerThreadProxy const): (WebCore::SWContextManager::postMessageToServiceWorkerGlobalScope): * workers/service/context/SWContextManager.h: * workers/service/context/ServiceWorkerThread.cpp: (WebCore::ServiceWorkerThread::ServiceWorkerThread): * workers/service/context/ServiceWorkerThread.h: (WebCore::ServiceWorkerThread::identifier const): * workers/service/context/ServiceWorkerThreadProxy.h: * workers/service/server/SWClientConnection.cpp: (WebCore::SWClientConnection::postMessageToServiceWorkerClient): * workers/service/server/SWClientConnection.h: * workers/service/server/SWServer.cpp: (WebCore::generateServiceWorkerIdentifier): (WebCore::SWServer::Connection::scriptContextFailedToStart): (WebCore::SWServer::Connection::scriptContextStarted): (WebCore::SWServer::scriptContextFailedToStart): (WebCore::SWServer::scriptContextStarted): (WebCore::SWServer::updateWorker): * workers/service/server/SWServer.h: * workers/service/server/SWServerJobQueue.cpp: (WebCore::SWServerJobQueue::scriptContextFailedToStart): (WebCore::SWServerJobQueue::scriptContextStarted): * workers/service/server/SWServerJobQueue.h: * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::setActiveServiceWorkerIdentifier): * workers/service/server/SWServerWorker.cpp: (WebCore::SWServerWorker::SWServerWorker): * workers/service/server/SWServerWorker.h: (WebCore::SWServerWorker::create): (WebCore::SWServerWorker::identifier const): Source/WebKit: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * Scripts/webkit/messages.py: (forward_declarations_and_headers): (forward_declarations_and_headers.templates): * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::startFetch): (WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWServerConnection::postMessageToServiceWorkerClient): * StorageProcess/ServiceWorker/WebSWServerConnection.h: * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in: * StorageProcess/StorageProcess.cpp: (WebKit::StorageProcess::serviceWorkerContextFailedToStart): (WebKit::StorageProcess::serviceWorkerContextStarted): (WebKit::StorageProcess::postMessageToServiceWorkerClient): * StorageProcess/StorageProcess.h: * StorageProcess/StorageProcess.messages.in: * WebProcess/Storage/WebSWClientConnection.cpp: (WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWClientConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWClientConnection.h: * WebProcess/Storage/WebSWClientConnection.messages.in: * WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::updateServiceWorker): (WebKit::WebSWContextManagerConnection::serviceWorkerStartedWithMessage): (WebKit::WebSWContextManagerConnection::startFetch): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWContextManagerConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.messages.in: Source/WTF: Introduce class for strongly typed identifiers. This avoids mixing up different types of identifiers. * WTF.xcodeproj/project.pbxproj: * wtf/ObjectIdentifier.h: Added. (WTF::ObjectIdentifier::encode const): (WTF::ObjectIdentifier::decode): (WTF::ObjectIdentifier::operator== const): (WTF::ObjectIdentifier::operator!= const): (WTF::ObjectIdentifier::ObjectIdentifier): (WTF::makeObjectIdentifier): (WTF::ObjectIdentifierHash::hash): (WTF::ObjectIdentifierHash::equal): (WTF::HashTraits<ObjectIdentifier<T>>::emptyValue): (WTF::HashTraits<ObjectIdentifier<T>>::constructDeletedValue): (WTF::HashTraits<ObjectIdentifier<T>>::isDeletedValue): Canonical link: https://commits.webkit.org/195341@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224403 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-03 16:37:04 +00:00
namespace WTF {
Make sure WTF::generateObjectIdentifier() internal counter does not get duplicated https://bugs.webkit.org/show_bug.cgi?id=193848 Reviewed by Youenn Fablet. Source/WebCore: * dom/Document.cpp: * dom/MessageChannel.cpp: (WebCore::MessageChannel::MessageChannel): * dom/ScriptExecutionContext.cpp: (WebCore::ScriptExecutionContext::contextIdentifier const): * history/HistoryItem.cpp: (WebCore::HistoryItem::HistoryItem): * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::registerTemporaryServiceWorkerClient): * page/DOMWindow.cpp: (WebCore::DOMWindow::DOMWindow): * platform/Process.cpp: (WebCore::Process::identifier): * workers/service/ServiceWorkerJobData.cpp: (WebCore::ServiceWorkerJobData::ServiceWorkerJobData): * workers/service/server/RegistrationDatabase.cpp: (WebCore::RegistrationDatabase::importRecords): * workers/service/server/SWServer.cpp: (WebCore::SWServer::Connection::Connection): (WebCore::SWServer::updateWorker): * workers/service/server/SWServerRegistration.cpp: (WebCore::generateServiceWorkerRegistrationIdentifier): * workers/service/server/SWServerToContextConnection.cpp: (WebCore::generateServerToContextConnectionIdentifier): Source/WebKit: * Platform/IPC/Connection.cpp: (IPC::Connection::Connection): * UIProcess/ChildProcessProxy.h: * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::WebUserContentControllerProxy): * UIProcess/WebBackForwardList.cpp: (WebKit::WebBackForwardList::restoreFromState): * UIProcess/WebProcessPool.cpp: * WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp: (WebKit::UserMediaPermissionRequestManager::addDeviceChangeObserver): Source/WTF: Move WTF::generateObjectIdentifier()'s internal counter out-of-line so make sure it never gets duplicated at each call site. This has caused some hard-to-debug issues with duplicate identifiers such as Bug 193761. Also move it to ObjectIdentifier and rename it to generate() as this make call sites nicer when they have a typedef for the ObjectIdentifier<T> type. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/ObjectIdentifier.cpp: Copied from Source/WebCore/platform/Process.cpp. (WTF::ObjectIdentifierBase::generateIdentifierInternal): (WTF::ObjectIdentifierBase::generateThreadSafeIdentifierInternal): * wtf/ObjectIdentifier.h: (WTF::ObjectIdentifier::generate): (WTF::ObjectIdentifier::generateThreadSafe): Canonical link: https://commits.webkit.org/208459@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240661 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-29 17:50:53 +00:00
class ObjectIdentifierBase {
protected:
WTF_EXPORT_PRIVATE static uint64_t generateIdentifierInternal();
WTF_EXPORT_PRIVATE static uint64_t generateThreadSafeIdentifierInternal();
};
template<typename T> class ObjectIdentifier : private ObjectIdentifierBase {
Use a single identifier type to identify Service Workers https://bugs.webkit.org/show_bug.cgi?id=179192 Reviewed by Brady Eidson. Source/WebCore: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * WebCore.xcodeproj/project.pbxproj: * loader/ResourceLoaderOptions.h: * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::setSelectedServiceWorkerIdentifierIfNeeded): * loader/cache/CachedResourceRequest.h: * workers/service/ServiceWorker.cpp: (WebCore::ServiceWorker::ServiceWorker): * workers/service/ServiceWorker.h: * workers/service/ServiceWorkerClient.cpp: (WebCore::ServiceWorkerClient::postMessage): * workers/service/ServiceWorkerContainer.cpp: (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration): * workers/service/ServiceWorkerContextData.cpp: (WebCore::ServiceWorkerContextData::isolatedCopy const): * workers/service/ServiceWorkerContextData.h: (WebCore::ServiceWorkerContextData::encode const): (WebCore::ServiceWorkerContextData::decode): * workers/service/ServiceWorkerIdentifier.h: Copied from Source/WebCore/workers/service/ServiceWorkerContextData.cpp. * workers/service/ServiceWorkerRegistrationData.h: (WebCore::ServiceWorkerRegistrationData::decode): * workers/service/context/SWContextManager.cpp: (WebCore::SWContextManager::serviceWorkerThreadProxy const): (WebCore::SWContextManager::postMessageToServiceWorkerGlobalScope): * workers/service/context/SWContextManager.h: * workers/service/context/ServiceWorkerThread.cpp: (WebCore::ServiceWorkerThread::ServiceWorkerThread): * workers/service/context/ServiceWorkerThread.h: (WebCore::ServiceWorkerThread::identifier const): * workers/service/context/ServiceWorkerThreadProxy.h: * workers/service/server/SWClientConnection.cpp: (WebCore::SWClientConnection::postMessageToServiceWorkerClient): * workers/service/server/SWClientConnection.h: * workers/service/server/SWServer.cpp: (WebCore::generateServiceWorkerIdentifier): (WebCore::SWServer::Connection::scriptContextFailedToStart): (WebCore::SWServer::Connection::scriptContextStarted): (WebCore::SWServer::scriptContextFailedToStart): (WebCore::SWServer::scriptContextStarted): (WebCore::SWServer::updateWorker): * workers/service/server/SWServer.h: * workers/service/server/SWServerJobQueue.cpp: (WebCore::SWServerJobQueue::scriptContextFailedToStart): (WebCore::SWServerJobQueue::scriptContextStarted): * workers/service/server/SWServerJobQueue.h: * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::setActiveServiceWorkerIdentifier): * workers/service/server/SWServerWorker.cpp: (WebCore::SWServerWorker::SWServerWorker): * workers/service/server/SWServerWorker.h: (WebCore::SWServerWorker::create): (WebCore::SWServerWorker::identifier const): Source/WebKit: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * Scripts/webkit/messages.py: (forward_declarations_and_headers): (forward_declarations_and_headers.templates): * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::startFetch): (WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWServerConnection::postMessageToServiceWorkerClient): * StorageProcess/ServiceWorker/WebSWServerConnection.h: * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in: * StorageProcess/StorageProcess.cpp: (WebKit::StorageProcess::serviceWorkerContextFailedToStart): (WebKit::StorageProcess::serviceWorkerContextStarted): (WebKit::StorageProcess::postMessageToServiceWorkerClient): * StorageProcess/StorageProcess.h: * StorageProcess/StorageProcess.messages.in: * WebProcess/Storage/WebSWClientConnection.cpp: (WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWClientConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWClientConnection.h: * WebProcess/Storage/WebSWClientConnection.messages.in: * WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::updateServiceWorker): (WebKit::WebSWContextManagerConnection::serviceWorkerStartedWithMessage): (WebKit::WebSWContextManagerConnection::startFetch): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWContextManagerConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.messages.in: Source/WTF: Introduce class for strongly typed identifiers. This avoids mixing up different types of identifiers. * WTF.xcodeproj/project.pbxproj: * wtf/ObjectIdentifier.h: Added. (WTF::ObjectIdentifier::encode const): (WTF::ObjectIdentifier::decode): (WTF::ObjectIdentifier::operator== const): (WTF::ObjectIdentifier::operator!= const): (WTF::ObjectIdentifier::ObjectIdentifier): (WTF::makeObjectIdentifier): (WTF::ObjectIdentifierHash::hash): (WTF::ObjectIdentifierHash::equal): (WTF::HashTraits<ObjectIdentifier<T>>::emptyValue): (WTF::HashTraits<ObjectIdentifier<T>>::constructDeletedValue): (WTF::HashTraits<ObjectIdentifier<T>>::isDeletedValue): Canonical link: https://commits.webkit.org/195341@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224403 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-03 16:37:04 +00:00
public:
Make sure WTF::generateObjectIdentifier() internal counter does not get duplicated https://bugs.webkit.org/show_bug.cgi?id=193848 Reviewed by Youenn Fablet. Source/WebCore: * dom/Document.cpp: * dom/MessageChannel.cpp: (WebCore::MessageChannel::MessageChannel): * dom/ScriptExecutionContext.cpp: (WebCore::ScriptExecutionContext::contextIdentifier const): * history/HistoryItem.cpp: (WebCore::HistoryItem::HistoryItem): * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::registerTemporaryServiceWorkerClient): * page/DOMWindow.cpp: (WebCore::DOMWindow::DOMWindow): * platform/Process.cpp: (WebCore::Process::identifier): * workers/service/ServiceWorkerJobData.cpp: (WebCore::ServiceWorkerJobData::ServiceWorkerJobData): * workers/service/server/RegistrationDatabase.cpp: (WebCore::RegistrationDatabase::importRecords): * workers/service/server/SWServer.cpp: (WebCore::SWServer::Connection::Connection): (WebCore::SWServer::updateWorker): * workers/service/server/SWServerRegistration.cpp: (WebCore::generateServiceWorkerRegistrationIdentifier): * workers/service/server/SWServerToContextConnection.cpp: (WebCore::generateServerToContextConnectionIdentifier): Source/WebKit: * Platform/IPC/Connection.cpp: (IPC::Connection::Connection): * UIProcess/ChildProcessProxy.h: * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::WebUserContentControllerProxy): * UIProcess/WebBackForwardList.cpp: (WebKit::WebBackForwardList::restoreFromState): * UIProcess/WebProcessPool.cpp: * WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp: (WebKit::UserMediaPermissionRequestManager::addDeviceChangeObserver): Source/WTF: Move WTF::generateObjectIdentifier()'s internal counter out-of-line so make sure it never gets duplicated at each call site. This has caused some hard-to-debug issues with duplicate identifiers such as Bug 193761. Also move it to ObjectIdentifier and rename it to generate() as this make call sites nicer when they have a typedef for the ObjectIdentifier<T> type. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/ObjectIdentifier.cpp: Copied from Source/WebCore/platform/Process.cpp. (WTF::ObjectIdentifierBase::generateIdentifierInternal): (WTF::ObjectIdentifierBase::generateThreadSafeIdentifierInternal): * wtf/ObjectIdentifier.h: (WTF::ObjectIdentifier::generate): (WTF::ObjectIdentifier::generateThreadSafe): Canonical link: https://commits.webkit.org/208459@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240661 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-29 17:50:53 +00:00
static ObjectIdentifier generate()
{
Make ContentWorlds be identified by an ObjectIdentifier instead of a uint64_t https://bugs.webkit.org/show_bug.cgi?id=206784 Reviewed by Alex Christensen. Source/WebKit: Refactor: No behavior change. * Scripts/webkit/messages.py: * Shared/AuxiliaryProcess.cpp: (WebKit::AuxiliaryProcess::initialize): * Shared/ContentWorldShared.h: (WebKit::pageContentWorldIdentifier): * Shared/WebPageCreationParameters.cpp: (WebKit::WebPageCreationParameters::decode): * Shared/WebPageCreationParameters.h: * Shared/WebUserContentControllerDataTypes.cpp: (WebKit::WebUserScriptData::decode): (WebKit::WebUserStyleSheetData::decode): (WebKit::WebScriptMessageHandlerData::decode): * Shared/WebUserContentControllerDataTypes.h: * UIProcess/API/APIContentWorld.cpp: (API::ContentWorld::pageContentWorld): (API::ContentWorld::defaultClientWorld): (API::ContentWorld::ContentWorld): (API::ContentWorldBase::generateIdentifier): Deleted. * UIProcess/API/APIContentWorld.h: (API::ContentWorldBase::identifier const): (API::ContentWorldBase::worldData const): (API::ContentWorldBase::ContentWorldBase): * UIProcess/API/APIUserContentWorld.cpp: (API::UserContentWorld::UserContentWorld): * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::removeUserContentWorldUses): (WebKit::WebUserContentControllerProxy::removeAllUserScripts): (WebKit::WebUserContentControllerProxy::removeAllUserStyleSheets): * WebProcess/UserContent/WebUserContentController.cpp: (WebKit::worldMap): (WebKit::WebUserContentController::worldForIdentifier): (WebKit::WebUserContentController::addUserContentWorld): (WebKit::WebUserContentController::addUserContentWorlds): (WebKit::WebUserContentController::removeUserContentWorlds): (WebKit::WebUserContentController::addUserScripts): (WebKit::WebUserContentController::removeUserScript): (WebKit::WebUserContentController::removeAllUserScripts): (WebKit::WebUserContentController::addUserStyleSheets): (WebKit::WebUserContentController::removeUserStyleSheet): (WebKit::WebUserContentController::removeAllUserStyleSheets): (WebKit::WebUserContentController::addUserScriptMessageHandlers): (WebKit::WebUserContentController::removeUserScriptMessageHandler): (WebKit::WebUserContentController::removeAllUserScriptMessageHandlers): * WebProcess/UserContent/WebUserContentController.h: * WebProcess/UserContent/WebUserContentController.messages.in: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::runJavaScript): (WebKit::WebPage::runJavaScriptInMainFrameScriptWorld): (WebKit::WebPage::runJavaScriptInFrame): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: Source/WTF: * wtf/ObjectIdentifier.h: (WTF::ObjectIdentifier::generate): (WTF::ObjectIdentifier::generateThreadSafe): (WTF::ObjectIdentifier::enableGenerationProtection): To allow restricting generating an identifier to the UIProcess. Canonical link: https://commits.webkit.org/219791@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255127 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-26 05:43:29 +00:00
RELEASE_ASSERT(!m_generationProtected);
Make sure WTF::generateObjectIdentifier() internal counter does not get duplicated https://bugs.webkit.org/show_bug.cgi?id=193848 Reviewed by Youenn Fablet. Source/WebCore: * dom/Document.cpp: * dom/MessageChannel.cpp: (WebCore::MessageChannel::MessageChannel): * dom/ScriptExecutionContext.cpp: (WebCore::ScriptExecutionContext::contextIdentifier const): * history/HistoryItem.cpp: (WebCore::HistoryItem::HistoryItem): * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::registerTemporaryServiceWorkerClient): * page/DOMWindow.cpp: (WebCore::DOMWindow::DOMWindow): * platform/Process.cpp: (WebCore::Process::identifier): * workers/service/ServiceWorkerJobData.cpp: (WebCore::ServiceWorkerJobData::ServiceWorkerJobData): * workers/service/server/RegistrationDatabase.cpp: (WebCore::RegistrationDatabase::importRecords): * workers/service/server/SWServer.cpp: (WebCore::SWServer::Connection::Connection): (WebCore::SWServer::updateWorker): * workers/service/server/SWServerRegistration.cpp: (WebCore::generateServiceWorkerRegistrationIdentifier): * workers/service/server/SWServerToContextConnection.cpp: (WebCore::generateServerToContextConnectionIdentifier): Source/WebKit: * Platform/IPC/Connection.cpp: (IPC::Connection::Connection): * UIProcess/ChildProcessProxy.h: * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::WebUserContentControllerProxy): * UIProcess/WebBackForwardList.cpp: (WebKit::WebBackForwardList::restoreFromState): * UIProcess/WebProcessPool.cpp: * WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp: (WebKit::UserMediaPermissionRequestManager::addDeviceChangeObserver): Source/WTF: Move WTF::generateObjectIdentifier()'s internal counter out-of-line so make sure it never gets duplicated at each call site. This has caused some hard-to-debug issues with duplicate identifiers such as Bug 193761. Also move it to ObjectIdentifier and rename it to generate() as this make call sites nicer when they have a typedef for the ObjectIdentifier<T> type. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/ObjectIdentifier.cpp: Copied from Source/WebCore/platform/Process.cpp. (WTF::ObjectIdentifierBase::generateIdentifierInternal): (WTF::ObjectIdentifierBase::generateThreadSafeIdentifierInternal): * wtf/ObjectIdentifier.h: (WTF::ObjectIdentifier::generate): (WTF::ObjectIdentifier::generateThreadSafe): Canonical link: https://commits.webkit.org/208459@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240661 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-29 17:50:53 +00:00
return ObjectIdentifier { generateIdentifierInternal() };
}
static ObjectIdentifier generateThreadSafe()
{
Make ContentWorlds be identified by an ObjectIdentifier instead of a uint64_t https://bugs.webkit.org/show_bug.cgi?id=206784 Reviewed by Alex Christensen. Source/WebKit: Refactor: No behavior change. * Scripts/webkit/messages.py: * Shared/AuxiliaryProcess.cpp: (WebKit::AuxiliaryProcess::initialize): * Shared/ContentWorldShared.h: (WebKit::pageContentWorldIdentifier): * Shared/WebPageCreationParameters.cpp: (WebKit::WebPageCreationParameters::decode): * Shared/WebPageCreationParameters.h: * Shared/WebUserContentControllerDataTypes.cpp: (WebKit::WebUserScriptData::decode): (WebKit::WebUserStyleSheetData::decode): (WebKit::WebScriptMessageHandlerData::decode): * Shared/WebUserContentControllerDataTypes.h: * UIProcess/API/APIContentWorld.cpp: (API::ContentWorld::pageContentWorld): (API::ContentWorld::defaultClientWorld): (API::ContentWorld::ContentWorld): (API::ContentWorldBase::generateIdentifier): Deleted. * UIProcess/API/APIContentWorld.h: (API::ContentWorldBase::identifier const): (API::ContentWorldBase::worldData const): (API::ContentWorldBase::ContentWorldBase): * UIProcess/API/APIUserContentWorld.cpp: (API::UserContentWorld::UserContentWorld): * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::removeUserContentWorldUses): (WebKit::WebUserContentControllerProxy::removeAllUserScripts): (WebKit::WebUserContentControllerProxy::removeAllUserStyleSheets): * WebProcess/UserContent/WebUserContentController.cpp: (WebKit::worldMap): (WebKit::WebUserContentController::worldForIdentifier): (WebKit::WebUserContentController::addUserContentWorld): (WebKit::WebUserContentController::addUserContentWorlds): (WebKit::WebUserContentController::removeUserContentWorlds): (WebKit::WebUserContentController::addUserScripts): (WebKit::WebUserContentController::removeUserScript): (WebKit::WebUserContentController::removeAllUserScripts): (WebKit::WebUserContentController::addUserStyleSheets): (WebKit::WebUserContentController::removeUserStyleSheet): (WebKit::WebUserContentController::removeAllUserStyleSheets): (WebKit::WebUserContentController::addUserScriptMessageHandlers): (WebKit::WebUserContentController::removeUserScriptMessageHandler): (WebKit::WebUserContentController::removeAllUserScriptMessageHandlers): * WebProcess/UserContent/WebUserContentController.h: * WebProcess/UserContent/WebUserContentController.messages.in: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::runJavaScript): (WebKit::WebPage::runJavaScriptInMainFrameScriptWorld): (WebKit::WebPage::runJavaScriptInFrame): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: Source/WTF: * wtf/ObjectIdentifier.h: (WTF::ObjectIdentifier::generate): (WTF::ObjectIdentifier::generateThreadSafe): (WTF::ObjectIdentifier::enableGenerationProtection): To allow restricting generating an identifier to the UIProcess. Canonical link: https://commits.webkit.org/219791@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255127 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-26 05:43:29 +00:00
RELEASE_ASSERT(!m_generationProtected);
Make sure WTF::generateObjectIdentifier() internal counter does not get duplicated https://bugs.webkit.org/show_bug.cgi?id=193848 Reviewed by Youenn Fablet. Source/WebCore: * dom/Document.cpp: * dom/MessageChannel.cpp: (WebCore::MessageChannel::MessageChannel): * dom/ScriptExecutionContext.cpp: (WebCore::ScriptExecutionContext::contextIdentifier const): * history/HistoryItem.cpp: (WebCore::HistoryItem::HistoryItem): * loader/DocumentLoader.cpp: (WebCore::DocumentLoader::registerTemporaryServiceWorkerClient): * page/DOMWindow.cpp: (WebCore::DOMWindow::DOMWindow): * platform/Process.cpp: (WebCore::Process::identifier): * workers/service/ServiceWorkerJobData.cpp: (WebCore::ServiceWorkerJobData::ServiceWorkerJobData): * workers/service/server/RegistrationDatabase.cpp: (WebCore::RegistrationDatabase::importRecords): * workers/service/server/SWServer.cpp: (WebCore::SWServer::Connection::Connection): (WebCore::SWServer::updateWorker): * workers/service/server/SWServerRegistration.cpp: (WebCore::generateServiceWorkerRegistrationIdentifier): * workers/service/server/SWServerToContextConnection.cpp: (WebCore::generateServerToContextConnectionIdentifier): Source/WebKit: * Platform/IPC/Connection.cpp: (IPC::Connection::Connection): * UIProcess/ChildProcessProxy.h: * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::WebUserContentControllerProxy): * UIProcess/WebBackForwardList.cpp: (WebKit::WebBackForwardList::restoreFromState): * UIProcess/WebProcessPool.cpp: * WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp: (WebKit::UserMediaPermissionRequestManager::addDeviceChangeObserver): Source/WTF: Move WTF::generateObjectIdentifier()'s internal counter out-of-line so make sure it never gets duplicated at each call site. This has caused some hard-to-debug issues with duplicate identifiers such as Bug 193761. Also move it to ObjectIdentifier and rename it to generate() as this make call sites nicer when they have a typedef for the ObjectIdentifier<T> type. * WTF.xcodeproj/project.pbxproj: * wtf/CMakeLists.txt: * wtf/ObjectIdentifier.cpp: Copied from Source/WebCore/platform/Process.cpp. (WTF::ObjectIdentifierBase::generateIdentifierInternal): (WTF::ObjectIdentifierBase::generateThreadSafeIdentifierInternal): * wtf/ObjectIdentifier.h: (WTF::ObjectIdentifier::generate): (WTF::ObjectIdentifier::generateThreadSafe): Canonical link: https://commits.webkit.org/208459@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240661 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-29 17:50:53 +00:00
return ObjectIdentifier { generateThreadSafeIdentifierInternal() };
}
Make ContentWorlds be identified by an ObjectIdentifier instead of a uint64_t https://bugs.webkit.org/show_bug.cgi?id=206784 Reviewed by Alex Christensen. Source/WebKit: Refactor: No behavior change. * Scripts/webkit/messages.py: * Shared/AuxiliaryProcess.cpp: (WebKit::AuxiliaryProcess::initialize): * Shared/ContentWorldShared.h: (WebKit::pageContentWorldIdentifier): * Shared/WebPageCreationParameters.cpp: (WebKit::WebPageCreationParameters::decode): * Shared/WebPageCreationParameters.h: * Shared/WebUserContentControllerDataTypes.cpp: (WebKit::WebUserScriptData::decode): (WebKit::WebUserStyleSheetData::decode): (WebKit::WebScriptMessageHandlerData::decode): * Shared/WebUserContentControllerDataTypes.h: * UIProcess/API/APIContentWorld.cpp: (API::ContentWorld::pageContentWorld): (API::ContentWorld::defaultClientWorld): (API::ContentWorld::ContentWorld): (API::ContentWorldBase::generateIdentifier): Deleted. * UIProcess/API/APIContentWorld.h: (API::ContentWorldBase::identifier const): (API::ContentWorldBase::worldData const): (API::ContentWorldBase::ContentWorldBase): * UIProcess/API/APIUserContentWorld.cpp: (API::UserContentWorld::UserContentWorld): * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::removeUserContentWorldUses): (WebKit::WebUserContentControllerProxy::removeAllUserScripts): (WebKit::WebUserContentControllerProxy::removeAllUserStyleSheets): * WebProcess/UserContent/WebUserContentController.cpp: (WebKit::worldMap): (WebKit::WebUserContentController::worldForIdentifier): (WebKit::WebUserContentController::addUserContentWorld): (WebKit::WebUserContentController::addUserContentWorlds): (WebKit::WebUserContentController::removeUserContentWorlds): (WebKit::WebUserContentController::addUserScripts): (WebKit::WebUserContentController::removeUserScript): (WebKit::WebUserContentController::removeAllUserScripts): (WebKit::WebUserContentController::addUserStyleSheets): (WebKit::WebUserContentController::removeUserStyleSheet): (WebKit::WebUserContentController::removeAllUserStyleSheets): (WebKit::WebUserContentController::addUserScriptMessageHandlers): (WebKit::WebUserContentController::removeUserScriptMessageHandler): (WebKit::WebUserContentController::removeAllUserScriptMessageHandlers): * WebProcess/UserContent/WebUserContentController.h: * WebProcess/UserContent/WebUserContentController.messages.in: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::runJavaScript): (WebKit::WebPage::runJavaScriptInMainFrameScriptWorld): (WebKit::WebPage::runJavaScriptInFrame): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: Source/WTF: * wtf/ObjectIdentifier.h: (WTF::ObjectIdentifier::generate): (WTF::ObjectIdentifier::generateThreadSafe): (WTF::ObjectIdentifier::enableGenerationProtection): To allow restricting generating an identifier to the UIProcess. Canonical link: https://commits.webkit.org/219791@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255127 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-26 05:43:29 +00:00
static void enableGenerationProtection()
{
m_generationProtected = true;
}
Use a single identifier type to identify Service Workers https://bugs.webkit.org/show_bug.cgi?id=179192 Reviewed by Brady Eidson. Source/WebCore: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * WebCore.xcodeproj/project.pbxproj: * loader/ResourceLoaderOptions.h: * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::setSelectedServiceWorkerIdentifierIfNeeded): * loader/cache/CachedResourceRequest.h: * workers/service/ServiceWorker.cpp: (WebCore::ServiceWorker::ServiceWorker): * workers/service/ServiceWorker.h: * workers/service/ServiceWorkerClient.cpp: (WebCore::ServiceWorkerClient::postMessage): * workers/service/ServiceWorkerContainer.cpp: (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration): * workers/service/ServiceWorkerContextData.cpp: (WebCore::ServiceWorkerContextData::isolatedCopy const): * workers/service/ServiceWorkerContextData.h: (WebCore::ServiceWorkerContextData::encode const): (WebCore::ServiceWorkerContextData::decode): * workers/service/ServiceWorkerIdentifier.h: Copied from Source/WebCore/workers/service/ServiceWorkerContextData.cpp. * workers/service/ServiceWorkerRegistrationData.h: (WebCore::ServiceWorkerRegistrationData::decode): * workers/service/context/SWContextManager.cpp: (WebCore::SWContextManager::serviceWorkerThreadProxy const): (WebCore::SWContextManager::postMessageToServiceWorkerGlobalScope): * workers/service/context/SWContextManager.h: * workers/service/context/ServiceWorkerThread.cpp: (WebCore::ServiceWorkerThread::ServiceWorkerThread): * workers/service/context/ServiceWorkerThread.h: (WebCore::ServiceWorkerThread::identifier const): * workers/service/context/ServiceWorkerThreadProxy.h: * workers/service/server/SWClientConnection.cpp: (WebCore::SWClientConnection::postMessageToServiceWorkerClient): * workers/service/server/SWClientConnection.h: * workers/service/server/SWServer.cpp: (WebCore::generateServiceWorkerIdentifier): (WebCore::SWServer::Connection::scriptContextFailedToStart): (WebCore::SWServer::Connection::scriptContextStarted): (WebCore::SWServer::scriptContextFailedToStart): (WebCore::SWServer::scriptContextStarted): (WebCore::SWServer::updateWorker): * workers/service/server/SWServer.h: * workers/service/server/SWServerJobQueue.cpp: (WebCore::SWServerJobQueue::scriptContextFailedToStart): (WebCore::SWServerJobQueue::scriptContextStarted): * workers/service/server/SWServerJobQueue.h: * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::setActiveServiceWorkerIdentifier): * workers/service/server/SWServerWorker.cpp: (WebCore::SWServerWorker::SWServerWorker): * workers/service/server/SWServerWorker.h: (WebCore::SWServerWorker::create): (WebCore::SWServerWorker::identifier const): Source/WebKit: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * Scripts/webkit/messages.py: (forward_declarations_and_headers): (forward_declarations_and_headers.templates): * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::startFetch): (WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWServerConnection::postMessageToServiceWorkerClient): * StorageProcess/ServiceWorker/WebSWServerConnection.h: * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in: * StorageProcess/StorageProcess.cpp: (WebKit::StorageProcess::serviceWorkerContextFailedToStart): (WebKit::StorageProcess::serviceWorkerContextStarted): (WebKit::StorageProcess::postMessageToServiceWorkerClient): * StorageProcess/StorageProcess.h: * StorageProcess/StorageProcess.messages.in: * WebProcess/Storage/WebSWClientConnection.cpp: (WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWClientConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWClientConnection.h: * WebProcess/Storage/WebSWClientConnection.messages.in: * WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::updateServiceWorker): (WebKit::WebSWContextManagerConnection::serviceWorkerStartedWithMessage): (WebKit::WebSWContextManagerConnection::startFetch): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWContextManagerConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.messages.in: Source/WTF: Introduce class for strongly typed identifiers. This avoids mixing up different types of identifiers. * WTF.xcodeproj/project.pbxproj: * wtf/ObjectIdentifier.h: Added. (WTF::ObjectIdentifier::encode const): (WTF::ObjectIdentifier::decode): (WTF::ObjectIdentifier::operator== const): (WTF::ObjectIdentifier::operator!= const): (WTF::ObjectIdentifier::ObjectIdentifier): (WTF::makeObjectIdentifier): (WTF::ObjectIdentifierHash::hash): (WTF::ObjectIdentifierHash::equal): (WTF::HashTraits<ObjectIdentifier<T>>::emptyValue): (WTF::HashTraits<ObjectIdentifier<T>>::constructDeletedValue): (WTF::HashTraits<ObjectIdentifier<T>>::isDeletedValue): Canonical link: https://commits.webkit.org/195341@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224403 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-03 16:37:04 +00:00
ObjectIdentifier() = default;
ObjectIdentifier(HashTableDeletedValueType) : m_identifier(hashTableDeletedValue()) { }
bool isHashTableDeletedValue() const { return m_identifier == hashTableDeletedValue(); }
[GPU Process] Object identifiers with the deleted value should cause MESSAGE_CHECKs https://bugs.webkit.org/show_bug.cgi?id=225886 rdar://78114708 Reviewed by Chris Dumez. Source/WebCore: Implement some stricter validation around object identifiers in when decoding display list items in the GPU Process. Currently, we only check for the empty value (i.e. raw identifier value of 0) when iterating over these items, but treat an identifier with the deleted value as valid; instead, we should be treating items with either empty or deleted identifiers as invalid. To address this, we introduce a new helper method, `ObjectIdentifier::isValid`, and turn existing checks for `!!identifier` into `identifier.isValid()`. Test: DisplayListTests.InlineItemValidationFailure * platform/graphics/displaylists/DisplayListItems.h: (WebCore::DisplayList::ClipToImageBuffer::isValid const): (WebCore::DisplayList::DrawImageBuffer::isValid const): (WebCore::DisplayList::DrawNativeImage::isValid const): (WebCore::DisplayList::DrawPattern::isValid const): (WebCore::DisplayList::PaintFrameForMedia::isValid const): (WebCore::DisplayList::FlushContext::isValid const): (WebCore::DisplayList::MetaCommandChangeItemBuffer::isValid const): (WebCore::DisplayList::MetaCommandChangeDestinationImageBuffer::isValid const): Source/WebKit: See WebCore/ChangeLog for more details. Use `ObjectIdentifier::isValid()` instead of just checking for the empty value, when determining whether an object identifier should trigger a message check to the web process. * GPUProcess/graphics/RemoteRenderingBackend.cpp: (WebKit::RemoteRenderingBackend::nextDestinationImageBufferAfterApplyingDisplayLists): Source/WTF: See WebCore/ChangeLog for more details. Add a helper method on `ObjectIdentifier` that returns true only if it is the empty value or deleted value. * wtf/ObjectIdentifier.h: (WTF::ObjectIdentifier::isValid const): Tools: Adjust an existing API test to verify that the deleted object identifier value triggers an inline item decoding failure. * TestWebKitAPI/Tests/WebCore/cg/DisplayListTestsCG.cpp: (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/237842@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277631 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-18 02:33:16 +00:00
bool isValid() const { return isValidIdentifier(m_identifier); }
Use a single identifier type to identify Service Workers https://bugs.webkit.org/show_bug.cgi?id=179192 Reviewed by Brady Eidson. Source/WebCore: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * WebCore.xcodeproj/project.pbxproj: * loader/ResourceLoaderOptions.h: * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::setSelectedServiceWorkerIdentifierIfNeeded): * loader/cache/CachedResourceRequest.h: * workers/service/ServiceWorker.cpp: (WebCore::ServiceWorker::ServiceWorker): * workers/service/ServiceWorker.h: * workers/service/ServiceWorkerClient.cpp: (WebCore::ServiceWorkerClient::postMessage): * workers/service/ServiceWorkerContainer.cpp: (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration): * workers/service/ServiceWorkerContextData.cpp: (WebCore::ServiceWorkerContextData::isolatedCopy const): * workers/service/ServiceWorkerContextData.h: (WebCore::ServiceWorkerContextData::encode const): (WebCore::ServiceWorkerContextData::decode): * workers/service/ServiceWorkerIdentifier.h: Copied from Source/WebCore/workers/service/ServiceWorkerContextData.cpp. * workers/service/ServiceWorkerRegistrationData.h: (WebCore::ServiceWorkerRegistrationData::decode): * workers/service/context/SWContextManager.cpp: (WebCore::SWContextManager::serviceWorkerThreadProxy const): (WebCore::SWContextManager::postMessageToServiceWorkerGlobalScope): * workers/service/context/SWContextManager.h: * workers/service/context/ServiceWorkerThread.cpp: (WebCore::ServiceWorkerThread::ServiceWorkerThread): * workers/service/context/ServiceWorkerThread.h: (WebCore::ServiceWorkerThread::identifier const): * workers/service/context/ServiceWorkerThreadProxy.h: * workers/service/server/SWClientConnection.cpp: (WebCore::SWClientConnection::postMessageToServiceWorkerClient): * workers/service/server/SWClientConnection.h: * workers/service/server/SWServer.cpp: (WebCore::generateServiceWorkerIdentifier): (WebCore::SWServer::Connection::scriptContextFailedToStart): (WebCore::SWServer::Connection::scriptContextStarted): (WebCore::SWServer::scriptContextFailedToStart): (WebCore::SWServer::scriptContextStarted): (WebCore::SWServer::updateWorker): * workers/service/server/SWServer.h: * workers/service/server/SWServerJobQueue.cpp: (WebCore::SWServerJobQueue::scriptContextFailedToStart): (WebCore::SWServerJobQueue::scriptContextStarted): * workers/service/server/SWServerJobQueue.h: * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::setActiveServiceWorkerIdentifier): * workers/service/server/SWServerWorker.cpp: (WebCore::SWServerWorker::SWServerWorker): * workers/service/server/SWServerWorker.h: (WebCore::SWServerWorker::create): (WebCore::SWServerWorker::identifier const): Source/WebKit: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * Scripts/webkit/messages.py: (forward_declarations_and_headers): (forward_declarations_and_headers.templates): * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::startFetch): (WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWServerConnection::postMessageToServiceWorkerClient): * StorageProcess/ServiceWorker/WebSWServerConnection.h: * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in: * StorageProcess/StorageProcess.cpp: (WebKit::StorageProcess::serviceWorkerContextFailedToStart): (WebKit::StorageProcess::serviceWorkerContextStarted): (WebKit::StorageProcess::postMessageToServiceWorkerClient): * StorageProcess/StorageProcess.h: * StorageProcess/StorageProcess.messages.in: * WebProcess/Storage/WebSWClientConnection.cpp: (WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWClientConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWClientConnection.h: * WebProcess/Storage/WebSWClientConnection.messages.in: * WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::updateServiceWorker): (WebKit::WebSWContextManagerConnection::serviceWorkerStartedWithMessage): (WebKit::WebSWContextManagerConnection::startFetch): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWContextManagerConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.messages.in: Source/WTF: Introduce class for strongly typed identifiers. This avoids mixing up different types of identifiers. * WTF.xcodeproj/project.pbxproj: * wtf/ObjectIdentifier.h: Added. (WTF::ObjectIdentifier::encode const): (WTF::ObjectIdentifier::decode): (WTF::ObjectIdentifier::operator== const): (WTF::ObjectIdentifier::operator!= const): (WTF::ObjectIdentifier::ObjectIdentifier): (WTF::makeObjectIdentifier): (WTF::ObjectIdentifierHash::hash): (WTF::ObjectIdentifierHash::equal): (WTF::HashTraits<ObjectIdentifier<T>>::emptyValue): (WTF::HashTraits<ObjectIdentifier<T>>::constructDeletedValue): (WTF::HashTraits<ObjectIdentifier<T>>::isDeletedValue): Canonical link: https://commits.webkit.org/195341@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224403 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-03 16:37:04 +00:00
template<typename Encoder> void encode(Encoder& encoder) const
{
ASSERT(isValidIdentifier(m_identifier));
encoder << m_identifier;
}
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
template<typename Decoder> static std::optional<ObjectIdentifier> decode(Decoder& decoder)
Use a single identifier type to identify Service Workers https://bugs.webkit.org/show_bug.cgi?id=179192 Reviewed by Brady Eidson. Source/WebCore: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * WebCore.xcodeproj/project.pbxproj: * loader/ResourceLoaderOptions.h: * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::setSelectedServiceWorkerIdentifierIfNeeded): * loader/cache/CachedResourceRequest.h: * workers/service/ServiceWorker.cpp: (WebCore::ServiceWorker::ServiceWorker): * workers/service/ServiceWorker.h: * workers/service/ServiceWorkerClient.cpp: (WebCore::ServiceWorkerClient::postMessage): * workers/service/ServiceWorkerContainer.cpp: (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration): * workers/service/ServiceWorkerContextData.cpp: (WebCore::ServiceWorkerContextData::isolatedCopy const): * workers/service/ServiceWorkerContextData.h: (WebCore::ServiceWorkerContextData::encode const): (WebCore::ServiceWorkerContextData::decode): * workers/service/ServiceWorkerIdentifier.h: Copied from Source/WebCore/workers/service/ServiceWorkerContextData.cpp. * workers/service/ServiceWorkerRegistrationData.h: (WebCore::ServiceWorkerRegistrationData::decode): * workers/service/context/SWContextManager.cpp: (WebCore::SWContextManager::serviceWorkerThreadProxy const): (WebCore::SWContextManager::postMessageToServiceWorkerGlobalScope): * workers/service/context/SWContextManager.h: * workers/service/context/ServiceWorkerThread.cpp: (WebCore::ServiceWorkerThread::ServiceWorkerThread): * workers/service/context/ServiceWorkerThread.h: (WebCore::ServiceWorkerThread::identifier const): * workers/service/context/ServiceWorkerThreadProxy.h: * workers/service/server/SWClientConnection.cpp: (WebCore::SWClientConnection::postMessageToServiceWorkerClient): * workers/service/server/SWClientConnection.h: * workers/service/server/SWServer.cpp: (WebCore::generateServiceWorkerIdentifier): (WebCore::SWServer::Connection::scriptContextFailedToStart): (WebCore::SWServer::Connection::scriptContextStarted): (WebCore::SWServer::scriptContextFailedToStart): (WebCore::SWServer::scriptContextStarted): (WebCore::SWServer::updateWorker): * workers/service/server/SWServer.h: * workers/service/server/SWServerJobQueue.cpp: (WebCore::SWServerJobQueue::scriptContextFailedToStart): (WebCore::SWServerJobQueue::scriptContextStarted): * workers/service/server/SWServerJobQueue.h: * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::setActiveServiceWorkerIdentifier): * workers/service/server/SWServerWorker.cpp: (WebCore::SWServerWorker::SWServerWorker): * workers/service/server/SWServerWorker.h: (WebCore::SWServerWorker::create): (WebCore::SWServerWorker::identifier const): Source/WebKit: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * Scripts/webkit/messages.py: (forward_declarations_and_headers): (forward_declarations_and_headers.templates): * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::startFetch): (WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWServerConnection::postMessageToServiceWorkerClient): * StorageProcess/ServiceWorker/WebSWServerConnection.h: * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in: * StorageProcess/StorageProcess.cpp: (WebKit::StorageProcess::serviceWorkerContextFailedToStart): (WebKit::StorageProcess::serviceWorkerContextStarted): (WebKit::StorageProcess::postMessageToServiceWorkerClient): * StorageProcess/StorageProcess.h: * StorageProcess/StorageProcess.messages.in: * WebProcess/Storage/WebSWClientConnection.cpp: (WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWClientConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWClientConnection.h: * WebProcess/Storage/WebSWClientConnection.messages.in: * WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::updateServiceWorker): (WebKit::WebSWContextManagerConnection::serviceWorkerStartedWithMessage): (WebKit::WebSWContextManagerConnection::startFetch): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWContextManagerConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.messages.in: Source/WTF: Introduce class for strongly typed identifiers. This avoids mixing up different types of identifiers. * WTF.xcodeproj/project.pbxproj: * wtf/ObjectIdentifier.h: Added. (WTF::ObjectIdentifier::encode const): (WTF::ObjectIdentifier::decode): (WTF::ObjectIdentifier::operator== const): (WTF::ObjectIdentifier::operator!= const): (WTF::ObjectIdentifier::ObjectIdentifier): (WTF::makeObjectIdentifier): (WTF::ObjectIdentifierHash::hash): (WTF::ObjectIdentifierHash::equal): (WTF::HashTraits<ObjectIdentifier<T>>::emptyValue): (WTF::HashTraits<ObjectIdentifier<T>>::constructDeletedValue): (WTF::HashTraits<ObjectIdentifier<T>>::isDeletedValue): Canonical link: https://commits.webkit.org/195341@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224403 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-03 16:37:04 +00:00
{
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
std::optional<uint64_t> identifier;
Use a single identifier type to identify Service Workers https://bugs.webkit.org/show_bug.cgi?id=179192 Reviewed by Brady Eidson. Source/WebCore: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * WebCore.xcodeproj/project.pbxproj: * loader/ResourceLoaderOptions.h: * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::setSelectedServiceWorkerIdentifierIfNeeded): * loader/cache/CachedResourceRequest.h: * workers/service/ServiceWorker.cpp: (WebCore::ServiceWorker::ServiceWorker): * workers/service/ServiceWorker.h: * workers/service/ServiceWorkerClient.cpp: (WebCore::ServiceWorkerClient::postMessage): * workers/service/ServiceWorkerContainer.cpp: (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration): * workers/service/ServiceWorkerContextData.cpp: (WebCore::ServiceWorkerContextData::isolatedCopy const): * workers/service/ServiceWorkerContextData.h: (WebCore::ServiceWorkerContextData::encode const): (WebCore::ServiceWorkerContextData::decode): * workers/service/ServiceWorkerIdentifier.h: Copied from Source/WebCore/workers/service/ServiceWorkerContextData.cpp. * workers/service/ServiceWorkerRegistrationData.h: (WebCore::ServiceWorkerRegistrationData::decode): * workers/service/context/SWContextManager.cpp: (WebCore::SWContextManager::serviceWorkerThreadProxy const): (WebCore::SWContextManager::postMessageToServiceWorkerGlobalScope): * workers/service/context/SWContextManager.h: * workers/service/context/ServiceWorkerThread.cpp: (WebCore::ServiceWorkerThread::ServiceWorkerThread): * workers/service/context/ServiceWorkerThread.h: (WebCore::ServiceWorkerThread::identifier const): * workers/service/context/ServiceWorkerThreadProxy.h: * workers/service/server/SWClientConnection.cpp: (WebCore::SWClientConnection::postMessageToServiceWorkerClient): * workers/service/server/SWClientConnection.h: * workers/service/server/SWServer.cpp: (WebCore::generateServiceWorkerIdentifier): (WebCore::SWServer::Connection::scriptContextFailedToStart): (WebCore::SWServer::Connection::scriptContextStarted): (WebCore::SWServer::scriptContextFailedToStart): (WebCore::SWServer::scriptContextStarted): (WebCore::SWServer::updateWorker): * workers/service/server/SWServer.h: * workers/service/server/SWServerJobQueue.cpp: (WebCore::SWServerJobQueue::scriptContextFailedToStart): (WebCore::SWServerJobQueue::scriptContextStarted): * workers/service/server/SWServerJobQueue.h: * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::setActiveServiceWorkerIdentifier): * workers/service/server/SWServerWorker.cpp: (WebCore::SWServerWorker::SWServerWorker): * workers/service/server/SWServerWorker.h: (WebCore::SWServerWorker::create): (WebCore::SWServerWorker::identifier const): Source/WebKit: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * Scripts/webkit/messages.py: (forward_declarations_and_headers): (forward_declarations_and_headers.templates): * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::startFetch): (WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWServerConnection::postMessageToServiceWorkerClient): * StorageProcess/ServiceWorker/WebSWServerConnection.h: * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in: * StorageProcess/StorageProcess.cpp: (WebKit::StorageProcess::serviceWorkerContextFailedToStart): (WebKit::StorageProcess::serviceWorkerContextStarted): (WebKit::StorageProcess::postMessageToServiceWorkerClient): * StorageProcess/StorageProcess.h: * StorageProcess/StorageProcess.messages.in: * WebProcess/Storage/WebSWClientConnection.cpp: (WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWClientConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWClientConnection.h: * WebProcess/Storage/WebSWClientConnection.messages.in: * WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::updateServiceWorker): (WebKit::WebSWContextManagerConnection::serviceWorkerStartedWithMessage): (WebKit::WebSWContextManagerConnection::startFetch): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWContextManagerConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.messages.in: Source/WTF: Introduce class for strongly typed identifiers. This avoids mixing up different types of identifiers. * WTF.xcodeproj/project.pbxproj: * wtf/ObjectIdentifier.h: Added. (WTF::ObjectIdentifier::encode const): (WTF::ObjectIdentifier::decode): (WTF::ObjectIdentifier::operator== const): (WTF::ObjectIdentifier::operator!= const): (WTF::ObjectIdentifier::ObjectIdentifier): (WTF::makeObjectIdentifier): (WTF::ObjectIdentifierHash::hash): (WTF::ObjectIdentifierHash::equal): (WTF::HashTraits<ObjectIdentifier<T>>::emptyValue): (WTF::HashTraits<ObjectIdentifier<T>>::constructDeletedValue): (WTF::HashTraits<ObjectIdentifier<T>>::isDeletedValue): Canonical link: https://commits.webkit.org/195341@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224403 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-03 16:37:04 +00:00
decoder >> identifier;
if (!identifier || !isValidIdentifier(*identifier))
Next step toward using std::optional directly instead of through WTF::Optional typedef https://bugs.webkit.org/show_bug.cgi?id=226280 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Accept the renaming done by do-webcore-rename. * yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file, tweaked style to make it happy after the renaming done by do-webcore-rename, and also hand-updated Optional to std::optional as long as we were touching it. Source/WebCore: * <many files>: Accept the renaming done by do-webcore-rename. * Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained about the names of some arguments, fixed them, and also hand-updated Optional to std::optional as long as we were touching it. * loader/EmptyClients.cpp: Since style checker complained about the mix of WEBCORE_EXPORT and inlined functions, moved them out of line, and also hand-updated Optional to std::optional as long as we were touching it. Also removed is<EmptyFrameLoaderClient>(). * loader/EmptyFrameLoaderClient.h: Ditto. Source/WebCore/PAL: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebDriver: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKit: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy: * Storage/StorageTracker.cpp: (WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/mac: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/win: * <many files>: Accept the renaming done by do-webcore-rename. Source/WTF: * <many files>: Accept the renaming done by do-webcore-rename. * wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional. * wtf/URLHelpers.cpp: (WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt. Tools: * Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t, WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily be done by the script and so will be done in later passes. * <many files>: Accept the renaming done by do-webcore-rename. Canonical link: https://commits.webkit.org/238228@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
return std::nullopt;
Use a single identifier type to identify Service Workers https://bugs.webkit.org/show_bug.cgi?id=179192 Reviewed by Brady Eidson. Source/WebCore: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * WebCore.xcodeproj/project.pbxproj: * loader/ResourceLoaderOptions.h: * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::setSelectedServiceWorkerIdentifierIfNeeded): * loader/cache/CachedResourceRequest.h: * workers/service/ServiceWorker.cpp: (WebCore::ServiceWorker::ServiceWorker): * workers/service/ServiceWorker.h: * workers/service/ServiceWorkerClient.cpp: (WebCore::ServiceWorkerClient::postMessage): * workers/service/ServiceWorkerContainer.cpp: (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration): * workers/service/ServiceWorkerContextData.cpp: (WebCore::ServiceWorkerContextData::isolatedCopy const): * workers/service/ServiceWorkerContextData.h: (WebCore::ServiceWorkerContextData::encode const): (WebCore::ServiceWorkerContextData::decode): * workers/service/ServiceWorkerIdentifier.h: Copied from Source/WebCore/workers/service/ServiceWorkerContextData.cpp. * workers/service/ServiceWorkerRegistrationData.h: (WebCore::ServiceWorkerRegistrationData::decode): * workers/service/context/SWContextManager.cpp: (WebCore::SWContextManager::serviceWorkerThreadProxy const): (WebCore::SWContextManager::postMessageToServiceWorkerGlobalScope): * workers/service/context/SWContextManager.h: * workers/service/context/ServiceWorkerThread.cpp: (WebCore::ServiceWorkerThread::ServiceWorkerThread): * workers/service/context/ServiceWorkerThread.h: (WebCore::ServiceWorkerThread::identifier const): * workers/service/context/ServiceWorkerThreadProxy.h: * workers/service/server/SWClientConnection.cpp: (WebCore::SWClientConnection::postMessageToServiceWorkerClient): * workers/service/server/SWClientConnection.h: * workers/service/server/SWServer.cpp: (WebCore::generateServiceWorkerIdentifier): (WebCore::SWServer::Connection::scriptContextFailedToStart): (WebCore::SWServer::Connection::scriptContextStarted): (WebCore::SWServer::scriptContextFailedToStart): (WebCore::SWServer::scriptContextStarted): (WebCore::SWServer::updateWorker): * workers/service/server/SWServer.h: * workers/service/server/SWServerJobQueue.cpp: (WebCore::SWServerJobQueue::scriptContextFailedToStart): (WebCore::SWServerJobQueue::scriptContextStarted): * workers/service/server/SWServerJobQueue.h: * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::setActiveServiceWorkerIdentifier): * workers/service/server/SWServerWorker.cpp: (WebCore::SWServerWorker::SWServerWorker): * workers/service/server/SWServerWorker.h: (WebCore::SWServerWorker::create): (WebCore::SWServerWorker::identifier const): Source/WebKit: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * Scripts/webkit/messages.py: (forward_declarations_and_headers): (forward_declarations_and_headers.templates): * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::startFetch): (WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWServerConnection::postMessageToServiceWorkerClient): * StorageProcess/ServiceWorker/WebSWServerConnection.h: * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in: * StorageProcess/StorageProcess.cpp: (WebKit::StorageProcess::serviceWorkerContextFailedToStart): (WebKit::StorageProcess::serviceWorkerContextStarted): (WebKit::StorageProcess::postMessageToServiceWorkerClient): * StorageProcess/StorageProcess.h: * StorageProcess/StorageProcess.messages.in: * WebProcess/Storage/WebSWClientConnection.cpp: (WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWClientConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWClientConnection.h: * WebProcess/Storage/WebSWClientConnection.messages.in: * WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::updateServiceWorker): (WebKit::WebSWContextManagerConnection::serviceWorkerStartedWithMessage): (WebKit::WebSWContextManagerConnection::startFetch): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWContextManagerConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.messages.in: Source/WTF: Introduce class for strongly typed identifiers. This avoids mixing up different types of identifiers. * WTF.xcodeproj/project.pbxproj: * wtf/ObjectIdentifier.h: Added. (WTF::ObjectIdentifier::encode const): (WTF::ObjectIdentifier::decode): (WTF::ObjectIdentifier::operator== const): (WTF::ObjectIdentifier::operator!= const): (WTF::ObjectIdentifier::ObjectIdentifier): (WTF::makeObjectIdentifier): (WTF::ObjectIdentifierHash::hash): (WTF::ObjectIdentifierHash::equal): (WTF::HashTraits<ObjectIdentifier<T>>::emptyValue): (WTF::HashTraits<ObjectIdentifier<T>>::constructDeletedValue): (WTF::HashTraits<ObjectIdentifier<T>>::isDeletedValue): Canonical link: https://commits.webkit.org/195341@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224403 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-03 16:37:04 +00:00
return ObjectIdentifier { *identifier };
}
bool operator==(const ObjectIdentifier& other) const
{
return m_identifier == other.m_identifier;
}
bool operator!=(const ObjectIdentifier& other) const
{
return m_identifier != other.m_identifier;
}
Use a strongly typed identifier for SWServer::Connection https://bugs.webkit.org/show_bug.cgi?id=179848 Reviewed by Brady Eidson. Source/WebCore: Use a strongly typed identifier for SWServer::Connection, for clarity. * workers/service/ServiceWorker.cpp: (WebCore::ServiceWorker::postMessage): * workers/service/ServiceWorkerClient.cpp: (WebCore::ServiceWorkerClient::ServiceWorkerClient): (WebCore::ServiceWorkerClient::id const): (WebCore::ServiceWorkerClient::postMessage): * workers/service/ServiceWorkerClient.h: (WebCore::ServiceWorkerClient::create): (WebCore::ServiceWorkerClient::identifier const): * workers/service/ServiceWorkerClientData.cpp: (WebCore::ServiceWorkerClientData::isolatedCopy const): (WebCore::ServiceWorkerClientData::from): * workers/service/ServiceWorkerClientData.h: (WebCore::ServiceWorkerClientData::encode const): (WebCore::ServiceWorkerClientData::decode): * workers/service/ServiceWorkerClientIdentifier.h: (WebCore::ServiceWorkerClientIdentifier::toString const): (WebCore::ServiceWorkerClientIdentifier::decode): * workers/service/ServiceWorkerContainer.cpp: (WebCore::ServiceWorkerContainer::addRegistration): (WebCore::ServiceWorkerContainer::removeRegistration): (WebCore::ServiceWorkerContainer::updateRegistration): (WebCore::ServiceWorkerContainer::connectionIdentifier): * workers/service/ServiceWorkerContainer.h: * workers/service/ServiceWorkerFetchResult.h: (WebCore::ServiceWorkerFetchResult::decode): * workers/service/ServiceWorkerJobClient.h: * workers/service/ServiceWorkerJobData.cpp: (WebCore::ServiceWorkerJobData::ServiceWorkerJobData): * workers/service/ServiceWorkerJobData.h: (WebCore::ServiceWorkerJobData::connectionIdentifier const): (WebCore::ServiceWorkerJobData::decode): * workers/service/ServiceWorkerTypes.h: * workers/service/ServiceWorkerWindowClient.cpp: (WebCore::ServiceWorkerWindowClient::ServiceWorkerWindowClient): * workers/service/ServiceWorkerWindowClient.h: * workers/service/context/SWContextManager.cpp: (WebCore::SWContextManager::postMessageToServiceWorkerGlobalScope): * workers/service/context/SWContextManager.h: * workers/service/context/ServiceWorkerThread.cpp: (WebCore::ServiceWorkerThread::postMessageToServiceWorkerGlobalScope): * workers/service/context/ServiceWorkerThread.h: * workers/service/server/SWClientConnection.h: * workers/service/server/SWServer.cpp: (WebCore::SWServer::Connection::Connection): (WebCore::SWServer::Connection::scheduleJobInServer): (WebCore::SWServer::rejectJob): (WebCore::SWServer::resolveRegistrationJob): (WebCore::SWServer::startScriptFetch): (WebCore::SWServer::scriptFetchFinished): * workers/service/server/SWServer.h: (WebCore::SWServer::Connection::identifier const): (WebCore::SWServer::getConnection): * workers/service/server/SWServerRegistration.cpp: (WebCore::SWServerRegistration::forEachConnection): (WebCore::SWServerRegistration::addClientServiceWorkerRegistration): (WebCore::SWServerRegistration::removeClientServiceWorkerRegistration): (WebCore::SWServerRegistration::unregisterServerConnection): * workers/service/server/SWServerRegistration.h: Source/WebKit: Use a strongly typed identifier for SWServer::Connection, for clarity. * Scripts/webkit/messages.py: (forward_declarations_and_headers): (forward_declarations_and_headers.templates): (headers_for_type): * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::WebSWServerConnection): (WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope): * StorageProcess/ServiceWorker/WebSWServerConnection.h: * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in: * StorageProcess/StorageProcess.cpp: (WebKit::StorageProcess::didFailFetch): (WebKit::StorageProcess::didNotHandleFetch): (WebKit::StorageProcess::didReceiveFetchResponse): (WebKit::StorageProcess::didReceiveFetchData): (WebKit::StorageProcess::didReceiveFetchFormData): (WebKit::StorageProcess::didFinishFetch): * StorageProcess/StorageProcess.h: * StorageProcess/StorageProcess.messages.in: * StorageProcess/StorageToWebProcessConnection.cpp: (WebKit::StorageToWebProcessConnection::didReceiveMessage): (WebKit::StorageToWebProcessConnection::establishSWServerConnection): (WebKit::StorageToWebProcessConnection::removeSWServerConnection): (WebKit::generateIDBConnectionToServerIdentifier): (WebKit::StorageToWebProcessConnection::establishIDBConnectionToServer): * StorageProcess/StorageToWebProcessConnection.h: * StorageProcess/StorageToWebProcessConnection.messages.in: * WebProcess/Storage/WebSWClientConnection.cpp: (WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope): * WebProcess/Storage/WebSWClientConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::startFetch): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope): * WebProcess/Storage/WebSWContextManagerConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.messages.in: * WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp: (WebKit::WebServiceWorkerFetchTaskClient::WebServiceWorkerFetchTaskClient): * WebProcess/Storage/WebServiceWorkerFetchTaskClient.h: * WebProcess/Storage/WebToStorageProcessConnection.cpp: (WebKit::WebToStorageProcessConnection::didReceiveMessage): (WebKit::WebToStorageProcessConnection::serviceWorkerConnectionForSession): * WebProcess/Storage/WebToStorageProcessConnection.h: Source/WTF: Make ObjectIdentifier a little more flexible to support more use cases. * wtf/ObjectIdentifier.h: (WTF::ObjectIdentifier::toUInt64 const): (WTF::makeObjectIdentifier): Canonical link: https://commits.webkit.org/195877@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225008 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-18 02:27:13 +00:00
uint64_t toUInt64() const { return m_identifier; }
imported/w3c/web-platform-tests/WebCryptoAPI/wrapKey_unwrapKey/wrapKey_unwrapKey.worker.html is crashing https://bugs.webkit.org/show_bug.cgi?id=183602 Reviewed by Chris Dumez. Introduce a map of ScriptExecutionContext that is read/write protected using a Lock. This allows introducing postTaskTo taking a ScriptExecutionContext identifier and callable from any thread. Use that method in Crypto instead of refing/unrefing the context. Lock only happens if context does some postTask activity. This is governed by calling or not the new contextIdentifier() getter. Covered by crypto tests no longer failing m_workerGlobalScope->hasOneRef() assertion. * crypto/CryptoAlgorithm.cpp: (WebCore::dispatchAlgorithmOperation): * crypto/algorithms/CryptoAlgorithmECDH.cpp: (WebCore::CryptoAlgorithmECDH::deriveBits): * crypto/algorithms/CryptoAlgorithmSHA1.cpp: (WebCore::CryptoAlgorithmSHA1::digest): * crypto/algorithms/CryptoAlgorithmSHA224.cpp: (WebCore::CryptoAlgorithmSHA224::digest): * crypto/algorithms/CryptoAlgorithmSHA256.cpp: (WebCore::CryptoAlgorithmSHA256::digest): * crypto/algorithms/CryptoAlgorithmSHA384.cpp: (WebCore::CryptoAlgorithmSHA384::digest): * crypto/algorithms/CryptoAlgorithmSHA512.cpp: (WebCore::CryptoAlgorithmSHA512::digest): * crypto/gcrypt/CryptoKeyRSAGCrypt.cpp: (WebCore::CryptoKeyRSA::generatePair): * crypto/mac/CryptoKeyRSAMac.cpp: (WebCore::CryptoKeyRSA::generatePair): * dom/Document.cpp: (WebCore::Document::~Document): * dom/ScriptExecutionContext.cpp: (WebCore::allScriptExecutionContextsMapLock): (WebCore::ScriptExecutionContext::ScriptExecutionContext): (WebCore::ScriptExecutionContext::removeFromContextsMap): (WebCore::ScriptExecutionContext::checkConsistency const): (WebCore::ScriptExecutionContext::postTaskTo): * dom/ScriptExecutionContext.h: (WebCore::ScriptExecutionContext::contextIdentifier const): * workers/WorkerGlobalScope.cpp: (WebCore::WorkerGlobalScope::~WorkerGlobalScope): Canonical link: https://commits.webkit.org/199296@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229616 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-03-14 22:52:09 +00:00
explicit operator bool() const { return m_identifier; }
Implement "UpdateWorkerState" and use it https://bugs.webkit.org/show_bug.cgi?id=179318 Reviewed by Chris Dumez. LayoutTests/imported/w3c: * web-platform-tests/service-workers/service-worker/update.https-expected.txt: Source/WebCore: No new tests (Existing tests and changes there-to). * workers/service/ServiceWorker.cpp: (WebCore::ServiceWorker::allWorkers): (WebCore::ServiceWorker::mutableAllWorkers): (WebCore::ServiceWorker::ServiceWorker): (WebCore::ServiceWorker::~ServiceWorker): (WebCore::ServiceWorker::updateWorkerState): (WebCore::ServiceWorker::setState): Deleted. * workers/service/ServiceWorker.h: * workers/service/ServiceWorkerContainer.cpp: (WebCore::ServiceWorkerContainer::updateRegistrationState): (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration): * workers/service/ServiceWorkerContainer.h: * workers/service/ServiceWorkerRegistration.cpp: (WebCore::ServiceWorkerRegistration::ServiceWorkerRegistration): (WebCore::ServiceWorkerRegistration::~ServiceWorkerRegistration): (WebCore::ServiceWorkerRegistration::updateStateFromServer): * workers/service/ServiceWorkerRegistrationData.cpp: (WebCore::ServiceWorkerRegistrationData::isolatedCopy const): * workers/service/ServiceWorkerRegistrationData.h: (WebCore::ServiceWorkerRegistrationData::encode const): (WebCore::ServiceWorkerRegistrationData::decode): * workers/service/ServiceWorkerRegistrationKey.cpp: (WebCore::ServiceWorkerRegistrationKey::loggingString const): * workers/service/ServiceWorkerRegistrationKey.h: * workers/service/ServiceWorkerTypes.h: * workers/service/context/SWContextManager.cpp: (WebCore::SWContextManager::registerServiceWorkerThreadForInstall): (WebCore::SWContextManager::registerServiceWorkerThreadForUpdate): Deleted. * workers/service/context/SWContextManager.h: * workers/service/server/SWClientConnection.cpp: (WebCore::SWClientConnection::updateRegistrationState): (WebCore::SWClientConnection::updateWorkerState): * workers/service/server/SWClientConnection.h: * workers/service/server/SWServer.cpp: (WebCore::SWServer::updateWorker): * workers/service/server/SWServer.h: (WebCore::SWServer::workerByID const): * workers/service/server/SWServerJobQueue.cpp: (WebCore::SWServerJobQueue::scriptFetchFinished): (WebCore::SWServerJobQueue::scriptContextStarted): (WebCore::SWServerJobQueue::install): (WebCore::SWServerJobQueue::tryClearRegistration): * workers/service/server/SWServerRegistration.cpp: (WebCore::SWServerRegistration::updateRegistrationState): (WebCore::SWServerRegistration::updateWorkerState): (WebCore::SWServerRegistration::data const): * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::setActiveServiceWorkerIdentifier): Deleted. * workers/service/server/SWServerWorker.h: (WebCore::SWServerWorker::state const): (WebCore::SWServerWorker::setState): Source/WebKit: * Scripts/webkit/messages.py: (headers_for_type): * Shared/WebCoreArgumentCoders.h: * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::updateWorkerStateInClient): (WebKit::WebSWServerConnection::installServiceWorkerContext): (WebKit::WebSWServerConnection::setContextConnection): (WebKit::WebSWServerConnection::updateServiceWorkerContext): Deleted. * StorageProcess/ServiceWorker/WebSWServerConnection.h: * WebProcess/Storage/WebSWClientConnection.messages.in: * WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::installServiceWorker): (WebKit::WebSWContextManagerConnection::updateServiceWorker): Deleted. * WebProcess/Storage/WebSWContextManagerConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.messages.in: Source/WTF: * wtf/ObjectIdentifier.h: (WTF::ObjectIdentifier::loggingString const): Canonical link: https://commits.webkit.org/195461@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224553 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-07 23:06:55 +00:00
String loggingString() const
{
return String::number(m_identifier);
}
Use a single identifier type to identify Service Workers https://bugs.webkit.org/show_bug.cgi?id=179192 Reviewed by Brady Eidson. Source/WebCore: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * WebCore.xcodeproj/project.pbxproj: * loader/ResourceLoaderOptions.h: * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::setSelectedServiceWorkerIdentifierIfNeeded): * loader/cache/CachedResourceRequest.h: * workers/service/ServiceWorker.cpp: (WebCore::ServiceWorker::ServiceWorker): * workers/service/ServiceWorker.h: * workers/service/ServiceWorkerClient.cpp: (WebCore::ServiceWorkerClient::postMessage): * workers/service/ServiceWorkerContainer.cpp: (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration): * workers/service/ServiceWorkerContextData.cpp: (WebCore::ServiceWorkerContextData::isolatedCopy const): * workers/service/ServiceWorkerContextData.h: (WebCore::ServiceWorkerContextData::encode const): (WebCore::ServiceWorkerContextData::decode): * workers/service/ServiceWorkerIdentifier.h: Copied from Source/WebCore/workers/service/ServiceWorkerContextData.cpp. * workers/service/ServiceWorkerRegistrationData.h: (WebCore::ServiceWorkerRegistrationData::decode): * workers/service/context/SWContextManager.cpp: (WebCore::SWContextManager::serviceWorkerThreadProxy const): (WebCore::SWContextManager::postMessageToServiceWorkerGlobalScope): * workers/service/context/SWContextManager.h: * workers/service/context/ServiceWorkerThread.cpp: (WebCore::ServiceWorkerThread::ServiceWorkerThread): * workers/service/context/ServiceWorkerThread.h: (WebCore::ServiceWorkerThread::identifier const): * workers/service/context/ServiceWorkerThreadProxy.h: * workers/service/server/SWClientConnection.cpp: (WebCore::SWClientConnection::postMessageToServiceWorkerClient): * workers/service/server/SWClientConnection.h: * workers/service/server/SWServer.cpp: (WebCore::generateServiceWorkerIdentifier): (WebCore::SWServer::Connection::scriptContextFailedToStart): (WebCore::SWServer::Connection::scriptContextStarted): (WebCore::SWServer::scriptContextFailedToStart): (WebCore::SWServer::scriptContextStarted): (WebCore::SWServer::updateWorker): * workers/service/server/SWServer.h: * workers/service/server/SWServerJobQueue.cpp: (WebCore::SWServerJobQueue::scriptContextFailedToStart): (WebCore::SWServerJobQueue::scriptContextStarted): * workers/service/server/SWServerJobQueue.h: * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::setActiveServiceWorkerIdentifier): * workers/service/server/SWServerWorker.cpp: (WebCore::SWServerWorker::SWServerWorker): * workers/service/server/SWServerWorker.h: (WebCore::SWServerWorker::create): (WebCore::SWServerWorker::identifier const): Source/WebKit: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * Scripts/webkit/messages.py: (forward_declarations_and_headers): (forward_declarations_and_headers.templates): * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::startFetch): (WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWServerConnection::postMessageToServiceWorkerClient): * StorageProcess/ServiceWorker/WebSWServerConnection.h: * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in: * StorageProcess/StorageProcess.cpp: (WebKit::StorageProcess::serviceWorkerContextFailedToStart): (WebKit::StorageProcess::serviceWorkerContextStarted): (WebKit::StorageProcess::postMessageToServiceWorkerClient): * StorageProcess/StorageProcess.h: * StorageProcess/StorageProcess.messages.in: * WebProcess/Storage/WebSWClientConnection.cpp: (WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWClientConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWClientConnection.h: * WebProcess/Storage/WebSWClientConnection.messages.in: * WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::updateServiceWorker): (WebKit::WebSWContextManagerConnection::serviceWorkerStartedWithMessage): (WebKit::WebSWContextManagerConnection::startFetch): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWContextManagerConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.messages.in: Source/WTF: Introduce class for strongly typed identifiers. This avoids mixing up different types of identifiers. * WTF.xcodeproj/project.pbxproj: * wtf/ObjectIdentifier.h: Added. (WTF::ObjectIdentifier::encode const): (WTF::ObjectIdentifier::decode): (WTF::ObjectIdentifier::operator== const): (WTF::ObjectIdentifier::operator!= const): (WTF::ObjectIdentifier::ObjectIdentifier): (WTF::makeObjectIdentifier): (WTF::ObjectIdentifierHash::hash): (WTF::ObjectIdentifierHash::equal): (WTF::HashTraits<ObjectIdentifier<T>>::emptyValue): (WTF::HashTraits<ObjectIdentifier<T>>::constructDeletedValue): (WTF::HashTraits<ObjectIdentifier<T>>::isDeletedValue): Canonical link: https://commits.webkit.org/195341@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224403 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-03 16:37:04 +00:00
Shrink CachedResource https://bugs.webkit.org/show_bug.cgi?id=207618 Reviewed by Mark Lam. Source/WebCore: This patch shrinks sizeof(CachedResource) by 80 bytes by aggressively using bit-fields and Markable<>. For each enum class, we define `bitsOfXXX` value, which indicates # of bits to represent it. And using this value for bit-field's width. No behavior change. * loader/FetchOptions.h: (WebCore::FetchOptions::encode const): * loader/ResourceLoaderOptions.h: (WebCore::ResourceLoaderOptions::ResourceLoaderOptions): (WebCore::ResourceLoaderOptions::loadedFromOpaqueSource): * loader/cache/CachedImage.cpp: (WebCore::CachedImage::CachedImage): (WebCore::CachedImage::shouldDeferUpdateImageData const): (WebCore::CachedImage::didUpdateImageData): * loader/cache/CachedImage.h: * loader/cache/CachedResource.cpp: (WebCore::CachedResource::CachedResource): (WebCore::CachedResource::load): (WebCore::CachedResource::finish): * loader/cache/CachedResource.h: (WebCore::CachedResource::setStatus): * page/csp/ContentSecurityPolicyResponseHeaders.h: (WebCore::ContentSecurityPolicyResponseHeaders::MarkableTraits::isEmptyValue): (WebCore::ContentSecurityPolicyResponseHeaders::MarkableTraits::emptyValue): (WebCore::ContentSecurityPolicyResponseHeaders::ContentSecurityPolicyResponseHeaders): * platform/network/NetworkLoadMetrics.h: (WebCore::NetworkLoadMetrics::isolatedCopy const): (WebCore::NetworkLoadMetrics::clearNonTimingData): (WebCore::NetworkLoadMetrics::operator== const): (WebCore::NetworkLoadMetrics::encode const): (WebCore::NetworkLoadMetrics::decode): * platform/network/ResourceLoadPriority.h: * platform/network/ResourceRequestBase.h: (WebCore::ResourceRequestBase::ResourceRequestBase): * platform/network/ResourceResponseBase.h: * platform/network/StoredCredentialsPolicy.h: Source/WTF: * wtf/Markable.h: (WTF::Markable::asOptional const): Add helper method to get Optional easily from Markable. * wtf/ObjectIdentifier.h: (WTF::ObjectIdentifier::MarkableTraits::isEmptyValue): (WTF::ObjectIdentifier::MarkableTraits::emptyValue): (WTF::ObjectIdentifier::ObjectIdentifier): Add MarkableTraits for ObjectIdentifier. Canonical link: https://commits.webkit.org/220633@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256482 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-02-12 22:51:19 +00:00
struct MarkableTraits {
static bool isEmptyValue(ObjectIdentifier identifier)
{
return !identifier.m_identifier;
}
static constexpr ObjectIdentifier emptyValue()
{
return ObjectIdentifier();
}
};
Use a single identifier type to identify Service Workers https://bugs.webkit.org/show_bug.cgi?id=179192 Reviewed by Brady Eidson. Source/WebCore: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * WebCore.xcodeproj/project.pbxproj: * loader/ResourceLoaderOptions.h: * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::setSelectedServiceWorkerIdentifierIfNeeded): * loader/cache/CachedResourceRequest.h: * workers/service/ServiceWorker.cpp: (WebCore::ServiceWorker::ServiceWorker): * workers/service/ServiceWorker.h: * workers/service/ServiceWorkerClient.cpp: (WebCore::ServiceWorkerClient::postMessage): * workers/service/ServiceWorkerContainer.cpp: (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration): * workers/service/ServiceWorkerContextData.cpp: (WebCore::ServiceWorkerContextData::isolatedCopy const): * workers/service/ServiceWorkerContextData.h: (WebCore::ServiceWorkerContextData::encode const): (WebCore::ServiceWorkerContextData::decode): * workers/service/ServiceWorkerIdentifier.h: Copied from Source/WebCore/workers/service/ServiceWorkerContextData.cpp. * workers/service/ServiceWorkerRegistrationData.h: (WebCore::ServiceWorkerRegistrationData::decode): * workers/service/context/SWContextManager.cpp: (WebCore::SWContextManager::serviceWorkerThreadProxy const): (WebCore::SWContextManager::postMessageToServiceWorkerGlobalScope): * workers/service/context/SWContextManager.h: * workers/service/context/ServiceWorkerThread.cpp: (WebCore::ServiceWorkerThread::ServiceWorkerThread): * workers/service/context/ServiceWorkerThread.h: (WebCore::ServiceWorkerThread::identifier const): * workers/service/context/ServiceWorkerThreadProxy.h: * workers/service/server/SWClientConnection.cpp: (WebCore::SWClientConnection::postMessageToServiceWorkerClient): * workers/service/server/SWClientConnection.h: * workers/service/server/SWServer.cpp: (WebCore::generateServiceWorkerIdentifier): (WebCore::SWServer::Connection::scriptContextFailedToStart): (WebCore::SWServer::Connection::scriptContextStarted): (WebCore::SWServer::scriptContextFailedToStart): (WebCore::SWServer::scriptContextStarted): (WebCore::SWServer::updateWorker): * workers/service/server/SWServer.h: * workers/service/server/SWServerJobQueue.cpp: (WebCore::SWServerJobQueue::scriptContextFailedToStart): (WebCore::SWServerJobQueue::scriptContextStarted): * workers/service/server/SWServerJobQueue.h: * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::setActiveServiceWorkerIdentifier): * workers/service/server/SWServerWorker.cpp: (WebCore::SWServerWorker::SWServerWorker): * workers/service/server/SWServerWorker.h: (WebCore::SWServerWorker::create): (WebCore::SWServerWorker::identifier const): Source/WebKit: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * Scripts/webkit/messages.py: (forward_declarations_and_headers): (forward_declarations_and_headers.templates): * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::startFetch): (WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWServerConnection::postMessageToServiceWorkerClient): * StorageProcess/ServiceWorker/WebSWServerConnection.h: * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in: * StorageProcess/StorageProcess.cpp: (WebKit::StorageProcess::serviceWorkerContextFailedToStart): (WebKit::StorageProcess::serviceWorkerContextStarted): (WebKit::StorageProcess::postMessageToServiceWorkerClient): * StorageProcess/StorageProcess.h: * StorageProcess/StorageProcess.messages.in: * WebProcess/Storage/WebSWClientConnection.cpp: (WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWClientConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWClientConnection.h: * WebProcess/Storage/WebSWClientConnection.messages.in: * WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::updateServiceWorker): (WebKit::WebSWContextManagerConnection::serviceWorkerStartedWithMessage): (WebKit::WebSWContextManagerConnection::startFetch): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWContextManagerConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.messages.in: Source/WTF: Introduce class for strongly typed identifiers. This avoids mixing up different types of identifiers. * WTF.xcodeproj/project.pbxproj: * wtf/ObjectIdentifier.h: Added. (WTF::ObjectIdentifier::encode const): (WTF::ObjectIdentifier::decode): (WTF::ObjectIdentifier::operator== const): (WTF::ObjectIdentifier::operator!= const): (WTF::ObjectIdentifier::ObjectIdentifier): (WTF::makeObjectIdentifier): (WTF::ObjectIdentifierHash::hash): (WTF::ObjectIdentifierHash::equal): (WTF::HashTraits<ObjectIdentifier<T>>::emptyValue): (WTF::HashTraits<ObjectIdentifier<T>>::constructDeletedValue): (WTF::HashTraits<ObjectIdentifier<T>>::isDeletedValue): Canonical link: https://commits.webkit.org/195341@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224403 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-03 16:37:04 +00:00
private:
Use a strongly typed identifier for SWServer::Connection https://bugs.webkit.org/show_bug.cgi?id=179848 Reviewed by Brady Eidson. Source/WebCore: Use a strongly typed identifier for SWServer::Connection, for clarity. * workers/service/ServiceWorker.cpp: (WebCore::ServiceWorker::postMessage): * workers/service/ServiceWorkerClient.cpp: (WebCore::ServiceWorkerClient::ServiceWorkerClient): (WebCore::ServiceWorkerClient::id const): (WebCore::ServiceWorkerClient::postMessage): * workers/service/ServiceWorkerClient.h: (WebCore::ServiceWorkerClient::create): (WebCore::ServiceWorkerClient::identifier const): * workers/service/ServiceWorkerClientData.cpp: (WebCore::ServiceWorkerClientData::isolatedCopy const): (WebCore::ServiceWorkerClientData::from): * workers/service/ServiceWorkerClientData.h: (WebCore::ServiceWorkerClientData::encode const): (WebCore::ServiceWorkerClientData::decode): * workers/service/ServiceWorkerClientIdentifier.h: (WebCore::ServiceWorkerClientIdentifier::toString const): (WebCore::ServiceWorkerClientIdentifier::decode): * workers/service/ServiceWorkerContainer.cpp: (WebCore::ServiceWorkerContainer::addRegistration): (WebCore::ServiceWorkerContainer::removeRegistration): (WebCore::ServiceWorkerContainer::updateRegistration): (WebCore::ServiceWorkerContainer::connectionIdentifier): * workers/service/ServiceWorkerContainer.h: * workers/service/ServiceWorkerFetchResult.h: (WebCore::ServiceWorkerFetchResult::decode): * workers/service/ServiceWorkerJobClient.h: * workers/service/ServiceWorkerJobData.cpp: (WebCore::ServiceWorkerJobData::ServiceWorkerJobData): * workers/service/ServiceWorkerJobData.h: (WebCore::ServiceWorkerJobData::connectionIdentifier const): (WebCore::ServiceWorkerJobData::decode): * workers/service/ServiceWorkerTypes.h: * workers/service/ServiceWorkerWindowClient.cpp: (WebCore::ServiceWorkerWindowClient::ServiceWorkerWindowClient): * workers/service/ServiceWorkerWindowClient.h: * workers/service/context/SWContextManager.cpp: (WebCore::SWContextManager::postMessageToServiceWorkerGlobalScope): * workers/service/context/SWContextManager.h: * workers/service/context/ServiceWorkerThread.cpp: (WebCore::ServiceWorkerThread::postMessageToServiceWorkerGlobalScope): * workers/service/context/ServiceWorkerThread.h: * workers/service/server/SWClientConnection.h: * workers/service/server/SWServer.cpp: (WebCore::SWServer::Connection::Connection): (WebCore::SWServer::Connection::scheduleJobInServer): (WebCore::SWServer::rejectJob): (WebCore::SWServer::resolveRegistrationJob): (WebCore::SWServer::startScriptFetch): (WebCore::SWServer::scriptFetchFinished): * workers/service/server/SWServer.h: (WebCore::SWServer::Connection::identifier const): (WebCore::SWServer::getConnection): * workers/service/server/SWServerRegistration.cpp: (WebCore::SWServerRegistration::forEachConnection): (WebCore::SWServerRegistration::addClientServiceWorkerRegistration): (WebCore::SWServerRegistration::removeClientServiceWorkerRegistration): (WebCore::SWServerRegistration::unregisterServerConnection): * workers/service/server/SWServerRegistration.h: Source/WebKit: Use a strongly typed identifier for SWServer::Connection, for clarity. * Scripts/webkit/messages.py: (forward_declarations_and_headers): (forward_declarations_and_headers.templates): (headers_for_type): * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::WebSWServerConnection): (WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope): * StorageProcess/ServiceWorker/WebSWServerConnection.h: * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in: * StorageProcess/StorageProcess.cpp: (WebKit::StorageProcess::didFailFetch): (WebKit::StorageProcess::didNotHandleFetch): (WebKit::StorageProcess::didReceiveFetchResponse): (WebKit::StorageProcess::didReceiveFetchData): (WebKit::StorageProcess::didReceiveFetchFormData): (WebKit::StorageProcess::didFinishFetch): * StorageProcess/StorageProcess.h: * StorageProcess/StorageProcess.messages.in: * StorageProcess/StorageToWebProcessConnection.cpp: (WebKit::StorageToWebProcessConnection::didReceiveMessage): (WebKit::StorageToWebProcessConnection::establishSWServerConnection): (WebKit::StorageToWebProcessConnection::removeSWServerConnection): (WebKit::generateIDBConnectionToServerIdentifier): (WebKit::StorageToWebProcessConnection::establishIDBConnectionToServer): * StorageProcess/StorageToWebProcessConnection.h: * StorageProcess/StorageToWebProcessConnection.messages.in: * WebProcess/Storage/WebSWClientConnection.cpp: (WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope): * WebProcess/Storage/WebSWClientConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::startFetch): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope): * WebProcess/Storage/WebSWContextManagerConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.messages.in: * WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp: (WebKit::WebServiceWorkerFetchTaskClient::WebServiceWorkerFetchTaskClient): * WebProcess/Storage/WebServiceWorkerFetchTaskClient.h: * WebProcess/Storage/WebToStorageProcessConnection.cpp: (WebKit::WebToStorageProcessConnection::didReceiveMessage): (WebKit::WebToStorageProcessConnection::serviceWorkerConnectionForSession): * WebProcess/Storage/WebToStorageProcessConnection.h: Source/WTF: Make ObjectIdentifier a little more flexible to support more use cases. * wtf/ObjectIdentifier.h: (WTF::ObjectIdentifier::toUInt64 const): (WTF::makeObjectIdentifier): Canonical link: https://commits.webkit.org/195877@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225008 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-18 02:27:13 +00:00
template<typename U> friend ObjectIdentifier<U> makeObjectIdentifier(uint64_t);
Use a single identifier type to identify Service Workers https://bugs.webkit.org/show_bug.cgi?id=179192 Reviewed by Brady Eidson. Source/WebCore: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * WebCore.xcodeproj/project.pbxproj: * loader/ResourceLoaderOptions.h: * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::setSelectedServiceWorkerIdentifierIfNeeded): * loader/cache/CachedResourceRequest.h: * workers/service/ServiceWorker.cpp: (WebCore::ServiceWorker::ServiceWorker): * workers/service/ServiceWorker.h: * workers/service/ServiceWorkerClient.cpp: (WebCore::ServiceWorkerClient::postMessage): * workers/service/ServiceWorkerContainer.cpp: (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration): * workers/service/ServiceWorkerContextData.cpp: (WebCore::ServiceWorkerContextData::isolatedCopy const): * workers/service/ServiceWorkerContextData.h: (WebCore::ServiceWorkerContextData::encode const): (WebCore::ServiceWorkerContextData::decode): * workers/service/ServiceWorkerIdentifier.h: Copied from Source/WebCore/workers/service/ServiceWorkerContextData.cpp. * workers/service/ServiceWorkerRegistrationData.h: (WebCore::ServiceWorkerRegistrationData::decode): * workers/service/context/SWContextManager.cpp: (WebCore::SWContextManager::serviceWorkerThreadProxy const): (WebCore::SWContextManager::postMessageToServiceWorkerGlobalScope): * workers/service/context/SWContextManager.h: * workers/service/context/ServiceWorkerThread.cpp: (WebCore::ServiceWorkerThread::ServiceWorkerThread): * workers/service/context/ServiceWorkerThread.h: (WebCore::ServiceWorkerThread::identifier const): * workers/service/context/ServiceWorkerThreadProxy.h: * workers/service/server/SWClientConnection.cpp: (WebCore::SWClientConnection::postMessageToServiceWorkerClient): * workers/service/server/SWClientConnection.h: * workers/service/server/SWServer.cpp: (WebCore::generateServiceWorkerIdentifier): (WebCore::SWServer::Connection::scriptContextFailedToStart): (WebCore::SWServer::Connection::scriptContextStarted): (WebCore::SWServer::scriptContextFailedToStart): (WebCore::SWServer::scriptContextStarted): (WebCore::SWServer::updateWorker): * workers/service/server/SWServer.h: * workers/service/server/SWServerJobQueue.cpp: (WebCore::SWServerJobQueue::scriptContextFailedToStart): (WebCore::SWServerJobQueue::scriptContextStarted): * workers/service/server/SWServerJobQueue.h: * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::setActiveServiceWorkerIdentifier): * workers/service/server/SWServerWorker.cpp: (WebCore::SWServerWorker::SWServerWorker): * workers/service/server/SWServerWorker.h: (WebCore::SWServerWorker::create): (WebCore::SWServerWorker::identifier const): Source/WebKit: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * Scripts/webkit/messages.py: (forward_declarations_and_headers): (forward_declarations_and_headers.templates): * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::startFetch): (WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWServerConnection::postMessageToServiceWorkerClient): * StorageProcess/ServiceWorker/WebSWServerConnection.h: * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in: * StorageProcess/StorageProcess.cpp: (WebKit::StorageProcess::serviceWorkerContextFailedToStart): (WebKit::StorageProcess::serviceWorkerContextStarted): (WebKit::StorageProcess::postMessageToServiceWorkerClient): * StorageProcess/StorageProcess.h: * StorageProcess/StorageProcess.messages.in: * WebProcess/Storage/WebSWClientConnection.cpp: (WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWClientConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWClientConnection.h: * WebProcess/Storage/WebSWClientConnection.messages.in: * WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::updateServiceWorker): (WebKit::WebSWContextManagerConnection::serviceWorkerStartedWithMessage): (WebKit::WebSWContextManagerConnection::startFetch): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWContextManagerConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.messages.in: Source/WTF: Introduce class for strongly typed identifiers. This avoids mixing up different types of identifiers. * WTF.xcodeproj/project.pbxproj: * wtf/ObjectIdentifier.h: Added. (WTF::ObjectIdentifier::encode const): (WTF::ObjectIdentifier::decode): (WTF::ObjectIdentifier::operator== const): (WTF::ObjectIdentifier::operator!= const): (WTF::ObjectIdentifier::ObjectIdentifier): (WTF::makeObjectIdentifier): (WTF::ObjectIdentifierHash::hash): (WTF::ObjectIdentifierHash::equal): (WTF::HashTraits<ObjectIdentifier<T>>::emptyValue): (WTF::HashTraits<ObjectIdentifier<T>>::constructDeletedValue): (WTF::HashTraits<ObjectIdentifier<T>>::isDeletedValue): Canonical link: https://commits.webkit.org/195341@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224403 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-03 16:37:04 +00:00
friend struct HashTraits<ObjectIdentifier>;
template<typename U> friend struct ObjectIdentifierHash;
static uint64_t hashTableDeletedValue() { return std::numeric_limits<uint64_t>::max(); }
static bool isValidIdentifier(uint64_t identifier) { return identifier && identifier != hashTableDeletedValue(); }
Shrink CachedResource https://bugs.webkit.org/show_bug.cgi?id=207618 Reviewed by Mark Lam. Source/WebCore: This patch shrinks sizeof(CachedResource) by 80 bytes by aggressively using bit-fields and Markable<>. For each enum class, we define `bitsOfXXX` value, which indicates # of bits to represent it. And using this value for bit-field's width. No behavior change. * loader/FetchOptions.h: (WebCore::FetchOptions::encode const): * loader/ResourceLoaderOptions.h: (WebCore::ResourceLoaderOptions::ResourceLoaderOptions): (WebCore::ResourceLoaderOptions::loadedFromOpaqueSource): * loader/cache/CachedImage.cpp: (WebCore::CachedImage::CachedImage): (WebCore::CachedImage::shouldDeferUpdateImageData const): (WebCore::CachedImage::didUpdateImageData): * loader/cache/CachedImage.h: * loader/cache/CachedResource.cpp: (WebCore::CachedResource::CachedResource): (WebCore::CachedResource::load): (WebCore::CachedResource::finish): * loader/cache/CachedResource.h: (WebCore::CachedResource::setStatus): * page/csp/ContentSecurityPolicyResponseHeaders.h: (WebCore::ContentSecurityPolicyResponseHeaders::MarkableTraits::isEmptyValue): (WebCore::ContentSecurityPolicyResponseHeaders::MarkableTraits::emptyValue): (WebCore::ContentSecurityPolicyResponseHeaders::ContentSecurityPolicyResponseHeaders): * platform/network/NetworkLoadMetrics.h: (WebCore::NetworkLoadMetrics::isolatedCopy const): (WebCore::NetworkLoadMetrics::clearNonTimingData): (WebCore::NetworkLoadMetrics::operator== const): (WebCore::NetworkLoadMetrics::encode const): (WebCore::NetworkLoadMetrics::decode): * platform/network/ResourceLoadPriority.h: * platform/network/ResourceRequestBase.h: (WebCore::ResourceRequestBase::ResourceRequestBase): * platform/network/ResourceResponseBase.h: * platform/network/StoredCredentialsPolicy.h: Source/WTF: * wtf/Markable.h: (WTF::Markable::asOptional const): Add helper method to get Optional easily from Markable. * wtf/ObjectIdentifier.h: (WTF::ObjectIdentifier::MarkableTraits::isEmptyValue): (WTF::ObjectIdentifier::MarkableTraits::emptyValue): (WTF::ObjectIdentifier::ObjectIdentifier): Add MarkableTraits for ObjectIdentifier. Canonical link: https://commits.webkit.org/220633@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@256482 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-02-12 22:51:19 +00:00
explicit constexpr ObjectIdentifier(uint64_t identifier)
Use a single identifier type to identify Service Workers https://bugs.webkit.org/show_bug.cgi?id=179192 Reviewed by Brady Eidson. Source/WebCore: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * WebCore.xcodeproj/project.pbxproj: * loader/ResourceLoaderOptions.h: * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::setSelectedServiceWorkerIdentifierIfNeeded): * loader/cache/CachedResourceRequest.h: * workers/service/ServiceWorker.cpp: (WebCore::ServiceWorker::ServiceWorker): * workers/service/ServiceWorker.h: * workers/service/ServiceWorkerClient.cpp: (WebCore::ServiceWorkerClient::postMessage): * workers/service/ServiceWorkerContainer.cpp: (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration): * workers/service/ServiceWorkerContextData.cpp: (WebCore::ServiceWorkerContextData::isolatedCopy const): * workers/service/ServiceWorkerContextData.h: (WebCore::ServiceWorkerContextData::encode const): (WebCore::ServiceWorkerContextData::decode): * workers/service/ServiceWorkerIdentifier.h: Copied from Source/WebCore/workers/service/ServiceWorkerContextData.cpp. * workers/service/ServiceWorkerRegistrationData.h: (WebCore::ServiceWorkerRegistrationData::decode): * workers/service/context/SWContextManager.cpp: (WebCore::SWContextManager::serviceWorkerThreadProxy const): (WebCore::SWContextManager::postMessageToServiceWorkerGlobalScope): * workers/service/context/SWContextManager.h: * workers/service/context/ServiceWorkerThread.cpp: (WebCore::ServiceWorkerThread::ServiceWorkerThread): * workers/service/context/ServiceWorkerThread.h: (WebCore::ServiceWorkerThread::identifier const): * workers/service/context/ServiceWorkerThreadProxy.h: * workers/service/server/SWClientConnection.cpp: (WebCore::SWClientConnection::postMessageToServiceWorkerClient): * workers/service/server/SWClientConnection.h: * workers/service/server/SWServer.cpp: (WebCore::generateServiceWorkerIdentifier): (WebCore::SWServer::Connection::scriptContextFailedToStart): (WebCore::SWServer::Connection::scriptContextStarted): (WebCore::SWServer::scriptContextFailedToStart): (WebCore::SWServer::scriptContextStarted): (WebCore::SWServer::updateWorker): * workers/service/server/SWServer.h: * workers/service/server/SWServerJobQueue.cpp: (WebCore::SWServerJobQueue::scriptContextFailedToStart): (WebCore::SWServerJobQueue::scriptContextStarted): * workers/service/server/SWServerJobQueue.h: * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::setActiveServiceWorkerIdentifier): * workers/service/server/SWServerWorker.cpp: (WebCore::SWServerWorker::SWServerWorker): * workers/service/server/SWServerWorker.h: (WebCore::SWServerWorker::create): (WebCore::SWServerWorker::identifier const): Source/WebKit: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * Scripts/webkit/messages.py: (forward_declarations_and_headers): (forward_declarations_and_headers.templates): * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::startFetch): (WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWServerConnection::postMessageToServiceWorkerClient): * StorageProcess/ServiceWorker/WebSWServerConnection.h: * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in: * StorageProcess/StorageProcess.cpp: (WebKit::StorageProcess::serviceWorkerContextFailedToStart): (WebKit::StorageProcess::serviceWorkerContextStarted): (WebKit::StorageProcess::postMessageToServiceWorkerClient): * StorageProcess/StorageProcess.h: * StorageProcess/StorageProcess.messages.in: * WebProcess/Storage/WebSWClientConnection.cpp: (WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWClientConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWClientConnection.h: * WebProcess/Storage/WebSWClientConnection.messages.in: * WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::updateServiceWorker): (WebKit::WebSWContextManagerConnection::serviceWorkerStartedWithMessage): (WebKit::WebSWContextManagerConnection::startFetch): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWContextManagerConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.messages.in: Source/WTF: Introduce class for strongly typed identifiers. This avoids mixing up different types of identifiers. * WTF.xcodeproj/project.pbxproj: * wtf/ObjectIdentifier.h: Added. (WTF::ObjectIdentifier::encode const): (WTF::ObjectIdentifier::decode): (WTF::ObjectIdentifier::operator== const): (WTF::ObjectIdentifier::operator!= const): (WTF::ObjectIdentifier::ObjectIdentifier): (WTF::makeObjectIdentifier): (WTF::ObjectIdentifierHash::hash): (WTF::ObjectIdentifierHash::equal): (WTF::HashTraits<ObjectIdentifier<T>>::emptyValue): (WTF::HashTraits<ObjectIdentifier<T>>::constructDeletedValue): (WTF::HashTraits<ObjectIdentifier<T>>::isDeletedValue): Canonical link: https://commits.webkit.org/195341@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224403 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-03 16:37:04 +00:00
: m_identifier(identifier)
{
}
uint64_t m_identifier { 0 };
Make ContentWorlds be identified by an ObjectIdentifier instead of a uint64_t https://bugs.webkit.org/show_bug.cgi?id=206784 Reviewed by Alex Christensen. Source/WebKit: Refactor: No behavior change. * Scripts/webkit/messages.py: * Shared/AuxiliaryProcess.cpp: (WebKit::AuxiliaryProcess::initialize): * Shared/ContentWorldShared.h: (WebKit::pageContentWorldIdentifier): * Shared/WebPageCreationParameters.cpp: (WebKit::WebPageCreationParameters::decode): * Shared/WebPageCreationParameters.h: * Shared/WebUserContentControllerDataTypes.cpp: (WebKit::WebUserScriptData::decode): (WebKit::WebUserStyleSheetData::decode): (WebKit::WebScriptMessageHandlerData::decode): * Shared/WebUserContentControllerDataTypes.h: * UIProcess/API/APIContentWorld.cpp: (API::ContentWorld::pageContentWorld): (API::ContentWorld::defaultClientWorld): (API::ContentWorld::ContentWorld): (API::ContentWorldBase::generateIdentifier): Deleted. * UIProcess/API/APIContentWorld.h: (API::ContentWorldBase::identifier const): (API::ContentWorldBase::worldData const): (API::ContentWorldBase::ContentWorldBase): * UIProcess/API/APIUserContentWorld.cpp: (API::UserContentWorld::UserContentWorld): * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::removeUserContentWorldUses): (WebKit::WebUserContentControllerProxy::removeAllUserScripts): (WebKit::WebUserContentControllerProxy::removeAllUserStyleSheets): * WebProcess/UserContent/WebUserContentController.cpp: (WebKit::worldMap): (WebKit::WebUserContentController::worldForIdentifier): (WebKit::WebUserContentController::addUserContentWorld): (WebKit::WebUserContentController::addUserContentWorlds): (WebKit::WebUserContentController::removeUserContentWorlds): (WebKit::WebUserContentController::addUserScripts): (WebKit::WebUserContentController::removeUserScript): (WebKit::WebUserContentController::removeAllUserScripts): (WebKit::WebUserContentController::addUserStyleSheets): (WebKit::WebUserContentController::removeUserStyleSheet): (WebKit::WebUserContentController::removeAllUserStyleSheets): (WebKit::WebUserContentController::addUserScriptMessageHandlers): (WebKit::WebUserContentController::removeUserScriptMessageHandler): (WebKit::WebUserContentController::removeAllUserScriptMessageHandlers): * WebProcess/UserContent/WebUserContentController.h: * WebProcess/UserContent/WebUserContentController.messages.in: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::runJavaScript): (WebKit::WebPage::runJavaScriptInMainFrameScriptWorld): (WebKit::WebPage::runJavaScriptInFrame): * WebProcess/WebPage/WebPage.h: * WebProcess/WebPage/WebPage.messages.in: Source/WTF: * wtf/ObjectIdentifier.h: (WTF::ObjectIdentifier::generate): (WTF::ObjectIdentifier::generateThreadSafe): (WTF::ObjectIdentifier::enableGenerationProtection): To allow restricting generating an identifier to the UIProcess. Canonical link: https://commits.webkit.org/219791@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255127 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-26 05:43:29 +00:00
inline static bool m_generationProtected { false };
Use a single identifier type to identify Service Workers https://bugs.webkit.org/show_bug.cgi?id=179192 Reviewed by Brady Eidson. Source/WebCore: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * WebCore.xcodeproj/project.pbxproj: * loader/ResourceLoaderOptions.h: * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::setSelectedServiceWorkerIdentifierIfNeeded): * loader/cache/CachedResourceRequest.h: * workers/service/ServiceWorker.cpp: (WebCore::ServiceWorker::ServiceWorker): * workers/service/ServiceWorker.h: * workers/service/ServiceWorkerClient.cpp: (WebCore::ServiceWorkerClient::postMessage): * workers/service/ServiceWorkerContainer.cpp: (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration): * workers/service/ServiceWorkerContextData.cpp: (WebCore::ServiceWorkerContextData::isolatedCopy const): * workers/service/ServiceWorkerContextData.h: (WebCore::ServiceWorkerContextData::encode const): (WebCore::ServiceWorkerContextData::decode): * workers/service/ServiceWorkerIdentifier.h: Copied from Source/WebCore/workers/service/ServiceWorkerContextData.cpp. * workers/service/ServiceWorkerRegistrationData.h: (WebCore::ServiceWorkerRegistrationData::decode): * workers/service/context/SWContextManager.cpp: (WebCore::SWContextManager::serviceWorkerThreadProxy const): (WebCore::SWContextManager::postMessageToServiceWorkerGlobalScope): * workers/service/context/SWContextManager.h: * workers/service/context/ServiceWorkerThread.cpp: (WebCore::ServiceWorkerThread::ServiceWorkerThread): * workers/service/context/ServiceWorkerThread.h: (WebCore::ServiceWorkerThread::identifier const): * workers/service/context/ServiceWorkerThreadProxy.h: * workers/service/server/SWClientConnection.cpp: (WebCore::SWClientConnection::postMessageToServiceWorkerClient): * workers/service/server/SWClientConnection.h: * workers/service/server/SWServer.cpp: (WebCore::generateServiceWorkerIdentifier): (WebCore::SWServer::Connection::scriptContextFailedToStart): (WebCore::SWServer::Connection::scriptContextStarted): (WebCore::SWServer::scriptContextFailedToStart): (WebCore::SWServer::scriptContextStarted): (WebCore::SWServer::updateWorker): * workers/service/server/SWServer.h: * workers/service/server/SWServerJobQueue.cpp: (WebCore::SWServerJobQueue::scriptContextFailedToStart): (WebCore::SWServerJobQueue::scriptContextStarted): * workers/service/server/SWServerJobQueue.h: * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::setActiveServiceWorkerIdentifier): * workers/service/server/SWServerWorker.cpp: (WebCore::SWServerWorker::SWServerWorker): * workers/service/server/SWServerWorker.h: (WebCore::SWServerWorker::create): (WebCore::SWServerWorker::identifier const): Source/WebKit: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * Scripts/webkit/messages.py: (forward_declarations_and_headers): (forward_declarations_and_headers.templates): * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::startFetch): (WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWServerConnection::postMessageToServiceWorkerClient): * StorageProcess/ServiceWorker/WebSWServerConnection.h: * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in: * StorageProcess/StorageProcess.cpp: (WebKit::StorageProcess::serviceWorkerContextFailedToStart): (WebKit::StorageProcess::serviceWorkerContextStarted): (WebKit::StorageProcess::postMessageToServiceWorkerClient): * StorageProcess/StorageProcess.h: * StorageProcess/StorageProcess.messages.in: * WebProcess/Storage/WebSWClientConnection.cpp: (WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWClientConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWClientConnection.h: * WebProcess/Storage/WebSWClientConnection.messages.in: * WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::updateServiceWorker): (WebKit::WebSWContextManagerConnection::serviceWorkerStartedWithMessage): (WebKit::WebSWContextManagerConnection::startFetch): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWContextManagerConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.messages.in: Source/WTF: Introduce class for strongly typed identifiers. This avoids mixing up different types of identifiers. * WTF.xcodeproj/project.pbxproj: * wtf/ObjectIdentifier.h: Added. (WTF::ObjectIdentifier::encode const): (WTF::ObjectIdentifier::decode): (WTF::ObjectIdentifier::operator== const): (WTF::ObjectIdentifier::operator!= const): (WTF::ObjectIdentifier::ObjectIdentifier): (WTF::makeObjectIdentifier): (WTF::ObjectIdentifierHash::hash): (WTF::ObjectIdentifierHash::equal): (WTF::HashTraits<ObjectIdentifier<T>>::emptyValue): (WTF::HashTraits<ObjectIdentifier<T>>::constructDeletedValue): (WTF::HashTraits<ObjectIdentifier<T>>::isDeletedValue): Canonical link: https://commits.webkit.org/195341@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224403 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-03 16:37:04 +00:00
};
Use a strongly typed identifier for SWServer::Connection https://bugs.webkit.org/show_bug.cgi?id=179848 Reviewed by Brady Eidson. Source/WebCore: Use a strongly typed identifier for SWServer::Connection, for clarity. * workers/service/ServiceWorker.cpp: (WebCore::ServiceWorker::postMessage): * workers/service/ServiceWorkerClient.cpp: (WebCore::ServiceWorkerClient::ServiceWorkerClient): (WebCore::ServiceWorkerClient::id const): (WebCore::ServiceWorkerClient::postMessage): * workers/service/ServiceWorkerClient.h: (WebCore::ServiceWorkerClient::create): (WebCore::ServiceWorkerClient::identifier const): * workers/service/ServiceWorkerClientData.cpp: (WebCore::ServiceWorkerClientData::isolatedCopy const): (WebCore::ServiceWorkerClientData::from): * workers/service/ServiceWorkerClientData.h: (WebCore::ServiceWorkerClientData::encode const): (WebCore::ServiceWorkerClientData::decode): * workers/service/ServiceWorkerClientIdentifier.h: (WebCore::ServiceWorkerClientIdentifier::toString const): (WebCore::ServiceWorkerClientIdentifier::decode): * workers/service/ServiceWorkerContainer.cpp: (WebCore::ServiceWorkerContainer::addRegistration): (WebCore::ServiceWorkerContainer::removeRegistration): (WebCore::ServiceWorkerContainer::updateRegistration): (WebCore::ServiceWorkerContainer::connectionIdentifier): * workers/service/ServiceWorkerContainer.h: * workers/service/ServiceWorkerFetchResult.h: (WebCore::ServiceWorkerFetchResult::decode): * workers/service/ServiceWorkerJobClient.h: * workers/service/ServiceWorkerJobData.cpp: (WebCore::ServiceWorkerJobData::ServiceWorkerJobData): * workers/service/ServiceWorkerJobData.h: (WebCore::ServiceWorkerJobData::connectionIdentifier const): (WebCore::ServiceWorkerJobData::decode): * workers/service/ServiceWorkerTypes.h: * workers/service/ServiceWorkerWindowClient.cpp: (WebCore::ServiceWorkerWindowClient::ServiceWorkerWindowClient): * workers/service/ServiceWorkerWindowClient.h: * workers/service/context/SWContextManager.cpp: (WebCore::SWContextManager::postMessageToServiceWorkerGlobalScope): * workers/service/context/SWContextManager.h: * workers/service/context/ServiceWorkerThread.cpp: (WebCore::ServiceWorkerThread::postMessageToServiceWorkerGlobalScope): * workers/service/context/ServiceWorkerThread.h: * workers/service/server/SWClientConnection.h: * workers/service/server/SWServer.cpp: (WebCore::SWServer::Connection::Connection): (WebCore::SWServer::Connection::scheduleJobInServer): (WebCore::SWServer::rejectJob): (WebCore::SWServer::resolveRegistrationJob): (WebCore::SWServer::startScriptFetch): (WebCore::SWServer::scriptFetchFinished): * workers/service/server/SWServer.h: (WebCore::SWServer::Connection::identifier const): (WebCore::SWServer::getConnection): * workers/service/server/SWServerRegistration.cpp: (WebCore::SWServerRegistration::forEachConnection): (WebCore::SWServerRegistration::addClientServiceWorkerRegistration): (WebCore::SWServerRegistration::removeClientServiceWorkerRegistration): (WebCore::SWServerRegistration::unregisterServerConnection): * workers/service/server/SWServerRegistration.h: Source/WebKit: Use a strongly typed identifier for SWServer::Connection, for clarity. * Scripts/webkit/messages.py: (forward_declarations_and_headers): (forward_declarations_and_headers.templates): (headers_for_type): * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::WebSWServerConnection): (WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope): * StorageProcess/ServiceWorker/WebSWServerConnection.h: * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in: * StorageProcess/StorageProcess.cpp: (WebKit::StorageProcess::didFailFetch): (WebKit::StorageProcess::didNotHandleFetch): (WebKit::StorageProcess::didReceiveFetchResponse): (WebKit::StorageProcess::didReceiveFetchData): (WebKit::StorageProcess::didReceiveFetchFormData): (WebKit::StorageProcess::didFinishFetch): * StorageProcess/StorageProcess.h: * StorageProcess/StorageProcess.messages.in: * StorageProcess/StorageToWebProcessConnection.cpp: (WebKit::StorageToWebProcessConnection::didReceiveMessage): (WebKit::StorageToWebProcessConnection::establishSWServerConnection): (WebKit::StorageToWebProcessConnection::removeSWServerConnection): (WebKit::generateIDBConnectionToServerIdentifier): (WebKit::StorageToWebProcessConnection::establishIDBConnectionToServer): * StorageProcess/StorageToWebProcessConnection.h: * StorageProcess/StorageToWebProcessConnection.messages.in: * WebProcess/Storage/WebSWClientConnection.cpp: (WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope): * WebProcess/Storage/WebSWClientConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::startFetch): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope): * WebProcess/Storage/WebSWContextManagerConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.messages.in: * WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp: (WebKit::WebServiceWorkerFetchTaskClient::WebServiceWorkerFetchTaskClient): * WebProcess/Storage/WebServiceWorkerFetchTaskClient.h: * WebProcess/Storage/WebToStorageProcessConnection.cpp: (WebKit::WebToStorageProcessConnection::didReceiveMessage): (WebKit::WebToStorageProcessConnection::serviceWorkerConnectionForSession): * WebProcess/Storage/WebToStorageProcessConnection.h: Source/WTF: Make ObjectIdentifier a little more flexible to support more use cases. * wtf/ObjectIdentifier.h: (WTF::ObjectIdentifier::toUInt64 const): (WTF::makeObjectIdentifier): Canonical link: https://commits.webkit.org/195877@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225008 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-18 02:27:13 +00:00
template<typename T> inline ObjectIdentifier<T> makeObjectIdentifier(uint64_t identifier)
{
return ObjectIdentifier<T> { identifier };
}
Use Hasher more, remove IntegerHasher, fix hashing-related mistakes https://bugs.webkit.org/show_bug.cgi?id=224138 Reviewed by Chris Dumez. Source/JavaScriptCore: * bytecode/BytecodeIndex.h: (JSC::BytecodeIndex::hash const): Remove unneeded WTF prefix on call to intHash. * ftl/FTLAbstractHeap.h: Use HashTraits instead of WTF::GenericHashTraits. * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::validateAIState): Remove unneeded WTF prefix on call to intHash. * wasm/WasmLLIntGenerator.cpp: Use HashTraits instead of WTF::GenericHashTraits. Source/WebCore: * contentextensions/ContentExtensionRule.h: (WebCore::ContentExtensions::TriggerHash::hash): Use computeHash to hash all the fields instead of a custom-written algorithm. The custom algorithm had some magic numbers, repeatedly hashed hashes, and combined hashes using exclusive or. The new one is almost certainly better. * contentextensions/Term.h: (WebCore::ContentExtensions::Term::CharacterSet::hash const): Use computeHash to hash the boolean and the characters rather than using intHash and pairIntHash. * css/parser/CSSParserContext.cpp: (WebCore::add): Moved the hashing here from the header. Fixed the mistake where this was using & instead of | and so none of the booleans were having any effect on the hash value. * css/parser/CSSParserContext.h: Use WTF_MAKE_STRUCT_FAST_ALLOCATED so we don't have to say public: explicitly. Also moved all the function members to the bottom of the struct. This is typically preferred style for structures as opposed to classes. Since the data members are the primary interface, they are first, and all function members are secondary and so they come after. (WebCore::CSSParserContextHash::hash): Use convertHash instead of a custom written hash function. The custom written function was combining hahes using exclusive or, not a best practice, and also had a mistake where it used & instead of | and so the "bits" local variable was always 0. * html/FormController.cpp: Use HashTraits instead of WTF::GenericHashTraits. * platform/encryptedmedia/CDMProxy.h: Removed unneedes includes. * platform/graphics/Font.cpp: Changed CharacterFallbackMapKey into a simple struct with no additional function members or static data members. Changed CharacterFallbackMapKeyHash to use computeHash to calculate the hash, instead of IntegerHasher. Probably better to hash the pointer of the AtomString rather than hashing the hash, but either way, we should have the best implementation for AtomString hashing in the Hasher class. Added CharacterFallbackMapKeyHashTraits instead of using SimpleClassHashTraits. Use the value U_SENTINEL for the UChar32 character, which is the same as the -1 used before, but slightly clearer why it's OK. (WebCore::Font::systemFallbackFontForCharacter const): Use HashMap::ensure instead of HashMap::add to make the logic simpler. * platform/graphics/Font.h: Use bool instead of uint8_t as the base type for the No/Yes enumeration IsForPlatformFont. * platform/graphics/FontCache.cpp: Removed unneeded "using namespace WTF", which is not our best practice, especially given unified builds. Changed FontPlatformDataCacheKey into a simple struct, removing all the hash-related member functions. Also used struct-style naming for the members without an "m_" prefix. Used the type FontFamilyName for the family name, which means we will use FontCascadeDescription's system for hashing and comparing family names for equality without having to remember do to so explicitly. Changed FontPlatformDataCacheKeyHash to use computeHash. The old version had unnecessarily complex logic to handle Optional and was unnecessarily hashing hashes. (WebCore::FontCache::cachedFontPlatformData): Renamed to remove "get" from the function's name. Also use shorter argument and local variable names that are single words, and updated since FontPlatformDataCacheKey is now a struct without a constructor. (WebCore::FontCache::fontForFamily): Use shorter names. (WebCore::operator==): To compare two FontCascadeCacheKey objects, use a simpler constructions, depending on the fact that Vector already has an == operator and we are using FontFamilyName for the elements of the vector, which has a correct == operator. (WebCore::FontCascadeCacheKeyHash::hash): Use computeHash since the FontFamilyName hashing is now correct, and we can rely on the way Hasher knows how to iterate a collection. (WebCore::FontCache::retrieveOrAddCachedFonts): Update since FontCascadeCacheEntry is now a simple struct. Also use constexpr a bit. (WebCore::FontCache::invalidate): Use copyToVectorOf<> to simplify the code that calls fontCacheInvalidated on all the font selectors. * platform/graphics/FontCache.h: Use "using" instead of "typedef". Remove FontDescriptionKey::computeHash. (WebCore::add): An overload of add for Hasher to include a FontDescriptionKey in a hash, which just lists all the data members. The old version did a hash of hashes, but that's not needed any more. Updated FontDescriptionKeyHash to use the Hasher version of ComputeHash. Added FontFamilyName. Change FontCascadeCacheKey to use a vector of FontFamilyName instead of AtomString. In FontCascadeCacheEntry, use WTF_MAKE_STRUCT_FAST_ALLOCATED instead of WTF_MAKE_FAST_ALLOCATED and also got rid of the unneeeded constructor. (WebCore::FontCascadeCacheKeyHashTraits::constructDeletedValue): Use the deleted value of FontDescriptionKey. (WebCore::FontCascadeCacheKeyHashTraits::isDeletedValue): Ditto. Renamed getCachedFontPlatformData to just cachedFontPlatformData. * platform/graphics/FontGenericFamilies.h: Use HashTraits instead of WTF::GenericHashTraits. * platform/graphics/FontSelectionAlgorithm.h: (WebCore::FontSelectionRange::uniqueValue const): Deleted. (WebCore::add): Add both the minimum and maximum values to the hash separately instead of combining them. For now, this makes the way they are hashed a bit inefficient, but that can be re-tightened up by improving the algorithm of Hasher if we like. Should be fine for our needs either way. * platform/graphics/FontTaggedSettings.cpp: (WebCore::FontFeatureSettings::hash const): Deleted. (WebCore::FontVariationSettings::hash const): Deleted. * platform/graphics/FontTaggedSettings.h: Added overloads of the add(Hasher&) function for std::array<char, 4> and FontTaggedSetting<T>. Got rid of many uses of pass by reference instead of value for FontTag, since it fits into a 32-bit register and bth more source code and less efficient to pass by value. * platform/graphics/Gradient.cpp: Removed "using WTF::pairIntHash" since that's now done in the WTF header. * platform/graphics/cg/GraphicsContextCG.cpp: Ditto. Also removed "using WTF::GenericHashTraits", which was unhelpful. The GenericHashTraits template is only really needed when specializing HashTraits, which already has to be done within the WTF namespace. In all other cases, we should just use HashTraits instead. * platform/graphics/cg/SubimageCacheWithTimer.h: Use HashTraits instead of WTF::GenericHashTraits. * platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp: Move the data members to the top of the FontFamilySpecificationKey struct. Removed unneeded computeHash function and WTF prefix from safeCFEqual. (WebCore::FontFamilySpecificationKeyHash::hash): Call the Hasher version of computeHash directly to hash the two items in this structure. * platform/graphics/cocoa/SystemFontDatabaseCoreText.h: (WebCore::SystemFontDatabaseCoreText::CascadeListParameters::hash const): Use computeHash instead of IntegerHasher. Also renamed the hash function struct from CascadeListParameters::CascadeListParametersHash to CascadeListParameters::Hash. * platform/graphics/mac/ComplexTextControllerCoreText.mm: (WebCore::ComplexTextController::collectComplexTextRunsForCharacters): Removed now-unneeded WTF prefixes from calls to safeCFEqual. * rendering/TextAutoSizing.h: Use HashTraits instead of WTF::GenericHashTraits. * rendering/style/RenderStyle.cpp: (WebCore::computeFontHash): Use computeHash instead of IntegerHasher. Still not great that we hash a hash here, but we can improve that later. * workers/service/ServiceWorkerClientIdentifier.h: (WebCore::ServiceWorkerClientIdentifier::decode): Removed unneeded WTFMove on ObjectIdentifier, which are just integers, so move vs. copy is not an important distinction. (WebCore::ServiceWorkerClientIdentifier::hash const): Use computeHash instead of combining intHash with StringHasher::hashMemory. This fixes two mistakes: one is that there is no need to hash a hash. The second is that intHash takes a 32-bit integer as its parameter, so high bits of object identifiers were discarded unnecessarily. * workers/service/ServiceWorkerContextData.h: Removed unneeded include. * workers/service/ServiceWorkerGlobalScope.h: Added now-needed include of URLHash.h, since we removed it from a widely-included header. * workers/service/context/SWContextManager.h: Ditto. * workers/service/server/ServiceWorkerThreadProxy.h: Ditto. * workers/service/server/RegistrationStore.h: Ditto. * workers/service/server/SWServer.h: Ditto. * workers/service/server/SWServerToContextConnection.h: Ditto. * workers/service/server/SWServerWorker.h: Ditto. Source/WebKit: * NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h: Added now-needed include of URLHash.h, since we removed it from a widely-included header. * NetworkProcess/cache/NetworkCache.h: (WebKit::NetworkCache::GlobalFrameID::hash const): Use computeHash instead of combining intHash with StringHasher::hashMemory. This fixes two mistakes: one is that there is no need to hash a hash. The second is that intHash takes a 32-bit integer as its parameter, so high bits of object identifiers were discarded unnecessarily. * Scripts/webkit/messages.py: Added code so that if URL is in an argument, we include the URLHash.h header. Would be better to just use URL.h and use URLHash.h only if it's a HashMap<URL>, but currently the script does not distinguish those cases. This wasn't needed before becuase a widely included header was always pulling in URLHash.h. * Shared/API/Cocoa/WKBrowsingContextHandle.mm: (-[WKBrowsingContextHandle hash]): Use computeHash instead of pairIntHash. This fixes a mistake: pairIntHash takes two 32-bit integers, so high bits of object identifiers were discarded unnecessarily. * NetworkProcess/Storage/WebSWContextManagerConnection.h: Added now-needed include of URLHash.h, since we removed it from a widely-included header. Source/WebKitLegacy/mac: * History/BinaryPropertyList.cpp: Use HashTraits instead of WTF::GenericHashTraits. Source/WTF: * wtf/HashFunctions.h: Export intHash and pairIntHash to the global namespace so they can be called without an explicit WTF prefix. This follows the usual WTF design pattern given that these functions are intended for use outside WTF. * wtf/Hasher.h: Deleted IntegerHasher. (WTF::add): Added overloads for String, AtomString, and URL. * wtf/ObjectIdentifier.h: (WTF::add): Added a Hasher overload for any ObjectIdentifier. * wtf/RetainPtr.h: Export safeCFEqual and safeCFHash to the global namespace so they can be called without an explicit WTF prefix. This follows the usual WTF design pattern given that these functions are intended for use outside WTF. * wtf/VectorHash.h: Removed the VectorHash template, instead just specializing DefaultHash. Use computeHash to hash the contents of the vector instead of hashing the hashes of the items in the vector. This is better in general and better for the one case where we are currently using this, for a Vector<int>. We want to hash all the integers rather than hashing hashes of all the integers. In the future, this means the elements of the Vector need to be hashable using the Hasher machinery. The old requirement was the the elements had a DefaultHash. Canonical link: https://commits.webkit.org/236286@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275650 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-04-08 02:19:20 +00:00
template<typename T> inline void add(Hasher& hasher, ObjectIdentifier<T> identifier)
{
add(hasher, identifier.toUInt64());
}
Use a single identifier type to identify Service Workers https://bugs.webkit.org/show_bug.cgi?id=179192 Reviewed by Brady Eidson. Source/WebCore: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * WebCore.xcodeproj/project.pbxproj: * loader/ResourceLoaderOptions.h: * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::setSelectedServiceWorkerIdentifierIfNeeded): * loader/cache/CachedResourceRequest.h: * workers/service/ServiceWorker.cpp: (WebCore::ServiceWorker::ServiceWorker): * workers/service/ServiceWorker.h: * workers/service/ServiceWorkerClient.cpp: (WebCore::ServiceWorkerClient::postMessage): * workers/service/ServiceWorkerContainer.cpp: (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration): * workers/service/ServiceWorkerContextData.cpp: (WebCore::ServiceWorkerContextData::isolatedCopy const): * workers/service/ServiceWorkerContextData.h: (WebCore::ServiceWorkerContextData::encode const): (WebCore::ServiceWorkerContextData::decode): * workers/service/ServiceWorkerIdentifier.h: Copied from Source/WebCore/workers/service/ServiceWorkerContextData.cpp. * workers/service/ServiceWorkerRegistrationData.h: (WebCore::ServiceWorkerRegistrationData::decode): * workers/service/context/SWContextManager.cpp: (WebCore::SWContextManager::serviceWorkerThreadProxy const): (WebCore::SWContextManager::postMessageToServiceWorkerGlobalScope): * workers/service/context/SWContextManager.h: * workers/service/context/ServiceWorkerThread.cpp: (WebCore::ServiceWorkerThread::ServiceWorkerThread): * workers/service/context/ServiceWorkerThread.h: (WebCore::ServiceWorkerThread::identifier const): * workers/service/context/ServiceWorkerThreadProxy.h: * workers/service/server/SWClientConnection.cpp: (WebCore::SWClientConnection::postMessageToServiceWorkerClient): * workers/service/server/SWClientConnection.h: * workers/service/server/SWServer.cpp: (WebCore::generateServiceWorkerIdentifier): (WebCore::SWServer::Connection::scriptContextFailedToStart): (WebCore::SWServer::Connection::scriptContextStarted): (WebCore::SWServer::scriptContextFailedToStart): (WebCore::SWServer::scriptContextStarted): (WebCore::SWServer::updateWorker): * workers/service/server/SWServer.h: * workers/service/server/SWServerJobQueue.cpp: (WebCore::SWServerJobQueue::scriptContextFailedToStart): (WebCore::SWServerJobQueue::scriptContextStarted): * workers/service/server/SWServerJobQueue.h: * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::setActiveServiceWorkerIdentifier): * workers/service/server/SWServerWorker.cpp: (WebCore::SWServerWorker::SWServerWorker): * workers/service/server/SWServerWorker.h: (WebCore::SWServerWorker::create): (WebCore::SWServerWorker::identifier const): Source/WebKit: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * Scripts/webkit/messages.py: (forward_declarations_and_headers): (forward_declarations_and_headers.templates): * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::startFetch): (WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWServerConnection::postMessageToServiceWorkerClient): * StorageProcess/ServiceWorker/WebSWServerConnection.h: * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in: * StorageProcess/StorageProcess.cpp: (WebKit::StorageProcess::serviceWorkerContextFailedToStart): (WebKit::StorageProcess::serviceWorkerContextStarted): (WebKit::StorageProcess::postMessageToServiceWorkerClient): * StorageProcess/StorageProcess.h: * StorageProcess/StorageProcess.messages.in: * WebProcess/Storage/WebSWClientConnection.cpp: (WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWClientConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWClientConnection.h: * WebProcess/Storage/WebSWClientConnection.messages.in: * WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::updateServiceWorker): (WebKit::WebSWContextManagerConnection::serviceWorkerStartedWithMessage): (WebKit::WebSWContextManagerConnection::startFetch): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWContextManagerConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.messages.in: Source/WTF: Introduce class for strongly typed identifiers. This avoids mixing up different types of identifiers. * WTF.xcodeproj/project.pbxproj: * wtf/ObjectIdentifier.h: Added. (WTF::ObjectIdentifier::encode const): (WTF::ObjectIdentifier::decode): (WTF::ObjectIdentifier::operator== const): (WTF::ObjectIdentifier::operator!= const): (WTF::ObjectIdentifier::ObjectIdentifier): (WTF::makeObjectIdentifier): (WTF::ObjectIdentifierHash::hash): (WTF::ObjectIdentifierHash::equal): (WTF::HashTraits<ObjectIdentifier<T>>::emptyValue): (WTF::HashTraits<ObjectIdentifier<T>>::constructDeletedValue): (WTF::HashTraits<ObjectIdentifier<T>>::isDeletedValue): Canonical link: https://commits.webkit.org/195341@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224403 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-03 16:37:04 +00:00
template<typename T> struct ObjectIdentifierHash {
static unsigned hash(const ObjectIdentifier<T>& identifier) { return intHash(identifier.m_identifier); }
static bool equal(const ObjectIdentifier<T>& a, const ObjectIdentifier<T>& b) { return a == b; }
Use constexpr instead of const in symbol definitions that are obviously constexpr. https://bugs.webkit.org/show_bug.cgi?id=201879 Rubber-stamped by Joseph Pecoraro. Source/bmalloc: * bmalloc/AvailableMemory.cpp: * bmalloc/IsoTLS.h: * bmalloc/Map.h: * bmalloc/Mutex.cpp: (bmalloc::Mutex::lockSlowCase): * bmalloc/PerThread.h: * bmalloc/Vector.h: * bmalloc/Zone.h: Source/JavaScriptCore: const may require external storage (at the compiler's whim) though these currently do not. constexpr makes it clear that the value is a literal constant that can be inlined. In most cases in the code, when we say static const, we actually mean static constexpr. I'm changing the code to reflect this. * API/JSAPIValueWrapper.h: * API/JSCallbackConstructor.h: * API/JSCallbackObject.h: * API/JSContextRef.cpp: * API/JSWrapperMap.mm: * API/tests/CompareAndSwapTest.cpp: * API/tests/TypedArrayCTest.cpp: * API/tests/testapi.mm: (testObjectiveCAPIMain): * KeywordLookupGenerator.py: (Trie.printAsC): * assembler/ARMv7Assembler.h: * assembler/AssemblerBuffer.h: * assembler/AssemblerCommon.h: * assembler/MacroAssembler.h: * assembler/MacroAssemblerARM64.h: * assembler/MacroAssemblerARM64E.h: * assembler/MacroAssemblerARMv7.h: * assembler/MacroAssemblerCodeRef.h: * assembler/MacroAssemblerMIPS.h: * assembler/MacroAssemblerX86.h: * assembler/MacroAssemblerX86Common.h: (JSC::MacroAssemblerX86Common::absDouble): (JSC::MacroAssemblerX86Common::negateDouble): * assembler/MacroAssemblerX86_64.h: * assembler/X86Assembler.h: * b3/B3Bank.h: * b3/B3CheckSpecial.h: * b3/B3DuplicateTails.cpp: * b3/B3EliminateCommonSubexpressions.cpp: * b3/B3FixSSA.cpp: * b3/B3FoldPathConstants.cpp: * b3/B3InferSwitches.cpp: * b3/B3Kind.h: * b3/B3LowerToAir.cpp: * b3/B3NativeTraits.h: * b3/B3ReduceDoubleToFloat.cpp: * b3/B3ReduceLoopStrength.cpp: * b3/B3ReduceStrength.cpp: * b3/B3ValueKey.h: * b3/air/AirAllocateRegistersByGraphColoring.cpp: * b3/air/AirAllocateStackByGraphColoring.cpp: * b3/air/AirArg.h: * b3/air/AirCCallSpecial.h: * b3/air/AirEmitShuffle.cpp: * b3/air/AirFixObviousSpills.cpp: * b3/air/AirFormTable.h: * b3/air/AirLowerAfterRegAlloc.cpp: * b3/air/AirPrintSpecial.h: * b3/air/AirStackAllocation.cpp: * b3/air/AirTmp.h: * b3/testb3_6.cpp: (testInterpreter): * bytecode/AccessCase.cpp: * bytecode/CallLinkStatus.cpp: * bytecode/CallVariant.h: * bytecode/CodeBlock.h: * bytecode/CodeOrigin.h: * bytecode/DFGExitProfile.h: * bytecode/DirectEvalCodeCache.h: * bytecode/ExecutableToCodeBlockEdge.h: * bytecode/GetterSetterAccessCase.cpp: * bytecode/LazyOperandValueProfile.h: * bytecode/ObjectPropertyCondition.h: * bytecode/ObjectPropertyConditionSet.cpp: * bytecode/PolymorphicAccess.cpp: * bytecode/PropertyCondition.h: * bytecode/SpeculatedType.h: * bytecode/StructureStubInfo.cpp: * bytecode/UnlinkedCodeBlock.cpp: (JSC::UnlinkedCodeBlock::typeProfilerExpressionInfoForBytecodeOffset): * bytecode/UnlinkedCodeBlock.h: * bytecode/UnlinkedEvalCodeBlock.h: * bytecode/UnlinkedFunctionCodeBlock.h: * bytecode/UnlinkedFunctionExecutable.h: * bytecode/UnlinkedModuleProgramCodeBlock.h: * bytecode/UnlinkedProgramCodeBlock.h: * bytecode/ValueProfile.h: * bytecode/VirtualRegister.h: * bytecode/Watchpoint.h: * bytecompiler/BytecodeGenerator.h: * bytecompiler/Label.h: * bytecompiler/NodesCodegen.cpp: (JSC::ThisNode::emitBytecode): * bytecompiler/RegisterID.h: * debugger/Breakpoint.h: * debugger/DebuggerParseData.cpp: * debugger/DebuggerPrimitives.h: * debugger/DebuggerScope.h: * dfg/DFGAbstractHeap.h: * dfg/DFGAbstractValue.h: * dfg/DFGArgumentsEliminationPhase.cpp: * dfg/DFGByteCodeParser.cpp: * dfg/DFGCSEPhase.cpp: * dfg/DFGCommon.h: * dfg/DFGCompilationKey.h: * dfg/DFGDesiredGlobalProperty.h: * dfg/DFGEdgeDominates.h: * dfg/DFGEpoch.h: * dfg/DFGForAllKills.h: (JSC::DFG::forAllKilledNodesAtNodeIndex): * dfg/DFGGraph.cpp: (JSC::DFG::Graph::isLiveInBytecode): * dfg/DFGHeapLocation.h: * dfg/DFGInPlaceAbstractState.cpp: * dfg/DFGIntegerCheckCombiningPhase.cpp: * dfg/DFGIntegerRangeOptimizationPhase.cpp: * dfg/DFGInvalidationPointInjectionPhase.cpp: * dfg/DFGLICMPhase.cpp: * dfg/DFGLazyNode.h: * dfg/DFGMinifiedID.h: * dfg/DFGMovHintRemovalPhase.cpp: * dfg/DFGNodeFlowProjection.h: * dfg/DFGNodeType.h: * dfg/DFGObjectAllocationSinkingPhase.cpp: * dfg/DFGPhantomInsertionPhase.cpp: * dfg/DFGPromotedHeapLocation.h: * dfg/DFGPropertyTypeKey.h: * dfg/DFGPureValue.h: * dfg/DFGPutStackSinkingPhase.cpp: * dfg/DFGRegisterBank.h: * dfg/DFGSSAConversionPhase.cpp: * dfg/DFGSSALoweringPhase.cpp: * dfg/DFGSpeculativeJIT.cpp: (JSC::DFG::SpeculativeJIT::compileDoubleRep): (JSC::DFG::compileClampDoubleToByte): (JSC::DFG::SpeculativeJIT::compileArithRounding): (JSC::DFG::compileArithPowIntegerFastPath): (JSC::DFG::SpeculativeJIT::compileArithPow): (JSC::DFG::SpeculativeJIT::emitBinarySwitchStringRecurse): * dfg/DFGStackLayoutPhase.cpp: * dfg/DFGStoreBarrierInsertionPhase.cpp: * dfg/DFGStrengthReductionPhase.cpp: * dfg/DFGStructureAbstractValue.h: * dfg/DFGVarargsForwardingPhase.cpp: * dfg/DFGVariableEventStream.cpp: (JSC::DFG::VariableEventStream::reconstruct const): * dfg/DFGWatchpointCollectionPhase.cpp: * disassembler/ARM64/A64DOpcode.h: * ftl/FTLLocation.h: * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileArithRandom): * ftl/FTLSlowPathCall.cpp: * ftl/FTLSlowPathCallKey.h: * heap/CellContainer.h: * heap/CellState.h: * heap/ConservativeRoots.h: * heap/GCSegmentedArray.h: * heap/HandleBlock.h: * heap/Heap.cpp: (JSC::Heap::updateAllocationLimits): * heap/Heap.h: * heap/HeapSnapshot.h: * heap/HeapUtil.h: (JSC::HeapUtil::findGCObjectPointersForMarking): * heap/IncrementalSweeper.cpp: * heap/LargeAllocation.h: * heap/MarkedBlock.cpp: * heap/Strong.h: * heap/VisitRaceKey.h: * heap/Weak.h: * heap/WeakBlock.h: * inspector/JSInjectedScriptHost.h: * inspector/JSInjectedScriptHostPrototype.h: * inspector/JSJavaScriptCallFrame.h: * inspector/JSJavaScriptCallFramePrototype.h: * inspector/agents/InspectorConsoleAgent.cpp: * inspector/agents/InspectorRuntimeAgent.cpp: (Inspector::InspectorRuntimeAgent::getRuntimeTypesForVariablesAtOffsets): * inspector/scripts/codegen/generate_cpp_protocol_types_header.py: (CppProtocolTypesHeaderGenerator._generate_versions): * inspector/scripts/tests/generic/expected/version.json-result: * interpreter/Interpreter.h: * interpreter/ShadowChicken.cpp: * jit/BinarySwitch.cpp: * jit/CallFrameShuffler.h: * jit/ExecutableAllocator.h: * jit/FPRInfo.h: * jit/GPRInfo.h: * jit/ICStats.h: * jit/JITThunks.h: * jit/Reg.h: * jit/RegisterSet.h: * jit/TempRegisterSet.h: * jsc.cpp: * parser/ASTBuilder.h: * parser/Nodes.h: * parser/SourceCodeKey.h: * parser/SyntaxChecker.h: * parser/VariableEnvironment.h: * profiler/ProfilerOrigin.h: * profiler/ProfilerOriginStack.h: * profiler/ProfilerUID.h: * runtime/AbstractModuleRecord.cpp: * runtime/ArrayBufferNeuteringWatchpointSet.h: * runtime/ArrayConstructor.h: * runtime/ArrayConventions.h: * runtime/ArrayIteratorPrototype.h: * runtime/ArrayPrototype.cpp: (JSC::setLength): * runtime/AsyncFromSyncIteratorPrototype.h: * runtime/AsyncGeneratorFunctionPrototype.h: * runtime/AsyncGeneratorPrototype.h: * runtime/AsyncIteratorPrototype.h: * runtime/AtomicsObject.cpp: * runtime/BigIntConstructor.h: * runtime/BigIntPrototype.h: * runtime/BooleanPrototype.h: * runtime/ClonedArguments.h: * runtime/CodeCache.h: * runtime/ControlFlowProfiler.h: * runtime/CustomGetterSetter.h: * runtime/DateConstructor.h: * runtime/DatePrototype.h: * runtime/DefinePropertyAttributes.h: * runtime/ErrorPrototype.h: * runtime/EvalExecutable.h: * runtime/Exception.h: * runtime/ExceptionHelpers.cpp: (JSC::invalidParameterInSourceAppender): (JSC::invalidParameterInstanceofSourceAppender): * runtime/ExceptionHelpers.h: * runtime/ExecutableBase.h: * runtime/FunctionExecutable.h: * runtime/FunctionRareData.h: * runtime/GeneratorPrototype.h: * runtime/GenericArguments.h: * runtime/GenericOffset.h: * runtime/GetPutInfo.h: * runtime/GetterSetter.h: * runtime/GlobalExecutable.h: * runtime/Identifier.h: * runtime/InspectorInstrumentationObject.h: * runtime/InternalFunction.h: * runtime/IntlCollatorConstructor.h: * runtime/IntlCollatorPrototype.h: * runtime/IntlDateTimeFormatConstructor.h: * runtime/IntlDateTimeFormatPrototype.h: * runtime/IntlNumberFormatConstructor.h: * runtime/IntlNumberFormatPrototype.h: * runtime/IntlObject.h: * runtime/IntlPluralRulesConstructor.h: * runtime/IntlPluralRulesPrototype.h: * runtime/IteratorPrototype.h: * runtime/JSArray.cpp: (JSC::JSArray::tryCreateUninitializedRestricted): * runtime/JSArray.h: * runtime/JSArrayBuffer.h: * runtime/JSArrayBufferView.h: * runtime/JSBigInt.h: * runtime/JSCJSValue.h: * runtime/JSCell.h: * runtime/JSCustomGetterSetterFunction.h: * runtime/JSDataView.h: * runtime/JSDataViewPrototype.h: * runtime/JSDestructibleObject.h: * runtime/JSFixedArray.h: * runtime/JSGenericTypedArrayView.h: * runtime/JSGlobalLexicalEnvironment.h: * runtime/JSGlobalObject.h: * runtime/JSImmutableButterfly.h: * runtime/JSInternalPromiseConstructor.h: * runtime/JSInternalPromiseDeferred.h: * runtime/JSInternalPromisePrototype.h: * runtime/JSLexicalEnvironment.h: * runtime/JSModuleEnvironment.h: * runtime/JSModuleLoader.h: * runtime/JSModuleNamespaceObject.h: * runtime/JSNonDestructibleProxy.h: * runtime/JSONObject.cpp: * runtime/JSONObject.h: * runtime/JSObject.h: * runtime/JSPromiseConstructor.h: * runtime/JSPromiseDeferred.h: * runtime/JSPromisePrototype.h: * runtime/JSPropertyNameEnumerator.h: * runtime/JSProxy.h: * runtime/JSScope.h: * runtime/JSScriptFetchParameters.h: * runtime/JSScriptFetcher.h: * runtime/JSSegmentedVariableObject.h: * runtime/JSSourceCode.h: * runtime/JSString.cpp: * runtime/JSString.h: * runtime/JSSymbolTableObject.h: * runtime/JSTemplateObjectDescriptor.h: * runtime/JSTypeInfo.h: * runtime/MapPrototype.h: * runtime/MinimumReservedZoneSize.h: * runtime/ModuleProgramExecutable.h: * runtime/NativeExecutable.h: * runtime/NativeFunction.h: * runtime/NativeStdFunctionCell.h: * runtime/NumberConstructor.h: * runtime/NumberPrototype.h: * runtime/ObjectConstructor.h: * runtime/ObjectPrototype.h: * runtime/ProgramExecutable.h: * runtime/PromiseDeferredTimer.cpp: * runtime/PropertyMapHashTable.h: * runtime/PropertyNameArray.h: (JSC::PropertyNameArray::add): * runtime/PrototypeKey.h: * runtime/ProxyConstructor.h: * runtime/ProxyObject.cpp: (JSC::ProxyObject::performGetOwnPropertyNames): * runtime/ProxyRevoke.h: * runtime/ReflectObject.h: * runtime/RegExp.h: * runtime/RegExpCache.h: * runtime/RegExpConstructor.h: * runtime/RegExpKey.h: * runtime/RegExpObject.h: * runtime/RegExpPrototype.h: * runtime/RegExpStringIteratorPrototype.h: * runtime/SamplingProfiler.cpp: * runtime/ScopedArgumentsTable.h: * runtime/ScriptExecutable.h: * runtime/SetPrototype.h: * runtime/SmallStrings.h: * runtime/SparseArrayValueMap.h: * runtime/StringConstructor.h: * runtime/StringIteratorPrototype.h: * runtime/StringObject.h: * runtime/StringPrototype.h: * runtime/Structure.h: * runtime/StructureChain.h: * runtime/StructureRareData.h: * runtime/StructureTransitionTable.h: * runtime/Symbol.h: * runtime/SymbolConstructor.h: * runtime/SymbolPrototype.h: * runtime/SymbolTable.h: * runtime/TemplateObjectDescriptor.h: * runtime/TypeProfiler.cpp: * runtime/TypeProfiler.h: * runtime/TypeProfilerLog.cpp: * runtime/VarOffset.h: * testRegExp.cpp: * tools/HeapVerifier.cpp: (JSC::HeapVerifier::checkIfRecorded): * tools/JSDollarVM.cpp: * wasm/WasmB3IRGenerator.cpp: * wasm/WasmBBQPlan.cpp: * wasm/WasmFaultSignalHandler.cpp: * wasm/WasmFunctionParser.h: * wasm/WasmOMGForOSREntryPlan.cpp: * wasm/WasmOMGPlan.cpp: * wasm/WasmPlan.cpp: * wasm/WasmSignature.cpp: * wasm/WasmSignature.h: * wasm/WasmWorklist.cpp: * wasm/js/JSWebAssembly.h: * wasm/js/JSWebAssemblyCodeBlock.h: * wasm/js/WebAssemblyCompileErrorConstructor.h: * wasm/js/WebAssemblyCompileErrorPrototype.h: * wasm/js/WebAssemblyFunction.h: * wasm/js/WebAssemblyInstanceConstructor.h: * wasm/js/WebAssemblyInstancePrototype.h: * wasm/js/WebAssemblyLinkErrorConstructor.h: * wasm/js/WebAssemblyLinkErrorPrototype.h: * wasm/js/WebAssemblyMemoryConstructor.h: * wasm/js/WebAssemblyMemoryPrototype.h: * wasm/js/WebAssemblyModuleConstructor.h: * wasm/js/WebAssemblyModulePrototype.h: * wasm/js/WebAssemblyRuntimeErrorConstructor.h: * wasm/js/WebAssemblyRuntimeErrorPrototype.h: * wasm/js/WebAssemblyTableConstructor.h: * wasm/js/WebAssemblyTablePrototype.h: * wasm/js/WebAssemblyToJSCallee.h: * yarr/Yarr.h: * yarr/YarrParser.h: * yarr/generateYarrCanonicalizeUnicode: Source/WebCore: No new tests. Covered by existing tests. * bindings/js/JSDOMConstructorBase.h: * bindings/js/JSDOMWindowProperties.h: * bindings/scripts/CodeGeneratorJS.pm: (GenerateHeader): (GeneratePrototypeDeclaration): * bindings/scripts/test/JS/JSTestActiveDOMObject.h: * bindings/scripts/test/JS/JSTestEnabledBySetting.h: * bindings/scripts/test/JS/JSTestEnabledForContext.h: * bindings/scripts/test/JS/JSTestEventTarget.h: * bindings/scripts/test/JS/JSTestGlobalObject.h: * bindings/scripts/test/JS/JSTestIndexedSetterNoIdentifier.h: * bindings/scripts/test/JS/JSTestIndexedSetterThrowingException.h: * bindings/scripts/test/JS/JSTestIndexedSetterWithIdentifier.h: * bindings/scripts/test/JS/JSTestNamedAndIndexedSetterNoIdentifier.h: * bindings/scripts/test/JS/JSTestNamedAndIndexedSetterThrowingException.h: * bindings/scripts/test/JS/JSTestNamedAndIndexedSetterWithIdentifier.h: * bindings/scripts/test/JS/JSTestNamedDeleterNoIdentifier.h: * bindings/scripts/test/JS/JSTestNamedDeleterThrowingException.h: * bindings/scripts/test/JS/JSTestNamedDeleterWithIdentifier.h: * bindings/scripts/test/JS/JSTestNamedDeleterWithIndexedGetter.h: * bindings/scripts/test/JS/JSTestNamedGetterCallWith.h: * bindings/scripts/test/JS/JSTestNamedGetterNoIdentifier.h: * bindings/scripts/test/JS/JSTestNamedGetterWithIdentifier.h: * bindings/scripts/test/JS/JSTestNamedSetterNoIdentifier.h: * bindings/scripts/test/JS/JSTestNamedSetterThrowingException.h: * bindings/scripts/test/JS/JSTestNamedSetterWithIdentifier.h: * bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetter.h: * bindings/scripts/test/JS/JSTestNamedSetterWithIndexedGetterAndSetter.h: * bindings/scripts/test/JS/JSTestNamedSetterWithOverrideBuiltins.h: * bindings/scripts/test/JS/JSTestNamedSetterWithUnforgableProperties.h: * bindings/scripts/test/JS/JSTestNamedSetterWithUnforgablePropertiesAndOverrideBuiltins.h: * bindings/scripts/test/JS/JSTestObj.h: * bindings/scripts/test/JS/JSTestOverrideBuiltins.h: * bindings/scripts/test/JS/JSTestPluginInterface.h: * bindings/scripts/test/JS/JSTestTypedefs.h: * bridge/objc/objc_runtime.h: * bridge/runtime_array.h: * bridge/runtime_method.h: * bridge/runtime_object.h: Source/WebKit: * WebProcess/Plugins/Netscape/JSNPObject.h: Source/WTF: * wtf/Assertions.cpp: * wtf/AutomaticThread.cpp: * wtf/BitVector.h: * wtf/Bitmap.h: * wtf/BloomFilter.h: * wtf/Brigand.h: * wtf/CheckedArithmetic.h: * wtf/CrossThreadCopier.h: * wtf/CurrentTime.cpp: * wtf/DataLog.cpp: * wtf/DateMath.cpp: (WTF::daysFrom1970ToYear): * wtf/DeferrableRefCounted.h: * wtf/GetPtr.h: * wtf/HashFunctions.h: * wtf/HashMap.h: * wtf/HashTable.h: * wtf/HashTraits.h: * wtf/JSONValues.cpp: * wtf/JSONValues.h: * wtf/ListHashSet.h: * wtf/Lock.h: * wtf/LockAlgorithm.h: * wtf/LockAlgorithmInlines.h: (WTF::Hooks>::lockSlow): * wtf/Logger.h: * wtf/LoggerHelper.h: (WTF::LoggerHelper::childLogIdentifier const): * wtf/MainThread.cpp: * wtf/MetaAllocatorPtr.h: * wtf/MonotonicTime.h: * wtf/NaturalLoops.h: (WTF::NaturalLoops::NaturalLoops): * wtf/ObjectIdentifier.h: * wtf/RAMSize.cpp: * wtf/Ref.h: * wtf/RefPtr.h: * wtf/RetainPtr.h: * wtf/SchedulePair.h: * wtf/StackShot.h: * wtf/StdLibExtras.h: * wtf/TinyPtrSet.h: * wtf/URL.cpp: * wtf/URLHash.h: * wtf/URLParser.cpp: (WTF::URLParser::defaultPortForProtocol): * wtf/Vector.h: * wtf/VectorTraits.h: * wtf/WallTime.h: * wtf/WeakHashSet.h: * wtf/WordLock.h: * wtf/cocoa/CPUTimeCocoa.cpp: * wtf/cocoa/MemoryPressureHandlerCocoa.mm: * wtf/persistence/PersistentDecoder.h: * wtf/persistence/PersistentEncoder.h: * wtf/text/AtomStringHash.h: * wtf/text/CString.h: * wtf/text/StringBuilder.cpp: (WTF::expandedCapacity): * wtf/text/StringHash.h: * wtf/text/StringImpl.h: * wtf/text/StringToIntegerConversion.h: (WTF::toIntegralType): * wtf/text/SymbolRegistry.h: * wtf/text/TextStream.cpp: (WTF::hasFractions): * wtf/text/WTFString.h: * wtf/text/cocoa/TextBreakIteratorInternalICUCocoa.cpp: Canonical link: https://commits.webkit.org/215538@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@250005 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-09-18 00:36:19 +00:00
static constexpr bool safeToCompareToEmptyOrDeleted = true;
Use a single identifier type to identify Service Workers https://bugs.webkit.org/show_bug.cgi?id=179192 Reviewed by Brady Eidson. Source/WebCore: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * WebCore.xcodeproj/project.pbxproj: * loader/ResourceLoaderOptions.h: * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::setSelectedServiceWorkerIdentifierIfNeeded): * loader/cache/CachedResourceRequest.h: * workers/service/ServiceWorker.cpp: (WebCore::ServiceWorker::ServiceWorker): * workers/service/ServiceWorker.h: * workers/service/ServiceWorkerClient.cpp: (WebCore::ServiceWorkerClient::postMessage): * workers/service/ServiceWorkerContainer.cpp: (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration): * workers/service/ServiceWorkerContextData.cpp: (WebCore::ServiceWorkerContextData::isolatedCopy const): * workers/service/ServiceWorkerContextData.h: (WebCore::ServiceWorkerContextData::encode const): (WebCore::ServiceWorkerContextData::decode): * workers/service/ServiceWorkerIdentifier.h: Copied from Source/WebCore/workers/service/ServiceWorkerContextData.cpp. * workers/service/ServiceWorkerRegistrationData.h: (WebCore::ServiceWorkerRegistrationData::decode): * workers/service/context/SWContextManager.cpp: (WebCore::SWContextManager::serviceWorkerThreadProxy const): (WebCore::SWContextManager::postMessageToServiceWorkerGlobalScope): * workers/service/context/SWContextManager.h: * workers/service/context/ServiceWorkerThread.cpp: (WebCore::ServiceWorkerThread::ServiceWorkerThread): * workers/service/context/ServiceWorkerThread.h: (WebCore::ServiceWorkerThread::identifier const): * workers/service/context/ServiceWorkerThreadProxy.h: * workers/service/server/SWClientConnection.cpp: (WebCore::SWClientConnection::postMessageToServiceWorkerClient): * workers/service/server/SWClientConnection.h: * workers/service/server/SWServer.cpp: (WebCore::generateServiceWorkerIdentifier): (WebCore::SWServer::Connection::scriptContextFailedToStart): (WebCore::SWServer::Connection::scriptContextStarted): (WebCore::SWServer::scriptContextFailedToStart): (WebCore::SWServer::scriptContextStarted): (WebCore::SWServer::updateWorker): * workers/service/server/SWServer.h: * workers/service/server/SWServerJobQueue.cpp: (WebCore::SWServerJobQueue::scriptContextFailedToStart): (WebCore::SWServerJobQueue::scriptContextStarted): * workers/service/server/SWServerJobQueue.h: * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::setActiveServiceWorkerIdentifier): * workers/service/server/SWServerWorker.cpp: (WebCore::SWServerWorker::SWServerWorker): * workers/service/server/SWServerWorker.h: (WebCore::SWServerWorker::create): (WebCore::SWServerWorker::identifier const): Source/WebKit: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * Scripts/webkit/messages.py: (forward_declarations_and_headers): (forward_declarations_and_headers.templates): * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::startFetch): (WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWServerConnection::postMessageToServiceWorkerClient): * StorageProcess/ServiceWorker/WebSWServerConnection.h: * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in: * StorageProcess/StorageProcess.cpp: (WebKit::StorageProcess::serviceWorkerContextFailedToStart): (WebKit::StorageProcess::serviceWorkerContextStarted): (WebKit::StorageProcess::postMessageToServiceWorkerClient): * StorageProcess/StorageProcess.h: * StorageProcess/StorageProcess.messages.in: * WebProcess/Storage/WebSWClientConnection.cpp: (WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWClientConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWClientConnection.h: * WebProcess/Storage/WebSWClientConnection.messages.in: * WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::updateServiceWorker): (WebKit::WebSWContextManagerConnection::serviceWorkerStartedWithMessage): (WebKit::WebSWContextManagerConnection::startFetch): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWContextManagerConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.messages.in: Source/WTF: Introduce class for strongly typed identifiers. This avoids mixing up different types of identifiers. * WTF.xcodeproj/project.pbxproj: * wtf/ObjectIdentifier.h: Added. (WTF::ObjectIdentifier::encode const): (WTF::ObjectIdentifier::decode): (WTF::ObjectIdentifier::operator== const): (WTF::ObjectIdentifier::operator!= const): (WTF::ObjectIdentifier::ObjectIdentifier): (WTF::makeObjectIdentifier): (WTF::ObjectIdentifierHash::hash): (WTF::ObjectIdentifierHash::equal): (WTF::HashTraits<ObjectIdentifier<T>>::emptyValue): (WTF::HashTraits<ObjectIdentifier<T>>::constructDeletedValue): (WTF::HashTraits<ObjectIdentifier<T>>::isDeletedValue): Canonical link: https://commits.webkit.org/195341@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224403 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-03 16:37:04 +00:00
};
template<typename T> struct HashTraits<ObjectIdentifier<T>> : SimpleClassHashTraits<ObjectIdentifier<T>> { };
[WTF] Remove the unnecessary inner class DefaultHash<T>::Hash https://bugs.webkit.org/show_bug.cgi?id=214389 Reviewed by Darin Adler. Source/JavaScriptCore: * assembler/MacroAssemblerCodeRef.h: * b3/B3CheckSpecial.h: * b3/B3Kind.h: * b3/B3ValueKey.h: * b3/air/AirAllocateRegistersByGraphColoring.cpp: * b3/air/AirArg.h: * b3/air/AirTmp.h: * bytecode/BytecodeIndex.h: * bytecode/CallVariant.h: * bytecode/CodeOrigin.h: * bytecode/DFGExitProfile.h: * bytecode/LazyOperandValueProfile.h: * bytecode/ObjectPropertyCondition.h: * bytecode/PropertyCondition.h: * dfg/DFGAbstractHeap.h: * dfg/DFGArgumentsEliminationPhase.cpp: * dfg/DFGByteCodeParser.cpp: * dfg/DFGCSEPhase.cpp: * dfg/DFGCompilationKey.h: * dfg/DFGDesiredGlobalProperty.h: * dfg/DFGHeapLocation.h: * dfg/DFGLivenessAnalysisPhase.cpp: * dfg/DFGMinifiedID.h: * dfg/DFGNodeFlowProjection.h: * dfg/DFGPromotedHeapLocation.h: * dfg/DFGPropertyTypeKey.h: * dfg/DFGPureValue.h: * ftl/FTLLocation.h: * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileNewArrayWithSpread): (JSC::FTL::DFG::LowerDFGToB3::compileCallOrConstructVarargsSpread): (JSC::FTL::DFG::LowerDFGToB3::compileMaterializeNewObject): * ftl/FTLSlowPathCallKey.h: * heap/MarkedBlock.h: * heap/VisitRaceKey.h: * inspector/scripts/codegen/generate_cpp_protocol_types_header.py: * inspector/scripts/tests/expected/commands-with-async-attribute.json-result: * inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result: * inspector/scripts/tests/expected/enum-values.json-result: * inspector/scripts/tests/expected/type-declaration-array-type.json-result: * inspector/scripts/tests/expected/type-declaration-enum-type.json-result: * inspector/scripts/tests/expected/type-declaration-object-type.json-result: * inspector/scripts/tests/expected/type-requiring-runtime-casts.json-result: * jit/ICStats.h: * jit/JITThunks.h: * jit/Reg.h: * jit/RegisterSet.h: * parser/VariableEnvironment.h: * profiler/ProfilerOrigin.h: * profiler/ProfilerOriginStack.h: * profiler/ProfilerUID.h: * runtime/CachedTypes.cpp: * runtime/ControlFlowProfiler.h: * runtime/NativeFunction.h: * runtime/PrototypeKey.h: * runtime/RegExpKey.h: * runtime/TemplateObjectDescriptor.h: * runtime/TypeProfiler.h: * runtime/VarOffset.h: * runtime/WeakGCMap.h: * wasm/WasmBBQPlan.h: * wasm/WasmCodeBlock.h: * wasm/WasmEntryPlan.h: * wasm/WasmLLIntPlan.h: * wasm/WasmSignature.h: Source/WebCore: * Modules/indexeddb/IDBDatabaseIdentifier.h: * Modules/indexeddb/shared/IDBResourceIdentifier.h: * Modules/webgpu/WHLSL/AST/WHLSLUnnamedTypeHash.h: * Modules/webgpu/WHLSL/WHLSLSemanticMatcher.cpp: (WebCore::WHLSL::matchResources): (WebCore::WHLSL::matchVertexAttributes): (WebCore::WHLSL::matchColorAttachments): * accessibility/AccessibilityObject.cpp: * accessibility/AccessibilityObject.h: * contentextensions/ContentExtensionCompiler.cpp: (WebCore::ContentExtensions::serializeActions): * contentextensions/ContentExtensionRule.h: (WebCore::ContentExtensions::TriggerHash::hash): * contentextensions/ContentExtensionStyleSheet.h: * contentextensions/DFA.cpp: (WebCore::ContentExtensions::printTransitions): * contentextensions/DFABytecodeInterpreter.h: * contentextensions/DFACombiner.cpp: (WebCore::ContentExtensions::DFAMerger::getOrCreateCombinedNode): * contentextensions/DFANode.cpp: (WebCore::ContentExtensions::DFANode::bestFallbackTarget const): * contentextensions/ImmutableNFANodeBuilder.h: * contentextensions/NFA.cpp: (WebCore::ContentExtensions::NFA::debugPrintDot const): * contentextensions/NFANode.h: * contentextensions/NFAToDFA.cpp: (WebCore::ContentExtensions::NodeIdSetToUniqueNodeIdSetSource::NodeIdSetToUniqueNodeIdSetSource): (WebCore::ContentExtensions::NodeIdSetToUniqueNodeIdSetTranslator::translate): * css/makeprop.pl: * css/parser/CSSParserContext.h: * dom/GCReachableRef.h: * dom/MessagePortIdentifier.h: * dom/NodeRareData.h: (WebCore::NodeListsNodeData::NodeListCacheMapEntryHash::hash): (WebCore::NodeListsNodeData::NodeListCacheMapEntryHash::equal): * dom/QualifiedName.h: * history/BackForwardItemIdentifier.h: * html/canvas/WebGLRenderingContextBase.h: * layout/LayoutUnits.h: * loader/AdClickAttribution.h: * loader/ResourceCryptographicDigest.h: (WTF::DefaultHash<WebCore::ResourceCryptographicDigest>::hash): (WTF::DefaultHash<WebCore::ResourceCryptographicDigest>::equal): (WTF::DefaultHash<WebCore::ResourceCryptographicDigest>::Hash::hash): Deleted. (WTF::DefaultHash<WebCore::ResourceCryptographicDigest>::Hash::equal): Deleted. * page/ClientOrigin.h: * page/GlobalWindowIdentifier.h: * page/SecurityOriginData.h: * page/SecurityOriginHash.h: * platform/Cookie.h: * platform/RegistrableDomain.h: * platform/graphics/ColorHash.h: * platform/graphics/FloatSizeHash.h: (WTF::FloatHash<WebCore::FloatSize>::hash): * platform/graphics/FontGenericFamilies.h: * platform/graphics/IntPointHash.h: * platform/graphics/IntRectHash.h: (WTF::IntHash<WebCore::IntRect>::hash): (WTF::IntHash<WebCore::IntRect>::equal): * platform/graphics/IntSizeHash.h: * platform/graphics/WidthCache.h: * platform/graphics/freetype/FontCacheFreeType.cpp: (WebCore::FallbackFontDescriptionKey::computeHash const): * platform/network/HTTPParsers.h: * platform/network/ProtectionSpaceHash.h: * platform/win/COMPtr.h: * platform/win/WindowsKeyNames.h: * rendering/CSSValueKey.h: * rendering/GridBaselineAlignment.h: * rendering/GridTrackSizingAlgorithm.h: * rendering/RenderGrid.cpp: (WebCore::RenderGrid::placeSpecifiedMajorAxisItemsOnGrid const): * rendering/RenderTheme.h: * style/RuleSet.cpp: (WebCore::Style::RuleSet::evaluateDynamicMediaQueryRules): * svg/SVGElement.h: (WebCore::SVGAttributeHashTranslator::hash): * workers/service/ServiceWorkerClientIdentifier.h: * workers/service/ServiceWorkerRegistrationKey.h: Source/WebCore/PAL: * pal/SessionID.h: Source/WebKit: * NetworkProcess/Downloads/DownloadID.h: * NetworkProcess/cache/NetworkCache.h: * NetworkProcess/cache/NetworkCacheKey.h: * Platform/IPC/MessageReceiverMap.h: * Platform/IPC/StringReference.h: * Shared/CallbackID.h: * UIProcess/API/cpp/WKRetainPtr.h: Source/WebKitLegacy/win: * COMPropertyBag.h: Source/WTF: DefaultHash<T> doesn't need to have a inner struct Hash. This can be a problem for forward declarations (Bug 214320 Comment 5). * wtf/BitVector.h: * wtf/Forward.h: * wtf/HashFunctions.h: (WTF::PairHash::hash): (WTF::PairHash::equal): (WTF::TupleHash::hash): (WTF::TupleHash::equal): * wtf/ListHashSet.h: * wtf/LoggingHashMap.h: * wtf/LoggingHashSet.h: * wtf/MetaAllocatorPtr.h: * wtf/ObjectIdentifier.h: * wtf/OptionSetHash.h: (WTF::DefaultHash<OptionSet<T>>::hash): (WTF::DefaultHash<OptionSet<T>>::equal): (WTF::DefaultHash<OptionSet<T>>::Hash::hash): Deleted. (WTF::DefaultHash<OptionSet<T>>::Hash::equal): Deleted. * wtf/Packed.h: * wtf/RetainPtr.h: * wtf/StackShot.h: * wtf/URLHash.h: * wtf/VectorHash.h: (WTF::VectorHash::hash): * wtf/text/AtomString.h: * wtf/text/AtomStringHash.h: * wtf/text/CString.h: * wtf/text/StringHash.h: * wtf/text/StringImpl.h: * wtf/text/SymbolRegistry.h: (WTF::DefaultHash<SymbolRegistryKey>::hash): (WTF::DefaultHash<SymbolRegistryKey>::equal): (WTF::DefaultHash<SymbolRegistryKey>::Hash::hash): Deleted. (WTF::DefaultHash<SymbolRegistryKey>::Hash::equal): Deleted. * wtf/text/WTFString.h: Tools: * TestWebKitAPI/Tests/WTF/DeletedAddressOfOperator.h: (WTF::DefaultHash<DeletedAddressOfOperator>::hash): (WTF::DefaultHash<DeletedAddressOfOperator>::equal): (WTF::DefaultHash<DeletedAddressOfOperator>::Hash::hash): Deleted. (WTF::DefaultHash<DeletedAddressOfOperator>::Hash::equal): Deleted. * TestWebKitAPI/Tests/WTF/HashCountedSet.cpp: (TestWebKitAPI::bucketForKey): * TestWebKitAPI/Tests/WTF/HashMap.cpp: (TestWebKitAPI::bucketForKey): (TestWebKitAPI::TEST): * TestWebKitAPI/Tests/WTF/HashSet.cpp: (TestWebKitAPI::testInitialCapacity): * TestWebKitAPI/Tests/WTF/MoveOnly.h: (WTF::DefaultHash<MoveOnly>::hash): (WTF::DefaultHash<MoveOnly>::equal): (WTF::DefaultHash<MoveOnly>::Hash::hash): Deleted. (WTF::DefaultHash<MoveOnly>::Hash::equal): Deleted. Canonical link: https://commits.webkit.org/227236@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@264488 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-07-17 00:33:37 +00:00
template<typename T> struct DefaultHash<ObjectIdentifier<T>> : ObjectIdentifierHash<T> { };
Use a single identifier type to identify Service Workers https://bugs.webkit.org/show_bug.cgi?id=179192 Reviewed by Brady Eidson. Source/WebCore: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * WebCore.xcodeproj/project.pbxproj: * loader/ResourceLoaderOptions.h: * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::setSelectedServiceWorkerIdentifierIfNeeded): * loader/cache/CachedResourceRequest.h: * workers/service/ServiceWorker.cpp: (WebCore::ServiceWorker::ServiceWorker): * workers/service/ServiceWorker.h: * workers/service/ServiceWorkerClient.cpp: (WebCore::ServiceWorkerClient::postMessage): * workers/service/ServiceWorkerContainer.cpp: (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration): * workers/service/ServiceWorkerContextData.cpp: (WebCore::ServiceWorkerContextData::isolatedCopy const): * workers/service/ServiceWorkerContextData.h: (WebCore::ServiceWorkerContextData::encode const): (WebCore::ServiceWorkerContextData::decode): * workers/service/ServiceWorkerIdentifier.h: Copied from Source/WebCore/workers/service/ServiceWorkerContextData.cpp. * workers/service/ServiceWorkerRegistrationData.h: (WebCore::ServiceWorkerRegistrationData::decode): * workers/service/context/SWContextManager.cpp: (WebCore::SWContextManager::serviceWorkerThreadProxy const): (WebCore::SWContextManager::postMessageToServiceWorkerGlobalScope): * workers/service/context/SWContextManager.h: * workers/service/context/ServiceWorkerThread.cpp: (WebCore::ServiceWorkerThread::ServiceWorkerThread): * workers/service/context/ServiceWorkerThread.h: (WebCore::ServiceWorkerThread::identifier const): * workers/service/context/ServiceWorkerThreadProxy.h: * workers/service/server/SWClientConnection.cpp: (WebCore::SWClientConnection::postMessageToServiceWorkerClient): * workers/service/server/SWClientConnection.h: * workers/service/server/SWServer.cpp: (WebCore::generateServiceWorkerIdentifier): (WebCore::SWServer::Connection::scriptContextFailedToStart): (WebCore::SWServer::Connection::scriptContextStarted): (WebCore::SWServer::scriptContextFailedToStart): (WebCore::SWServer::scriptContextStarted): (WebCore::SWServer::updateWorker): * workers/service/server/SWServer.h: * workers/service/server/SWServerJobQueue.cpp: (WebCore::SWServerJobQueue::scriptContextFailedToStart): (WebCore::SWServerJobQueue::scriptContextStarted): * workers/service/server/SWServerJobQueue.h: * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::setActiveServiceWorkerIdentifier): * workers/service/server/SWServerWorker.cpp: (WebCore::SWServerWorker::SWServerWorker): * workers/service/server/SWServerWorker.h: (WebCore::SWServerWorker::create): (WebCore::SWServerWorker::identifier const): Source/WebKit: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * Scripts/webkit/messages.py: (forward_declarations_and_headers): (forward_declarations_and_headers.templates): * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::startFetch): (WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWServerConnection::postMessageToServiceWorkerClient): * StorageProcess/ServiceWorker/WebSWServerConnection.h: * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in: * StorageProcess/StorageProcess.cpp: (WebKit::StorageProcess::serviceWorkerContextFailedToStart): (WebKit::StorageProcess::serviceWorkerContextStarted): (WebKit::StorageProcess::postMessageToServiceWorkerClient): * StorageProcess/StorageProcess.h: * StorageProcess/StorageProcess.messages.in: * WebProcess/Storage/WebSWClientConnection.cpp: (WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWClientConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWClientConnection.h: * WebProcess/Storage/WebSWClientConnection.messages.in: * WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::updateServiceWorker): (WebKit::WebSWContextManagerConnection::serviceWorkerStartedWithMessage): (WebKit::WebSWContextManagerConnection::startFetch): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWContextManagerConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.messages.in: Source/WTF: Introduce class for strongly typed identifiers. This avoids mixing up different types of identifiers. * WTF.xcodeproj/project.pbxproj: * wtf/ObjectIdentifier.h: Added. (WTF::ObjectIdentifier::encode const): (WTF::ObjectIdentifier::decode): (WTF::ObjectIdentifier::operator== const): (WTF::ObjectIdentifier::operator!= const): (WTF::ObjectIdentifier::ObjectIdentifier): (WTF::makeObjectIdentifier): (WTF::ObjectIdentifierHash::hash): (WTF::ObjectIdentifierHash::equal): (WTF::HashTraits<ObjectIdentifier<T>>::emptyValue): (WTF::HashTraits<ObjectIdentifier<T>>::constructDeletedValue): (WTF::HashTraits<ObjectIdentifier<T>>::isDeletedValue): Canonical link: https://commits.webkit.org/195341@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224403 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-03 16:37:04 +00:00
template<typename T>
TextStream& operator<<(TextStream& ts, const ObjectIdentifier<T>& identifier)
{
ts << identifier.toUInt64();
return ts;
}
Use a single identifier type to identify Service Workers https://bugs.webkit.org/show_bug.cgi?id=179192 Reviewed by Brady Eidson. Source/WebCore: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * WebCore.xcodeproj/project.pbxproj: * loader/ResourceLoaderOptions.h: * loader/cache/CachedResourceRequest.cpp: (WebCore::CachedResourceRequest::setSelectedServiceWorkerIdentifierIfNeeded): * loader/cache/CachedResourceRequest.h: * workers/service/ServiceWorker.cpp: (WebCore::ServiceWorker::ServiceWorker): * workers/service/ServiceWorker.h: * workers/service/ServiceWorkerClient.cpp: (WebCore::ServiceWorkerClient::postMessage): * workers/service/ServiceWorkerContainer.cpp: (WebCore::ServiceWorkerContainer::jobResolvedWithRegistration): * workers/service/ServiceWorkerContextData.cpp: (WebCore::ServiceWorkerContextData::isolatedCopy const): * workers/service/ServiceWorkerContextData.h: (WebCore::ServiceWorkerContextData::encode const): (WebCore::ServiceWorkerContextData::decode): * workers/service/ServiceWorkerIdentifier.h: Copied from Source/WebCore/workers/service/ServiceWorkerContextData.cpp. * workers/service/ServiceWorkerRegistrationData.h: (WebCore::ServiceWorkerRegistrationData::decode): * workers/service/context/SWContextManager.cpp: (WebCore::SWContextManager::serviceWorkerThreadProxy const): (WebCore::SWContextManager::postMessageToServiceWorkerGlobalScope): * workers/service/context/SWContextManager.h: * workers/service/context/ServiceWorkerThread.cpp: (WebCore::ServiceWorkerThread::ServiceWorkerThread): * workers/service/context/ServiceWorkerThread.h: (WebCore::ServiceWorkerThread::identifier const): * workers/service/context/ServiceWorkerThreadProxy.h: * workers/service/server/SWClientConnection.cpp: (WebCore::SWClientConnection::postMessageToServiceWorkerClient): * workers/service/server/SWClientConnection.h: * workers/service/server/SWServer.cpp: (WebCore::generateServiceWorkerIdentifier): (WebCore::SWServer::Connection::scriptContextFailedToStart): (WebCore::SWServer::Connection::scriptContextStarted): (WebCore::SWServer::scriptContextFailedToStart): (WebCore::SWServer::scriptContextStarted): (WebCore::SWServer::updateWorker): * workers/service/server/SWServer.h: * workers/service/server/SWServerJobQueue.cpp: (WebCore::SWServerJobQueue::scriptContextFailedToStart): (WebCore::SWServerJobQueue::scriptContextStarted): * workers/service/server/SWServerJobQueue.h: * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::setActiveServiceWorkerIdentifier): * workers/service/server/SWServerWorker.cpp: (WebCore::SWServerWorker::SWServerWorker): * workers/service/server/SWServerWorker.h: (WebCore::SWServerWorker::create): (WebCore::SWServerWorker::identifier const): Source/WebKit: Use a single identifier type to identify Service Workers. We had both a String identifier and a uint64_t identifier for each service worker. We now consistently use a ServiceWorkerIdentifier which is a strongly typed identifier backed by a uint64_t. * Scripts/webkit/messages.py: (forward_declarations_and_headers): (forward_declarations_and_headers.templates): * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::startFetch): (WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWServerConnection::postMessageToServiceWorkerClient): * StorageProcess/ServiceWorker/WebSWServerConnection.h: * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in: * StorageProcess/StorageProcess.cpp: (WebKit::StorageProcess::serviceWorkerContextFailedToStart): (WebKit::StorageProcess::serviceWorkerContextStarted): (WebKit::StorageProcess::postMessageToServiceWorkerClient): * StorageProcess/StorageProcess.h: * StorageProcess/StorageProcess.messages.in: * WebProcess/Storage/WebSWClientConnection.cpp: (WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWClientConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWClientConnection.h: * WebProcess/Storage/WebSWClientConnection.messages.in: * WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::updateServiceWorker): (WebKit::WebSWContextManagerConnection::serviceWorkerStartedWithMessage): (WebKit::WebSWContextManagerConnection::startFetch): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerClient): * WebProcess/Storage/WebSWContextManagerConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.messages.in: Source/WTF: Introduce class for strongly typed identifiers. This avoids mixing up different types of identifiers. * WTF.xcodeproj/project.pbxproj: * wtf/ObjectIdentifier.h: Added. (WTF::ObjectIdentifier::encode const): (WTF::ObjectIdentifier::decode): (WTF::ObjectIdentifier::operator== const): (WTF::ObjectIdentifier::operator!= const): (WTF::ObjectIdentifier::ObjectIdentifier): (WTF::makeObjectIdentifier): (WTF::ObjectIdentifierHash::hash): (WTF::ObjectIdentifierHash::equal): (WTF::HashTraits<ObjectIdentifier<T>>::emptyValue): (WTF::HashTraits<ObjectIdentifier<T>>::constructDeletedValue): (WTF::HashTraits<ObjectIdentifier<T>>::isDeletedValue): Canonical link: https://commits.webkit.org/195341@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224403 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-03 16:37:04 +00:00
} // namespace WTF
using WTF::ObjectIdentifier;
Use a strongly typed identifier for SWServer::Connection https://bugs.webkit.org/show_bug.cgi?id=179848 Reviewed by Brady Eidson. Source/WebCore: Use a strongly typed identifier for SWServer::Connection, for clarity. * workers/service/ServiceWorker.cpp: (WebCore::ServiceWorker::postMessage): * workers/service/ServiceWorkerClient.cpp: (WebCore::ServiceWorkerClient::ServiceWorkerClient): (WebCore::ServiceWorkerClient::id const): (WebCore::ServiceWorkerClient::postMessage): * workers/service/ServiceWorkerClient.h: (WebCore::ServiceWorkerClient::create): (WebCore::ServiceWorkerClient::identifier const): * workers/service/ServiceWorkerClientData.cpp: (WebCore::ServiceWorkerClientData::isolatedCopy const): (WebCore::ServiceWorkerClientData::from): * workers/service/ServiceWorkerClientData.h: (WebCore::ServiceWorkerClientData::encode const): (WebCore::ServiceWorkerClientData::decode): * workers/service/ServiceWorkerClientIdentifier.h: (WebCore::ServiceWorkerClientIdentifier::toString const): (WebCore::ServiceWorkerClientIdentifier::decode): * workers/service/ServiceWorkerContainer.cpp: (WebCore::ServiceWorkerContainer::addRegistration): (WebCore::ServiceWorkerContainer::removeRegistration): (WebCore::ServiceWorkerContainer::updateRegistration): (WebCore::ServiceWorkerContainer::connectionIdentifier): * workers/service/ServiceWorkerContainer.h: * workers/service/ServiceWorkerFetchResult.h: (WebCore::ServiceWorkerFetchResult::decode): * workers/service/ServiceWorkerJobClient.h: * workers/service/ServiceWorkerJobData.cpp: (WebCore::ServiceWorkerJobData::ServiceWorkerJobData): * workers/service/ServiceWorkerJobData.h: (WebCore::ServiceWorkerJobData::connectionIdentifier const): (WebCore::ServiceWorkerJobData::decode): * workers/service/ServiceWorkerTypes.h: * workers/service/ServiceWorkerWindowClient.cpp: (WebCore::ServiceWorkerWindowClient::ServiceWorkerWindowClient): * workers/service/ServiceWorkerWindowClient.h: * workers/service/context/SWContextManager.cpp: (WebCore::SWContextManager::postMessageToServiceWorkerGlobalScope): * workers/service/context/SWContextManager.h: * workers/service/context/ServiceWorkerThread.cpp: (WebCore::ServiceWorkerThread::postMessageToServiceWorkerGlobalScope): * workers/service/context/ServiceWorkerThread.h: * workers/service/server/SWClientConnection.h: * workers/service/server/SWServer.cpp: (WebCore::SWServer::Connection::Connection): (WebCore::SWServer::Connection::scheduleJobInServer): (WebCore::SWServer::rejectJob): (WebCore::SWServer::resolveRegistrationJob): (WebCore::SWServer::startScriptFetch): (WebCore::SWServer::scriptFetchFinished): * workers/service/server/SWServer.h: (WebCore::SWServer::Connection::identifier const): (WebCore::SWServer::getConnection): * workers/service/server/SWServerRegistration.cpp: (WebCore::SWServerRegistration::forEachConnection): (WebCore::SWServerRegistration::addClientServiceWorkerRegistration): (WebCore::SWServerRegistration::removeClientServiceWorkerRegistration): (WebCore::SWServerRegistration::unregisterServerConnection): * workers/service/server/SWServerRegistration.h: Source/WebKit: Use a strongly typed identifier for SWServer::Connection, for clarity. * Scripts/webkit/messages.py: (forward_declarations_and_headers): (forward_declarations_and_headers.templates): (headers_for_type): * StorageProcess/ServiceWorker/WebSWServerConnection.cpp: (WebKit::WebSWServerConnection::WebSWServerConnection): (WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope): * StorageProcess/ServiceWorker/WebSWServerConnection.h: * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in: * StorageProcess/StorageProcess.cpp: (WebKit::StorageProcess::didFailFetch): (WebKit::StorageProcess::didNotHandleFetch): (WebKit::StorageProcess::didReceiveFetchResponse): (WebKit::StorageProcess::didReceiveFetchData): (WebKit::StorageProcess::didReceiveFetchFormData): (WebKit::StorageProcess::didFinishFetch): * StorageProcess/StorageProcess.h: * StorageProcess/StorageProcess.messages.in: * StorageProcess/StorageToWebProcessConnection.cpp: (WebKit::StorageToWebProcessConnection::didReceiveMessage): (WebKit::StorageToWebProcessConnection::establishSWServerConnection): (WebKit::StorageToWebProcessConnection::removeSWServerConnection): (WebKit::generateIDBConnectionToServerIdentifier): (WebKit::StorageToWebProcessConnection::establishIDBConnectionToServer): * StorageProcess/StorageToWebProcessConnection.h: * StorageProcess/StorageToWebProcessConnection.messages.in: * WebProcess/Storage/WebSWClientConnection.cpp: (WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope): * WebProcess/Storage/WebSWClientConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::WebSWContextManagerConnection::startFetch): (WebKit::WebSWContextManagerConnection::postMessageToServiceWorkerGlobalScope): * WebProcess/Storage/WebSWContextManagerConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.messages.in: * WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp: (WebKit::WebServiceWorkerFetchTaskClient::WebServiceWorkerFetchTaskClient): * WebProcess/Storage/WebServiceWorkerFetchTaskClient.h: * WebProcess/Storage/WebToStorageProcessConnection.cpp: (WebKit::WebToStorageProcessConnection::didReceiveMessage): (WebKit::WebToStorageProcessConnection::serviceWorkerConnectionForSession): * WebProcess/Storage/WebToStorageProcessConnection.h: Source/WTF: Make ObjectIdentifier a little more flexible to support more use cases. * wtf/ObjectIdentifier.h: (WTF::ObjectIdentifier::toUInt64 const): (WTF::makeObjectIdentifier): Canonical link: https://commits.webkit.org/195877@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225008 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-18 02:27:13 +00:00
using WTF::makeObjectIdentifier;