Use SecurityOriginData more consistently in Service Worker code
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 24 Mar 2018 19:54:42 +0000 (19:54 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 24 Mar 2018 19:54:42 +0000 (19:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=183969

Reviewed by Darin Adler.

Source/WebCore:

Use SecurityOriginData more consistently in Service Worker code to avoid constructing
SecurityOrigin objects unnecessarily.

I also updated SecurityOrigin to use SecurityOriginData as a data member. This reduces
code duplication a bit. This also avoids constructing SecurityOriginData unnecessarily
in some cases as callers can now use SecurityOrigin::data() instead of
SecurityOriginData::fromSecurityOrigin().

No new tests, no Web-facing behavior change.

* Modules/cache/DOMCacheStorage.cpp:
(WebCore::DOMCacheStorage::origin const):
* Modules/encryptedmedia/CDM.cpp:
(WebCore::CDM::storageDirectory const):
* Modules/encryptedmedia/MediaKeySession.cpp:
(WebCore::MediaKeySession::mediaKeysStorageDirectory const):
* Modules/encryptedmedia/legacy/WebKitMediaKeySession.cpp:
(WebCore::WebKitMediaKeySession::mediaKeysStorageDirectory const):
* Modules/indexeddb/IDBFactory.cpp:
(WebCore::IDBFactory::openInternal):
(WebCore::IDBFactory::deleteDatabase):
* Modules/indexeddb/client/IDBConnectionToServer.cpp:
(WebCore::IDBClient::IDBConnectionToServer::getAllDatabaseNames):
* Modules/webdatabase/Database.cpp:
(WebCore::Database::securityOrigin):
* Modules/webdatabase/DatabaseContext.cpp:
(WebCore::DatabaseContext::securityOrigin const):
* Modules/webdatabase/DatabaseContext.h:
* Modules/webdatabase/DatabaseManager.cpp:
(WebCore::DatabaseManager::fullPathForDatabase):
(WebCore::DatabaseManager::detailsForNameAndOrigin):
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::mediaPlayerMediaKeysStorageDirectory const):
* inspector/agents/InspectorDOMStorageAgent.cpp:
(WebCore::InspectorDOMStorageAgent::findStorageArea):
* loader/appcache/ApplicationCacheStorage.cpp:
(WebCore::ApplicationCacheStorage::calculateQuotaForOrigin):
(WebCore::ApplicationCacheStorage::calculateUsageForOrigin):
(WebCore::ApplicationCacheStorage::calculateRemainingSizeForOriginExcludingCache):
(WebCore::ApplicationCacheStorage::storeUpdatedQuotaForOrigin):
(WebCore::ApplicationCacheStorage::store):
(WebCore::ApplicationCacheStorage::ensureOriginRecord):
* page/DOMWindow.cpp:
(WebCore:: const):
* page/SecurityOrigin.cpp:
(WebCore::SecurityOrigin::SecurityOrigin):
(WebCore::SecurityOrigin::isPotentiallyTrustworthy const):
(WebCore::SecurityOrigin::canAccess const):
(WebCore::SecurityOrigin::canDisplay const):
(WebCore::SecurityOrigin::domainForCachePartition const):
(WebCore::SecurityOrigin::isLocal const):
(WebCore::SecurityOrigin::toString const):
(WebCore::SecurityOrigin::toRawString const):
(WebCore::SecurityOrigin::create):
(WebCore::SecurityOrigin::isSameSchemeHostPort const):
* page/SecurityOrigin.h:
(WebCore::SecurityOrigin::protocol const):
(WebCore::SecurityOrigin::host const):
(WebCore::SecurityOrigin::port const):
(WebCore::SecurityOrigin::data const):
(WebCore::SecurityOrigin::isHTTPFamily const):
* page/SecurityOriginData.cpp:
(WebCore::SecurityOriginData::toString const):
(WebCore::SecurityOriginData::fromFrame):
* page/SecurityOriginData.h:
(WebCore::SecurityOriginData::fromURL):
* storage/StorageNamespaceProvider.cpp:
(WebCore::StorageNamespaceProvider::localStorageArea):
* testing/Internals.cpp:
(WebCore::Internals::clearCacheStorageMemoryRepresentation):
* workers/service/ServiceWorkerContainer.cpp:
(WebCore::ServiceWorkerContainer::addRegistration):
(WebCore::ServiceWorkerContainer::removeRegistration):
(WebCore::ServiceWorkerContainer::updateRegistration):
* workers/service/ServiceWorkerRegistrationKey.cpp:
(WebCore::ServiceWorkerRegistrationKey::relatesToOrigin const):
* workers/service/ServiceWorkerRegistrationKey.h:
* workers/service/server/SWOriginStore.cpp:
(WebCore::SWOriginStore::add):
(WebCore::SWOriginStore::remove):
(WebCore::SWOriginStore::clear):
* workers/service/server/SWOriginStore.h:
* workers/service/server/SWServer.cpp:
(WebCore::SWServer::addRegistration):
(WebCore::SWServer::removeRegistration):
(WebCore::SWServer::clear):
(WebCore::SWServer::tryInstallContextData):
(WebCore::SWServer::serverToContextConnectionCreated):
(WebCore::SWServer::markAllWorkersForOriginAsTerminated):
(WebCore::SWServer::unregisterServiceWorkerClient):
(WebCore::SWServer::needsServerToContextConnectionForOrigin const):
* workers/service/server/SWServer.h:
* workers/service/server/SWServerToContextConnection.cpp:
(WebCore::SWServerToContextConnection::SWServerToContextConnection):
(WebCore::SWServerToContextConnection::~SWServerToContextConnection):
(WebCore::SWServerToContextConnection::connectionForOrigin):
* workers/service/server/SWServerToContextConnection.h:
(WebCore::SWServerToContextConnection::securityOrigin const):
* workers/service/server/SWServerWorker.cpp:
(WebCore::SWServerWorker::origin const):
(WebCore::SWServerWorker::securityOrigin const):
* workers/service/server/SWServerWorker.h:

Source/WebKit:

Use SecurityOriginData more consistently in Service Worker code to avoid constructing
SecurityOrigin objects unnecessarily.

* NetworkProcess/NetworkResourceLoadParameters.cpp:
(WebKit::NetworkResourceLoadParameters::encode const):
* Shared/API/c/WKSecurityOriginRef.cpp:
(WKSecurityOriginCopyDatabaseIdentifier):
* StorageProcess/ServiceWorker/WebSWOriginStore.cpp:
(WebKit::WebSWOriginStore::addToStore):
(WebKit::WebSWOriginStore::removeFromStore):
* StorageProcess/ServiceWorker/WebSWOriginStore.h:
* StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
(WebKit::WebSWServerConnection::scheduleJobInServer):
(WebKit::WebSWServerConnection::registerServiceWorkerClient):
* StorageProcess/ServiceWorker/WebSWServerToContextConnection.cpp:
(WebKit::WebSWServerToContextConnection::WebSWServerToContextConnection):
* StorageProcess/ServiceWorker/WebSWServerToContextConnection.h:
* StorageProcess/StorageProcess.cpp:
(WebKit::StorageProcess::connectionToContextProcessWasClosed):
(WebKit::StorageProcess::needsServerToContextConnectionForOrigin const):
(WebKit::StorageProcess::createStorageToWebProcessConnection):
(WebKit::StorageProcess::deleteWebsiteDataForOrigins):
(WebKit::StorageProcess::serverToContextConnectionForOrigin):
(WebKit::StorageProcess::createServerToContextConnection):
(WebKit::StorageProcess::swContextConnectionMayNoLongerBeNeeded):
* StorageProcess/StorageProcess.h:
* UIProcess/API/APIFrameInfo.cpp:
(API::FrameInfo::create):
* UIProcess/API/C/WKApplicationCacheManager.cpp:
(WKApplicationCacheManagerDeleteEntriesForOrigin):
* UIProcess/API/C/WKKeyValueStorageManager.cpp:
(WKKeyValueStorageManagerDeleteEntriesForOrigin):
* UIProcess/API/C/WKResourceCacheManager.cpp:
(WKResourceCacheManagerClearCacheForOrigin):
* UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
(WKWebsiteDataStoreRemoveFetchCacheForOrigin):
(WKWebsiteDataStoreGetFetchCacheSizeForOrigin):
* UIProcess/ServiceWorkerProcessProxy.cpp:
(WebKit::ServiceWorkerProcessProxy::create):
(WebKit::ServiceWorkerProcessProxy::ServiceWorkerProcessProxy):
(WebKit::ServiceWorkerProcessProxy::getLaunchOptions):
* UIProcess/ServiceWorkerProcessProxy.h:
* UIProcess/Storage/StorageProcessProxy.cpp:
(WebKit::StorageProcessProxy::getStorageProcessConnection):
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::establishWorkerContextConnectionToStorageProcess):
(WebKit::WebProcessPool::disconnectProcess):
(WebKit::WebProcessPool::updateProcessAssertions):
* UIProcess/WebProcessPool.h:
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::fetchDataAndApply):
* WebProcess/Geolocation/GeolocationPermissionRequestManager.cpp:
(WebKit::GeolocationPermissionRequestManager::startRequestForGeolocation):
* WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
(WKBundlePageCopyOriginsWithApplicationCache):
* WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp:
(WebKit::UserMediaPermissionRequestManager::sendUserMediaRequest):
(WebKit::UserMediaPermissionRequestManager::enumerateMediaDevices):
* WebProcess/Storage/WebSWClientConnection.cpp:
(WebKit::WebSWClientConnection::registerServiceWorkerClient):
(WebKit::WebSWClientConnection::matchRegistration):
(WebKit::WebSWClientConnection::whenRegistrationReady):
(WebKit::WebSWClientConnection::getRegistrations):
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::exceededDatabaseQuota):
(WebKit::WebChromeClient::reachedApplicationCacheOriginQuota):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::fetchWebsiteData):
* WebProcess/WebStorage/StorageAreaImpl.cpp:
(WebKit::StorageAreaImpl::securityOrigin const):
* WebProcess/WebStorage/StorageAreaImpl.h:
* WebProcess/WebStorage/StorageAreaMap.cpp:
(WebKit::StorageAreaMap::StorageAreaMap):
(WebKit::StorageAreaMap::dispatchSessionStorageEvent):
(WebKit::StorageAreaMap::dispatchLocalStorageEvent):
* WebProcess/WebStorage/StorageNamespaceImpl.cpp:
(WebKit::StorageNamespaceImpl::didDestroyStorageAreaMap):

Source/WebKitLegacy:

Use SecurityOrigin::data() instead of SecurityOriginData::fromSecurityOrigin().

* Storage/StorageTracker.cpp:
(WebKit::StorageTracker::diskUsageForOrigin):

Source/WebKitLegacy/mac:

Use SecurityOrigin::data() instead of SecurityOriginData::fromSecurityOrigin().

* Storage/WebDatabaseManager.mm:
(-[WebDatabaseManager databasesWithOrigin:]):
(-[WebDatabaseManager deleteOrigin:]):
(-[WebDatabaseManager deleteDatabase:withOrigin:]):
* Storage/WebDatabaseQuotaManager.mm:
(-[WebDatabaseQuotaManager usage]):
(-[WebDatabaseQuotaManager quota]):
(-[WebDatabaseQuotaManager setQuota:]):
* Storage/WebStorageManager.mm:
(-[WebStorageManager deleteOrigin:]):
* WebCoreSupport/WebSecurityOrigin.mm:
(-[WebSecurityOrigin databaseIdentifier]):
(-[WebSecurityOrigin usage]):
(-[WebSecurityOrigin quota]):
(-[WebSecurityOrigin setQuota:]):

Source/WebKitLegacy/win:

Use SecurityOrigin::data() instead of SecurityOriginData::fromSecurityOrigin().

* WebDatabaseManager.cpp:
(WebDatabaseManager::databasesWithOrigin):
(WebDatabaseManager::deleteOrigin):
(WebDatabaseManager::deleteDatabase):
(WebDatabaseManager::setQuota):
* WebSecurityOrigin.cpp:
(WebSecurityOrigin::usage):
(WebSecurityOrigin::quota):
(WebSecurityOrigin::setQuota):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229954 268f45cc-cd09-0410-ab3c-d52691b4dbfc

79 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/cache/DOMCacheStorage.cpp
Source/WebCore/Modules/encryptedmedia/CDM.cpp
Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp
Source/WebCore/Modules/encryptedmedia/legacy/WebKitMediaKeySession.cpp
Source/WebCore/Modules/indexeddb/IDBFactory.cpp
Source/WebCore/Modules/indexeddb/client/IDBConnectionToServer.cpp
Source/WebCore/Modules/webdatabase/Database.cpp
Source/WebCore/Modules/webdatabase/DatabaseContext.cpp
Source/WebCore/Modules/webdatabase/DatabaseContext.h
Source/WebCore/Modules/webdatabase/DatabaseManager.cpp
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/inspector/agents/InspectorDOMStorageAgent.cpp
Source/WebCore/loader/EmptyClients.cpp
Source/WebCore/loader/appcache/ApplicationCacheStorage.cpp
Source/WebCore/page/DOMWindow.cpp
Source/WebCore/page/SecurityOrigin.cpp
Source/WebCore/page/SecurityOrigin.h
Source/WebCore/page/SecurityOriginData.cpp
Source/WebCore/page/SecurityOriginData.h
Source/WebCore/storage/StorageArea.h
Source/WebCore/storage/StorageNamespaceProvider.cpp
Source/WebCore/testing/Internals.cpp
Source/WebCore/workers/service/ServiceWorkerContainer.cpp
Source/WebCore/workers/service/ServiceWorkerRegistrationKey.cpp
Source/WebCore/workers/service/ServiceWorkerRegistrationKey.h
Source/WebCore/workers/service/server/SWOriginStore.cpp
Source/WebCore/workers/service/server/SWOriginStore.h
Source/WebCore/workers/service/server/SWServer.cpp
Source/WebCore/workers/service/server/SWServer.h
Source/WebCore/workers/service/server/SWServerToContextConnection.cpp
Source/WebCore/workers/service/server/SWServerToContextConnection.h
Source/WebCore/workers/service/server/SWServerWorker.cpp
Source/WebCore/workers/service/server/SWServerWorker.h
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/NetworkResourceLoadParameters.cpp
Source/WebKit/Shared/API/c/WKSecurityOriginRef.cpp
Source/WebKit/StorageProcess/ServiceWorker/WebSWOriginStore.cpp
Source/WebKit/StorageProcess/ServiceWorker/WebSWOriginStore.h
Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp
Source/WebKit/StorageProcess/ServiceWorker/WebSWServerToContextConnection.cpp
Source/WebKit/StorageProcess/ServiceWorker/WebSWServerToContextConnection.h
Source/WebKit/StorageProcess/StorageProcess.cpp
Source/WebKit/StorageProcess/StorageProcess.h
Source/WebKit/UIProcess/API/APIFrameInfo.cpp
Source/WebKit/UIProcess/API/C/WKApplicationCacheManager.cpp
Source/WebKit/UIProcess/API/C/WKKeyValueStorageManager.cpp
Source/WebKit/UIProcess/API/C/WKResourceCacheManager.cpp
Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp
Source/WebKit/UIProcess/ServiceWorkerProcessProxy.cpp
Source/WebKit/UIProcess/ServiceWorkerProcessProxy.h
Source/WebKit/UIProcess/Storage/StorageProcessProxy.cpp
Source/WebKit/UIProcess/WebProcessPool.cpp
Source/WebKit/UIProcess/WebProcessPool.h
Source/WebKit/UIProcess/WebStorage/StorageManager.cpp
Source/WebKit/UIProcess/WebStorage/StorageManager.h
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
Source/WebKit/WebProcess/Geolocation/GeolocationPermissionRequestManager.cpp
Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
Source/WebKit/WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp
Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp
Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp
Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKit/WebProcess/WebProcess.cpp
Source/WebKit/WebProcess/WebStorage/StorageAreaImpl.cpp
Source/WebKit/WebProcess/WebStorage/StorageAreaImpl.h
Source/WebKit/WebProcess/WebStorage/StorageAreaMap.cpp
Source/WebKit/WebProcess/WebStorage/StorageNamespaceImpl.cpp
Source/WebKitLegacy/ChangeLog
Source/WebKitLegacy/Storage/StorageAreaImpl.h
Source/WebKitLegacy/Storage/StorageTracker.cpp
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/Storage/WebDatabaseManager.mm
Source/WebKitLegacy/mac/Storage/WebDatabaseQuotaManager.mm
Source/WebKitLegacy/mac/Storage/WebStorageManager.mm
Source/WebKitLegacy/mac/WebCoreSupport/WebSecurityOrigin.mm
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/WebDatabaseManager.cpp
Source/WebKitLegacy/win/WebSecurityOrigin.cpp

