haikuwebkit/Source/WTF/wtf/Identified.h

109 lines
3.1 KiB
C
Raw Permalink Normal View History

Add "Identified" base class to replace a whole bunch of custom identifier generators. https://bugs.webkit.org/show_bug.cgi?id=176120 Reviewed by Alex Christensen. Source/WebCore: No new tests (No behavior change). Instead of repeating the common pattern of a class with an integer identifier keeping its own static counter of the next identifier and generating it for each instance, this uses a common template in WTF that does that automatically. * Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp: (WebCore::IDBServer::UniqueIDBDatabaseConnection::UniqueIDBDatabaseConnection): (WebCore::IDBServer::UniqueIDBDatabaseConnection::connectionPendingCloseFromClient): (WebCore::IDBServer::UniqueIDBDatabaseConnection::connectionClosedFromClient): (WebCore::IDBServer::UniqueIDBDatabaseConnection::confirmDidCloseFromServer): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didFireVersionChangeEvent): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didFinishHandlingVersionChange): (WebCore::IDBServer::UniqueIDBDatabaseConnection::createVersionChangeTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::establishTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didAbortTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didCommitTransaction): (WebCore::IDBServer::nextDatabaseConnectionIdentifier): Deleted. * Modules/indexeddb/server/UniqueIDBDatabaseConnection.h: (WebCore::IDBServer::UniqueIDBDatabaseConnection::identifier const): Deleted. * workers/service/ServiceWorkerJobData.cpp: (WebCore::ServiceWorkerJobData::ServiceWorkerJobData): (WebCore::ServiceWorkerJobData::isolatedCopy const): * workers/service/ServiceWorkerJobData.h: (WebCore::ServiceWorkerJobData::encode const): (WebCore::ServiceWorkerJobData::decode): (WebCore::ServiceWorkerJobData::identifier const): Deleted. * workers/service/server/SWServer.cpp: (WebCore::SWServer::Connection::Connection): * workers/service/server/SWServer.h: (WebCore::SWServer::Connection::identifier const): Deleted. * workers/service/server/SWServerRegistration.cpp: (WebCore::SWServerRegistration::SWServerRegistration): (WebCore::SWServerRegistration::data const): * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::identifier const): Deleted. Source/WebKit: * UIProcess/API/APIUserScript.cpp: (API::UserScript::UserScript): (API::generateIdentifier): Deleted. * UIProcess/API/APIUserScript.h: * UIProcess/API/APIUserStyleSheet.cpp: (API::UserStyleSheet::UserStyleSheet): (API::generateIdentifier): Deleted. * UIProcess/API/APIUserStyleSheet.h: * UIProcess/UserContent/WebScriptMessageHandler.cpp: (WebKit::WebScriptMessageHandler::WebScriptMessageHandler): (WebKit::generateIdentifier): Deleted. * UIProcess/UserContent/WebScriptMessageHandler.h: (WebKit::WebScriptMessageHandler::identifier const): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::WebUserContentControllerProxy): (WebKit::WebUserContentControllerProxy::~WebUserContentControllerProxy): (WebKit::WebUserContentControllerProxy::addProcess): (WebKit::WebUserContentControllerProxy::removeProcess): (WebKit::WebUserContentControllerProxy::addUserContentWorldUse): (WebKit::WebUserContentControllerProxy::removeUserContentWorldUses): (WebKit::WebUserContentControllerProxy::addUserScript): (WebKit::WebUserContentControllerProxy::removeUserScript): (WebKit::WebUserContentControllerProxy::removeAllUserScripts): (WebKit::WebUserContentControllerProxy::addUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeAllUserStyleSheets): (WebKit::WebUserContentControllerProxy::addUserScriptMessageHandler): (WebKit::WebUserContentControllerProxy::removeUserMessageHandlerForName): (WebKit::WebUserContentControllerProxy::removeAllUserMessageHandlers): (WebKit::WebUserContentControllerProxy::addContentRuleList): (WebKit::WebUserContentControllerProxy::removeContentRuleList): (WebKit::WebUserContentControllerProxy::removeAllContentRuleLists): (WebKit::generateIdentifier): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.h: (WebKit::WebUserContentControllerProxy::identifier const): Deleted. * UIProcess/VisitedLinkStore.cpp: (WebKit::VisitedLinkStore::~VisitedLinkStore): (WebKit::VisitedLinkStore::VisitedLinkStore): (WebKit::VisitedLinkStore::addProcess): (WebKit::VisitedLinkStore::removeProcess): (WebKit::VisitedLinkStore::removeAll): (WebKit::VisitedLinkStore::pendingVisitedLinksTimerFired): (WebKit::VisitedLinkStore::sendTable): (WebKit::generateIdentifier): Deleted. * UIProcess/VisitedLinkStore.h: * UIProcess/WebsiteData/WebsiteDataStore.cpp: (WebKit::WebsiteDataStore::WebsiteDataStore): (WebKit::generateIdentifier): Deleted. * UIProcess/WebsiteData/WebsiteDataStore.h: (WebKit::WebsiteDataStore::identifier const): Deleted. * WebProcess/Network/WebSocketStream.cpp: (WebKit::WebSocketStream::WebSocketStream): (WebKit::WebSocketStream::~WebSocketStream): (WebKit::WebSocketStream::messageSenderDestinationID): * WebProcess/Network/WebSocketStream.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/Identified.h: Added. (WTF::IdentifiedBase::identifier const): (WTF::IdentifiedBase::IdentifiedBase): (WTF::Identified::Identified): (WTF::ThreadSafeIdentified::ThreadSafeIdentified): Canonical link: https://commits.webkit.org/192802@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221399 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-30 21:50:27 +00:00
/*
* Copyright (C) 2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
Make SERVICE_WORKER feature buildable on GTK, WPE https://bugs.webkit.org/show_bug.cgi?id=178574 Reviewed by Carlos Garcia Campos. Source/WebCore: * CMakeLists.txt: Add missing include paths and files to the build. * Sources.txt: Add missing files to the build. * WebCore.xcodeproj/project.pbxproj: Remove the JSDOMPromise.cpp and JSFetchEventCustom.cpp targets, they're now built via unified sources. * bindings/js/JSFetchEventCustom.cpp: Guard custom JSFetchEvent code with the ENABLE(SERVICE_WORKER) guards. Source/WebKit: * CMakeLists.txt: Add missing files to the build. * StorageProcess/StorageProcess.cpp: (WebKit::StorageProcess::didGetWorkerContextProcessConnection): IPC::Attachment object should be accessed through an rvalue reference, making it mutable and enabling releasing the file descriptor. * StorageProcess/StorageProcess.h: Adjust the method signature. * WebProcess/Storage/ServiceWorkerClientFetch.cpp: Explicitly include the ResourceError header from WebCore (using a forwarding header). * WebProcess/Storage/WebServiceWorkerProvider.cpp: Include the CachedResource header from WebCore (again using a forwarding header). * WebProcess/Storage/WebServiceWorkerProvider.h: Forward-declare the WebCore::CachedResource type. Source/WTF: * wtf/Identified.h: Explicitly include the <atomic> header since std::atomic<> is used in the ThreadSafeIdentified definition. Tools: * Scripts/webkitperl/FeatureList.pm: Add the --service-worker option that enables the SERVICE_WORKER feature flag. For now it's enabled on Apple's Cocoa ports (even when build-webkit isn't used for those builds, the flag is enabled here for consistency). Canonical link: https://commits.webkit.org/194947@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223951 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-25 07:17:21 +00:00
#include <atomic>
#include <wtf/NeverDestroyed.h>
Make SERVICE_WORKER feature buildable on GTK, WPE https://bugs.webkit.org/show_bug.cgi?id=178574 Reviewed by Carlos Garcia Campos. Source/WebCore: * CMakeLists.txt: Add missing include paths and files to the build. * Sources.txt: Add missing files to the build. * WebCore.xcodeproj/project.pbxproj: Remove the JSDOMPromise.cpp and JSFetchEventCustom.cpp targets, they're now built via unified sources. * bindings/js/JSFetchEventCustom.cpp: Guard custom JSFetchEvent code with the ENABLE(SERVICE_WORKER) guards. Source/WebKit: * CMakeLists.txt: Add missing files to the build. * StorageProcess/StorageProcess.cpp: (WebKit::StorageProcess::didGetWorkerContextProcessConnection): IPC::Attachment object should be accessed through an rvalue reference, making it mutable and enabling releasing the file descriptor. * StorageProcess/StorageProcess.h: Adjust the method signature. * WebProcess/Storage/ServiceWorkerClientFetch.cpp: Explicitly include the ResourceError header from WebCore (using a forwarding header). * WebProcess/Storage/WebServiceWorkerProvider.cpp: Include the CachedResource header from WebCore (again using a forwarding header). * WebProcess/Storage/WebServiceWorkerProvider.h: Forward-declare the WebCore::CachedResource type. Source/WTF: * wtf/Identified.h: Explicitly include the <atomic> header since std::atomic<> is used in the ThreadSafeIdentified definition. Tools: * Scripts/webkitperl/FeatureList.pm: Add the --service-worker option that enables the SERVICE_WORKER feature flag. For now it's enabled on Apple's Cocoa ports (even when build-webkit isn't used for those builds, the flag is enabled here for consistency). Canonical link: https://commits.webkit.org/194947@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223951 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-25 07:17:21 +00:00
Add "Identified" base class to replace a whole bunch of custom identifier generators. https://bugs.webkit.org/show_bug.cgi?id=176120 Reviewed by Alex Christensen. Source/WebCore: No new tests (No behavior change). Instead of repeating the common pattern of a class with an integer identifier keeping its own static counter of the next identifier and generating it for each instance, this uses a common template in WTF that does that automatically. * Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp: (WebCore::IDBServer::UniqueIDBDatabaseConnection::UniqueIDBDatabaseConnection): (WebCore::IDBServer::UniqueIDBDatabaseConnection::connectionPendingCloseFromClient): (WebCore::IDBServer::UniqueIDBDatabaseConnection::connectionClosedFromClient): (WebCore::IDBServer::UniqueIDBDatabaseConnection::confirmDidCloseFromServer): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didFireVersionChangeEvent): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didFinishHandlingVersionChange): (WebCore::IDBServer::UniqueIDBDatabaseConnection::createVersionChangeTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::establishTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didAbortTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didCommitTransaction): (WebCore::IDBServer::nextDatabaseConnectionIdentifier): Deleted. * Modules/indexeddb/server/UniqueIDBDatabaseConnection.h: (WebCore::IDBServer::UniqueIDBDatabaseConnection::identifier const): Deleted. * workers/service/ServiceWorkerJobData.cpp: (WebCore::ServiceWorkerJobData::ServiceWorkerJobData): (WebCore::ServiceWorkerJobData::isolatedCopy const): * workers/service/ServiceWorkerJobData.h: (WebCore::ServiceWorkerJobData::encode const): (WebCore::ServiceWorkerJobData::decode): (WebCore::ServiceWorkerJobData::identifier const): Deleted. * workers/service/server/SWServer.cpp: (WebCore::SWServer::Connection::Connection): * workers/service/server/SWServer.h: (WebCore::SWServer::Connection::identifier const): Deleted. * workers/service/server/SWServerRegistration.cpp: (WebCore::SWServerRegistration::SWServerRegistration): (WebCore::SWServerRegistration::data const): * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::identifier const): Deleted. Source/WebKit: * UIProcess/API/APIUserScript.cpp: (API::UserScript::UserScript): (API::generateIdentifier): Deleted. * UIProcess/API/APIUserScript.h: * UIProcess/API/APIUserStyleSheet.cpp: (API::UserStyleSheet::UserStyleSheet): (API::generateIdentifier): Deleted. * UIProcess/API/APIUserStyleSheet.h: * UIProcess/UserContent/WebScriptMessageHandler.cpp: (WebKit::WebScriptMessageHandler::WebScriptMessageHandler): (WebKit::generateIdentifier): Deleted. * UIProcess/UserContent/WebScriptMessageHandler.h: (WebKit::WebScriptMessageHandler::identifier const): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::WebUserContentControllerProxy): (WebKit::WebUserContentControllerProxy::~WebUserContentControllerProxy): (WebKit::WebUserContentControllerProxy::addProcess): (WebKit::WebUserContentControllerProxy::removeProcess): (WebKit::WebUserContentControllerProxy::addUserContentWorldUse): (WebKit::WebUserContentControllerProxy::removeUserContentWorldUses): (WebKit::WebUserContentControllerProxy::addUserScript): (WebKit::WebUserContentControllerProxy::removeUserScript): (WebKit::WebUserContentControllerProxy::removeAllUserScripts): (WebKit::WebUserContentControllerProxy::addUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeAllUserStyleSheets): (WebKit::WebUserContentControllerProxy::addUserScriptMessageHandler): (WebKit::WebUserContentControllerProxy::removeUserMessageHandlerForName): (WebKit::WebUserContentControllerProxy::removeAllUserMessageHandlers): (WebKit::WebUserContentControllerProxy::addContentRuleList): (WebKit::WebUserContentControllerProxy::removeContentRuleList): (WebKit::WebUserContentControllerProxy::removeAllContentRuleLists): (WebKit::generateIdentifier): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.h: (WebKit::WebUserContentControllerProxy::identifier const): Deleted. * UIProcess/VisitedLinkStore.cpp: (WebKit::VisitedLinkStore::~VisitedLinkStore): (WebKit::VisitedLinkStore::VisitedLinkStore): (WebKit::VisitedLinkStore::addProcess): (WebKit::VisitedLinkStore::removeProcess): (WebKit::VisitedLinkStore::removeAll): (WebKit::VisitedLinkStore::pendingVisitedLinksTimerFired): (WebKit::VisitedLinkStore::sendTable): (WebKit::generateIdentifier): Deleted. * UIProcess/VisitedLinkStore.h: * UIProcess/WebsiteData/WebsiteDataStore.cpp: (WebKit::WebsiteDataStore::WebsiteDataStore): (WebKit::generateIdentifier): Deleted. * UIProcess/WebsiteData/WebsiteDataStore.h: (WebKit::WebsiteDataStore::identifier const): Deleted. * WebProcess/Network/WebSocketStream.cpp: (WebKit::WebSocketStream::WebSocketStream): (WebKit::WebSocketStream::~WebSocketStream): (WebKit::WebSocketStream::messageSenderDestinationID): * WebProcess/Network/WebSocketStream.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/Identified.h: Added. (WTF::IdentifiedBase::identifier const): (WTF::IdentifiedBase::IdentifiedBase): (WTF::Identified::Identified): (WTF::ThreadSafeIdentified::ThreadSafeIdentified): Canonical link: https://commits.webkit.org/192802@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221399 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-30 21:50:27 +00:00
namespace WTF {
template <typename IdentifierType, typename ClassType>
Add "Identified" base class to replace a whole bunch of custom identifier generators. https://bugs.webkit.org/show_bug.cgi?id=176120 Reviewed by Alex Christensen. Source/WebCore: No new tests (No behavior change). Instead of repeating the common pattern of a class with an integer identifier keeping its own static counter of the next identifier and generating it for each instance, this uses a common template in WTF that does that automatically. * Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp: (WebCore::IDBServer::UniqueIDBDatabaseConnection::UniqueIDBDatabaseConnection): (WebCore::IDBServer::UniqueIDBDatabaseConnection::connectionPendingCloseFromClient): (WebCore::IDBServer::UniqueIDBDatabaseConnection::connectionClosedFromClient): (WebCore::IDBServer::UniqueIDBDatabaseConnection::confirmDidCloseFromServer): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didFireVersionChangeEvent): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didFinishHandlingVersionChange): (WebCore::IDBServer::UniqueIDBDatabaseConnection::createVersionChangeTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::establishTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didAbortTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didCommitTransaction): (WebCore::IDBServer::nextDatabaseConnectionIdentifier): Deleted. * Modules/indexeddb/server/UniqueIDBDatabaseConnection.h: (WebCore::IDBServer::UniqueIDBDatabaseConnection::identifier const): Deleted. * workers/service/ServiceWorkerJobData.cpp: (WebCore::ServiceWorkerJobData::ServiceWorkerJobData): (WebCore::ServiceWorkerJobData::isolatedCopy const): * workers/service/ServiceWorkerJobData.h: (WebCore::ServiceWorkerJobData::encode const): (WebCore::ServiceWorkerJobData::decode): (WebCore::ServiceWorkerJobData::identifier const): Deleted. * workers/service/server/SWServer.cpp: (WebCore::SWServer::Connection::Connection): * workers/service/server/SWServer.h: (WebCore::SWServer::Connection::identifier const): Deleted. * workers/service/server/SWServerRegistration.cpp: (WebCore::SWServerRegistration::SWServerRegistration): (WebCore::SWServerRegistration::data const): * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::identifier const): Deleted. Source/WebKit: * UIProcess/API/APIUserScript.cpp: (API::UserScript::UserScript): (API::generateIdentifier): Deleted. * UIProcess/API/APIUserScript.h: * UIProcess/API/APIUserStyleSheet.cpp: (API::UserStyleSheet::UserStyleSheet): (API::generateIdentifier): Deleted. * UIProcess/API/APIUserStyleSheet.h: * UIProcess/UserContent/WebScriptMessageHandler.cpp: (WebKit::WebScriptMessageHandler::WebScriptMessageHandler): (WebKit::generateIdentifier): Deleted. * UIProcess/UserContent/WebScriptMessageHandler.h: (WebKit::WebScriptMessageHandler::identifier const): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::WebUserContentControllerProxy): (WebKit::WebUserContentControllerProxy::~WebUserContentControllerProxy): (WebKit::WebUserContentControllerProxy::addProcess): (WebKit::WebUserContentControllerProxy::removeProcess): (WebKit::WebUserContentControllerProxy::addUserContentWorldUse): (WebKit::WebUserContentControllerProxy::removeUserContentWorldUses): (WebKit::WebUserContentControllerProxy::addUserScript): (WebKit::WebUserContentControllerProxy::removeUserScript): (WebKit::WebUserContentControllerProxy::removeAllUserScripts): (WebKit::WebUserContentControllerProxy::addUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeAllUserStyleSheets): (WebKit::WebUserContentControllerProxy::addUserScriptMessageHandler): (WebKit::WebUserContentControllerProxy::removeUserMessageHandlerForName): (WebKit::WebUserContentControllerProxy::removeAllUserMessageHandlers): (WebKit::WebUserContentControllerProxy::addContentRuleList): (WebKit::WebUserContentControllerProxy::removeContentRuleList): (WebKit::WebUserContentControllerProxy::removeAllContentRuleLists): (WebKit::generateIdentifier): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.h: (WebKit::WebUserContentControllerProxy::identifier const): Deleted. * UIProcess/VisitedLinkStore.cpp: (WebKit::VisitedLinkStore::~VisitedLinkStore): (WebKit::VisitedLinkStore::VisitedLinkStore): (WebKit::VisitedLinkStore::addProcess): (WebKit::VisitedLinkStore::removeProcess): (WebKit::VisitedLinkStore::removeAll): (WebKit::VisitedLinkStore::pendingVisitedLinksTimerFired): (WebKit::VisitedLinkStore::sendTable): (WebKit::generateIdentifier): Deleted. * UIProcess/VisitedLinkStore.h: * UIProcess/WebsiteData/WebsiteDataStore.cpp: (WebKit::WebsiteDataStore::WebsiteDataStore): (WebKit::generateIdentifier): Deleted. * UIProcess/WebsiteData/WebsiteDataStore.h: (WebKit::WebsiteDataStore::identifier const): Deleted. * WebProcess/Network/WebSocketStream.cpp: (WebKit::WebSocketStream::WebSocketStream): (WebKit::WebSocketStream::~WebSocketStream): (WebKit::WebSocketStream::messageSenderDestinationID): * WebProcess/Network/WebSocketStream.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/Identified.h: Added. (WTF::IdentifiedBase::identifier const): (WTF::IdentifiedBase::IdentifiedBase): (WTF::Identified::Identified): (WTF::ThreadSafeIdentified::ThreadSafeIdentified): Canonical link: https://commits.webkit.org/192802@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221399 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-30 21:50:27 +00:00
class IdentifiedBase {
public:
IdentifierType identifier() const
{
return m_identifier;
}
protected:
IdentifiedBase(const IdentifiedBase&) = default;
Add "Identified" base class to replace a whole bunch of custom identifier generators. https://bugs.webkit.org/show_bug.cgi?id=176120 Reviewed by Alex Christensen. Source/WebCore: No new tests (No behavior change). Instead of repeating the common pattern of a class with an integer identifier keeping its own static counter of the next identifier and generating it for each instance, this uses a common template in WTF that does that automatically. * Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp: (WebCore::IDBServer::UniqueIDBDatabaseConnection::UniqueIDBDatabaseConnection): (WebCore::IDBServer::UniqueIDBDatabaseConnection::connectionPendingCloseFromClient): (WebCore::IDBServer::UniqueIDBDatabaseConnection::connectionClosedFromClient): (WebCore::IDBServer::UniqueIDBDatabaseConnection::confirmDidCloseFromServer): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didFireVersionChangeEvent): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didFinishHandlingVersionChange): (WebCore::IDBServer::UniqueIDBDatabaseConnection::createVersionChangeTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::establishTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didAbortTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didCommitTransaction): (WebCore::IDBServer::nextDatabaseConnectionIdentifier): Deleted. * Modules/indexeddb/server/UniqueIDBDatabaseConnection.h: (WebCore::IDBServer::UniqueIDBDatabaseConnection::identifier const): Deleted. * workers/service/ServiceWorkerJobData.cpp: (WebCore::ServiceWorkerJobData::ServiceWorkerJobData): (WebCore::ServiceWorkerJobData::isolatedCopy const): * workers/service/ServiceWorkerJobData.h: (WebCore::ServiceWorkerJobData::encode const): (WebCore::ServiceWorkerJobData::decode): (WebCore::ServiceWorkerJobData::identifier const): Deleted. * workers/service/server/SWServer.cpp: (WebCore::SWServer::Connection::Connection): * workers/service/server/SWServer.h: (WebCore::SWServer::Connection::identifier const): Deleted. * workers/service/server/SWServerRegistration.cpp: (WebCore::SWServerRegistration::SWServerRegistration): (WebCore::SWServerRegistration::data const): * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::identifier const): Deleted. Source/WebKit: * UIProcess/API/APIUserScript.cpp: (API::UserScript::UserScript): (API::generateIdentifier): Deleted. * UIProcess/API/APIUserScript.h: * UIProcess/API/APIUserStyleSheet.cpp: (API::UserStyleSheet::UserStyleSheet): (API::generateIdentifier): Deleted. * UIProcess/API/APIUserStyleSheet.h: * UIProcess/UserContent/WebScriptMessageHandler.cpp: (WebKit::WebScriptMessageHandler::WebScriptMessageHandler): (WebKit::generateIdentifier): Deleted. * UIProcess/UserContent/WebScriptMessageHandler.h: (WebKit::WebScriptMessageHandler::identifier const): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::WebUserContentControllerProxy): (WebKit::WebUserContentControllerProxy::~WebUserContentControllerProxy): (WebKit::WebUserContentControllerProxy::addProcess): (WebKit::WebUserContentControllerProxy::removeProcess): (WebKit::WebUserContentControllerProxy::addUserContentWorldUse): (WebKit::WebUserContentControllerProxy::removeUserContentWorldUses): (WebKit::WebUserContentControllerProxy::addUserScript): (WebKit::WebUserContentControllerProxy::removeUserScript): (WebKit::WebUserContentControllerProxy::removeAllUserScripts): (WebKit::WebUserContentControllerProxy::addUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeAllUserStyleSheets): (WebKit::WebUserContentControllerProxy::addUserScriptMessageHandler): (WebKit::WebUserContentControllerProxy::removeUserMessageHandlerForName): (WebKit::WebUserContentControllerProxy::removeAllUserMessageHandlers): (WebKit::WebUserContentControllerProxy::addContentRuleList): (WebKit::WebUserContentControllerProxy::removeContentRuleList): (WebKit::WebUserContentControllerProxy::removeAllContentRuleLists): (WebKit::generateIdentifier): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.h: (WebKit::WebUserContentControllerProxy::identifier const): Deleted. * UIProcess/VisitedLinkStore.cpp: (WebKit::VisitedLinkStore::~VisitedLinkStore): (WebKit::VisitedLinkStore::VisitedLinkStore): (WebKit::VisitedLinkStore::addProcess): (WebKit::VisitedLinkStore::removeProcess): (WebKit::VisitedLinkStore::removeAll): (WebKit::VisitedLinkStore::pendingVisitedLinksTimerFired): (WebKit::VisitedLinkStore::sendTable): (WebKit::generateIdentifier): Deleted. * UIProcess/VisitedLinkStore.h: * UIProcess/WebsiteData/WebsiteDataStore.cpp: (WebKit::WebsiteDataStore::WebsiteDataStore): (WebKit::generateIdentifier): Deleted. * UIProcess/WebsiteData/WebsiteDataStore.h: (WebKit::WebsiteDataStore::identifier const): Deleted. * WebProcess/Network/WebSocketStream.cpp: (WebKit::WebSocketStream::WebSocketStream): (WebKit::WebSocketStream::~WebSocketStream): (WebKit::WebSocketStream::messageSenderDestinationID): * WebProcess/Network/WebSocketStream.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/Identified.h: Added. (WTF::IdentifiedBase::identifier const): (WTF::IdentifiedBase::IdentifiedBase): (WTF::Identified::Identified): (WTF::ThreadSafeIdentified::ThreadSafeIdentified): Canonical link: https://commits.webkit.org/192802@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221399 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-30 21:50:27 +00:00
explicit IdentifiedBase(IdentifierType identifier)
: m_identifier(identifier)
{
}
IdentifiedBase& operator=(const IdentifiedBase&) = default;
Add "Identified" base class to replace a whole bunch of custom identifier generators. https://bugs.webkit.org/show_bug.cgi?id=176120 Reviewed by Alex Christensen. Source/WebCore: No new tests (No behavior change). Instead of repeating the common pattern of a class with an integer identifier keeping its own static counter of the next identifier and generating it for each instance, this uses a common template in WTF that does that automatically. * Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp: (WebCore::IDBServer::UniqueIDBDatabaseConnection::UniqueIDBDatabaseConnection): (WebCore::IDBServer::UniqueIDBDatabaseConnection::connectionPendingCloseFromClient): (WebCore::IDBServer::UniqueIDBDatabaseConnection::connectionClosedFromClient): (WebCore::IDBServer::UniqueIDBDatabaseConnection::confirmDidCloseFromServer): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didFireVersionChangeEvent): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didFinishHandlingVersionChange): (WebCore::IDBServer::UniqueIDBDatabaseConnection::createVersionChangeTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::establishTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didAbortTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didCommitTransaction): (WebCore::IDBServer::nextDatabaseConnectionIdentifier): Deleted. * Modules/indexeddb/server/UniqueIDBDatabaseConnection.h: (WebCore::IDBServer::UniqueIDBDatabaseConnection::identifier const): Deleted. * workers/service/ServiceWorkerJobData.cpp: (WebCore::ServiceWorkerJobData::ServiceWorkerJobData): (WebCore::ServiceWorkerJobData::isolatedCopy const): * workers/service/ServiceWorkerJobData.h: (WebCore::ServiceWorkerJobData::encode const): (WebCore::ServiceWorkerJobData::decode): (WebCore::ServiceWorkerJobData::identifier const): Deleted. * workers/service/server/SWServer.cpp: (WebCore::SWServer::Connection::Connection): * workers/service/server/SWServer.h: (WebCore::SWServer::Connection::identifier const): Deleted. * workers/service/server/SWServerRegistration.cpp: (WebCore::SWServerRegistration::SWServerRegistration): (WebCore::SWServerRegistration::data const): * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::identifier const): Deleted. Source/WebKit: * UIProcess/API/APIUserScript.cpp: (API::UserScript::UserScript): (API::generateIdentifier): Deleted. * UIProcess/API/APIUserScript.h: * UIProcess/API/APIUserStyleSheet.cpp: (API::UserStyleSheet::UserStyleSheet): (API::generateIdentifier): Deleted. * UIProcess/API/APIUserStyleSheet.h: * UIProcess/UserContent/WebScriptMessageHandler.cpp: (WebKit::WebScriptMessageHandler::WebScriptMessageHandler): (WebKit::generateIdentifier): Deleted. * UIProcess/UserContent/WebScriptMessageHandler.h: (WebKit::WebScriptMessageHandler::identifier const): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::WebUserContentControllerProxy): (WebKit::WebUserContentControllerProxy::~WebUserContentControllerProxy): (WebKit::WebUserContentControllerProxy::addProcess): (WebKit::WebUserContentControllerProxy::removeProcess): (WebKit::WebUserContentControllerProxy::addUserContentWorldUse): (WebKit::WebUserContentControllerProxy::removeUserContentWorldUses): (WebKit::WebUserContentControllerProxy::addUserScript): (WebKit::WebUserContentControllerProxy::removeUserScript): (WebKit::WebUserContentControllerProxy::removeAllUserScripts): (WebKit::WebUserContentControllerProxy::addUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeAllUserStyleSheets): (WebKit::WebUserContentControllerProxy::addUserScriptMessageHandler): (WebKit::WebUserContentControllerProxy::removeUserMessageHandlerForName): (WebKit::WebUserContentControllerProxy::removeAllUserMessageHandlers): (WebKit::WebUserContentControllerProxy::addContentRuleList): (WebKit::WebUserContentControllerProxy::removeContentRuleList): (WebKit::WebUserContentControllerProxy::removeAllContentRuleLists): (WebKit::generateIdentifier): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.h: (WebKit::WebUserContentControllerProxy::identifier const): Deleted. * UIProcess/VisitedLinkStore.cpp: (WebKit::VisitedLinkStore::~VisitedLinkStore): (WebKit::VisitedLinkStore::VisitedLinkStore): (WebKit::VisitedLinkStore::addProcess): (WebKit::VisitedLinkStore::removeProcess): (WebKit::VisitedLinkStore::removeAll): (WebKit::VisitedLinkStore::pendingVisitedLinksTimerFired): (WebKit::VisitedLinkStore::sendTable): (WebKit::generateIdentifier): Deleted. * UIProcess/VisitedLinkStore.h: * UIProcess/WebsiteData/WebsiteDataStore.cpp: (WebKit::WebsiteDataStore::WebsiteDataStore): (WebKit::generateIdentifier): Deleted. * UIProcess/WebsiteData/WebsiteDataStore.h: (WebKit::WebsiteDataStore::identifier const): Deleted. * WebProcess/Network/WebSocketStream.cpp: (WebKit::WebSocketStream::WebSocketStream): (WebKit::WebSocketStream::~WebSocketStream): (WebKit::WebSocketStream::messageSenderDestinationID): * WebProcess/Network/WebSocketStream.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/Identified.h: Added. (WTF::IdentifiedBase::identifier const): (WTF::IdentifiedBase::IdentifiedBase): (WTF::Identified::Identified): (WTF::ThreadSafeIdentified::ThreadSafeIdentified): Canonical link: https://commits.webkit.org/192802@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221399 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-30 21:50:27 +00:00
private:
IdentifierType m_identifier;
};
template <typename T>
class Identified : public IdentifiedBase<uint64_t, T> {
Add "Identified" base class to replace a whole bunch of custom identifier generators. https://bugs.webkit.org/show_bug.cgi?id=176120 Reviewed by Alex Christensen. Source/WebCore: No new tests (No behavior change). Instead of repeating the common pattern of a class with an integer identifier keeping its own static counter of the next identifier and generating it for each instance, this uses a common template in WTF that does that automatically. * Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp: (WebCore::IDBServer::UniqueIDBDatabaseConnection::UniqueIDBDatabaseConnection): (WebCore::IDBServer::UniqueIDBDatabaseConnection::connectionPendingCloseFromClient): (WebCore::IDBServer::UniqueIDBDatabaseConnection::connectionClosedFromClient): (WebCore::IDBServer::UniqueIDBDatabaseConnection::confirmDidCloseFromServer): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didFireVersionChangeEvent): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didFinishHandlingVersionChange): (WebCore::IDBServer::UniqueIDBDatabaseConnection::createVersionChangeTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::establishTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didAbortTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didCommitTransaction): (WebCore::IDBServer::nextDatabaseConnectionIdentifier): Deleted. * Modules/indexeddb/server/UniqueIDBDatabaseConnection.h: (WebCore::IDBServer::UniqueIDBDatabaseConnection::identifier const): Deleted. * workers/service/ServiceWorkerJobData.cpp: (WebCore::ServiceWorkerJobData::ServiceWorkerJobData): (WebCore::ServiceWorkerJobData::isolatedCopy const): * workers/service/ServiceWorkerJobData.h: (WebCore::ServiceWorkerJobData::encode const): (WebCore::ServiceWorkerJobData::decode): (WebCore::ServiceWorkerJobData::identifier const): Deleted. * workers/service/server/SWServer.cpp: (WebCore::SWServer::Connection::Connection): * workers/service/server/SWServer.h: (WebCore::SWServer::Connection::identifier const): Deleted. * workers/service/server/SWServerRegistration.cpp: (WebCore::SWServerRegistration::SWServerRegistration): (WebCore::SWServerRegistration::data const): * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::identifier const): Deleted. Source/WebKit: * UIProcess/API/APIUserScript.cpp: (API::UserScript::UserScript): (API::generateIdentifier): Deleted. * UIProcess/API/APIUserScript.h: * UIProcess/API/APIUserStyleSheet.cpp: (API::UserStyleSheet::UserStyleSheet): (API::generateIdentifier): Deleted. * UIProcess/API/APIUserStyleSheet.h: * UIProcess/UserContent/WebScriptMessageHandler.cpp: (WebKit::WebScriptMessageHandler::WebScriptMessageHandler): (WebKit::generateIdentifier): Deleted. * UIProcess/UserContent/WebScriptMessageHandler.h: (WebKit::WebScriptMessageHandler::identifier const): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::WebUserContentControllerProxy): (WebKit::WebUserContentControllerProxy::~WebUserContentControllerProxy): (WebKit::WebUserContentControllerProxy::addProcess): (WebKit::WebUserContentControllerProxy::removeProcess): (WebKit::WebUserContentControllerProxy::addUserContentWorldUse): (WebKit::WebUserContentControllerProxy::removeUserContentWorldUses): (WebKit::WebUserContentControllerProxy::addUserScript): (WebKit::WebUserContentControllerProxy::removeUserScript): (WebKit::WebUserContentControllerProxy::removeAllUserScripts): (WebKit::WebUserContentControllerProxy::addUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeAllUserStyleSheets): (WebKit::WebUserContentControllerProxy::addUserScriptMessageHandler): (WebKit::WebUserContentControllerProxy::removeUserMessageHandlerForName): (WebKit::WebUserContentControllerProxy::removeAllUserMessageHandlers): (WebKit::WebUserContentControllerProxy::addContentRuleList): (WebKit::WebUserContentControllerProxy::removeContentRuleList): (WebKit::WebUserContentControllerProxy::removeAllContentRuleLists): (WebKit::generateIdentifier): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.h: (WebKit::WebUserContentControllerProxy::identifier const): Deleted. * UIProcess/VisitedLinkStore.cpp: (WebKit::VisitedLinkStore::~VisitedLinkStore): (WebKit::VisitedLinkStore::VisitedLinkStore): (WebKit::VisitedLinkStore::addProcess): (WebKit::VisitedLinkStore::removeProcess): (WebKit::VisitedLinkStore::removeAll): (WebKit::VisitedLinkStore::pendingVisitedLinksTimerFired): (WebKit::VisitedLinkStore::sendTable): (WebKit::generateIdentifier): Deleted. * UIProcess/VisitedLinkStore.h: * UIProcess/WebsiteData/WebsiteDataStore.cpp: (WebKit::WebsiteDataStore::WebsiteDataStore): (WebKit::generateIdentifier): Deleted. * UIProcess/WebsiteData/WebsiteDataStore.h: (WebKit::WebsiteDataStore::identifier const): Deleted. * WebProcess/Network/WebSocketStream.cpp: (WebKit::WebSocketStream::WebSocketStream): (WebKit::WebSocketStream::~WebSocketStream): (WebKit::WebSocketStream::messageSenderDestinationID): * WebProcess/Network/WebSocketStream.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/Identified.h: Added. (WTF::IdentifiedBase::identifier const): (WTF::IdentifiedBase::IdentifiedBase): (WTF::Identified::Identified): (WTF::ThreadSafeIdentified::ThreadSafeIdentified): Canonical link: https://commits.webkit.org/192802@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221399 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-30 21:50:27 +00:00
protected:
Identified()
: IdentifiedBase<uint64_t, T>(generateIdentifier())
{
}
Add "Identified" base class to replace a whole bunch of custom identifier generators. https://bugs.webkit.org/show_bug.cgi?id=176120 Reviewed by Alex Christensen. Source/WebCore: No new tests (No behavior change). Instead of repeating the common pattern of a class with an integer identifier keeping its own static counter of the next identifier and generating it for each instance, this uses a common template in WTF that does that automatically. * Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp: (WebCore::IDBServer::UniqueIDBDatabaseConnection::UniqueIDBDatabaseConnection): (WebCore::IDBServer::UniqueIDBDatabaseConnection::connectionPendingCloseFromClient): (WebCore::IDBServer::UniqueIDBDatabaseConnection::connectionClosedFromClient): (WebCore::IDBServer::UniqueIDBDatabaseConnection::confirmDidCloseFromServer): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didFireVersionChangeEvent): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didFinishHandlingVersionChange): (WebCore::IDBServer::UniqueIDBDatabaseConnection::createVersionChangeTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::establishTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didAbortTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didCommitTransaction): (WebCore::IDBServer::nextDatabaseConnectionIdentifier): Deleted. * Modules/indexeddb/server/UniqueIDBDatabaseConnection.h: (WebCore::IDBServer::UniqueIDBDatabaseConnection::identifier const): Deleted. * workers/service/ServiceWorkerJobData.cpp: (WebCore::ServiceWorkerJobData::ServiceWorkerJobData): (WebCore::ServiceWorkerJobData::isolatedCopy const): * workers/service/ServiceWorkerJobData.h: (WebCore::ServiceWorkerJobData::encode const): (WebCore::ServiceWorkerJobData::decode): (WebCore::ServiceWorkerJobData::identifier const): Deleted. * workers/service/server/SWServer.cpp: (WebCore::SWServer::Connection::Connection): * workers/service/server/SWServer.h: (WebCore::SWServer::Connection::identifier const): Deleted. * workers/service/server/SWServerRegistration.cpp: (WebCore::SWServerRegistration::SWServerRegistration): (WebCore::SWServerRegistration::data const): * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::identifier const): Deleted. Source/WebKit: * UIProcess/API/APIUserScript.cpp: (API::UserScript::UserScript): (API::generateIdentifier): Deleted. * UIProcess/API/APIUserScript.h: * UIProcess/API/APIUserStyleSheet.cpp: (API::UserStyleSheet::UserStyleSheet): (API::generateIdentifier): Deleted. * UIProcess/API/APIUserStyleSheet.h: * UIProcess/UserContent/WebScriptMessageHandler.cpp: (WebKit::WebScriptMessageHandler::WebScriptMessageHandler): (WebKit::generateIdentifier): Deleted. * UIProcess/UserContent/WebScriptMessageHandler.h: (WebKit::WebScriptMessageHandler::identifier const): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::WebUserContentControllerProxy): (WebKit::WebUserContentControllerProxy::~WebUserContentControllerProxy): (WebKit::WebUserContentControllerProxy::addProcess): (WebKit::WebUserContentControllerProxy::removeProcess): (WebKit::WebUserContentControllerProxy::addUserContentWorldUse): (WebKit::WebUserContentControllerProxy::removeUserContentWorldUses): (WebKit::WebUserContentControllerProxy::addUserScript): (WebKit::WebUserContentControllerProxy::removeUserScript): (WebKit::WebUserContentControllerProxy::removeAllUserScripts): (WebKit::WebUserContentControllerProxy::addUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeAllUserStyleSheets): (WebKit::WebUserContentControllerProxy::addUserScriptMessageHandler): (WebKit::WebUserContentControllerProxy::removeUserMessageHandlerForName): (WebKit::WebUserContentControllerProxy::removeAllUserMessageHandlers): (WebKit::WebUserContentControllerProxy::addContentRuleList): (WebKit::WebUserContentControllerProxy::removeContentRuleList): (WebKit::WebUserContentControllerProxy::removeAllContentRuleLists): (WebKit::generateIdentifier): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.h: (WebKit::WebUserContentControllerProxy::identifier const): Deleted. * UIProcess/VisitedLinkStore.cpp: (WebKit::VisitedLinkStore::~VisitedLinkStore): (WebKit::VisitedLinkStore::VisitedLinkStore): (WebKit::VisitedLinkStore::addProcess): (WebKit::VisitedLinkStore::removeProcess): (WebKit::VisitedLinkStore::removeAll): (WebKit::VisitedLinkStore::pendingVisitedLinksTimerFired): (WebKit::VisitedLinkStore::sendTable): (WebKit::generateIdentifier): Deleted. * UIProcess/VisitedLinkStore.h: * UIProcess/WebsiteData/WebsiteDataStore.cpp: (WebKit::WebsiteDataStore::WebsiteDataStore): (WebKit::generateIdentifier): Deleted. * UIProcess/WebsiteData/WebsiteDataStore.h: (WebKit::WebsiteDataStore::identifier const): Deleted. * WebProcess/Network/WebSocketStream.cpp: (WebKit::WebSocketStream::WebSocketStream): (WebKit::WebSocketStream::~WebSocketStream): (WebKit::WebSocketStream::messageSenderDestinationID): * WebProcess/Network/WebSocketStream.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/Identified.h: Added. (WTF::IdentifiedBase::identifier const): (WTF::IdentifiedBase::IdentifiedBase): (WTF::Identified::Identified): (WTF::ThreadSafeIdentified::ThreadSafeIdentified): Canonical link: https://commits.webkit.org/192802@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221399 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-30 21:50:27 +00:00
Identified(const Identified&) = default;
explicit Identified(uint64_t identifier)
: IdentifiedBase<uint64_t, T>(identifier)
{
}
private:
static uint64_t generateIdentifier()
Add "Identified" base class to replace a whole bunch of custom identifier generators. https://bugs.webkit.org/show_bug.cgi?id=176120 Reviewed by Alex Christensen. Source/WebCore: No new tests (No behavior change). Instead of repeating the common pattern of a class with an integer identifier keeping its own static counter of the next identifier and generating it for each instance, this uses a common template in WTF that does that automatically. * Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp: (WebCore::IDBServer::UniqueIDBDatabaseConnection::UniqueIDBDatabaseConnection): (WebCore::IDBServer::UniqueIDBDatabaseConnection::connectionPendingCloseFromClient): (WebCore::IDBServer::UniqueIDBDatabaseConnection::connectionClosedFromClient): (WebCore::IDBServer::UniqueIDBDatabaseConnection::confirmDidCloseFromServer): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didFireVersionChangeEvent): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didFinishHandlingVersionChange): (WebCore::IDBServer::UniqueIDBDatabaseConnection::createVersionChangeTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::establishTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didAbortTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didCommitTransaction): (WebCore::IDBServer::nextDatabaseConnectionIdentifier): Deleted. * Modules/indexeddb/server/UniqueIDBDatabaseConnection.h: (WebCore::IDBServer::UniqueIDBDatabaseConnection::identifier const): Deleted. * workers/service/ServiceWorkerJobData.cpp: (WebCore::ServiceWorkerJobData::ServiceWorkerJobData): (WebCore::ServiceWorkerJobData::isolatedCopy const): * workers/service/ServiceWorkerJobData.h: (WebCore::ServiceWorkerJobData::encode const): (WebCore::ServiceWorkerJobData::decode): (WebCore::ServiceWorkerJobData::identifier const): Deleted. * workers/service/server/SWServer.cpp: (WebCore::SWServer::Connection::Connection): * workers/service/server/SWServer.h: (WebCore::SWServer::Connection::identifier const): Deleted. * workers/service/server/SWServerRegistration.cpp: (WebCore::SWServerRegistration::SWServerRegistration): (WebCore::SWServerRegistration::data const): * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::identifier const): Deleted. Source/WebKit: * UIProcess/API/APIUserScript.cpp: (API::UserScript::UserScript): (API::generateIdentifier): Deleted. * UIProcess/API/APIUserScript.h: * UIProcess/API/APIUserStyleSheet.cpp: (API::UserStyleSheet::UserStyleSheet): (API::generateIdentifier): Deleted. * UIProcess/API/APIUserStyleSheet.h: * UIProcess/UserContent/WebScriptMessageHandler.cpp: (WebKit::WebScriptMessageHandler::WebScriptMessageHandler): (WebKit::generateIdentifier): Deleted. * UIProcess/UserContent/WebScriptMessageHandler.h: (WebKit::WebScriptMessageHandler::identifier const): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::WebUserContentControllerProxy): (WebKit::WebUserContentControllerProxy::~WebUserContentControllerProxy): (WebKit::WebUserContentControllerProxy::addProcess): (WebKit::WebUserContentControllerProxy::removeProcess): (WebKit::WebUserContentControllerProxy::addUserContentWorldUse): (WebKit::WebUserContentControllerProxy::removeUserContentWorldUses): (WebKit::WebUserContentControllerProxy::addUserScript): (WebKit::WebUserContentControllerProxy::removeUserScript): (WebKit::WebUserContentControllerProxy::removeAllUserScripts): (WebKit::WebUserContentControllerProxy::addUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeAllUserStyleSheets): (WebKit::WebUserContentControllerProxy::addUserScriptMessageHandler): (WebKit::WebUserContentControllerProxy::removeUserMessageHandlerForName): (WebKit::WebUserContentControllerProxy::removeAllUserMessageHandlers): (WebKit::WebUserContentControllerProxy::addContentRuleList): (WebKit::WebUserContentControllerProxy::removeContentRuleList): (WebKit::WebUserContentControllerProxy::removeAllContentRuleLists): (WebKit::generateIdentifier): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.h: (WebKit::WebUserContentControllerProxy::identifier const): Deleted. * UIProcess/VisitedLinkStore.cpp: (WebKit::VisitedLinkStore::~VisitedLinkStore): (WebKit::VisitedLinkStore::VisitedLinkStore): (WebKit::VisitedLinkStore::addProcess): (WebKit::VisitedLinkStore::removeProcess): (WebKit::VisitedLinkStore::removeAll): (WebKit::VisitedLinkStore::pendingVisitedLinksTimerFired): (WebKit::VisitedLinkStore::sendTable): (WebKit::generateIdentifier): Deleted. * UIProcess/VisitedLinkStore.h: * UIProcess/WebsiteData/WebsiteDataStore.cpp: (WebKit::WebsiteDataStore::WebsiteDataStore): (WebKit::generateIdentifier): Deleted. * UIProcess/WebsiteData/WebsiteDataStore.h: (WebKit::WebsiteDataStore::identifier const): Deleted. * WebProcess/Network/WebSocketStream.cpp: (WebKit::WebSocketStream::WebSocketStream): (WebKit::WebSocketStream::~WebSocketStream): (WebKit::WebSocketStream::messageSenderDestinationID): * WebProcess/Network/WebSocketStream.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/Identified.h: Added. (WTF::IdentifiedBase::identifier const): (WTF::IdentifiedBase::IdentifiedBase): (WTF::Identified::Identified): (WTF::ThreadSafeIdentified::ThreadSafeIdentified): Canonical link: https://commits.webkit.org/192802@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221399 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-30 21:50:27 +00:00
{
static uint64_t currentIdentifier;
return ++currentIdentifier;
Add "Identified" base class to replace a whole bunch of custom identifier generators. https://bugs.webkit.org/show_bug.cgi?id=176120 Reviewed by Alex Christensen. Source/WebCore: No new tests (No behavior change). Instead of repeating the common pattern of a class with an integer identifier keeping its own static counter of the next identifier and generating it for each instance, this uses a common template in WTF that does that automatically. * Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp: (WebCore::IDBServer::UniqueIDBDatabaseConnection::UniqueIDBDatabaseConnection): (WebCore::IDBServer::UniqueIDBDatabaseConnection::connectionPendingCloseFromClient): (WebCore::IDBServer::UniqueIDBDatabaseConnection::connectionClosedFromClient): (WebCore::IDBServer::UniqueIDBDatabaseConnection::confirmDidCloseFromServer): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didFireVersionChangeEvent): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didFinishHandlingVersionChange): (WebCore::IDBServer::UniqueIDBDatabaseConnection::createVersionChangeTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::establishTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didAbortTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didCommitTransaction): (WebCore::IDBServer::nextDatabaseConnectionIdentifier): Deleted. * Modules/indexeddb/server/UniqueIDBDatabaseConnection.h: (WebCore::IDBServer::UniqueIDBDatabaseConnection::identifier const): Deleted. * workers/service/ServiceWorkerJobData.cpp: (WebCore::ServiceWorkerJobData::ServiceWorkerJobData): (WebCore::ServiceWorkerJobData::isolatedCopy const): * workers/service/ServiceWorkerJobData.h: (WebCore::ServiceWorkerJobData::encode const): (WebCore::ServiceWorkerJobData::decode): (WebCore::ServiceWorkerJobData::identifier const): Deleted. * workers/service/server/SWServer.cpp: (WebCore::SWServer::Connection::Connection): * workers/service/server/SWServer.h: (WebCore::SWServer::Connection::identifier const): Deleted. * workers/service/server/SWServerRegistration.cpp: (WebCore::SWServerRegistration::SWServerRegistration): (WebCore::SWServerRegistration::data const): * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::identifier const): Deleted. Source/WebKit: * UIProcess/API/APIUserScript.cpp: (API::UserScript::UserScript): (API::generateIdentifier): Deleted. * UIProcess/API/APIUserScript.h: * UIProcess/API/APIUserStyleSheet.cpp: (API::UserStyleSheet::UserStyleSheet): (API::generateIdentifier): Deleted. * UIProcess/API/APIUserStyleSheet.h: * UIProcess/UserContent/WebScriptMessageHandler.cpp: (WebKit::WebScriptMessageHandler::WebScriptMessageHandler): (WebKit::generateIdentifier): Deleted. * UIProcess/UserContent/WebScriptMessageHandler.h: (WebKit::WebScriptMessageHandler::identifier const): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::WebUserContentControllerProxy): (WebKit::WebUserContentControllerProxy::~WebUserContentControllerProxy): (WebKit::WebUserContentControllerProxy::addProcess): (WebKit::WebUserContentControllerProxy::removeProcess): (WebKit::WebUserContentControllerProxy::addUserContentWorldUse): (WebKit::WebUserContentControllerProxy::removeUserContentWorldUses): (WebKit::WebUserContentControllerProxy::addUserScript): (WebKit::WebUserContentControllerProxy::removeUserScript): (WebKit::WebUserContentControllerProxy::removeAllUserScripts): (WebKit::WebUserContentControllerProxy::addUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeAllUserStyleSheets): (WebKit::WebUserContentControllerProxy::addUserScriptMessageHandler): (WebKit::WebUserContentControllerProxy::removeUserMessageHandlerForName): (WebKit::WebUserContentControllerProxy::removeAllUserMessageHandlers): (WebKit::WebUserContentControllerProxy::addContentRuleList): (WebKit::WebUserContentControllerProxy::removeContentRuleList): (WebKit::WebUserContentControllerProxy::removeAllContentRuleLists): (WebKit::generateIdentifier): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.h: (WebKit::WebUserContentControllerProxy::identifier const): Deleted. * UIProcess/VisitedLinkStore.cpp: (WebKit::VisitedLinkStore::~VisitedLinkStore): (WebKit::VisitedLinkStore::VisitedLinkStore): (WebKit::VisitedLinkStore::addProcess): (WebKit::VisitedLinkStore::removeProcess): (WebKit::VisitedLinkStore::removeAll): (WebKit::VisitedLinkStore::pendingVisitedLinksTimerFired): (WebKit::VisitedLinkStore::sendTable): (WebKit::generateIdentifier): Deleted. * UIProcess/VisitedLinkStore.h: * UIProcess/WebsiteData/WebsiteDataStore.cpp: (WebKit::WebsiteDataStore::WebsiteDataStore): (WebKit::generateIdentifier): Deleted. * UIProcess/WebsiteData/WebsiteDataStore.h: (WebKit::WebsiteDataStore::identifier const): Deleted. * WebProcess/Network/WebSocketStream.cpp: (WebKit::WebSocketStream::WebSocketStream): (WebKit::WebSocketStream::~WebSocketStream): (WebKit::WebSocketStream::messageSenderDestinationID): * WebProcess/Network/WebSocketStream.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/Identified.h: Added. (WTF::IdentifiedBase::identifier const): (WTF::IdentifiedBase::IdentifiedBase): (WTF::Identified::Identified): (WTF::ThreadSafeIdentified::ThreadSafeIdentified): Canonical link: https://commits.webkit.org/192802@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221399 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-30 21:50:27 +00:00
}
};
template <typename T>
class ThreadSafeIdentified : public IdentifiedBase<uint64_t, T> {
Add "Identified" base class to replace a whole bunch of custom identifier generators. https://bugs.webkit.org/show_bug.cgi?id=176120 Reviewed by Alex Christensen. Source/WebCore: No new tests (No behavior change). Instead of repeating the common pattern of a class with an integer identifier keeping its own static counter of the next identifier and generating it for each instance, this uses a common template in WTF that does that automatically. * Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp: (WebCore::IDBServer::UniqueIDBDatabaseConnection::UniqueIDBDatabaseConnection): (WebCore::IDBServer::UniqueIDBDatabaseConnection::connectionPendingCloseFromClient): (WebCore::IDBServer::UniqueIDBDatabaseConnection::connectionClosedFromClient): (WebCore::IDBServer::UniqueIDBDatabaseConnection::confirmDidCloseFromServer): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didFireVersionChangeEvent): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didFinishHandlingVersionChange): (WebCore::IDBServer::UniqueIDBDatabaseConnection::createVersionChangeTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::establishTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didAbortTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didCommitTransaction): (WebCore::IDBServer::nextDatabaseConnectionIdentifier): Deleted. * Modules/indexeddb/server/UniqueIDBDatabaseConnection.h: (WebCore::IDBServer::UniqueIDBDatabaseConnection::identifier const): Deleted. * workers/service/ServiceWorkerJobData.cpp: (WebCore::ServiceWorkerJobData::ServiceWorkerJobData): (WebCore::ServiceWorkerJobData::isolatedCopy const): * workers/service/ServiceWorkerJobData.h: (WebCore::ServiceWorkerJobData::encode const): (WebCore::ServiceWorkerJobData::decode): (WebCore::ServiceWorkerJobData::identifier const): Deleted. * workers/service/server/SWServer.cpp: (WebCore::SWServer::Connection::Connection): * workers/service/server/SWServer.h: (WebCore::SWServer::Connection::identifier const): Deleted. * workers/service/server/SWServerRegistration.cpp: (WebCore::SWServerRegistration::SWServerRegistration): (WebCore::SWServerRegistration::data const): * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::identifier const): Deleted. Source/WebKit: * UIProcess/API/APIUserScript.cpp: (API::UserScript::UserScript): (API::generateIdentifier): Deleted. * UIProcess/API/APIUserScript.h: * UIProcess/API/APIUserStyleSheet.cpp: (API::UserStyleSheet::UserStyleSheet): (API::generateIdentifier): Deleted. * UIProcess/API/APIUserStyleSheet.h: * UIProcess/UserContent/WebScriptMessageHandler.cpp: (WebKit::WebScriptMessageHandler::WebScriptMessageHandler): (WebKit::generateIdentifier): Deleted. * UIProcess/UserContent/WebScriptMessageHandler.h: (WebKit::WebScriptMessageHandler::identifier const): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::WebUserContentControllerProxy): (WebKit::WebUserContentControllerProxy::~WebUserContentControllerProxy): (WebKit::WebUserContentControllerProxy::addProcess): (WebKit::WebUserContentControllerProxy::removeProcess): (WebKit::WebUserContentControllerProxy::addUserContentWorldUse): (WebKit::WebUserContentControllerProxy::removeUserContentWorldUses): (WebKit::WebUserContentControllerProxy::addUserScript): (WebKit::WebUserContentControllerProxy::removeUserScript): (WebKit::WebUserContentControllerProxy::removeAllUserScripts): (WebKit::WebUserContentControllerProxy::addUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeAllUserStyleSheets): (WebKit::WebUserContentControllerProxy::addUserScriptMessageHandler): (WebKit::WebUserContentControllerProxy::removeUserMessageHandlerForName): (WebKit::WebUserContentControllerProxy::removeAllUserMessageHandlers): (WebKit::WebUserContentControllerProxy::addContentRuleList): (WebKit::WebUserContentControllerProxy::removeContentRuleList): (WebKit::WebUserContentControllerProxy::removeAllContentRuleLists): (WebKit::generateIdentifier): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.h: (WebKit::WebUserContentControllerProxy::identifier const): Deleted. * UIProcess/VisitedLinkStore.cpp: (WebKit::VisitedLinkStore::~VisitedLinkStore): (WebKit::VisitedLinkStore::VisitedLinkStore): (WebKit::VisitedLinkStore::addProcess): (WebKit::VisitedLinkStore::removeProcess): (WebKit::VisitedLinkStore::removeAll): (WebKit::VisitedLinkStore::pendingVisitedLinksTimerFired): (WebKit::VisitedLinkStore::sendTable): (WebKit::generateIdentifier): Deleted. * UIProcess/VisitedLinkStore.h: * UIProcess/WebsiteData/WebsiteDataStore.cpp: (WebKit::WebsiteDataStore::WebsiteDataStore): (WebKit::generateIdentifier): Deleted. * UIProcess/WebsiteData/WebsiteDataStore.h: (WebKit::WebsiteDataStore::identifier const): Deleted. * WebProcess/Network/WebSocketStream.cpp: (WebKit::WebSocketStream::WebSocketStream): (WebKit::WebSocketStream::~WebSocketStream): (WebKit::WebSocketStream::messageSenderDestinationID): * WebProcess/Network/WebSocketStream.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/Identified.h: Added. (WTF::IdentifiedBase::identifier const): (WTF::IdentifiedBase::IdentifiedBase): (WTF::Identified::Identified): (WTF::ThreadSafeIdentified::ThreadSafeIdentified): Canonical link: https://commits.webkit.org/192802@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221399 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-30 21:50:27 +00:00
protected:
ThreadSafeIdentified()
: IdentifiedBase<uint64_t, T>(generateIdentifier())
{
}
Add "Identified" base class to replace a whole bunch of custom identifier generators. https://bugs.webkit.org/show_bug.cgi?id=176120 Reviewed by Alex Christensen. Source/WebCore: No new tests (No behavior change). Instead of repeating the common pattern of a class with an integer identifier keeping its own static counter of the next identifier and generating it for each instance, this uses a common template in WTF that does that automatically. * Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp: (WebCore::IDBServer::UniqueIDBDatabaseConnection::UniqueIDBDatabaseConnection): (WebCore::IDBServer::UniqueIDBDatabaseConnection::connectionPendingCloseFromClient): (WebCore::IDBServer::UniqueIDBDatabaseConnection::connectionClosedFromClient): (WebCore::IDBServer::UniqueIDBDatabaseConnection::confirmDidCloseFromServer): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didFireVersionChangeEvent): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didFinishHandlingVersionChange): (WebCore::IDBServer::UniqueIDBDatabaseConnection::createVersionChangeTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::establishTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didAbortTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didCommitTransaction): (WebCore::IDBServer::nextDatabaseConnectionIdentifier): Deleted. * Modules/indexeddb/server/UniqueIDBDatabaseConnection.h: (WebCore::IDBServer::UniqueIDBDatabaseConnection::identifier const): Deleted. * workers/service/ServiceWorkerJobData.cpp: (WebCore::ServiceWorkerJobData::ServiceWorkerJobData): (WebCore::ServiceWorkerJobData::isolatedCopy const): * workers/service/ServiceWorkerJobData.h: (WebCore::ServiceWorkerJobData::encode const): (WebCore::ServiceWorkerJobData::decode): (WebCore::ServiceWorkerJobData::identifier const): Deleted. * workers/service/server/SWServer.cpp: (WebCore::SWServer::Connection::Connection): * workers/service/server/SWServer.h: (WebCore::SWServer::Connection::identifier const): Deleted. * workers/service/server/SWServerRegistration.cpp: (WebCore::SWServerRegistration::SWServerRegistration): (WebCore::SWServerRegistration::data const): * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::identifier const): Deleted. Source/WebKit: * UIProcess/API/APIUserScript.cpp: (API::UserScript::UserScript): (API::generateIdentifier): Deleted. * UIProcess/API/APIUserScript.h: * UIProcess/API/APIUserStyleSheet.cpp: (API::UserStyleSheet::UserStyleSheet): (API::generateIdentifier): Deleted. * UIProcess/API/APIUserStyleSheet.h: * UIProcess/UserContent/WebScriptMessageHandler.cpp: (WebKit::WebScriptMessageHandler::WebScriptMessageHandler): (WebKit::generateIdentifier): Deleted. * UIProcess/UserContent/WebScriptMessageHandler.h: (WebKit::WebScriptMessageHandler::identifier const): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::WebUserContentControllerProxy): (WebKit::WebUserContentControllerProxy::~WebUserContentControllerProxy): (WebKit::WebUserContentControllerProxy::addProcess): (WebKit::WebUserContentControllerProxy::removeProcess): (WebKit::WebUserContentControllerProxy::addUserContentWorldUse): (WebKit::WebUserContentControllerProxy::removeUserContentWorldUses): (WebKit::WebUserContentControllerProxy::addUserScript): (WebKit::WebUserContentControllerProxy::removeUserScript): (WebKit::WebUserContentControllerProxy::removeAllUserScripts): (WebKit::WebUserContentControllerProxy::addUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeAllUserStyleSheets): (WebKit::WebUserContentControllerProxy::addUserScriptMessageHandler): (WebKit::WebUserContentControllerProxy::removeUserMessageHandlerForName): (WebKit::WebUserContentControllerProxy::removeAllUserMessageHandlers): (WebKit::WebUserContentControllerProxy::addContentRuleList): (WebKit::WebUserContentControllerProxy::removeContentRuleList): (WebKit::WebUserContentControllerProxy::removeAllContentRuleLists): (WebKit::generateIdentifier): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.h: (WebKit::WebUserContentControllerProxy::identifier const): Deleted. * UIProcess/VisitedLinkStore.cpp: (WebKit::VisitedLinkStore::~VisitedLinkStore): (WebKit::VisitedLinkStore::VisitedLinkStore): (WebKit::VisitedLinkStore::addProcess): (WebKit::VisitedLinkStore::removeProcess): (WebKit::VisitedLinkStore::removeAll): (WebKit::VisitedLinkStore::pendingVisitedLinksTimerFired): (WebKit::VisitedLinkStore::sendTable): (WebKit::generateIdentifier): Deleted. * UIProcess/VisitedLinkStore.h: * UIProcess/WebsiteData/WebsiteDataStore.cpp: (WebKit::WebsiteDataStore::WebsiteDataStore): (WebKit::generateIdentifier): Deleted. * UIProcess/WebsiteData/WebsiteDataStore.h: (WebKit::WebsiteDataStore::identifier const): Deleted. * WebProcess/Network/WebSocketStream.cpp: (WebKit::WebSocketStream::WebSocketStream): (WebKit::WebSocketStream::~WebSocketStream): (WebKit::WebSocketStream::messageSenderDestinationID): * WebProcess/Network/WebSocketStream.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/Identified.h: Added. (WTF::IdentifiedBase::identifier const): (WTF::IdentifiedBase::IdentifiedBase): (WTF::Identified::Identified): (WTF::ThreadSafeIdentified::ThreadSafeIdentified): Canonical link: https://commits.webkit.org/192802@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221399 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-30 21:50:27 +00:00
ThreadSafeIdentified(const ThreadSafeIdentified&) = default;
explicit ThreadSafeIdentified(uint64_t identifier)
: IdentifiedBase<uint64_t, T>(identifier)
{
}
private:
static uint64_t generateIdentifier()
Add "Identified" base class to replace a whole bunch of custom identifier generators. https://bugs.webkit.org/show_bug.cgi?id=176120 Reviewed by Alex Christensen. Source/WebCore: No new tests (No behavior change). Instead of repeating the common pattern of a class with an integer identifier keeping its own static counter of the next identifier and generating it for each instance, this uses a common template in WTF that does that automatically. * Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp: (WebCore::IDBServer::UniqueIDBDatabaseConnection::UniqueIDBDatabaseConnection): (WebCore::IDBServer::UniqueIDBDatabaseConnection::connectionPendingCloseFromClient): (WebCore::IDBServer::UniqueIDBDatabaseConnection::connectionClosedFromClient): (WebCore::IDBServer::UniqueIDBDatabaseConnection::confirmDidCloseFromServer): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didFireVersionChangeEvent): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didFinishHandlingVersionChange): (WebCore::IDBServer::UniqueIDBDatabaseConnection::createVersionChangeTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::establishTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didAbortTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didCommitTransaction): (WebCore::IDBServer::nextDatabaseConnectionIdentifier): Deleted. * Modules/indexeddb/server/UniqueIDBDatabaseConnection.h: (WebCore::IDBServer::UniqueIDBDatabaseConnection::identifier const): Deleted. * workers/service/ServiceWorkerJobData.cpp: (WebCore::ServiceWorkerJobData::ServiceWorkerJobData): (WebCore::ServiceWorkerJobData::isolatedCopy const): * workers/service/ServiceWorkerJobData.h: (WebCore::ServiceWorkerJobData::encode const): (WebCore::ServiceWorkerJobData::decode): (WebCore::ServiceWorkerJobData::identifier const): Deleted. * workers/service/server/SWServer.cpp: (WebCore::SWServer::Connection::Connection): * workers/service/server/SWServer.h: (WebCore::SWServer::Connection::identifier const): Deleted. * workers/service/server/SWServerRegistration.cpp: (WebCore::SWServerRegistration::SWServerRegistration): (WebCore::SWServerRegistration::data const): * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::identifier const): Deleted. Source/WebKit: * UIProcess/API/APIUserScript.cpp: (API::UserScript::UserScript): (API::generateIdentifier): Deleted. * UIProcess/API/APIUserScript.h: * UIProcess/API/APIUserStyleSheet.cpp: (API::UserStyleSheet::UserStyleSheet): (API::generateIdentifier): Deleted. * UIProcess/API/APIUserStyleSheet.h: * UIProcess/UserContent/WebScriptMessageHandler.cpp: (WebKit::WebScriptMessageHandler::WebScriptMessageHandler): (WebKit::generateIdentifier): Deleted. * UIProcess/UserContent/WebScriptMessageHandler.h: (WebKit::WebScriptMessageHandler::identifier const): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::WebUserContentControllerProxy): (WebKit::WebUserContentControllerProxy::~WebUserContentControllerProxy): (WebKit::WebUserContentControllerProxy::addProcess): (WebKit::WebUserContentControllerProxy::removeProcess): (WebKit::WebUserContentControllerProxy::addUserContentWorldUse): (WebKit::WebUserContentControllerProxy::removeUserContentWorldUses): (WebKit::WebUserContentControllerProxy::addUserScript): (WebKit::WebUserContentControllerProxy::removeUserScript): (WebKit::WebUserContentControllerProxy::removeAllUserScripts): (WebKit::WebUserContentControllerProxy::addUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeAllUserStyleSheets): (WebKit::WebUserContentControllerProxy::addUserScriptMessageHandler): (WebKit::WebUserContentControllerProxy::removeUserMessageHandlerForName): (WebKit::WebUserContentControllerProxy::removeAllUserMessageHandlers): (WebKit::WebUserContentControllerProxy::addContentRuleList): (WebKit::WebUserContentControllerProxy::removeContentRuleList): (WebKit::WebUserContentControllerProxy::removeAllContentRuleLists): (WebKit::generateIdentifier): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.h: (WebKit::WebUserContentControllerProxy::identifier const): Deleted. * UIProcess/VisitedLinkStore.cpp: (WebKit::VisitedLinkStore::~VisitedLinkStore): (WebKit::VisitedLinkStore::VisitedLinkStore): (WebKit::VisitedLinkStore::addProcess): (WebKit::VisitedLinkStore::removeProcess): (WebKit::VisitedLinkStore::removeAll): (WebKit::VisitedLinkStore::pendingVisitedLinksTimerFired): (WebKit::VisitedLinkStore::sendTable): (WebKit::generateIdentifier): Deleted. * UIProcess/VisitedLinkStore.h: * UIProcess/WebsiteData/WebsiteDataStore.cpp: (WebKit::WebsiteDataStore::WebsiteDataStore): (WebKit::generateIdentifier): Deleted. * UIProcess/WebsiteData/WebsiteDataStore.h: (WebKit::WebsiteDataStore::identifier const): Deleted. * WebProcess/Network/WebSocketStream.cpp: (WebKit::WebSocketStream::WebSocketStream): (WebKit::WebSocketStream::~WebSocketStream): (WebKit::WebSocketStream::messageSenderDestinationID): * WebProcess/Network/WebSocketStream.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/Identified.h: Added. (WTF::IdentifiedBase::identifier const): (WTF::IdentifiedBase::IdentifiedBase): (WTF::Identified::Identified): (WTF::ThreadSafeIdentified::ThreadSafeIdentified): Canonical link: https://commits.webkit.org/192802@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221399 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-30 21:50:27 +00:00
{
static LazyNeverDestroyed<std::atomic<uint64_t>> currentIdentifier;
static std::once_flag initializeCurrentIdentifier;
std::call_once(initializeCurrentIdentifier, [] {
currentIdentifier.construct(0);
});
return ++currentIdentifier.get();
Add "Identified" base class to replace a whole bunch of custom identifier generators. https://bugs.webkit.org/show_bug.cgi?id=176120 Reviewed by Alex Christensen. Source/WebCore: No new tests (No behavior change). Instead of repeating the common pattern of a class with an integer identifier keeping its own static counter of the next identifier and generating it for each instance, this uses a common template in WTF that does that automatically. * Modules/indexeddb/server/UniqueIDBDatabaseConnection.cpp: (WebCore::IDBServer::UniqueIDBDatabaseConnection::UniqueIDBDatabaseConnection): (WebCore::IDBServer::UniqueIDBDatabaseConnection::connectionPendingCloseFromClient): (WebCore::IDBServer::UniqueIDBDatabaseConnection::connectionClosedFromClient): (WebCore::IDBServer::UniqueIDBDatabaseConnection::confirmDidCloseFromServer): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didFireVersionChangeEvent): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didFinishHandlingVersionChange): (WebCore::IDBServer::UniqueIDBDatabaseConnection::createVersionChangeTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::establishTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didAbortTransaction): (WebCore::IDBServer::UniqueIDBDatabaseConnection::didCommitTransaction): (WebCore::IDBServer::nextDatabaseConnectionIdentifier): Deleted. * Modules/indexeddb/server/UniqueIDBDatabaseConnection.h: (WebCore::IDBServer::UniqueIDBDatabaseConnection::identifier const): Deleted. * workers/service/ServiceWorkerJobData.cpp: (WebCore::ServiceWorkerJobData::ServiceWorkerJobData): (WebCore::ServiceWorkerJobData::isolatedCopy const): * workers/service/ServiceWorkerJobData.h: (WebCore::ServiceWorkerJobData::encode const): (WebCore::ServiceWorkerJobData::decode): (WebCore::ServiceWorkerJobData::identifier const): Deleted. * workers/service/server/SWServer.cpp: (WebCore::SWServer::Connection::Connection): * workers/service/server/SWServer.h: (WebCore::SWServer::Connection::identifier const): Deleted. * workers/service/server/SWServerRegistration.cpp: (WebCore::SWServerRegistration::SWServerRegistration): (WebCore::SWServerRegistration::data const): * workers/service/server/SWServerRegistration.h: (WebCore::SWServerRegistration::identifier const): Deleted. Source/WebKit: * UIProcess/API/APIUserScript.cpp: (API::UserScript::UserScript): (API::generateIdentifier): Deleted. * UIProcess/API/APIUserScript.h: * UIProcess/API/APIUserStyleSheet.cpp: (API::UserStyleSheet::UserStyleSheet): (API::generateIdentifier): Deleted. * UIProcess/API/APIUserStyleSheet.h: * UIProcess/UserContent/WebScriptMessageHandler.cpp: (WebKit::WebScriptMessageHandler::WebScriptMessageHandler): (WebKit::generateIdentifier): Deleted. * UIProcess/UserContent/WebScriptMessageHandler.h: (WebKit::WebScriptMessageHandler::identifier const): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.cpp: (WebKit::WebUserContentControllerProxy::WebUserContentControllerProxy): (WebKit::WebUserContentControllerProxy::~WebUserContentControllerProxy): (WebKit::WebUserContentControllerProxy::addProcess): (WebKit::WebUserContentControllerProxy::removeProcess): (WebKit::WebUserContentControllerProxy::addUserContentWorldUse): (WebKit::WebUserContentControllerProxy::removeUserContentWorldUses): (WebKit::WebUserContentControllerProxy::addUserScript): (WebKit::WebUserContentControllerProxy::removeUserScript): (WebKit::WebUserContentControllerProxy::removeAllUserScripts): (WebKit::WebUserContentControllerProxy::addUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeUserStyleSheet): (WebKit::WebUserContentControllerProxy::removeAllUserStyleSheets): (WebKit::WebUserContentControllerProxy::addUserScriptMessageHandler): (WebKit::WebUserContentControllerProxy::removeUserMessageHandlerForName): (WebKit::WebUserContentControllerProxy::removeAllUserMessageHandlers): (WebKit::WebUserContentControllerProxy::addContentRuleList): (WebKit::WebUserContentControllerProxy::removeContentRuleList): (WebKit::WebUserContentControllerProxy::removeAllContentRuleLists): (WebKit::generateIdentifier): Deleted. * UIProcess/UserContent/WebUserContentControllerProxy.h: (WebKit::WebUserContentControllerProxy::identifier const): Deleted. * UIProcess/VisitedLinkStore.cpp: (WebKit::VisitedLinkStore::~VisitedLinkStore): (WebKit::VisitedLinkStore::VisitedLinkStore): (WebKit::VisitedLinkStore::addProcess): (WebKit::VisitedLinkStore::removeProcess): (WebKit::VisitedLinkStore::removeAll): (WebKit::VisitedLinkStore::pendingVisitedLinksTimerFired): (WebKit::VisitedLinkStore::sendTable): (WebKit::generateIdentifier): Deleted. * UIProcess/VisitedLinkStore.h: * UIProcess/WebsiteData/WebsiteDataStore.cpp: (WebKit::WebsiteDataStore::WebsiteDataStore): (WebKit::generateIdentifier): Deleted. * UIProcess/WebsiteData/WebsiteDataStore.h: (WebKit::WebsiteDataStore::identifier const): Deleted. * WebProcess/Network/WebSocketStream.cpp: (WebKit::WebSocketStream::WebSocketStream): (WebKit::WebSocketStream::~WebSocketStream): (WebKit::WebSocketStream::messageSenderDestinationID): * WebProcess/Network/WebSocketStream.h: Source/WTF: * WTF.xcodeproj/project.pbxproj: * wtf/Identified.h: Added. (WTF::IdentifiedBase::identifier const): (WTF::IdentifiedBase::IdentifiedBase): (WTF::Identified::Identified): (WTF::ThreadSafeIdentified::ThreadSafeIdentified): Canonical link: https://commits.webkit.org/192802@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221399 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-08-30 21:50:27 +00:00
}
};
} // namespace WTF
using WTF::Identified;
using WTF::ThreadSafeIdentified;