index 18e7d21..51f9ebc 100644 (file)
@@ -1,3 +1,113 @@
+2018-03-24  Chris Dumez  <cdumez@apple.com>
+
+        Use SecurityOriginData more consistently in Service Worker code
+        https://bugs.webkit.org/show_bug.cgi?id=183969
+
+        Reviewed by Darin Adler.
+
+        Use SecurityOriginData more consistently in Service Worker code to avoid constructing
+        SecurityOrigin objects unnecessarily.
+
+        I also updated SecurityOrigin to use SecurityOriginData as a data member. This reduces
+        code duplication a bit. This also avoids constructing SecurityOriginData unnecessarily
+        in some cases as callers can now use SecurityOrigin::data() instead of
+        SecurityOriginData::fromSecurityOrigin().
+
+        No new tests, no Web-facing behavior change.
+
+        * Modules/cache/DOMCacheStorage.cpp:
+        (WebCore::DOMCacheStorage::origin const):
+        * Modules/encryptedmedia/CDM.cpp:
+        (WebCore::CDM::storageDirectory const):
+        * Modules/encryptedmedia/MediaKeySession.cpp:
+        (WebCore::MediaKeySession::mediaKeysStorageDirectory const):
+        * Modules/encryptedmedia/legacy/WebKitMediaKeySession.cpp:
+        (WebCore::WebKitMediaKeySession::mediaKeysStorageDirectory const):
+        * Modules/indexeddb/IDBFactory.cpp:
+        (WebCore::IDBFactory::openInternal):
+        (WebCore::IDBFactory::deleteDatabase):
+        * Modules/indexeddb/client/IDBConnectionToServer.cpp:
+        (WebCore::IDBClient::IDBConnectionToServer::getAllDatabaseNames):
+        * Modules/webdatabase/Database.cpp:
+        (WebCore::Database::securityOrigin):
+        * Modules/webdatabase/DatabaseContext.cpp:
+        (WebCore::DatabaseContext::securityOrigin const):
+        * Modules/webdatabase/DatabaseContext.h:
+        * Modules/webdatabase/DatabaseManager.cpp:
+        (WebCore::DatabaseManager::fullPathForDatabase):
+        (WebCore::DatabaseManager::detailsForNameAndOrigin):
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::mediaPlayerMediaKeysStorageDirectory const):
+        * inspector/agents/InspectorDOMStorageAgent.cpp:
+        (WebCore::InspectorDOMStorageAgent::findStorageArea):
+        * loader/appcache/ApplicationCacheStorage.cpp:
+        (WebCore::ApplicationCacheStorage::calculateQuotaForOrigin):
+        (WebCore::ApplicationCacheStorage::calculateUsageForOrigin):
+        (WebCore::ApplicationCacheStorage::calculateRemainingSizeForOriginExcludingCache):
+        (WebCore::ApplicationCacheStorage::storeUpdatedQuotaForOrigin):
+        (WebCore::ApplicationCacheStorage::store):
+        (WebCore::ApplicationCacheStorage::ensureOriginRecord):
+        * page/DOMWindow.cpp:
+        (WebCore:: const):
+        * page/SecurityOrigin.cpp:
+        (WebCore::SecurityOrigin::SecurityOrigin):
+        (WebCore::SecurityOrigin::isPotentiallyTrustworthy const):
+        (WebCore::SecurityOrigin::canAccess const):
+        (WebCore::SecurityOrigin::canDisplay const):
+        (WebCore::SecurityOrigin::domainForCachePartition const):
+        (WebCore::SecurityOrigin::isLocal const):
+        (WebCore::SecurityOrigin::toString const):
+        (WebCore::SecurityOrigin::toRawString const):
+        (WebCore::SecurityOrigin::create):
+        (WebCore::SecurityOrigin::isSameSchemeHostPort const):
+        * page/SecurityOrigin.h:
+        (WebCore::SecurityOrigin::protocol const):
+        (WebCore::SecurityOrigin::host const):
+        (WebCore::SecurityOrigin::port const):
+        (WebCore::SecurityOrigin::data const):
+        (WebCore::SecurityOrigin::isHTTPFamily const):
+        * page/SecurityOriginData.cpp:
+        (WebCore::SecurityOriginData::toString const):
+        (WebCore::SecurityOriginData::fromFrame):
+        * page/SecurityOriginData.h:
+        (WebCore::SecurityOriginData::fromURL):
+        * storage/StorageNamespaceProvider.cpp:
+        (WebCore::StorageNamespaceProvider::localStorageArea):
+        * testing/Internals.cpp:
+        (WebCore::Internals::clearCacheStorageMemoryRepresentation):
+        * workers/service/ServiceWorkerContainer.cpp:
+        (WebCore::ServiceWorkerContainer::addRegistration):
+        (WebCore::ServiceWorkerContainer::removeRegistration):
+        (WebCore::ServiceWorkerContainer::updateRegistration):
+        * workers/service/ServiceWorkerRegistrationKey.cpp:
+        (WebCore::ServiceWorkerRegistrationKey::relatesToOrigin const):
+        * workers/service/ServiceWorkerRegistrationKey.h:
+        * workers/service/server/SWOriginStore.cpp:
+        (WebCore::SWOriginStore::add):
+        (WebCore::SWOriginStore::remove):
+        (WebCore::SWOriginStore::clear):
+        * workers/service/server/SWOriginStore.h:
+        * workers/service/server/SWServer.cpp:
+        (WebCore::SWServer::addRegistration):
+        (WebCore::SWServer::removeRegistration):
+        (WebCore::SWServer::clear):
+        (WebCore::SWServer::tryInstallContextData):
+        (WebCore::SWServer::serverToContextConnectionCreated):
+        (WebCore::SWServer::markAllWorkersForOriginAsTerminated):
+        (WebCore::SWServer::unregisterServiceWorkerClient):
+        (WebCore::SWServer::needsServerToContextConnectionForOrigin const):
+        * workers/service/server/SWServer.h:
+        * workers/service/server/SWServerToContextConnection.cpp:
+        (WebCore::SWServerToContextConnection::SWServerToContextConnection):
+        (WebCore::SWServerToContextConnection::~SWServerToContextConnection):
+        (WebCore::SWServerToContextConnection::connectionForOrigin):
+        * workers/service/server/SWServerToContextConnection.h:
+        (WebCore::SWServerToContextConnection::securityOrigin const):
+        * workers/service/server/SWServerWorker.cpp:
+        (WebCore::SWServerWorker::origin const):
+        (WebCore::SWServerWorker::securityOrigin const):
+        * workers/service/server/SWServerWorker.h:
+
 2018-03-24  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r229792.
index 3f5fb93..27e8f02 100644 (file)
@@ -49,7 +49,7 @@ std::optional<ClientOrigin> DOMCacheStorage::origin() const
     if (!origin)
         return std::nullopt;
 
-    return ClientOrigin { SecurityOriginData::fromSecurityOrigin(scriptExecutionContext()->topOrigin()), SecurityOriginData::fromSecurityOrigin(*origin) };
+    return ClientOrigin { scriptExecutionContext()->topOrigin().data(), origin->data() };
 }
 
 static void doSequentialMatch(size_t index, Vector<Ref<DOMCache>>&& caches, DOMCache::RequestInfo&& info, CacheQueryOptions&& options, DOMCache::MatchCallback&& completionHandler)
index cbf43b4..a2bd44c 100644 (file)
@@ -652,7 +652,7 @@ String CDM::storageDirectory() const
     if (storageDirectory.isEmpty())
         return emptyString();
 
-    return FileSystem::pathByAppendingComponent(storageDirectory, SecurityOriginData::fromSecurityOrigin(document->securityOrigin()).databaseIdentifier());
+    return FileSystem::pathByAppendingComponent(storageDirectory, document->securityOrigin().data().databaseIdentifier());
 }
 
 }
index d5aceda..77c3771 100644 (file)
@@ -697,7 +697,7 @@ String MediaKeySession::mediaKeysStorageDirectory() const
     if (storageDirectory.isEmpty())
         return emptyString();
 
-    return FileSystem::pathByAppendingComponent(storageDirectory, SecurityOriginData::fromSecurityOrigin(document->securityOrigin()).databaseIdentifier());
+    return FileSystem::pathByAppendingComponent(storageDirectory, document->securityOrigin().data().databaseIdentifier());
 }
 
 bool MediaKeySession::hasPendingActivity() const
index 7efb79d..73f2d26 100644 (file)
@@ -231,7 +231,7 @@ String WebKitMediaKeySession::mediaKeysStorageDirectory() const
     if (storageDirectory.isEmpty())
         return emptyString();
 
-    return FileSystem::pathByAppendingComponent(storageDirectory, SecurityOriginData::fromSecurityOrigin(document->securityOrigin()).databaseIdentifier());
+    return FileSystem::pathByAppendingComponent(storageDirectory, document->securityOrigin().data().databaseIdentifier());
 }
 
 bool WebKitMediaKeySession::hasPendingActivity() const
index 5a2b6ec..d7e4727 100644 (file)
@@ -91,7 +91,7 @@ ExceptionOr<Ref<IDBOpenDBRequest>> IDBFactory::openInternal(ScriptExecutionConte
         return Exception { SecurityError, ASCIILiteral("IDBFactory.open() called in an invalid security context") };
 
     ASSERT(context.securityOrigin());
-    IDBDatabaseIdentifier databaseIdentifier(name, SecurityOriginData::fromSecurityOrigin(*context.securityOrigin()), SecurityOriginData::fromSecurityOrigin(context.topOrigin()));
+    IDBDatabaseIdentifier databaseIdentifier(name, SecurityOriginData { context.securityOrigin()->data() }, SecurityOriginData { context.topOrigin().data() });
     if (!databaseIdentifier.isValid())
         return Exception { TypeError, ASCIILiteral("IDBFactory.open() called with an invalid security origin") };
 
@@ -111,7 +111,7 @@ ExceptionOr<Ref<IDBOpenDBRequest>> IDBFactory::deleteDatabase(ScriptExecutionCon
         return Exception { SecurityError, ASCIILiteral("IDBFactory.deleteDatabase() called in an invalid security context") };
 
     ASSERT(context.securityOrigin());
-    IDBDatabaseIdentifier databaseIdentifier(name, SecurityOriginData::fromSecurityOrigin(*context.securityOrigin()), SecurityOriginData::fromSecurityOrigin(context.topOrigin()));
+    IDBDatabaseIdentifier databaseIdentifier(name, SecurityOriginData { context.securityOrigin()->data() }, SecurityOriginData { context.topOrigin().data() });
     if (!databaseIdentifier.isValid())
         return Exception { TypeError, ASCIILiteral("IDBFactory.deleteDatabase() called with an invalid security origin") };
 
index 9e5eea2..2b0fdc5 100644 (file)
@@ -429,7 +429,7 @@ void IDBConnectionToServer::getAllDatabaseNames(const SecurityOrigin& mainFrameO
 
     m_getAllDatabaseNamesCallbacks.add(++callbackID, WTFMove(callback));
 
-    m_delegate->getAllDatabaseNames(SecurityOriginData::fromSecurityOrigin(mainFrameOrigin), SecurityOriginData::fromSecurityOrigin(openingOrigin), callbackID);
+    m_delegate->getAllDatabaseNames(mainFrameOrigin.data(), openingOrigin.data(), callbackID);
 }
 
 void IDBConnectionToServer::didGetAllDatabaseNames(uint64_t callbackID, const Vector<String>& databaseNames)
index dd75a3d..461e01a 100644 (file)
@@ -767,9 +767,9 @@ Vector<String> Database::tableNames()
 SecurityOriginData Database::securityOrigin()
 {
     if (m_scriptExecutionContext->isContextThread())
-        return SecurityOriginData::fromSecurityOrigin(m_contextThreadSecurityOrigin.get());
+        return m_contextThreadSecurityOrigin->data();
     if (databaseThread().getThread() == &Thread::current())
-        return SecurityOriginData::fromSecurityOrigin(m_databaseThreadSecurityOrigin.get());
+        return m_databaseThreadSecurityOrigin->data();
     RELEASE_ASSERT_NOT_REACHED();
 }
 
index d2a65e2..497131c 100644 (file)
@@ -209,9 +209,9 @@ void DatabaseContext::databaseExceededQuota(const String& name, DatabaseDetails
     ASSERT(m_scriptExecutionContext->isWorkerGlobalScope());
 }
 
-SecurityOriginData DatabaseContext::securityOrigin() const
+const SecurityOriginData& DatabaseContext::securityOrigin() const
 {
-    return SecurityOriginData::fromSecurityOrigin(*m_scriptExecutionContext->securityOrigin());
+    return m_scriptExecutionContext->securityOrigin()->data();
 }
 
 bool DatabaseContext::isContextThread() const
index 4c3c463..d186448 100644 (file)
@@ -61,7 +61,7 @@ public:
     void databaseExceededQuota(const String& name, DatabaseDetails);
 
     using ActiveDOMObject::scriptExecutionContext;
-    SecurityOriginData securityOrigin() const;
+    const SecurityOriginData& securityOrigin() const;
 
     bool isContextThread() const;
 
index b4adc66..bbf4493 100644 (file)
@@ -248,7 +248,7 @@ String DatabaseManager::fullPathForDatabase(SecurityOrigin& origin, const String
                 return String();
         }
     }
-    return DatabaseTracker::singleton().fullPathForDatabase(SecurityOriginData::fromSecurityOrigin(origin), name, createIfDoesNotExist);
+    return DatabaseTracker::singleton().fullPathForDatabase(origin.data(), name, createIfDoesNotExist);
 }
 
 DatabaseDetails DatabaseManager::detailsForNameAndOrigin(const String& name, SecurityOrigin& origin)
@@ -263,7 +263,7 @@ DatabaseDetails DatabaseManager::detailsForNameAndOrigin(const String& name, Sec
         }
     }
 
-    return DatabaseTracker::singleton().detailsForNameAndOrigin(name, SecurityOriginData::fromSecurityOrigin(origin));
+    return DatabaseTracker::singleton().detailsForNameAndOrigin(name, origin.data());
 }
 
 void DatabaseManager::logErrorMessage(ScriptExecutionContext& context, const String& message)
index ad36258..7f9feb1 100644 (file)
@@ -2611,7 +2611,7 @@ String HTMLMediaElement::mediaPlayerMediaKeysStorageDirectory() const
     if (storageDirectory.isEmpty())
         return emptyString();
 
-    return FileSystem::pathByAppendingComponent(storageDirectory, SecurityOriginData::fromSecurityOrigin(document().securityOrigin()).databaseIdentifier());
+    return FileSystem::pathByAppendingComponent(storageDirectory, document().securityOrigin().data().databaseIdentifier());
 }
 
 void HTMLMediaElement::webkitSetMediaKeys(WebKitMediaKeys* mediaKeys)
index 0d25da0..7d632da 100644 (file)
@@ -195,7 +195,7 @@ RefPtr<StorageArea> InspectorDOMStorageAgent::findStorageArea(ErrorString& error
     }
 
     if (!isLocalStorage)
-        return m_pageAgent->page().sessionStorage()->storageArea(SecurityOriginData::fromSecurityOrigin(targetFrame->document()->securityOrigin()));
+        return m_pageAgent->page().sessionStorage()->storageArea(targetFrame->document()->securityOrigin().data());
     return m_pageAgent->page().storageNamespaceProvider().localStorageArea(*targetFrame->document());
 }
 
index d8850ff..1ed3cb1 100644 (file)
@@ -374,7 +374,7 @@ class EmptyStorageNamespaceProvider final : public StorageNamespaceProvider {
         bool contains(const String&) final { return false; }
         StorageType storageType() const final { return StorageType::Local; }
         size_t memoryBytesUsedByCache() final { return 0; }
-        SecurityOriginData securityOrigin() const final { return { }; }
+        const SecurityOriginData& securityOrigin() const final { static NeverDestroyed<SecurityOriginData> origin; return origin.get(); }
     };
 
     struct EmptyStorageNamespace final : public StorageNamespace {
index 9c1cc38..ff29389 100644 (file)
@@ -430,7 +430,7 @@ bool ApplicationCacheStorage::calculateQuotaForOrigin(const SecurityOrigin& orig
     if (statement.prepare() != SQLITE_OK)
         return false;
 
-    statement.bindText(1, SecurityOriginData::fromSecurityOrigin(origin).databaseIdentifier());
+    statement.bindText(1, origin.data().databaseIdentifier());
     int result = statement.step();
 
     // Return the quota, or if it was null the default.
@@ -458,7 +458,7 @@ bool ApplicationCacheStorage::calculateUsageForOrigin(const SecurityOrigin* orig
     if (statement.prepare() != SQLITE_OK)
         return false;
 
-    statement.bindText(1, SecurityOriginData::fromSecurityOrigin(*origin).databaseIdentifier());
+    statement.bindText(1, origin->data().databaseIdentifier());
     int result = statement.step();
 
     if (result == SQLITE_ROW) {
@@ -501,7 +501,7 @@ bool ApplicationCacheStorage::calculateRemainingSizeForOriginExcludingCache(cons
     if (statement.prepare() != SQLITE_OK)
         return false;
 
-    statement.bindText(1, SecurityOriginData::fromSecurityOrigin(origin).databaseIdentifier());
+    statement.bindText(1, origin.data().databaseIdentifier());
     if (excludingCacheIdentifier != 0)
         statement.bindInt64(2, excludingCacheIdentifier);
     int result = statement.step();
@@ -537,7 +537,7 @@ bool ApplicationCacheStorage::storeUpdatedQuotaForOrigin(const SecurityOrigin* o
         return false;
 
     updateStatement.bindInt64(1, quota);
-    updateStatement.bindText(2, SecurityOriginData::fromSecurityOrigin(*origin).databaseIdentifier());
+    updateStatement.bindText(2, origin->data().databaseIdentifier());
 
     return executeStatement(updateStatement);
 }
@@ -686,7 +686,7 @@ bool ApplicationCacheStorage::store(ApplicationCacheGroup* group, GroupStorageID
 
     statement.bindInt64(1, urlHostHash(group->manifestURL()));
     statement.bindText(2, group->manifestURL());
-    statement.bindText(3, SecurityOriginData::fromSecurityOrigin(group->origin()).databaseIdentifier());
+    statement.bindText(3, group->origin().data().databaseIdentifier());
 
     if (!executeStatement(statement))
         return false;
@@ -957,7 +957,7 @@ bool ApplicationCacheStorage::ensureOriginRecord(const SecurityOrigin* origin)
     if (insertOriginStatement.prepare() != SQLITE_OK)
         return false;
 
-    insertOriginStatement.bindText(1, SecurityOriginData::fromSecurityOrigin(*origin).databaseIdentifier());
+    insertOriginStatement.bindText(1, origin->data().databaseIdentifier());
     insertOriginStatement.bindInt64(2, m_defaultOriginQuota);
     if (!executeStatement(insertOriginStatement))
         return false;
index 31fb95c..2d423cf 100644 (file)
@@ -874,7 +874,7 @@ ExceptionOr<Storage*> DOMWindow::sessionStorage() const
     if (!page)
         return nullptr;
 
-    auto storageArea = page->sessionStorage()->storageArea(SecurityOriginData::fromSecurityOrigin(document->securityOrigin()));
+    auto storageArea = page->sessionStorage()->storageArea(document->securityOrigin().data());
     m_sessionStorage = Storage::create(m_frame, WTFMove(storageArea));
     return m_sessionStorage.get();
 }
index 6d230b9..693e8f9 100644 (file)
@@ -145,15 +145,13 @@ bool shouldTreatAsPotentiallyTrustworthy(const URL& url)
 }
 
 SecurityOrigin::SecurityOrigin(const URL& url)
-    : m_protocol { url.protocol().isNull() ? emptyString() : url.protocol().toString().convertToASCIILowercase() }
-    , m_host { url.host().isNull() ? emptyString() : url.host().convertToASCIILowercase() }
-    , m_port { url.port() }
+    : m_data(SecurityOriginData::fromURL(url))
 {
-    // document.domain starts as m_host, but can be set by the DOM.
-    m_domain = m_host;
+    // document.domain starts as m_data.host, but can be set by the DOM.
+    m_domain = m_data.host;
 
-    if (m_port && isDefaultPortForProtocol(m_port.value(), m_protocol))
-        m_port = std::nullopt;
+    if (m_data.port && isDefaultPortForProtocol(m_data.port.value(), m_data.protocol))
+        m_data.port = std::nullopt;
 
     // By default, only local SecurityOrigins can load local resources.
     m_canLoadLocalResources = isLocal();
@@ -166,8 +164,7 @@ SecurityOrigin::SecurityOrigin(const URL& url)
 }
 
 SecurityOrigin::SecurityOrigin()
-    : m_protocol { emptyString() }
-    , m_host { emptyString() }
+    : m_data { emptyString(), emptyString(), std::nullopt }
     , m_domain { emptyString() }
     , m_isUnique { true }
     , m_isPotentiallyTrustworthy { IsPotentiallyTrustworthy::Yes }
@@ -175,11 +172,9 @@ SecurityOrigin::SecurityOrigin()
 }
 
 SecurityOrigin::SecurityOrigin(const SecurityOrigin* other)
-    : m_protocol { other->m_protocol.isolatedCopy() }
-    , m_host { other->m_host.isolatedCopy() }
+    : m_data { other->m_data.isolatedCopy() }
     , m_domain { other->m_domain.isolatedCopy() }
     , m_filePath { other->m_filePath.isolatedCopy() }
-    , m_port { other->m_port }
     , m_isUnique { other->m_isUnique }
     , m_universalAccess { other->m_universalAccess }
     , m_domainWasSetInDOM { other->m_domainWasSetInDOM }
@@ -228,7 +223,7 @@ bool SecurityOrigin::isPotentiallyTrustworthy() const
     // This code is using an enum instead of an std::optional for thread-safety. Worst case scenario, several thread will read
     // 'Unknown' value concurrently and they'll all call shouldTreatAsPotentiallyTrustworthy() and get the same result.
     if (m_isPotentiallyTrustworthy == IsPotentiallyTrustworthy::Unknown)
-        m_isPotentiallyTrustworthy = shouldTreatAsPotentiallyTrustworthy(m_protocol, m_host) ? IsPotentiallyTrustworthy::Yes : IsPotentiallyTrustworthy::No;
+        m_isPotentiallyTrustworthy = shouldTreatAsPotentiallyTrustworthy(m_data.protocol, m_data.host) ? IsPotentiallyTrustworthy::Yes : IsPotentiallyTrustworthy::No;
     return m_isPotentiallyTrustworthy == IsPotentiallyTrustworthy::Yes;
 }
 
@@ -277,9 +272,9 @@ bool SecurityOrigin::canAccess(const SecurityOrigin& other) const
     // this is a security vulnerability.
 
     bool canAccess = false;
-    if (m_protocol == other.m_protocol) {
+    if (m_data.protocol == other.m_data.protocol) {
         if (!m_domainWasSetInDOM && !other.m_domainWasSetInDOM) {
-            if (m_host == other.m_host && m_port == other.m_port)
+            if (m_data.host == other.m_data.host && m_data.port == other.m_data.port)
                 canAccess = true;
         } else if (m_domainWasSetInDOM && other.m_domainWasSetInDOM) {
             if (m_domain == other.m_domain)
@@ -363,7 +358,7 @@ bool SecurityOrigin::canDisplay(const URL& url) const
         return true;
 
 #if !PLATFORM(IOS)
-    if (m_protocol == "file" && url.isLocalFile() && !FileSystem::filesHaveSameVolume(m_filePath, url.fileSystemPath()))
+    if (m_data.protocol == "file" && url.isLocalFile() && !FileSystem::filesHaveSameVolume(m_filePath, url.fileSystemPath()))
         return false;
 #endif
 
@@ -376,7 +371,7 @@ bool SecurityOrigin::canDisplay(const URL& url) const
         return canRequest(url);
 
     if (SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated(protocol))
-        return equalIgnoringASCIICase(m_protocol, protocol) || SecurityPolicy::isAccessToURLWhiteListed(this, url);
+        return equalIgnoringASCIICase(m_data.protocol, protocol) || SecurityPolicy::isAccessToURLWhiteListed(this, url);
 
     if (SecurityPolicy::restrictAccessToLocal() && SchemeRegistry::shouldTreatURLSchemeAsLocal(protocol))
         return canLoadLocalResources() || SecurityPolicy::isAccessToURLWhiteListed(this, url);
@@ -461,7 +456,7 @@ String SecurityOrigin::domainForCachePartition() const
     if (isHTTPFamily())
         return host();
 
-    if (SchemeRegistry::shouldPartitionCacheForURLScheme(m_protocol))
+    if (SchemeRegistry::shouldPartitionCacheForURLScheme(m_data.protocol))
         return host();
 
     return emptyString();
@@ -475,35 +470,21 @@ void SecurityOrigin::setEnforcesFilePathSeparation()
 
 bool SecurityOrigin::isLocal() const
 {
-    return SchemeRegistry::shouldTreatURLSchemeAsLocal(m_protocol);
+    return SchemeRegistry::shouldTreatURLSchemeAsLocal(m_data.protocol);
 }
 
 String SecurityOrigin::toString() const
 {
     if (isUnique())
         return ASCIILiteral("null");
-    if (m_protocol == "file" && m_enforcesFilePathSeparation)
+    if (m_data.protocol == "file" && m_enforcesFilePathSeparation)
         return ASCIILiteral("null");
     return toRawString();
 }
 
 String SecurityOrigin::toRawString() const
 {
-    if (m_protocol == "file")
-        return ASCIILiteral("file://");
-
-    StringBuilder result;
-    result.reserveCapacity(m_protocol.length() + m_host.length() + 10);
-    result.append(m_protocol);
-    result.appendLiteral("://");
-    result.append(m_host);
-
-    if (m_port) {
-        result.append(':');
-        result.appendNumber(m_port.value());
-    }
-
-    return result.toString();
+    return m_data.toString();
 }
 
 static inline bool areOriginsMatching(const SecurityOrigin& origin1, const SecurityOrigin& origin2)
@@ -552,7 +533,7 @@ Ref<SecurityOrigin> SecurityOrigin::create(const String& protocol, const String&
     String decodedHost = decodeURLEscapeSequences(host);
     auto origin = create(URL(URL(), protocol + "://" + host + "/"));
     if (port && !isDefaultPortForProtocol(*port, protocol))
-        origin->m_port = port;
+        origin->m_data.port = port;
     return origin;
 }
 
@@ -575,13 +556,7 @@ bool SecurityOrigin::equal(const SecurityOrigin* other) const
 
 bool SecurityOrigin::isSameSchemeHostPort(const SecurityOrigin& other) const
 {
-    if (m_host != other.m_host)
-        return false;
-
-    if (m_protocol != other.m_protocol)
-        return false;
-
-    if (m_port != other.m_port)
+    if (m_data != other.m_data)
         return false;
 
     if (isLocal() && !passesFileCheck(other))
index 6481a38..6e79090 100644 (file)
@@ -28,6 +28,7 @@
 
 #pragma once
 
+#include "SecurityOriginData.h"
 #include <wtf/ThreadSafeRefCounted.h>
 #include <wtf/text/WTFString.h>
 
@@ -78,10 +79,10 @@ public:
     void setDomainFromDOM(const String& newDomain);
     bool domainWasSetInDOM() const { return m_domainWasSetInDOM; }
 
-    const String& protocol() const { return m_protocol; }
-    const String& host() const { return m_host; }
+    const String& protocol() const { return m_data.protocol; }
+    const String& host() const { return m_data.host; }
     const String& domain() const { return m_domain; }
-    std::optional<uint16_t> port() const { return m_port; }
+    std::optional<uint16_t> port() const { return m_data.port; }
 
     // Returns true if a given URL is secure, based either directly on its
     // own protocol, or, when relevant, on the protocol of its "inner URL"
@@ -205,6 +206,8 @@ public:
 
     static bool isLocalHostOrLoopbackIPAddress(const String& host);
 
+    const SecurityOriginData& data() const { return m_data; }
+
 private:
     SecurityOrigin();
     explicit SecurityOrigin(const URL&);
@@ -215,16 +218,14 @@ private:
 
     // This method checks that the scheme for this origin is an HTTP-family
     // scheme, e.g. HTTP and HTTPS.
-    bool isHTTPFamily() const { return m_protocol == "http" || m_protocol == "https"; }
+    bool isHTTPFamily() const { return m_data.protocol == "http" || m_data.protocol == "https"; }
     
     enum ShouldAllowFromThirdParty { AlwaysAllowFromThirdParty, MaybeAllowFromThirdParty };
     WEBCORE_EXPORT bool canAccessStorage(const SecurityOrigin*, ShouldAllowFromThirdParty = MaybeAllowFromThirdParty) const;
 
-    String m_protocol;
-    String m_host;
+    SecurityOriginData m_data;
     String m_domain;
     String m_filePath;
-    std::optional<uint16_t> m_port;
     bool m_isUnique { false };
     bool m_universalAccess { false };
     bool m_domainWasSetInDOM { false };
index e90ab82..2aac8ee 100644 (file)
 #include "SecurityOrigin.h"
 #include <wtf/text/CString.h>
 #include <wtf/text/StringBuilder.h>
+#include <wtf/text/StringConcatenateNumbers.h>
 
 using namespace WebCore;
 
 namespace WebCore {
 
-SecurityOriginData SecurityOriginData::fromSecurityOrigin(const SecurityOrigin& securityOrigin)
-{
-    SecurityOriginData securityOriginData;
-
-    securityOriginData.protocol = securityOrigin.protocol();
-    securityOriginData.host = securityOrigin.host();
-    securityOriginData.port = securityOrigin.port();
-
-    return securityOriginData;
-}
-
 String SecurityOriginData::toString() const
 {
-    return makeString(protocol, "://", host, ":", String::number(port.value_or(0)));
+    if (protocol == "file")
+        return ASCIILiteral("file://");
+
+    if (!port)
+        return makeString(protocol, "://", host);
+    return makeString(protocol, "://", host, ':', static_cast<uint32_t>(*port));
 }
 
 SecurityOriginData SecurityOriginData::fromFrame(Frame* frame)
 {
     if (!frame)
-        return SecurityOriginData();
+        return SecurityOriginData { };
     
-    Document* document = frame->document();
+    auto* document = frame->document();
     if (!document)
-        return SecurityOriginData();
+        return SecurityOriginData { };
 
-    return SecurityOriginData::fromSecurityOrigin(document->securityOrigin());
+    return document->securityOrigin().data();
 }
 
 Ref<SecurityOrigin> SecurityOriginData::securityOrigin() const
index 5f55f94..7990239 100644 (file)
@@ -25,7 +25,7 @@
 
 #pragma once
 
-#include <wtf/text/WTFString.h>
+#include "URL.h"
 
 namespace WebCore {
 
@@ -45,8 +45,15 @@ struct SecurityOriginData {
     {
     }
     
-    WEBCORE_EXPORT static SecurityOriginData fromSecurityOrigin(const SecurityOrigin&);
     WEBCORE_EXPORT static SecurityOriginData fromFrame(Frame*);
+    static SecurityOriginData fromURL(const URL& url)
+    {
+        return SecurityOriginData {
+            url.protocol().isNull() ? emptyString() : url.protocol().toString().convertToASCIILowercase(),
+            url.host().isNull() ? emptyString() : url.host().convertToASCIILowercase(),
+            url.port()
+        };
+    }
 
     WEBCORE_EXPORT Ref<SecurityOrigin> securityOrigin() const;
 
index 5341ca6..9732b66 100644 (file)
@@ -59,7 +59,7 @@ public:
     virtual void decrementAccessCount() { }
     virtual void closeDatabaseIfIdle() { }
 
-    virtual SecurityOriginData securityOrigin() const = 0;
+    virtual const SecurityOriginData& securityOrigin() const = 0;
 };
 
 } // namespace WebCore
index 8c4af42..69c1b33 100644 (file)
@@ -78,7 +78,7 @@ RefPtr<StorageArea> StorageNamespaceProvider::localStorageArea(Document& documen
     else
         storageNamespace = &localStorageNamespace();
 
-    return storageNamespace->storageArea(SecurityOriginData::fromSecurityOrigin(document.securityOrigin()));
+    return storageNamespace->storageArea(document.securityOrigin().data());
 }
 
 StorageNamespace& StorageNamespaceProvider::localStorageNamespace()
index aa8a52e..4fc233f 100644 (file)
@@ -4324,7 +4324,7 @@ void Internals::clearCacheStorageMemoryRepresentation(DOMPromiseDeferred<void>&&
         if (!m_cacheStorageConnection)
             return;
     }
-    m_cacheStorageConnection->clearMemoryRepresentation(ClientOrigin { SecurityOriginData::fromSecurityOrigin(document->topOrigin()), SecurityOriginData::fromSecurityOrigin(document->securityOrigin()) }, [promise = WTFMove(promise)] (auto && result) mutable {
+    m_cacheStorageConnection->clearMemoryRepresentation(ClientOrigin { document->topOrigin().data(), document->securityOrigin().data() }, [promise = WTFMove(promise)] (auto && result) mutable {
         ASSERT_UNUSED(result, !result);
         promise.resolve();
     });
index 250114e..ab007c9 100644 (file)
@@ -172,7 +172,7 @@ void ServiceWorkerContainer::addRegistration(const String& relativeScriptURL, co
     CONTAINER_RELEASE_LOG_IF_ALLOWED("addRegistration: Registering service worker. Job ID: %" PRIu64, jobData.identifier().jobIdentifier.toUInt64());
 
     jobData.clientCreationURL = context->url();
-    jobData.topOrigin = SecurityOriginData::fromSecurityOrigin(context->topOrigin());
+    jobData.topOrigin = context->topOrigin().data();
     jobData.type = ServiceWorkerJobType::Register;
     jobData.registrationOptions = options;
 
@@ -196,7 +196,7 @@ void ServiceWorkerContainer::removeRegistration(const URL& scopeURL, Ref<Deferre
 
     ServiceWorkerJobData jobData(m_swConnection->serverConnectionIdentifier(), contextIdentifier());
     jobData.clientCreationURL = context->url();
-    jobData.topOrigin = SecurityOriginData::fromSecurityOrigin(context->topOrigin());
+    jobData.topOrigin = context->topOrigin().data();
     jobData.type = ServiceWorkerJobType::Unregister;
     jobData.scopeURL = scopeURL;
 
@@ -221,7 +221,7 @@ void ServiceWorkerContainer::updateRegistration(const URL& scopeURL, const URL&
 
     ServiceWorkerJobData jobData(m_swConnection->serverConnectionIdentifier(), contextIdentifier());
     jobData.clientCreationURL = context.url();
-    jobData.topOrigin = SecurityOriginData::fromSecurityOrigin(context.topOrigin());
+    jobData.topOrigin = context.topOrigin().data();
     jobData.type = ServiceWorkerJobType::Update;
     jobData.scopeURL = scopeURL;
     jobData.scriptURL = scriptURL;
index b84c66e..1c3d746 100644 (file)
@@ -77,13 +77,12 @@ bool ServiceWorkerRegistrationKey::originIsMatching(const SecurityOriginData& to
     return protocolHostAndPortAreEqual(clientURL, m_scope);
 }
 
-bool ServiceWorkerRegistrationKey::relatesToOrigin(const SecurityOrigin& origin) const
+bool ServiceWorkerRegistrationKey::relatesToOrigin(const SecurityOriginData& securityOrigin) const
 {
-    if (m_topOrigin == SecurityOriginData::fromSecurityOrigin(origin))
+    if (m_topOrigin == securityOrigin)
         return true;
 
-    auto scopeOrigin = SecurityOrigin::create(m_scope);
-    return scopeOrigin->isSameOriginAs(origin);
+    return SecurityOriginData::fromURL(m_scope) == securityOrigin;
 }
 
 static const char separatorCharacter = '_';
index 239a300..710f412 100644 (file)
@@ -49,7 +49,7 @@ public:
     const URL& scope() const { return m_scope; }
     void setScope(URL&& scope) { m_scope = WTFMove(scope); }
 
-    bool relatesToOrigin(const SecurityOrigin&) const;
+    bool relatesToOrigin(const SecurityOriginData&) const;
 
     ServiceWorkerRegistrationKey isolatedCopy() const;
 
index 5ea45b9..f01fb16 100644 (file)
 
 namespace WebCore {
 
-void SWOriginStore::add(const SecurityOrigin& origin)
+void SWOriginStore::add(const SecurityOriginData& origin)
 {
-    ++m_originCounts.ensure(origin.toString(), [&] {
+    ++m_originCounts.ensure(origin, [&] {
         addToStore(origin);
         return 0;
     }).iterator->value;
 }
 
-void SWOriginStore::remove(const SecurityOrigin& origin)
+void SWOriginStore::remove(const SecurityOriginData& origin)
 {
-    auto iterator = m_originCounts.find(origin.toString());
+    auto iterator = m_originCounts.find(origin);
     ASSERT(iterator != m_originCounts.end());
     if (iterator == m_originCounts.end())
         return;
@@ -54,9 +54,9 @@ void SWOriginStore::remove(const SecurityOrigin& origin)
     removeFromStore(origin);
 }
 
-void SWOriginStore::clear(const SecurityOrigin& origin)
+void SWOriginStore::clear(const SecurityOriginData& origin)
 {
-    m_originCounts.remove(origin.toString());
+    m_originCounts.remove(origin);
     removeFromStore(origin);
 }
 
index e11e451..cb28b39 100644 (file)
 
 #if ENABLE(SERVICE_WORKER)
 
+#include "SecurityOriginData.h"
 #include <wtf/HashMap.h>
-#include <wtf/text/StringHash.h>
-#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
-class SecurityOrigin;
-
 class SWOriginStore {
     WTF_MAKE_FAST_ALLOCATED;
 public:
     virtual ~SWOriginStore() = default;
 
-    void add(const SecurityOrigin&);
-    void remove(const SecurityOrigin&);
-    void clear(const SecurityOrigin&);
+    void add(const SecurityOriginData&);
+    void remove(const SecurityOriginData&);
+    void clear(const SecurityOriginData&);
     void clearAll();
 
     virtual void importComplete() = 0;
 
 private:
-    virtual void addToStore(const SecurityOrigin&) = 0;
-    virtual void removeFromStore(const SecurityOrigin&) = 0;
+    virtual void addToStore(const SecurityOriginData&) = 0;
+    virtual void removeFromStore(const SecurityOriginData&) = 0;
     virtual void clearStore() = 0;
 
-    HashMap<String, uint64_t> m_originCounts;
+    HashMap<SecurityOriginData, uint64_t> m_originCounts;
 };
 
 } // namespace WebCore
index beef0e3..a0b7fc2 100644 (file)
@@ -153,12 +153,12 @@ void SWServer::addRegistration(std::unique_ptr<SWServerRegistration>&& registrat
     auto addResult2 = m_registrationsByID.add(registrationPtr->identifier(), registrationPtr);
     ASSERT_UNUSED(addResult2, addResult2.isNewEntry);
 
-    m_originStore->add(key.topOrigin().securityOrigin());
+    m_originStore->add(key.topOrigin());
 }
 
 void SWServer::removeRegistration(const ServiceWorkerRegistrationKey& key)
 {
-    auto topOrigin = key.topOrigin().securityOrigin();
+    auto topOrigin = key.topOrigin();
     auto registration = m_registrations.take(key);
     ASSERT(registration);
     bool wasRemoved = m_registrationsByID.remove(registration->identifier());
@@ -205,29 +205,29 @@ void SWServer::clearAll(CompletionHandler<void()>&& completionHandler)
     m_registrationStore.clearAll(WTFMove(completionHandler));
 }
 
-void SWServer::clear(const SecurityOrigin& origin, CompletionHandler<void()>&& completionHandler)
+void SWServer::clear(const SecurityOriginData& securityOrigin, CompletionHandler<void()>&& completionHandler)
 {
     if (!m_importCompleted) {
-        m_clearCompletionCallbacks.append([this, origin = makeRef(origin), completionHandler = WTFMove(completionHandler)] () mutable {
+        m_clearCompletionCallbacks.append([this, securityOrigin, completionHandler = WTFMove(completionHandler)] () mutable {
             ASSERT(m_importCompleted);
-            clear(origin, WTFMove(completionHandler));
+            clear(securityOrigin, WTFMove(completionHandler));
         });
         return;
     }
 
     m_jobQueues.removeIf([&](auto& keyAndValue) {
-        return keyAndValue.key.relatesToOrigin(origin);
+        return keyAndValue.key.relatesToOrigin(securityOrigin);
     });
 
     Vector<SWServerRegistration*> registrationsToRemove;
     for (auto& keyAndValue : m_registrations) {
-        if (keyAndValue.key.relatesToOrigin(origin))
+        if (keyAndValue.key.relatesToOrigin(securityOrigin))
             registrationsToRemove.append(keyAndValue.value.get());
     }
 
     for (auto& contextDatas : m_pendingContextDatas.values()) {
         contextDatas.removeAllMatching([&](auto& contextData) {
-            return contextData.registration.key.relatesToOrigin(origin);
+            return contextData.registration.key.relatesToOrigin(securityOrigin);
         });
     }
 
@@ -498,10 +498,10 @@ void SWServer::updateWorker(Connection&, const ServiceWorkerJobDataIdentifier& j
 
 void SWServer::tryInstallContextData(ServiceWorkerContextData&& data)
 {
-    auto origin = SecurityOrigin::create(data.scriptURL);
-    auto* connection = SWServerToContextConnection::connectionForOrigin(origin);
+    auto securityOrigin = SecurityOriginData::fromURL(data.scriptURL);
+    auto* connection = SWServerToContextConnection::connectionForOrigin(securityOrigin);
     if (!connection) {
-        m_pendingContextDatas.ensure(WTFMove(origin), [] {
+        m_pendingContextDatas.ensure(WTFMove(securityOrigin), [] {
             return Vector<ServiceWorkerContextData> { };
         }).iterator->value.append(WTFMove(data));
         return;
@@ -512,11 +512,11 @@ void SWServer::tryInstallContextData(ServiceWorkerContextData&& data)
 
 void SWServer::serverToContextConnectionCreated(SWServerToContextConnection& contextConnection)
 {
-    auto pendingContextDatas = m_pendingContextDatas.take(&contextConnection.origin());
+    auto pendingContextDatas = m_pendingContextDatas.take(contextConnection.securityOrigin());
     for (auto& data : pendingContextDatas)
         installContextData(data);
 
-    auto serviceWorkerRunRequests = m_serviceWorkerRunRequests.take(&contextConnection.origin());
+    auto serviceWorkerRunRequests = m_serviceWorkerRunRequests.take(contextConnection.securityOrigin());
     for (auto& item : serviceWorkerRunRequests) {
         bool success = runServiceWorker(item.key);
         for (auto& callback : item.value)
@@ -641,11 +641,11 @@ void SWServer::terminateWorkerInternal(SWServerWorker& worker, TerminationMode m
     };
 }
 
-void SWServer::markAllWorkersForOriginAsTerminated(const SecurityOrigin& origin)
+void SWServer::markAllWorkersForOriginAsTerminated(const SecurityOriginData& securityOrigin)
 {
     Vector<SWServerWorker*> terminatedWorkers;
     for (auto& worker : m_runningOrTerminatingWorkers.values()) {
-        if (origin.isSameSchemeHostPort(worker->securityOrigin()))
+        if (worker->securityOrigin() == securityOrigin)
             terminatedWorkers.append(worker.ptr());
     }
     for (auto& terminatedWorker : terminatedWorkers)
@@ -779,7 +779,7 @@ void SWServer::unregisterServiceWorkerClient(const ClientOrigin& clientOrigin, S
                     terminateWorker(worker);
             }
             if (!m_clientsBySecurityOrigin.contains(clientOrigin.clientOrigin)) {
-                if (auto* connection = SWServerToContextConnection::connectionForOrigin(clientOrigin.clientOrigin.securityOrigin()))
+                if (auto* connection = SWServerToContextConnection::connectionForOrigin(clientOrigin.clientOrigin))
                     connection->connectionMayNoLongerBeNeeded();
             }
 
@@ -805,9 +805,9 @@ void SWServer::unregisterServiceWorkerClient(const ClientOrigin& clientOrigin, S
     m_clientToControllingRegistration.remove(registrationIterator);
 }
 
-bool SWServer::needsServerToContextConnectionForOrigin(const SecurityOrigin& origin) const
+bool SWServer::needsServerToContextConnectionForOrigin(const SecurityOriginData& securityOrigin) const
 {
-    return m_clientsBySecurityOrigin.contains(SecurityOriginData::fromSecurityOrigin(origin));
+    return m_clientsBySecurityOrigin.contains(securityOrigin);
 }
 
 void SWServer::resolveRegistrationReadyRequests(SWServerRegistration& registration)
index 606db46..c13f482 100644 (file)
@@ -31,7 +31,7 @@
 #include "DocumentIdentifier.h"
 #include "RegistrationStore.h"
 #include "SWServerWorker.h"
-#include "SecurityOriginHash.h"
+#include "SecurityOriginData.h"
 #include "ServiceWorkerClientData.h"
 #include "ServiceWorkerIdentifier.h"
 #include "ServiceWorkerJob.h"
@@ -122,7 +122,7 @@ public:
     WEBCORE_EXPORT ~SWServer();
 
     WEBCORE_EXPORT void clearAll(WTF::CompletionHandler<void()>&&);
-    WEBCORE_EXPORT void clear(const SecurityOrigin&, WTF::CompletionHandler<void()>&&);
+    WEBCORE_EXPORT void clear(const SecurityOriginData&, WTF::CompletionHandler<void()>&&);
 
     SWServerRegistration* getRegistration(const ServiceWorkerRegistrationKey&);
     void addRegistration(std::unique_ptr<SWServerRegistration>&&);
@@ -145,7 +145,7 @@ public:
     std::optional<ServiceWorkerClientData> serviceWorkerClientWithOriginByID(const ClientOrigin&, const ServiceWorkerClientIdentifier&) const;
     WEBCORE_EXPORT SWServerWorker* activeWorkerFromRegistrationID(ServiceWorkerRegistrationIdentifier);
 
-    WEBCORE_EXPORT void markAllWorkersForOriginAsTerminated(const SecurityOrigin&);
+    WEBCORE_EXPORT void markAllWorkersForOriginAsTerminated(const SecurityOriginData&);
     
     Connection* getConnection(SWServerConnectionIdentifier identifier) { return m_connections.get(identifier); }
     SWOriginStore& originStore() { return m_originStore; }
@@ -177,7 +177,7 @@ public:
     WEBCORE_EXPORT void getOriginsWithRegistrations(Function<void(const HashSet<SecurityOriginData>&)>&&);
 
     PAL::SessionID sessionID() const { return m_sessionID; }
-    WEBCORE_EXPORT bool needsServerToContextConnectionForOrigin(const SecurityOrigin&) const;
+    WEBCORE_EXPORT bool needsServerToContextConnectionForOrigin(const SecurityOriginData&) const;
 
     void disableServiceWorkerProcessTerminationDelay() { m_shouldDisableServiceWorkerProcessTerminationDelay = true; }
 
@@ -229,8 +229,8 @@ private:
 
     UniqueRef<SWOriginStore> m_originStore;
     RegistrationStore m_registrationStore;
-    HashMap<RefPtr<SecurityOrigin>, Vector<ServiceWorkerContextData>> m_pendingContextDatas;
-    HashMap<RefPtr<SecurityOrigin>, HashMap<ServiceWorkerIdentifier, Vector<RunServiceWorkerCallback>>> m_serviceWorkerRunRequests;
+    HashMap<SecurityOriginData, Vector<ServiceWorkerContextData>> m_pendingContextDatas;
+    HashMap<SecurityOriginData, HashMap<ServiceWorkerIdentifier, Vector<RunServiceWorkerCallback>>> m_serviceWorkerRunRequests;
     PAL::SessionID m_sessionID;
     bool m_importCompleted { false };
     bool m_shouldDisableServiceWorkerProcessTerminationDelay { false };
index 6aa5a2a..3c26172 100644 (file)
@@ -30,7 +30,6 @@
 
 #include "SWServer.h"
 #include "SWServerWorker.h"
-#include "SecurityOriginHash.h"
 #include <wtf/NeverDestroyed.h>
 
 namespace WebCore {
@@ -40,29 +39,29 @@ static SWServerToContextConnectionIdentifier generateServerToContextConnectionId
     return generateObjectIdentifier<SWServerToContextConnectionIdentifierType>();
 }
 
-static HashMap<RefPtr<SecurityOrigin>, SWServerToContextConnection*>& allConnectionsByOrigin()
+static HashMap<SecurityOriginData, SWServerToContextConnection*>& allConnectionsByOrigin()
 {
-    static NeverDestroyed<HashMap<RefPtr<SecurityOrigin>, SWServerToContextConnection*>> connectionsByOrigin;
+    static NeverDestroyed<HashMap<SecurityOriginData, SWServerToContextConnection*>> connectionsByOrigin;
     return connectionsByOrigin;
 }
 
-SWServerToContextConnection::SWServerToContextConnection(Ref<SecurityOrigin>&& origin)
+SWServerToContextConnection::SWServerToContextConnection(const SecurityOriginData& securityOrigin)
     : m_identifier(generateServerToContextConnectionIdentifier())
-    , m_origin(WTFMove(origin))
+    , m_securityOrigin(securityOrigin)
 {
-    auto result = allConnectionsByOrigin().add(m_origin.copyRef(), this);
+    auto result = allConnectionsByOrigin().add(m_securityOrigin, this);
     ASSERT_UNUSED(result, result.isNewEntry);
 }
 
 SWServerToContextConnection::~SWServerToContextConnection()
 {
-    auto result = allConnectionsByOrigin().remove(m_origin.ptr());
+    auto result = allConnectionsByOrigin().remove(m_securityOrigin);
     ASSERT_UNUSED(result, result);
 }
 
-SWServerToContextConnection* SWServerToContextConnection::connectionForOrigin(const SecurityOrigin& origin)
+SWServerToContextConnection* SWServerToContextConnection::connectionForOrigin(const SecurityOriginData& securityOrigin)
 {
-    return allConnectionsByOrigin().get(&const_cast<SecurityOrigin&>(origin));
+    return allConnectionsByOrigin().get(securityOrigin);
 }
 
 void SWServerToContextConnection::scriptContextFailedToStart(const std::optional<ServiceWorkerJobDataIdentifier>& jobDataIdentifier, ServiceWorkerIdentifier serviceWorkerIdentifier, const String& message)
index 6f102bc..2e604ef 100644 (file)
@@ -27,7 +27,7 @@
 
 #if ENABLE(SERVICE_WORKER)
 
-#include "SecurityOrigin.h"
+#include "SecurityOriginData.h"
 #include "ServiceWorkerClientQueryOptions.h"
 #include "ServiceWorkerIdentifier.h"
 #include "ServiceWorkerTypes.h"
@@ -74,18 +74,18 @@ public:
     WEBCORE_EXPORT void matchAll(uint64_t requestIdentifier, ServiceWorkerIdentifier, const ServiceWorkerClientQueryOptions&);
     WEBCORE_EXPORT void claim(uint64_t requestIdentifier, ServiceWorkerIdentifier);
 
-    static SWServerToContextConnection* connectionForOrigin(const SecurityOrigin&);
+    static SWServerToContextConnection* connectionForOrigin(const SecurityOriginData&);
 
-    SecurityOrigin& origin() { return m_origin.get(); }
+    const SecurityOriginData& securityOrigin() const { return m_securityOrigin; }
 
     virtual void connectionMayNoLongerBeNeeded() = 0;
 
 protected:
-    WEBCORE_EXPORT explicit SWServerToContextConnection(Ref<SecurityOrigin>&&);
+    WEBCORE_EXPORT explicit SWServerToContextConnection(const SecurityOriginData&);
 
 private:
     SWServerToContextConnectionIdentifier m_identifier;
-    Ref<SecurityOrigin> m_origin;
+    SecurityOriginData m_securityOrigin;
 };
 
 } // namespace WebCore
index 90a19a5..159bce6 100644 (file)
@@ -85,14 +85,14 @@ void SWServerWorker::terminate()
 const ClientOrigin& SWServerWorker::origin() const
 {
     if (!m_origin)
-        m_origin = ClientOrigin { m_registrationKey.topOrigin(), SecurityOriginData::fromSecurityOrigin(SecurityOrigin::create(m_data.scriptURL)) };
+        m_origin = ClientOrigin { m_registrationKey.topOrigin(), SecurityOriginData::fromURL(m_data.scriptURL) };
 
     return *m_origin;
 }
 
-Ref<SecurityOrigin> SWServerWorker::securityOrigin() const
+const SecurityOriginData& SWServerWorker::securityOrigin() const
 {
-    return SecurityOrigin::create(m_data.scriptURL);
+    return origin().clientOrigin;
 }
 
 SWServerToContextConnection* SWServerWorker::contextConnection()
index cc0759c..d93f500 100644 (file)
@@ -104,7 +104,7 @@ public:
     ServiceWorkerContextData contextData() const;
 
     const ClientOrigin& origin() const;
-    WEBCORE_EXPORT Ref<SecurityOrigin> securityOrigin() const;
+    WEBCORE_EXPORT const SecurityOriginData& securityOrigin() const;
 
     WEBCORE_EXPORT SWServerToContextConnection* contextConnection();
 
index 14e7312..60472e3 100644 (file)
@@ -1,3 +1,90 @@
+2018-03-24  Chris Dumez  <cdumez@apple.com>
+
+        Use SecurityOriginData more consistently in Service Worker code
+        https://bugs.webkit.org/show_bug.cgi?id=183969
+
+        Reviewed by Darin Adler.
+
+        Use SecurityOriginData more consistently in Service Worker code to avoid constructing
+        SecurityOrigin objects unnecessarily.
+
+        * NetworkProcess/NetworkResourceLoadParameters.cpp:
+        (WebKit::NetworkResourceLoadParameters::encode const):
+        * Shared/API/c/WKSecurityOriginRef.cpp:
+        (WKSecurityOriginCopyDatabaseIdentifier):
+        * StorageProcess/ServiceWorker/WebSWOriginStore.cpp:
+        (WebKit::WebSWOriginStore::addToStore):
+        (WebKit::WebSWOriginStore::removeFromStore):
+        * StorageProcess/ServiceWorker/WebSWOriginStore.h:
+        * StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
+        (WebKit::WebSWServerConnection::scheduleJobInServer):
+        (WebKit::WebSWServerConnection::registerServiceWorkerClient):
+        * StorageProcess/ServiceWorker/WebSWServerToContextConnection.cpp:
+        (WebKit::WebSWServerToContextConnection::WebSWServerToContextConnection):
+        * StorageProcess/ServiceWorker/WebSWServerToContextConnection.h:
+        * StorageProcess/StorageProcess.cpp:
+        (WebKit::StorageProcess::connectionToContextProcessWasClosed):
+        (WebKit::StorageProcess::needsServerToContextConnectionForOrigin const):
+        (WebKit::StorageProcess::createStorageToWebProcessConnection):
+        (WebKit::StorageProcess::deleteWebsiteDataForOrigins):
+        (WebKit::StorageProcess::serverToContextConnectionForOrigin):
+        (WebKit::StorageProcess::createServerToContextConnection):
+        (WebKit::StorageProcess::swContextConnectionMayNoLongerBeNeeded):
+        * StorageProcess/StorageProcess.h:
+        * UIProcess/API/APIFrameInfo.cpp:
+        (API::FrameInfo::create):
+        * UIProcess/API/C/WKApplicationCacheManager.cpp:
+        (WKApplicationCacheManagerDeleteEntriesForOrigin):
+        * UIProcess/API/C/WKKeyValueStorageManager.cpp:
+        (WKKeyValueStorageManagerDeleteEntriesForOrigin):
+        * UIProcess/API/C/WKResourceCacheManager.cpp:
+        (WKResourceCacheManagerClearCacheForOrigin):
+        * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
+        (WKWebsiteDataStoreRemoveFetchCacheForOrigin):
+        (WKWebsiteDataStoreGetFetchCacheSizeForOrigin):
+        * UIProcess/ServiceWorkerProcessProxy.cpp:
+        (WebKit::ServiceWorkerProcessProxy::create):
+        (WebKit::ServiceWorkerProcessProxy::ServiceWorkerProcessProxy):
+        (WebKit::ServiceWorkerProcessProxy::getLaunchOptions):
+        * UIProcess/ServiceWorkerProcessProxy.h:
+        * UIProcess/Storage/StorageProcessProxy.cpp:
+        (WebKit::StorageProcessProxy::getStorageProcessConnection):
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::establishWorkerContextConnectionToStorageProcess):
+        (WebKit::WebProcessPool::disconnectProcess):
+        (WebKit::WebProcessPool::updateProcessAssertions):
+        * UIProcess/WebProcessPool.h:
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::fetchDataAndApply):
+        * WebProcess/Geolocation/GeolocationPermissionRequestManager.cpp:
+        (WebKit::GeolocationPermissionRequestManager::startRequestForGeolocation):
+        * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
+        (WKBundlePageCopyOriginsWithApplicationCache):
+        * WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp:
+        (WebKit::UserMediaPermissionRequestManager::sendUserMediaRequest):
+        (WebKit::UserMediaPermissionRequestManager::enumerateMediaDevices):
+        * WebProcess/Storage/WebSWClientConnection.cpp:
+        (WebKit::WebSWClientConnection::registerServiceWorkerClient):
+        (WebKit::WebSWClientConnection::matchRegistration):
+        (WebKit::WebSWClientConnection::whenRegistrationReady):
+        (WebKit::WebSWClientConnection::getRegistrations):
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::exceededDatabaseQuota):
+        (WebKit::WebChromeClient::reachedApplicationCacheOriginQuota):
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::fetchWebsiteData):
+        * WebProcess/WebStorage/StorageAreaImpl.cpp:
+        (WebKit::StorageAreaImpl::securityOrigin const):
+        * WebProcess/WebStorage/StorageAreaImpl.h:
+        * WebProcess/WebStorage/StorageAreaMap.cpp:
+        (WebKit::StorageAreaMap::StorageAreaMap):
+        (WebKit::StorageAreaMap::dispatchSessionStorageEvent):
+        (WebKit::StorageAreaMap::dispatchLocalStorageEvent):
+        * WebProcess/WebStorage/StorageNamespaceImpl.cpp:
+        (WebKit::StorageNamespaceImpl::didDestroyStorageAreaMap):
+
 2018-03-24  Tim Horton  <timothy_horton@apple.com>
 
         Fix the !ENABLE(MEDIA_STREAM) build
index 0e7d80c..0172c3b 100644 (file)
@@ -87,7 +87,7 @@ void NetworkResourceLoadParameters::encode(IPC::Encoder& encoder) const
 
     encoder << static_cast<bool>(sourceOrigin);
     if (sourceOrigin)
-        encoder << SecurityOriginData::fromSecurityOrigin(*sourceOrigin);
+        encoder << sourceOrigin->data();
     encoder.encodeEnum(mode);
     encoder << cspResponseHeaders;
 
index 3c4b424..bcf955a 100644 (file)
@@ -58,7 +58,7 @@ WKSecurityOriginRef WKSecurityOriginCreate(WKStringRef protocol, WKStringRef hos
 
 WKStringRef WKSecurityOriginCopyDatabaseIdentifier(WKSecurityOriginRef securityOrigin)
 {
-    return toCopiedAPI(WebCore::SecurityOriginData::fromSecurityOrigin(toImpl(securityOrigin)->securityOrigin()).databaseIdentifier());
+    return toCopiedAPI(toImpl(securityOrigin)->securityOrigin().data().databaseIdentifier());
 }
 
 WKStringRef WKSecurityOriginCopyToString(WKSecurityOriginRef securityOrigin)
index 9dcad94..04cbf21 100644 (file)
@@ -41,13 +41,13 @@ WebSWOriginStore::WebSWOriginStore()
 {
 }
 
-void WebSWOriginStore::addToStore(const SecurityOrigin& origin)
+void WebSWOriginStore::addToStore(const SecurityOriginData& origin)
 {
     m_store.scheduleAddition(computeSharedStringHash(origin.toString()));
     m_store.flushPendingChanges();
 }
 
-void WebSWOriginStore::removeFromStore(const SecurityOrigin& origin)
+void WebSWOriginStore::removeFromStore(const SecurityOriginData& origin)
 {
     m_store.scheduleRemoval(computeSharedStringHash(origin.toString()));
     m_store.flushPendingChanges();
index 7f8c987..2d29f56 100644 (file)
 #include <WebCore/SWOriginStore.h>
 #include <wtf/HashSet.h>
 
-namespace WebCore {
-class SecurityOrigin;
-}
-
 namespace WebKit {
 
 class WebSWServerConnection;
@@ -50,8 +46,8 @@ public:
 private:
     void sendStoreHandle(WebSWServerConnection&);
 
-    void addToStore(const WebCore::SecurityOrigin&) final;
-    void removeFromStore(const WebCore::SecurityOrigin&) final;
+    void addToStore(const WebCore::SecurityOriginData&) final;
+    void removeFromStore(const WebCore::SecurityOriginData&) final;
     void clearStore() final;
 
     // SharedStringHashStore::Client.
index 500f949..38c3991 100644 (file)
@@ -212,7 +212,7 @@ void WebSWServerConnection::postMessageToServiceWorker(ServiceWorkerIdentifier d
 
 void WebSWServerConnection::scheduleJobInServer(ServiceWorkerJobData&& jobData)
 {
-    auto securityOrigin = SecurityOrigin::create(jobData.scriptURL);
+    auto securityOrigin = SecurityOriginData::fromURL(jobData.scriptURL);
     if (!StorageProcess::singleton().serverToContextConnectionForOrigin(securityOrigin))
         StorageProcess::singleton().createServerToContextConnection(securityOrigin, server().sessionID());
 
@@ -287,7 +287,7 @@ void WebSWServerConnection::getRegistrations(uint64_t registrationMatchRequestId
 
 void WebSWServerConnection::registerServiceWorkerClient(SecurityOriginData&& topOrigin, ServiceWorkerClientData&& data, const std::optional<ServiceWorkerRegistrationIdentifier>& controllingServiceWorkerRegistrationIdentifier)
 {
-    auto clientOrigin = ClientOrigin { WTFMove(topOrigin), SecurityOriginData::fromSecurityOrigin(SecurityOrigin::create(data.url)) };
+    auto clientOrigin = ClientOrigin { WTFMove(topOrigin), SecurityOriginData::fromURL(data.url) };
     m_clientOrigins.add(data.identifier, clientOrigin);
     server().registerServiceWorkerClient(WTFMove(clientOrigin), WTFMove(data), controllingServiceWorkerRegistrationIdentifier);
 }
index 14850ac..00b7fc7 100644 (file)
@@ -37,8 +37,8 @@ using namespace WebCore;
 
 namespace WebKit {
 
-WebSWServerToContextConnection::WebSWServerToContextConnection(Ref<SecurityOrigin>&& origin, Ref<IPC::Connection>&& connection)
-    : SWServerToContextConnection(WTFMove(origin))
+WebSWServerToContextConnection::WebSWServerToContextConnection(const SecurityOriginData& securityOrigin, Ref<IPC::Connection>&& connection)
+    : SWServerToContextConnection(securityOrigin)
     , m_ipcConnection(WTFMove(connection))
 {
 }
index bb10bde..e9c3988 100644 (file)
@@ -50,7 +50,7 @@ public:
     void terminate();
 
 private:
-    explicit WebSWServerToContextConnection(Ref<WebCore::SecurityOrigin>&&, Ref<IPC::Connection>&&);
+    WebSWServerToContextConnection(const WebCore::SecurityOriginData&, Ref<IPC::Connection>&&);
 
     // IPC::MessageSender
     IPC::Connection* messageSenderConnection() final;
index dd488c6..f85724e 100644 (file)
@@ -113,23 +113,24 @@ void StorageProcess::didClose(IPC::Connection& connection)
 #if ENABLE(SERVICE_WORKER)
 void StorageProcess::connectionToContextProcessWasClosed(Ref<WebSWServerToContextConnection>&& serverToContextConnection)
 {
+    auto& securityOrigin = serverToContextConnection->securityOrigin();
+
     serverToContextConnection->connectionClosed();
-    m_serverToContextConnections.remove(&serverToContextConnection->origin());
+    m_serverToContextConnections.remove(securityOrigin);
 
     for (auto& swServer : m_swServers.values())
-        swServer->markAllWorkersForOriginAsTerminated(serverToContextConnection->origin());
+        swServer->markAllWorkersForOriginAsTerminated(securityOrigin);
 
-    Ref<SecurityOrigin> origin = serverToContextConnection->origin();
-    if (needsServerToContextConnectionForOrigin(origin)) {
+    if (needsServerToContextConnectionForOrigin(securityOrigin)) {
         RELEASE_LOG(ServiceWorker, "Connection to service worker process was closed but is still needed, relaunching it");
-        createServerToContextConnection(origin, std::nullopt);
+        createServerToContextConnection(securityOrigin, std::nullopt);
     }
 }
 
-bool StorageProcess::needsServerToContextConnectionForOrigin(SecurityOrigin& origin) const
+bool StorageProcess::needsServerToContextConnectionForOrigin(const SecurityOriginData& securityOrigin) const
 {
     return WTF::anyOf(m_swServers.values(), [&](auto& swServer) {
-        return swServer->needsServerToContextConnectionForOrigin(origin);
+        return swServer->needsServerToContextConnectionForOrigin(securityOrigin);
     });
 }
 #endif
@@ -250,7 +251,7 @@ void StorageProcess::performNextStorageTask()
     task.performTask();
 }
 
-void StorageProcess::createStorageToWebProcessConnection(bool isServiceWorkerProcess, WebCore::SecurityOriginData&& originData)
+void StorageProcess::createStorageToWebProcessConnection(bool isServiceWorkerProcess, WebCore::SecurityOriginData&& securityOrigin)
 {
 #if USE(UNIX_DOMAIN_SOCKETS)
     IPC::Connection::SocketPair socketPair = IPC::Connection::createPlatformConnection();
@@ -274,9 +275,8 @@ void StorageProcess::createStorageToWebProcessConnection(bool isServiceWorkerPro
     if (isServiceWorkerProcess && !m_storageToWebProcessConnections.isEmpty()) {
         ASSERT(parentProcessHasServiceWorkerEntitlement());
         ASSERT(m_waitingForServerToContextProcessConnection);
-        auto origin = originData.securityOrigin();
-        auto contextConnection = WebSWServerToContextConnection::create(origin.copyRef(), m_storageToWebProcessConnections.last()->connection());
-        auto addResult = m_serverToContextConnections.add(WTFMove(origin), contextConnection.copyRef());
+        auto contextConnection = WebSWServerToContextConnection::create(securityOrigin, m_storageToWebProcessConnections.last()->connection());
+        auto addResult = m_serverToContextConnections.add(WTFMove(securityOrigin), contextConnection.copyRef());
         ASSERT_UNUSED(addResult, addResult.isNewEntry);
 
         m_waitingForServerToContextProcessConnection = false;
@@ -339,7 +339,7 @@ void StorageProcess::deleteWebsiteData(PAL::SessionID sessionID, OptionSet<Websi
 #endif
 }
 
-void StorageProcess::deleteWebsiteDataForOrigins(PAL::SessionID sessionID, OptionSet<WebsiteDataType> websiteDataTypes, const Vector<SecurityOriginData>& securityOriginDatas, uint64_t callbackID)
+void StorageProcess::deleteWebsiteDataForOrigins(PAL::SessionID sessionID, OptionSet<WebsiteDataType> websiteDataTypes, const Vector<SecurityOriginData>& securityOrigins, uint64_t callbackID)
 {
     auto callbackAggregator = CallbackAggregator::create([this, callbackID]() {
         parentProcessConnection()->send(Messages::StorageProcessProxy::DidDeleteWebsiteDataForOrigins(callbackID), 0);
@@ -348,14 +348,14 @@ void StorageProcess::deleteWebsiteDataForOrigins(PAL::SessionID sessionID, Optio
 #if ENABLE(SERVICE_WORKER)
     if (websiteDataTypes.contains(WebsiteDataType::ServiceWorkerRegistrations)) {
         auto& server = swServerForSession(sessionID);
-        for (auto& originData : securityOriginDatas)
-            server.clear(originData.securityOrigin(), [callbackAggregator = callbackAggregator.copyRef()] { });
+        for (auto& securityOrigin : securityOrigins)
+            server.clear(securityOrigin, [callbackAggregator = callbackAggregator.copyRef()] { });
     }
 #endif
 
 #if ENABLE(INDEXED_DATABASE)
     if (!websiteDataTypes.contains(WebsiteDataType::IndexedDBDatabases))
-        idbServer(sessionID).closeAndDeleteDatabasesForOrigins(securityOriginDatas, [callbackAggregator = WTFMove(callbackAggregator)] { });
+        idbServer(sessionID).closeAndDeleteDatabasesForOrigins(securityOrigins, [callbackAggregator = WTFMove(callbackAggregator)] { });
 #endif
 }
 
@@ -455,21 +455,21 @@ WebSWOriginStore& StorageProcess::swOriginStoreForSession(PAL::SessionID session
     return static_cast<WebSWOriginStore&>(swServerForSession(sessionID).originStore());
 }
 
-WebSWServerToContextConnection* StorageProcess::serverToContextConnectionForOrigin(const WebCore::SecurityOrigin& origin)
+WebSWServerToContextConnection* StorageProcess::serverToContextConnectionForOrigin(const SecurityOriginData& securityOrigin)
 {
-    return m_serverToContextConnections.get(&const_cast<SecurityOrigin&>(origin));
+    return m_serverToContextConnections.get(securityOrigin);
 }
 
-void StorageProcess::createServerToContextConnection(const SecurityOrigin& origin, std::optional<PAL::SessionID> sessionID)
+void StorageProcess::createServerToContextConnection(const SecurityOriginData& securityOrigin, std::optional<PAL::SessionID> sessionID)
 {
     if (m_waitingForServerToContextProcessConnection)
         return;
     
     m_waitingForServerToContextProcessConnection = true;
     if (sessionID)
-        parentProcessConnection()->send(Messages::StorageProcessProxy::EstablishWorkerContextConnectionToStorageProcessForExplicitSession(SecurityOriginData::fromSecurityOrigin(origin), *sessionID), 0);
+        parentProcessConnection()->send(Messages::StorageProcessProxy::EstablishWorkerContextConnectionToStorageProcessForExplicitSession(securityOrigin, *sessionID), 0);
     else
-        parentProcessConnection()->send(Messages::StorageProcessProxy::EstablishWorkerContextConnectionToStorageProcess(SecurityOriginData::fromSecurityOrigin(origin)), 0);
+        parentProcessConnection()->send(Messages::StorageProcessProxy::EstablishWorkerContextConnectionToStorageProcess(securityOrigin), 0);
 }
 
 void StorageProcess::didFailFetch(SWServerConnectionIdentifier serverConnectionIdentifier, uint64_t fetchIdentifier)
@@ -537,15 +537,15 @@ void StorageProcess::unregisterSWServerConnection(WebSWServerConnection& connect
 
 void StorageProcess::swContextConnectionMayNoLongerBeNeeded(WebSWServerToContextConnection& serverToContextConnection)
 {
-    auto& origin = serverToContextConnection.origin();
-    if (needsServerToContextConnectionForOrigin(origin))
+    auto& securityOrigin = serverToContextConnection.securityOrigin();
+    if (needsServerToContextConnectionForOrigin(securityOrigin))
         return;
 
     RELEASE_LOG(ServiceWorker, "Service worker process is no longer needed, terminating it");
     serverToContextConnection.terminate();
 
     serverToContextConnection.connectionClosed();
-    m_serverToContextConnections.remove(&origin);
+    m_serverToContextConnections.remove(securityOrigin);
 }
 
 void StorageProcess::disableServiceWorkerProcessTerminationDelay()
index d12fe31..2078a13 100644 (file)
@@ -29,7 +29,7 @@
 #include "SandboxExtension.h"
 #include <WebCore/IDBBackingStore.h>
 #include <WebCore/IDBServer.h>
-#include <WebCore/SecurityOriginHash.h>
+#include <WebCore/SecurityOriginData.h>
 #include <WebCore/ServiceWorkerIdentifier.h>
 #include <WebCore/ServiceWorkerTypes.h>
 #include <WebCore/UniqueIDBDatabase.h>
@@ -45,7 +45,6 @@ namespace WebCore {
 class SWServer;
 class ServiceWorkerRegistrationKey;
 struct MessageWithMessagePorts;
-struct SecurityOriginData;
 struct ServiceWorkerClientIdentifier;
 }
 
@@ -94,8 +93,8 @@ public:
 #endif
 
 #if ENABLE(SERVICE_WORKER)
-    WebSWServerToContextConnection* serverToContextConnectionForOrigin(const WebCore::SecurityOrigin&);
-    void createServerToContextConnection(const WebCore::SecurityOrigin&, std::optional<PAL::SessionID>);
+    WebSWServerToContextConnection* serverToContextConnectionForOrigin(const WebCore::SecurityOriginData&);
+    void createServerToContextConnection(const WebCore::SecurityOriginData&, std::optional<PAL::SessionID>);
 
     WebCore::SWServer& swServerForSession(PAL::SessionID);
     void registerSWServerConnection(WebSWServerConnection&);
@@ -150,7 +149,7 @@ private:
     void disableServiceWorkerProcessTerminationDelay();
 
     WebSWOriginStore& swOriginStoreForSession(PAL::SessionID);
-    bool needsServerToContextConnectionForOrigin(WebCore::SecurityOrigin&) const;
+    bool needsServerToContextConnectionForOrigin(const WebCore::SecurityOriginData&) const;
 #endif
 #if ENABLE(INDEXED_DATABASE)
     Vector<WebCore::SecurityOriginData> indexedDatabaseOrigins(const String& path);
@@ -177,7 +176,7 @@ private:
 #if ENABLE(SERVICE_WORKER)
     void didCreateWorkerContextProcessConnection(const IPC::Attachment&);
 
-    HashMap<RefPtr<WebCore::SecurityOrigin>, Ref<WebSWServerToContextConnection>> m_serverToContextConnections;
+    HashMap<WebCore::SecurityOriginData, Ref<WebSWServerToContextConnection>> m_serverToContextConnections;
     bool m_waitingForServerToContextProcessConnection { false };
     bool m_shouldDisableServiceWorkerProcessTerminationDelay { false };
     HashMap<PAL::SessionID, String> m_swDatabasePaths;
index 0319e5a..96b13d1 100644 (file)
@@ -45,7 +45,7 @@ Ref<FrameInfo> FrameInfo::create(const WebKit::WebFrameProxy& frame, const WebCo
     frameInfoData.isMainFrame = frame.isMainFrame();
     // FIXME: This should use the full request of the frame, not just the URL.
     frameInfoData.request = WebCore::ResourceRequest(frame.url());
-    frameInfoData.securityOrigin = WebCore::SecurityOriginData::fromSecurityOrigin(securityOrigin);
+    frameInfoData.securityOrigin = securityOrigin.data();
     frameInfoData.frameID = frame.frameID();
 
     return create(frameInfoData, frame.page());
index fab60af..ee87ac1 100644 (file)
@@ -57,7 +57,7 @@ void WKApplicationCacheManagerDeleteEntriesForOrigin(WKApplicationCacheManagerRe
     auto& websiteDataStore = toImpl(reinterpret_cast<WKWebsiteDataStoreRef>(applicationCacheManager))->websiteDataStore();
 
     WebsiteDataRecord dataRecord;
-    dataRecord.add(WebsiteDataType::OfflineWebApplicationCache, WebCore::SecurityOriginData::fromSecurityOrigin(toImpl(origin)->securityOrigin()));
+    dataRecord.add(WebsiteDataType::OfflineWebApplicationCache, toImpl(origin)->securityOrigin().data());
 
     websiteDataStore.removeData(WebsiteDataType::OfflineWebApplicationCache, { dataRecord }, [] { });
 }
index f10d633..4e39dad 100644 (file)
@@ -119,7 +119,7 @@ void WKKeyValueStorageManagerDeleteEntriesForOrigin(WKKeyValueStorageManagerRef
     if (!storageManager)
         return;
 
-    storageManager->deleteLocalStorageEntriesForOrigin(WebCore::SecurityOriginData::fromSecurityOrigin(toImpl(origin)->securityOrigin()));
+    storageManager->deleteLocalStorageEntriesForOrigin(toImpl(origin)->securityOrigin().data());
 }
 
 void WKKeyValueStorageManagerDeleteAllEntries(WKKeyValueStorageManagerRef keyValueStorageManager)
index 23aa4d1..6b16c2a 100644 (file)
@@ -72,14 +72,14 @@ void WKResourceCacheManagerClearCacheForOrigin(WKResourceCacheManagerRef cacheMa
 
     {
         WebsiteDataRecord dataRecord;
-        dataRecord.add(WebsiteDataType::MemoryCache, WebCore::SecurityOriginData::fromSecurityOrigin(toImpl(origin)->securityOrigin()));
+        dataRecord.add(WebsiteDataType::MemoryCache, toImpl(origin)->securityOrigin().data());
 
         dataRecords.append(dataRecord);
     }
 
     if (cachesToClear == WKResourceCachesToClearAll) {
         WebsiteDataRecord dataRecord;
-        dataRecord.add(WebsiteDataType::DiskCache, WebCore::SecurityOriginData::fromSecurityOrigin(toImpl(origin)->securityOrigin()));
+        dataRecord.add(WebsiteDataType::DiskCache, toImpl(origin)->securityOrigin().data());
 
         dataRecords.append(dataRecord);
     }
index 6650b58..ca29aaf 100644 (file)
@@ -436,7 +436,7 @@ void WKWebsiteDataStoreRemoveAllFetchCaches(WKWebsiteDataStoreRef dataStoreRef,
 void WKWebsiteDataStoreRemoveFetchCacheForOrigin(WKWebsiteDataStoreRef dataStoreRef, WKSecurityOriginRef origin, void* context, WKWebsiteDataStoreRemoveFetchCacheRemovalFunction callback)
 {
     WebKit::WebsiteDataRecord dataRecord;
-    dataRecord.add(WebKit::WebsiteDataType::DOMCache, WebCore::SecurityOriginData::fromSecurityOrigin(WebKit::toImpl(origin)->securityOrigin()));
+    dataRecord.add(WebKit::WebsiteDataType::DOMCache, WebKit::toImpl(origin)->securityOrigin().data());
     Vector<WebKit::WebsiteDataRecord> dataRecords = { WTFMove(dataRecord) };
 
     OptionSet<WebKit::WebsiteDataType> dataTypes = WebKit::WebsiteDataType::DOMCache;
@@ -480,7 +480,7 @@ void WKWebsiteDataStoreGetFetchCacheSizeForOrigin(WKWebsiteDataStoreRef dataStor
     OptionSet<WebKit::WebsiteDataFetchOption> fetchOptions = WebKit::WebsiteDataFetchOption::ComputeSizes;
 
     WebKit::toImpl(dataStoreRef)->websiteDataStore().fetchData(WebKit::WebsiteDataType::DOMCache, fetchOptions, [origin, context, callback] (auto dataRecords) {
-        auto originData = WebCore::SecurityOriginData::fromSecurityOrigin(WebCore::SecurityOrigin::createFromString(WebKit::toImpl(origin)->string()));
+        auto originData = WebCore::SecurityOrigin::createFromString(WebKit::toImpl(origin)->string())->data();
         for (auto& dataRecord : dataRecords) {
             for (const auto& recordOrigin : dataRecord.origins) {
                 if (originData == recordOrigin) {
index caeeec3..b61904c 100644 (file)
@@ -42,16 +42,16 @@ namespace WebKit {
 
 using namespace WebCore;
 
-Ref<ServiceWorkerProcessProxy> ServiceWorkerProcessProxy::create(WebProcessPool& pool, Ref<SecurityOrigin>&& origin, WebsiteDataStore& store)
+Ref<ServiceWorkerProcessProxy> ServiceWorkerProcessProxy::create(WebProcessPool& pool, const SecurityOriginData& securityOrigin, WebsiteDataStore& store)
 {
-    auto proxy = adoptRef(*new ServiceWorkerProcessProxy { pool, WTFMove(origin), store });
+    auto proxy = adoptRef(*new ServiceWorkerProcessProxy { pool, securityOrigin, store });
     proxy->connect();
     return proxy;
 }
 
-ServiceWorkerProcessProxy::ServiceWorkerProcessProxy(WebProcessPool& pool, Ref<SecurityOrigin>&& origin, WebsiteDataStore& store)
+ServiceWorkerProcessProxy::ServiceWorkerProcessProxy(WebProcessPool& pool, const SecurityOriginData& securityOrigin, WebsiteDataStore& store)
     : WebProcessProxy { pool, store }
-    , m_origin(WTFMove(origin))
+    , m_securityOrigin(securityOrigin)
     , m_serviceWorkerPageID(generatePageID())
 {
 }
@@ -71,7 +71,7 @@ void ServiceWorkerProcessProxy::getLaunchOptions(ProcessLauncher::LaunchOptions&
     WebProcessProxy::getLaunchOptions(launchOptions);
 
     launchOptions.extraInitializationData.add(ASCIILiteral("service-worker-process"), ASCIILiteral("1"));
-    launchOptions.extraInitializationData.add(ASCIILiteral("security-origin"), origin().toString());
+    launchOptions.extraInitializationData.add(ASCIILiteral("security-origin"), securityOrigin().toString());
 }
 
 void ServiceWorkerProcessProxy::start(const WebPreferencesStore& store, std::optional<PAL::SessionID> initialSessionID)
index 1c770b1..3351b74 100644 (file)
@@ -28,7 +28,7 @@
 #if ENABLE(SERVICE_WORKER)
 
 #include "WebProcessProxy.h"
-#include <WebCore/SecurityOrigin.h>
+#include <WebCore/SecurityOriginData.h>
 
 namespace WebKit {
 class AuthenticationChallengeProxy;
@@ -36,7 +36,7 @@ struct WebPreferencesStore;
 
 class ServiceWorkerProcessProxy final : public WebProcessProxy {
 public:
-    static Ref<ServiceWorkerProcessProxy> create(WebProcessPool&, Ref<WebCore::SecurityOrigin>&&, WebsiteDataStore&);
+    static Ref<ServiceWorkerProcessProxy> create(WebProcessPool&, const WebCore::SecurityOriginData&, WebsiteDataStore&);
     ~ServiceWorkerProcessProxy();
 
     static bool hasRegisteredServiceWorkers(const String& serviceWorkerDirectory);
@@ -47,7 +47,7 @@ public:
     void setUserAgent(const String&);
     void updatePreferencesStore(const WebPreferencesStore&);
 
-    WebCore::SecurityOrigin& origin() { return m_origin.get(); }
+    const WebCore::SecurityOriginData& securityOrigin() { return m_securityOrigin; }
     uint64_t pageID() const { return m_serviceWorkerPageID; }
 
 private:
@@ -56,9 +56,9 @@ private:
 
     bool isServiceWorkerProcess() const final { return true; }
 
-    ServiceWorkerProcessProxy(WebProcessPool&, Ref<WebCore::SecurityOrigin>&&, WebsiteDataStore&);
+    ServiceWorkerProcessProxy(WebProcessPool&, const WebCore::SecurityOriginData&, WebsiteDataStore&);
 
-    Ref<WebCore::SecurityOrigin> m_origin;
+    WebCore::SecurityOriginData m_securityOrigin;
     uint64_t m_serviceWorkerPageID { 0 };
 };
 
index 9e788f4..54a0792 100644 (file)
@@ -122,15 +122,15 @@ void StorageProcessProxy::getStorageProcessConnection(WebProcessProxy& webProces
     }
 
     bool isServiceWorkerProcess = false;
-    SecurityOriginData origin;
+    SecurityOriginData securityOrigin;
 #if ENABLE(SERVICE_WORKER)
     if (is<ServiceWorkerProcessProxy>(webProcessProxy)) {
         isServiceWorkerProcess = true;
-        origin = SecurityOriginData::fromSecurityOrigin(downcast<ServiceWorkerProcessProxy>(webProcessProxy).origin());
+        securityOrigin = downcast<ServiceWorkerProcessProxy>(webProcessProxy).securityOrigin();
     }
 #endif
 
-    send(Messages::StorageProcess::CreateStorageToWebProcessConnection(isServiceWorkerProcess, origin), 0, IPC::SendOption::DispatchMessageEvenWhenWaitingForSyncReply);
+    send(Messages::StorageProcess::CreateStorageToWebProcessConnection(isServiceWorkerProcess, securityOrigin), 0, IPC::SendOption::DispatchMessageEvenWhenWaitingForSyncReply);
 }
 
 void StorageProcessProxy::didClose(IPC::Connection&)
index 351bf6a..2de7dba 100644 (file)
@@ -591,12 +591,11 @@ void WebProcessPool::storageProcessCrashed(StorageProcessProxy* storageProcessPr
 }
 
 #if ENABLE(SERVICE_WORKER)
-void WebProcessPool::establishWorkerContextConnectionToStorageProcess(StorageProcessProxy& proxy, SecurityOriginData&& originData, std::optional<PAL::SessionID> sessionID)
+void WebProcessPool::establishWorkerContextConnectionToStorageProcess(StorageProcessProxy& proxy, SecurityOriginData&& securityOrigin, std::optional<PAL::SessionID> sessionID)
 {
     ASSERT_UNUSED(proxy, &proxy == m_storageProcess);
 
-    auto origin = originData.securityOrigin();
-    if (m_serviceWorkerProcesses.contains(origin.ptr()))
+    if (m_serviceWorkerProcesses.contains(securityOrigin))
         return;
 
     m_mayHaveRegisteredServiceWorkers.clear();
@@ -614,8 +613,8 @@ void WebProcessPool::establishWorkerContextConnectionToStorageProcess(StoragePro
     if (m_serviceWorkerProcesses.isEmpty())
         sendToAllProcesses(Messages::WebProcess::RegisterServiceWorkerClients { });
 
-    auto serviceWorkerProcessProxy = ServiceWorkerProcessProxy::create(*this, origin.copyRef(), *websiteDataStore);
-    m_serviceWorkerProcesses.add(origin.copyRef(), serviceWorkerProcessProxy.ptr());
+    auto serviceWorkerProcessProxy = ServiceWorkerProcessProxy::create(*this, securityOrigin, *websiteDataStore);
+    m_serviceWorkerProcesses.add(WTFMove(securityOrigin), serviceWorkerProcessProxy.ptr());
 
     updateProcessAssertions();
     initializeNewWebProcess(serviceWorkerProcessProxy, *websiteDataStore);
@@ -990,7 +989,7 @@ void WebProcessPool::disconnectProcess(WebProcessProxy* process)
 
 #if ENABLE(SERVICE_WORKER)
     if (is<ServiceWorkerProcessProxy>(*process)) {
-        auto* removedProcess = m_serviceWorkerProcesses.take(&downcast<ServiceWorkerProcessProxy>(*process).origin());
+        auto* removedProcess = m_serviceWorkerProcesses.take(downcast<ServiceWorkerProcessProxy>(*process).securityOrigin());
         ASSERT_UNUSED(removedProcess, removedProcess == process);
         updateProcessAssertions();
     }
@@ -1878,9 +1877,9 @@ void WebProcessPool::updateProcessAssertions()
         if (!m_serviceWorkerProcesses.isEmpty() && m_foregroundWebProcessCounter.value()) {
             // FIXME: We can do better than this once we have process per origin.
             for (auto* serviceWorkerProcess : m_serviceWorkerProcesses.values()) {
-                auto& origin = serviceWorkerProcess->origin();
-                if (!m_foregroundTokensForServiceWorkerProcesses.contains(&origin))
-                    m_foregroundTokensForServiceWorkerProcesses.add(&origin, serviceWorkerProcess->throttler().foregroundActivityToken());
+                auto& securityOrigin = serviceWorkerProcess->securityOrigin();
+                if (!m_foregroundTokensForServiceWorkerProcesses.contains(securityOrigin))
+                    m_foregroundTokensForServiceWorkerProcesses.add(securityOrigin, serviceWorkerProcess->throttler().foregroundActivityToken());
             }
             m_backgroundTokensForServiceWorkerProcesses.clear();
             return;
@@ -1888,9 +1887,9 @@ void WebProcessPool::updateProcessAssertions()
         if (!m_serviceWorkerProcesses.isEmpty() && m_backgroundWebProcessCounter.value()) {
             // FIXME: We can do better than this once we have process per origin.
             for (auto* serviceWorkerProcess : m_serviceWorkerProcesses.values()) {
-                auto& origin = serviceWorkerProcess->origin();
-                if (!m_backgroundTokensForServiceWorkerProcesses.contains(&origin))
-                    m_backgroundTokensForServiceWorkerProcesses.add(&origin, serviceWorkerProcess->throttler().backgroundActivityToken());
+                auto& securityOrigin = serviceWorkerProcess->securityOrigin();
+                if (!m_backgroundTokensForServiceWorkerProcesses.contains(securityOrigin))
+                    m_backgroundTokensForServiceWorkerProcesses.add(securityOrigin, serviceWorkerProcess->throttler().backgroundActivityToken());
             }
             m_foregroundTokensForServiceWorkerProcesses.clear();
             return;
index 457f4c4..895fc33 100644 (file)
@@ -335,7 +335,7 @@ public:
 #if ENABLE(SERVICE_WORKER)
     void establishWorkerContextConnectionToStorageProcess(StorageProcessProxy&, WebCore::SecurityOriginData&&, std::optional<PAL::SessionID>);
     ServiceWorkerProcessProxy* serviceWorkerProcessProxyFromPageID(uint64_t pageID) const;
-    const HashMap<RefPtr<WebCore::SecurityOrigin>, ServiceWorkerProcessProxy*>& serviceWorkerProxies() const { return m_serviceWorkerProcesses; }
+    const HashMap<WebCore::SecurityOriginData, ServiceWorkerProcessProxy*>& serviceWorkerProxies() const { return m_serviceWorkerProcesses; }
     void setAllowsAnySSLCertificateForServiceWorker(bool allows) { m_allowsAnySSLCertificateForServiceWorker = allows; }
     bool allowsAnySSLCertificateForServiceWorker() const { return m_allowsAnySSLCertificateForServiceWorker; }
     void updateServiceWorkerUserAgent(const String& userAgent);
@@ -517,7 +517,7 @@ private:
 
     WebProcessProxy* m_processWithPageCache { nullptr };
 #if ENABLE(SERVICE_WORKER)
-    HashMap<RefPtr<WebCore::SecurityOrigin>, ServiceWorkerProcessProxy*> m_serviceWorkerProcesses;
+    HashMap<WebCore::SecurityOriginData, ServiceWorkerProcessProxy*> m_serviceWorkerProcesses;
     bool m_waitingForWorkerContextProcessConnection { false };
     bool m_allowsAnySSLCertificateForServiceWorker { false };
     bool m_shouldDisableServiceWorkerProcessTerminationDelay { false };
@@ -677,8 +677,8 @@ private:
     ProcessThrottler::ForegroundActivityToken m_foregroundTokenForNetworkProcess;
     ProcessThrottler::BackgroundActivityToken m_backgroundTokenForNetworkProcess;
 #if ENABLE(SERVICE_WORKER)
-    HashMap<RefPtr<WebCore::SecurityOrigin>, ProcessThrottler::ForegroundActivityToken> m_foregroundTokensForServiceWorkerProcesses;
-    HashMap<RefPtr<WebCore::SecurityOrigin>, ProcessThrottler::BackgroundActivityToken> m_backgroundTokensForServiceWorkerProcesses;
+    HashMap<WebCore::SecurityOriginData, ProcessThrottler::ForegroundActivityToken> m_foregroundTokensForServiceWorkerProcesses;
+    HashMap<WebCore::SecurityOriginData, ProcessThrottler::BackgroundActivityToken> m_backgroundTokensForServiceWorkerProcesses;
 #endif
 #endif
 };
index fd4804d..7f702e1 100644 (file)
@@ -602,7 +602,7 @@ void StorageManager::getLocalStorageOriginDetails(Function<void (Vector<LocalSto
     });
 }
 
-void StorageManager::deleteLocalStorageEntriesForOrigin(SecurityOriginData&& securityOrigin)
+void StorageManager::deleteLocalStorageEntriesForOrigin(const SecurityOriginData& securityOrigin)
 {
     m_queue->dispatch([this, protectedThis = makeRef(*this), copiedOrigin = securityOrigin.isolatedCopy()]() mutable {
         for (auto& localStorageNamespace : m_localStorageNamespaces.values())
index 2b1f8de..8423b99 100644 (file)
@@ -63,7 +63,7 @@ public:
     void deleteSessionStorageEntriesForOrigins(const Vector<WebCore::SecurityOriginData>&, Function<void()>&& completionHandler);
 
     void getLocalStorageOrigins(Function<void(HashSet<WebCore::SecurityOriginData>&&)>&& completionHandler);
-    void deleteLocalStorageEntriesForOrigin(WebCore::SecurityOriginData&&);
+    void deleteLocalStorageEntriesForOrigin(const WebCore::SecurityOriginData&);
 
     void deleteLocalStorageOriginsModifiedSince(WallTime, Function<void()>&& completionHandler);
     void deleteLocalStorageEntriesForOrigins(const Vector<WebCore::SecurityOriginData>&, Function<void()>&& completionHandler);
index c2143fd..0f9e9ac 100644 (file)
@@ -347,7 +347,7 @@ void WebsiteDataStore::fetchDataAndApply(OptionSet<WebsiteDataType> dataTypes, O
             WebsiteData websiteData;
             
             for (auto& origin : origins) {
-                WebsiteData::Entry entry { WebCore::SecurityOriginData::fromSecurityOrigin(*origin), WebsiteDataType::DiskCache, 0 };
+                WebsiteData::Entry entry { origin->data(), WebsiteDataType::DiskCache, 0 };
                 websiteData.entries.append(WTFMove(entry));
             }
             
@@ -447,7 +447,7 @@ void WebsiteDataStore::fetchDataAndApply(OptionSet<WebsiteDataType> dataTypes, O
 
             for (auto& origin : origins) {
                 uint64_t size = fetchOptions.contains(WebsiteDataFetchOption::ComputeSizes) ? storage->diskUsageForOrigin(*origin) : 0;
-                WebsiteData::Entry entry { WebCore::SecurityOriginData::fromSecurityOrigin(*origin), WebsiteDataType::OfflineWebApplicationCache, size };
+                WebsiteData::Entry entry { origin->data(), WebsiteDataType::OfflineWebApplicationCache, size };
 
                 websiteData.entries.append(WTFMove(entry));
             }
index 93b936f..01f1357 100644 (file)
@@ -74,7 +74,7 @@ void GeolocationPermissionRequestManager::startRequestForGeolocation(Geolocation
 
     SecurityOrigin& origin = frame->document()->securityOrigin();
 
-    m_page.send(Messages::WebPageProxy::RequestGeolocationPermissionForFrame(geolocationID, webFrame->frameID(), SecurityOriginData::fromSecurityOrigin(origin).databaseIdentifier()));
+    m_page.send(Messages::WebPageProxy::RequestGeolocationPermissionForFrame(geolocationID, webFrame->frameID(), origin.data().databaseIdentifier()));
 }
 
 void GeolocationPermissionRequestManager::cancelRequestForGeolocation(Geolocation& geolocation)
index 5b30f38..8f5d61b 100644 (file)
@@ -693,7 +693,7 @@ WKArrayRef WKBundlePageCopyOriginsWithApplicationCache(WKBundlePageRef page)
     originIdentifiers.reserveInitialCapacity(origins.size());
 
     for (const auto& origin : origins)
-        originIdentifiers.uncheckedAppend(API::String::create(WebCore::SecurityOriginData::fromSecurityOrigin(*origin).databaseIdentifier()));
+        originIdentifiers.uncheckedAppend(API::String::create(origin->data().databaseIdentifier()));
 
     return toAPI(&API::Array::create(WTFMove(originIdentifiers)).leakRef());
 }
index e4d37a2..9ccace0 100644 (file)
@@ -94,7 +94,7 @@ void UserMediaPermissionRequestManager::sendUserMediaRequest(UserMediaRequest& u
     ASSERT(webFrame);
 
     auto* topLevelDocumentOrigin = userRequest.topLevelDocumentOrigin();
-    m_page.send(Messages::WebPageProxy::RequestUserMediaPermissionForFrame(requestID, webFrame->frameID(), SecurityOriginData::fromSecurityOrigin(*userRequest.userMediaDocumentOrigin()), SecurityOriginData::fromSecurityOrigin(*topLevelDocumentOrigin), userRequest.request()));
+    m_page.send(Messages::WebPageProxy::RequestUserMediaPermissionForFrame(requestID, webFrame->frameID(), userRequest.userMediaDocumentOrigin()->data(), topLevelDocumentOrigin->data(), userRequest.request()));
 }
 
 void UserMediaPermissionRequestManager::cancelUserMediaRequest(UserMediaRequest& request)
@@ -182,7 +182,7 @@ void UserMediaPermissionRequestManager::enumerateMediaDevices(MediaDevicesEnumer
 
     SecurityOrigin* topLevelDocumentOrigin = request.topLevelDocumentOrigin();
     ASSERT(topLevelDocumentOrigin);
-    m_page.send(Messages::WebPageProxy::EnumerateMediaDevicesForFrame(requestID, webFrame->frameID(), SecurityOriginData::fromSecurityOrigin(*request.userMediaDocumentOrigin()), SecurityOriginData::fromSecurityOrigin(*topLevelDocumentOrigin)));
+    m_page.send(Messages::WebPageProxy::EnumerateMediaDevicesForFrame(requestID, webFrame->frameID(), request.userMediaDocumentOrigin()->data(), topLevelDocumentOrigin->data()));
 }
 
 void UserMediaPermissionRequestManager::cancelMediaDevicesEnumeration(WebCore::MediaDevicesEnumerationRequest& request)
index 1e2212e..5898402 100644 (file)
@@ -39,6 +39,7 @@
 #include "WebSWOriginTable.h"
 #include "WebSWServerConnectionMessages.h"
 #include <WebCore/Document.h>
+#include <WebCore/SecurityOrigin.h>
 #include <WebCore/SerializedScriptValue.h>
 #include <WebCore/ServiceWorkerClientData.h>
 #include <WebCore/ServiceWorkerFetchResult.h>
@@ -95,7 +96,7 @@ void WebSWClientConnection::postMessageToServiceWorker(ServiceWorkerIdentifier d
 
 void WebSWClientConnection::registerServiceWorkerClient(const SecurityOrigin& topOrigin, const WebCore::ServiceWorkerClientData& data, const std::optional<WebCore::ServiceWorkerRegistrationIdentifier>& controllingServiceWorkerRegistrationIdentifier)
 {
-    send(Messages::WebSWServerConnection::RegisterServiceWorkerClient { SecurityOriginData::fromSecurityOrigin(topOrigin), data, controllingServiceWorkerRegistrationIdentifier });
+    send(Messages::WebSWServerConnection::RegisterServiceWorkerClient { topOrigin.data(), data, controllingServiceWorkerRegistrationIdentifier });
 }
 
 void WebSWClientConnection::unregisterServiceWorkerClient(DocumentIdentifier contextIdentifier)
@@ -153,7 +154,7 @@ void WebSWClientConnection::matchRegistration(const SecurityOrigin& topOrigin, c
         return;
     }
 
-    runOrDelayTaskForImport([this, callback = WTFMove(callback), topOrigin = SecurityOriginData::fromSecurityOrigin(topOrigin), clientURL]() mutable {
+    runOrDelayTaskForImport([this, callback = WTFMove(callback), topOrigin = topOrigin.data(), clientURL]() mutable {
         uint64_t callbackID = ++m_previousCallbackIdentifier;
         m_ongoingMatchRegistrationTasks.add(callbackID, WTFMove(callback));
         send(Messages::WebSWServerConnection::MatchRegistration(callbackID, topOrigin, clientURL));
@@ -172,7 +173,7 @@ void WebSWClientConnection::whenRegistrationReady(const SecurityOrigin& topOrigi
 {
     uint64_t callbackID = ++m_previousCallbackIdentifier;
     m_ongoingRegistrationReadyTasks.add(callbackID, WTFMove(callback));
-    send(Messages::WebSWServerConnection::WhenRegistrationReady(callbackID, SecurityOriginData::fromSecurityOrigin(topOrigin), clientURL));
+    send(Messages::WebSWServerConnection::WhenRegistrationReady(callbackID, topOrigin.data(), clientURL));
 }
 
 void WebSWClientConnection::registrationReady(uint64_t callbackID, WebCore::ServiceWorkerRegistrationData&& registrationData)
@@ -191,7 +192,7 @@ void WebSWClientConnection::getRegistrations(const SecurityOrigin& topOrigin, co
         return;
     }
 
-    runOrDelayTaskForImport([this, callback = WTFMove(callback), topOrigin = SecurityOriginData::fromSecurityOrigin(topOrigin), clientURL]() mutable {
+    runOrDelayTaskForImport([this, callback = WTFMove(callback), topOrigin = topOrigin.data(), clientURL]() mutable {
         uint64_t callbackID = ++m_previousCallbackIdentifier;
         m_ongoingGetRegistrationsTasks.add(callbackID, WTFMove(callback));
         send(Messages::WebSWServerConnection::GetRegistrations(callbackID, topOrigin, clientURL));
index 47b4dbb..d4eee32 100644 (file)
@@ -731,17 +731,17 @@ void WebChromeClient::exceededDatabaseQuota(Frame& frame, const String& database
     ASSERT(webFrame);
     
     auto& origin = frame.document()->securityOrigin();
-    auto originData = SecurityOriginData::fromSecurityOrigin(origin);
+    auto& originData = origin.data();
     auto& tracker = DatabaseTracker::singleton();
     auto currentQuota = tracker.quota(originData);
     auto currentOriginUsage = tracker.usage(originData);
     uint64_t newQuota = 0;
-    RefPtr<API::SecurityOrigin> securityOrigin = API::SecurityOrigin::create(SecurityOriginData::fromDatabaseIdentifier(SecurityOriginData::fromSecurityOrigin(origin).databaseIdentifier())->securityOrigin());
+    RefPtr<API::SecurityOrigin> securityOrigin = API::SecurityOrigin::create(SecurityOriginData::fromDatabaseIdentifier(originData.databaseIdentifier())->securityOrigin());
     newQuota = m_page.injectedBundleUIClient().didExceedDatabaseQuota(&m_page, securityOrigin.get(), databaseName, details.displayName(), currentQuota, currentOriginUsage, details.currentUsage(), details.expectedUsage());
 
     if (!newQuota) {
         WebProcess::singleton().parentProcessConnection()->sendSync(
-            Messages::WebPageProxy::ExceededDatabaseQuota(webFrame->frameID(), SecurityOriginData::fromSecurityOrigin(origin).databaseIdentifier(), databaseName, details.displayName(), currentQuota, currentOriginUsage, details.currentUsage(), details.expectedUsage()),
+            Messages::WebPageProxy::ExceededDatabaseQuota(webFrame->frameID(), originData.databaseIdentifier(), databaseName, details.displayName(), currentQuota, currentOriginUsage, details.currentUsage(), details.expectedUsage()),
             Messages::WebPageProxy::ExceededDatabaseQuota::Reply(newQuota), m_page.pageID(), Seconds::infinity(), IPC::SendSyncOption::InformPlatformProcessWillSuspend);
     }
 
@@ -766,7 +766,7 @@ void WebChromeClient::reachedApplicationCacheOriginQuota(SecurityOrigin& origin,
 
     uint64_t newQuota = 0;
     WebProcess::singleton().parentProcessConnection()->sendSync(
-        Messages::WebPageProxy::ReachedApplicationCacheOriginQuota(SecurityOriginData::fromSecurityOrigin(origin).databaseIdentifier(), currentQuota, totalBytesNeeded),
+        Messages::WebPageProxy::ReachedApplicationCacheOriginQuota(origin.data().databaseIdentifier(), currentQuota, totalBytesNeeded),
         Messages::WebPageProxy::ReachedApplicationCacheOriginQuota::Reply(newQuota), m_page.pageID(), Seconds::infinity(), IPC::SendSyncOption::InformPlatformProcessWillSuspend);
 
     cacheStorage.storeUpdatedQuotaForOrigin(&origin, newQuota);
index 3fbb17d..ee8397c 100644 (file)
@@ -845,7 +845,7 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(const Navigat
     FrameInfoData originatingFrameInfoData;
     originatingFrameInfoData.isMainFrame = navigationAction.initiatedByMainFrame() == InitiatedByMainFrame::Yes;
     originatingFrameInfoData.request = ResourceRequest(sourceDocument.url());
-    originatingFrameInfoData.securityOrigin = SecurityOriginData::fromSecurityOrigin(sourceDocument.securityOrigin());
+    originatingFrameInfoData.securityOrigin = sourceDocument.securityOrigin().data();
     if (originatingFrame)
         originatingFrameInfoData.frameID = originatingFrame->frameID();
 
index b6fdf0a..6c7fc98 100644 (file)
@@ -1273,7 +1273,7 @@ void WebProcess::fetchWebsiteData(PAL::SessionID sessionID, OptionSet<WebsiteDat
 {
     if (websiteDataTypes.contains(WebsiteDataType::MemoryCache)) {
         for (auto& origin : MemoryCache::singleton().originsWithCache(sessionID))
-            websiteData.entries.append(WebsiteData::Entry { SecurityOriginData::fromSecurityOrigin(*origin), WebsiteDataType::MemoryCache, 0 });
+            websiteData.entries.append(WebsiteData::Entry { origin->data(), WebsiteDataType::MemoryCache, 0 });
     }
 
     if (websiteDataTypes.contains(WebsiteDataType::Credentials)) {
index c30dfed..5d5c2bc 100644 (file)
@@ -122,9 +122,9 @@ void StorageAreaImpl::closeDatabaseIfIdle()
     ASSERT_NOT_REACHED();
 }
 
-WebCore::SecurityOriginData StorageAreaImpl::securityOrigin() const
+const SecurityOriginData& StorageAreaImpl::securityOrigin() const
 {
-    return WebCore::SecurityOriginData::fromSecurityOrigin(m_storageAreaMap->securityOrigin());
+    return m_storageAreaMap->securityOrigin().data();
 }
 
 } // namespace WebKit
index 433c487..165af44 100644 (file)
@@ -60,7 +60,7 @@ private:
     void incrementAccessCount() override;
     void decrementAccessCount() override;
     void closeDatabaseIfIdle() override;
-    WebCore::SecurityOriginData securityOrigin() const override;
+    const WebCore::SecurityOriginData& securityOrigin() const override;
 
     uint64_t m_storageAreaID;
     Ref<StorageAreaMap> m_storageAreaMap;
index a2650d1..4713ac4 100644 (file)
@@ -74,14 +74,14 @@ StorageAreaMap::StorageAreaMap(StorageNamespaceImpl* storageNamespace, Ref<WebCo
     case StorageType::Local:
     case StorageType::TransientLocal:
         if (SecurityOrigin* topLevelOrigin = storageNamespace->topLevelOrigin())
-            WebProcess::singleton().parentProcessConnection()->send(Messages::StorageManager::CreateTransientLocalStorageMap(m_storageMapID, storageNamespace->storageNamespaceID(), SecurityOriginData::fromSecurityOrigin(*topLevelOrigin), SecurityOriginData::fromSecurityOrigin(m_securityOrigin)), 0);
+            WebProcess::singleton().parentProcessConnection()->send(Messages::StorageManager::CreateTransientLocalStorageMap(m_storageMapID, storageNamespace->storageNamespaceID(), topLevelOrigin->data(), m_securityOrigin->data()), 0);
         else
-            WebProcess::singleton().parentProcessConnection()->send(Messages::StorageManager::CreateLocalStorageMap(m_storageMapID, storageNamespace->storageNamespaceID(), SecurityOriginData::fromSecurityOrigin(m_securityOrigin)), 0);
+            WebProcess::singleton().parentProcessConnection()->send(Messages::StorageManager::CreateLocalStorageMap(m_storageMapID, storageNamespace->storageNamespaceID(), m_securityOrigin->data()), 0);
 
         break;
 
     case StorageType::Session:
-        WebProcess::singleton().parentProcessConnection()->send(Messages::StorageManager::CreateSessionStorageMap(m_storageMapID, storageNamespace->storageNamespaceID(), SecurityOriginData::fromSecurityOrigin(m_securityOrigin)), 0);
+        WebProcess::singleton().parentProcessConnection()->send(Messages::StorageManager::CreateSessionStorageMap(m_storageMapID, storageNamespace->storageNamespaceID(), m_securityOrigin->data()), 0);
         break;
 
     case StorageType::EphemeralLocal:
@@ -352,7 +352,7 @@ void StorageAreaMap::dispatchSessionStorageEvent(uint64_t sourceStorageAreaID, c
         frames.append(frame);
     }
 
-    StorageEventDispatcher::dispatchSessionStorageEventsToFrames(*page, frames, key, oldValue, newValue, urlString, SecurityOriginData::fromSecurityOrigin(m_securityOrigin));
+    StorageEventDispatcher::dispatchSessionStorageEventsToFrames(*page, frames, key, oldValue, newValue, urlString, m_securityOrigin->data());
 }
 
 void StorageAreaMap::dispatchLocalStorageEvent(uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString)
@@ -383,7 +383,7 @@ void StorageAreaMap::dispatchLocalStorageEvent(uint64_t sourceStorageAreaID, con
         }
     }
 
-    StorageEventDispatcher::dispatchLocalStorageEventsToFrames(pageGroup, frames, key, oldValue, newValue, urlString, SecurityOriginData::fromSecurityOrigin(m_securityOrigin));
+    StorageEventDispatcher::dispatchLocalStorageEventsToFrames(pageGroup, frames, key, oldValue, newValue, urlString, m_securityOrigin->data());
 }
 
 } // namespace WebKit
index 21fd587..2f1cd07 100644 (file)
@@ -75,7 +75,7 @@ StorageNamespaceImpl::~StorageNamespaceImpl()
 
 void StorageNamespaceImpl::didDestroyStorageAreaMap(StorageAreaMap& map)
 {
-    m_storageAreaMaps.remove(SecurityOriginData::fromSecurityOrigin(map.securityOrigin()));
+    m_storageAreaMaps.remove(map.securityOrigin().data());
 }
 
 RefPtr<StorageArea> StorageNamespaceImpl::storageArea(const SecurityOriginData& securityOrigin)
@@ -177,7 +177,7 @@ private:
     void decrementAccessCount() { }
     void closeDatabaseIfIdle() { }
 
-    SecurityOriginData securityOrigin() const
+    const SecurityOriginData& securityOrigin() const
     {
         return m_securityOriginData;
     }
index 193a1e1..7f2ae95 100644 (file)
@@ -1,3 +1,15 @@
+2018-03-24  Chris Dumez  <cdumez@apple.com>
+
+        Use SecurityOriginData more consistently in Service Worker code
+        https://bugs.webkit.org/show_bug.cgi?id=183969
+
+        Reviewed by Darin Adler.
+
+        Use SecurityOrigin::data() instead of SecurityOriginData::fromSecurityOrigin().
+
+        * Storage/StorageTracker.cpp:
+        (WebKit::StorageTracker::diskUsageForOrigin):
+
 2018-03-23  Tim Horton  <timothy_horton@apple.com>
 
         Adopt WK_PLATFORM_NAME in WebKitLegacy
index 1647722..386d48d 100644 (file)
@@ -61,7 +61,7 @@ public:
     void decrementAccessCount() override;
     void closeDatabaseIfIdle() override;
 
-    WebCore::SecurityOriginData securityOrigin() const override { return m_securityOrigin; }
+    const WebCore::SecurityOriginData& securityOrigin() const override { return m_securityOrigin; }
 
     Ref<StorageAreaImpl> copy();
     void close();
index d5e5f74..ddbdb22 100644 (file)
@@ -637,7 +637,7 @@ long long StorageTracker::diskUsageForOrigin(SecurityOrigin* origin)
 
     LockHolder locker(m_databaseMutex);
 
-    String path = databasePathForOrigin(SecurityOriginData::fromSecurityOrigin(*origin).databaseIdentifier());
+    String path = databasePathForOrigin(origin->data().databaseIdentifier());
     if (path.isEmpty())
         return 0;
 
index 9b122a5..9f7afbc 100644 (file)
@@ -1,3 +1,28 @@
+2018-03-24  Chris Dumez  <cdumez@apple.com>
+
+        Use SecurityOriginData more consistently in Service Worker code
+        https://bugs.webkit.org/show_bug.cgi?id=183969
+
+        Reviewed by Darin Adler.
+
+        Use SecurityOrigin::data() instead of SecurityOriginData::fromSecurityOrigin().
+
+        * Storage/WebDatabaseManager.mm:
+        (-[WebDatabaseManager databasesWithOrigin:]):
+        (-[WebDatabaseManager deleteOrigin:]):
+        (-[WebDatabaseManager deleteDatabase:withOrigin:]):
+        * Storage/WebDatabaseQuotaManager.mm:
+        (-[WebDatabaseQuotaManager usage]):
+        (-[WebDatabaseQuotaManager quota]):
+        (-[WebDatabaseQuotaManager setQuota:]):
+        * Storage/WebStorageManager.mm:
+        (-[WebStorageManager deleteOrigin:]):
+        * WebCoreSupport/WebSecurityOrigin.mm:
+        (-[WebSecurityOrigin databaseIdentifier]):
+        (-[WebSecurityOrigin usage]):
+        (-[WebSecurityOrigin quota]):
+        (-[WebSecurityOrigin setQuota:]):
+
 2018-03-24  Timothy Horton  <timothy_horton@apple.com>
 
         Fix the build
index 76c28f4..0051f58 100644 (file)
@@ -106,7 +106,7 @@ static NSString *databasesDirectoryPath();
 {
     if (!origin)
         return nil;
-    Vector<String> nameVector = DatabaseTracker::singleton().databaseNames(SecurityOriginData::fromSecurityOrigin(*[origin _core]));
+    Vector<String> nameVector = DatabaseTracker::singleton().databaseNames([origin _core]->data());
     NSMutableArray *names = [[NSMutableArray alloc] initWithCapacity:nameVector.size()];
     for (auto& name : nameVector)
         [names addObject:(NSString *)name];
@@ -142,12 +142,12 @@ static NSString *databasesDirectoryPath();
 
 - (BOOL)deleteOrigin:(WebSecurityOrigin *)origin
 {
-    return origin && DatabaseTracker::singleton().deleteOrigin(SecurityOriginData::fromSecurityOrigin(*[origin _core]));
+    return origin && DatabaseTracker::singleton().deleteOrigin([origin _core]->data());
 }
 
 - (BOOL)deleteDatabase:(NSString *)databaseIdentifier withOrigin:(WebSecurityOrigin *)origin
 {
-    return origin && DatabaseTracker::singleton().deleteDatabase(SecurityOriginData::fromSecurityOrigin(*[origin _core]), databaseIdentifier);
+    return origin && DatabaseTracker::singleton().deleteDatabase([origin _core]->data(), databaseIdentifier);
 }
 
 // For DumpRenderTree support only
index 9b84186..108c528 100644 (file)
@@ -53,12 +53,12 @@ using namespace WebCore;
 
 - (unsigned long long)usage
 {
-    return DatabaseTracker::singleton().usage(SecurityOriginData::fromSecurityOrigin(*[_origin _core]));
+    return DatabaseTracker::singleton().usage([_origin _core]->data());
 }
 
 - (unsigned long long)quota
 {
-    return DatabaseTracker::singleton().quota(SecurityOriginData::fromSecurityOrigin(*[_origin _core]));
+    return DatabaseTracker::singleton().quota([_origin _core]->data());
 }
 
 // If the quota is set to a value lower than the current usage, that quota will
@@ -66,7 +66,7 @@ using namespace WebCore;
 // prevent new data from being added to databases in that origin.
 - (void)setQuota:(unsigned long long)quota
 {
-    DatabaseTracker::singleton().setQuota(SecurityOriginData::fromSecurityOrigin(*[_origin _core]), quota);
+    DatabaseTracker::singleton().setQuota([_origin _core]->data(), quota);
 }
 
 @end
index 9a689ca..6e57ecb 100644 (file)
@@ -84,7 +84,7 @@ NSString * const WebStorageDidModifyOriginNotification = @"WebStorageDidModifyOr
 
 - (void)deleteOrigin:(WebSecurityOrigin *)origin
 {
-    WebKit::StorageTracker::tracker().deleteOrigin(SecurityOriginData::fromSecurityOrigin(*[origin _core]));
+    WebKit::StorageTracker::tracker().deleteOrigin([origin _core]->data());
 }
 
 - (unsigned long long)diskUsageForOrigin:(WebSecurityOrigin *)origin
index 4f42483..4e4c13d 100644 (file)
@@ -71,7 +71,7 @@ using namespace WebCore;
 
 - (NSString *)databaseIdentifier
 {
-    return SecurityOriginData::fromSecurityOrigin(*reinterpret_cast<SecurityOrigin*>(_private)).databaseIdentifier();
+    return reinterpret_cast<SecurityOrigin*>(_private)->data().databaseIdentifier();
 }
 
 #if PLATFORM(IOS)
@@ -169,17 +169,17 @@ using namespace WebCore;
 
 - (unsigned long long)usage
 {
-    return DatabaseTracker::singleton().usage(SecurityOriginData::fromSecurityOrigin(*reinterpret_cast<SecurityOrigin*>(_private)));
+    return DatabaseTracker::singleton().usage(reinterpret_cast<SecurityOrigin*>(_private)->data());
 }
 
 - (unsigned long long)quota
 {
-    return DatabaseTracker::singleton().quota(SecurityOriginData::fromSecurityOrigin(*reinterpret_cast<SecurityOrigin*>(_private)));
+    return DatabaseTracker::singleton().quota(reinterpret_cast<SecurityOrigin*>(_private)->data());
 }
 
 - (void)setQuota:(unsigned long long)quota
 {
-    DatabaseTracker::singleton().setQuota(SecurityOriginData::fromSecurityOrigin(*reinterpret_cast<SecurityOrigin*>(_private)), quota);
+    DatabaseTracker::singleton().setQuota(reinterpret_cast<SecurityOrigin*>(_private)->data(), quota);
 }
 
 @end
index b64ffcc..22169c6 100644 (file)
@@ -1,3 +1,22 @@
+2018-03-24  Chris Dumez  <cdumez@apple.com>
+
+        Use SecurityOriginData more consistently in Service Worker code
+        https://bugs.webkit.org/show_bug.cgi?id=183969
+
+        Reviewed by Darin Adler.
+
+        Use SecurityOrigin::data() instead of SecurityOriginData::fromSecurityOrigin().
+
+        * WebDatabaseManager.cpp:
+        (WebDatabaseManager::databasesWithOrigin):
+        (WebDatabaseManager::deleteOrigin):
+        (WebDatabaseManager::deleteDatabase):
+        (WebDatabaseManager::setQuota):
+        * WebSecurityOrigin.cpp:
+        (WebSecurityOrigin::usage):
+        (WebSecurityOrigin::quota):
+        (WebSecurityOrigin::setQuota):
+
 2018-03-23  Chris Dumez  <cdumez@apple.com>
 
         Unreviewed attempt to fix Windows build after r229926.
index fb54408..3605623 100644 (file)
@@ -256,7 +256,7 @@ HRESULT WebDatabaseManager::databasesWithOrigin(_In_opt_ IWebSecurityOrigin* ori
     if (!webSecurityOrigin)
         return E_FAIL;
 
-    auto databaseNames = DatabaseTracker::singleton().databaseNames(SecurityOriginData::fromSecurityOrigin(*webSecurityOrigin->securityOrigin()));
+    auto databaseNames = DatabaseTracker::singleton().databaseNames(webSecurityOrigin->securityOrigin()->data());
 
     COMPtr<COMEnumVariant<Vector<String>>> enumVariant(AdoptCOM, COMEnumVariant<Vector<String>>::adopt(databaseNames));
 
@@ -311,7 +311,7 @@ HRESULT WebDatabaseManager::deleteOrigin(_In_opt_ IWebSecurityOrigin* origin)
     if (!webSecurityOrigin)
         return E_FAIL;
 
-    DatabaseTracker::singleton().deleteOrigin(SecurityOriginData::fromSecurityOrigin(*webSecurityOrigin->securityOrigin()));
+    DatabaseTracker::singleton().deleteOrigin(webSecurityOrigin->securityOrigin()->data());
 
     return S_OK;
 }
@@ -331,7 +331,7 @@ HRESULT WebDatabaseManager::deleteDatabase(_In_ BSTR databaseName, _In_opt_ IWeb
     if (!webSecurityOrigin)
         return E_FAIL;
 
-    DatabaseTracker::singleton().deleteDatabase(SecurityOriginData::fromSecurityOrigin(*webSecurityOrigin->securityOrigin()), String(databaseName, SysStringLen(databaseName)));
+    DatabaseTracker::singleton().deleteDatabase(webSecurityOrigin->securityOrigin()->data(), String(databaseName, SysStringLen(databaseName)));
 
     return S_OK;
 }
@@ -396,7 +396,7 @@ HRESULT WebDatabaseManager::setQuota(_In_ BSTR origin, unsigned long long quota)
     if (this != s_sharedWebDatabaseManager)
         return E_FAIL;
 
-    DatabaseTracker::singleton().setQuota(SecurityOriginData::fromSecurityOrigin(SecurityOrigin::createFromString(origin)), quota);
+    DatabaseTracker::singleton().setQuota(SecurityOrigin::createFromString(origin)->data(), quota);
 
     return S_OK;
 }
index 906cbba..81b269f 100644 (file)
@@ -130,7 +130,7 @@ HRESULT WebSecurityOrigin::usage(_Out_ unsigned long long* result)
     if (!result)
         return E_POINTER;
 
-    *result = DatabaseTracker::singleton().usage(SecurityOriginData::fromSecurityOrigin(*m_securityOrigin));
+    *result = DatabaseTracker::singleton().usage(m_securityOrigin->data());
 
     return S_OK;
 }
@@ -140,13 +140,13 @@ HRESULT WebSecurityOrigin::quota(_Out_ unsigned long long* result)
     if (!result)
         return E_POINTER;
 
-    *result = DatabaseTracker::singleton().quota(SecurityOriginData::fromSecurityOrigin(*m_securityOrigin));
+    *result = DatabaseTracker::singleton().quota(m_securityOrigin->data());
     return S_OK;
 }
         
 HRESULT WebSecurityOrigin::setQuota(unsigned long long quota) 
 {
-    DatabaseTracker::singleton().setQuota(SecurityOriginData::fromSecurityOrigin(*m_securityOrigin), quota);
+    DatabaseTracker::singleton().setQuota(m_securityOrigin->data(), quota);
 
     return S_OK;
 }