WebKit Bugzilla
Attachment 359493 Details for
Bug 193556
: Implement message handlers for NetworkProcess-based ResourceLoadStatistics
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-193556-20190118083824.patch (text/plain), 286.56 KB, created by
Brent Fulgham
on 2019-01-18 08:38:25 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Brent Fulgham
Created:
2019-01-18 08:38:25 PST
Size:
286.56 KB
patch
obsolete
>Subversion Revision: 240138 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 225edcfd507d5c59206ac0bd80fd4dee075e0cf4..4314e2d2b6c3af5039f12e308d66bda81a5aad7b 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,22 @@ >+2019-01-17 Brent Fulgham <bfulgham@apple.com> >+ >+ Implement message handlers for NetworkProcess-based ResourceLoadStatistics >+ https://bugs.webkit.org/show_bug.cgi?id=193556 >+ <rdar://problem/47368501> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This patch adds a new observer callback used to message the NetworkProcess when >+ user interaction events are received. This is needed when the ResourceLoadStatistics >+ data is not being managed by the UIProcess. >+ >+ Tested by existing ResourceLoadStatistics and storageAccess tests. >+ >+ * loader/ResourceLoadObserver.cpp: >+ (WebCore::ResourceLoadObserver::setLogUserInteractionNotificationCallback): >+ (WebCore::ResourceLoadObserver::logUserInteractionWithReducedTimeResolution): >+ * loader/ResourceLoadObserver.h: >+ > 2019-01-17 Truitt Savell <tsavell@apple.com> > > Unreviewed, rolling out r240124. >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 89b471d52a11987499a3d60408d24a98c65ac239..e82a18323abb1fc7d45df876cdbf9f6562185171 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,316 @@ >+2019-01-17 Brent Fulgham <bfulgham@apple.com> >+ >+ Implement message handlers for NetworkProcess-based ResourceLoadStatistics >+ https://bugs.webkit.org/show_bug.cgi?id=193556 >+ <rdar://problem/47368501> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This patch adds a number of sibling methods for tracking ResourceLoadStatistics when the >+ observations are being handled in the NetworkProcess, rather than the UIProcess. The >+ original versions of these methods will be removed as part of Bug 193303. >+ >+ * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp: >+ (WebKit::ResourceLoadStatisticsMemoryStore::removeDataRecords): >+ (WebKit::ResourceLoadStatisticsMemoryStore::processStatisticsAndDataRecords): >+ (WebKit::ResourceLoadStatisticsMemoryStore::grandfatherExistingWebsiteData): >+ * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h: >+ (WebKit::ResourceLoadStatisticsMemoryStore::store const): >+ * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp: >+ (WebKit::WebResourceLoadStatisticsStore::setNotifyPagesWhenDataRecordsWereScanned): >+ (WebKit::WebResourceLoadStatisticsStore::setNotifyPagesWhenTelemetryWasCaptured): >+ (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore): >+ (WebKit::WebResourceLoadStatisticsStore::setPrevalentResourceForDebugMode): >+ (WebKit::WebResourceLoadStatisticsStore::scheduleStatisticsAndDataRecordsProcessing): >+ (WebKit::WebResourceLoadStatisticsStore::hasStorageAccess): >+ (WebKit::WebResourceLoadStatisticsStore::callHasStorageAccessForFrameHandler): >+ (WebKit::WebResourceLoadStatisticsStore::requestStorageAccess): >+ (WebKit::WebResourceLoadStatisticsStore::logUserInteraction): >+ (WebKit::WebResourceLoadStatisticsStore::clearUserInteraction): >+ (WebKit::WebResourceLoadStatisticsStore::hasHadUserInteraction): >+ (WebKit::WebResourceLoadStatisticsStore::setLastSeen): >+ (WebKit::WebResourceLoadStatisticsStore::setPrevalentResource): >+ (WebKit::WebResourceLoadStatisticsStore::setVeryPrevalentResource): >+ (WebKit::WebResourceLoadStatisticsStore::isPrevalentResource): >+ (WebKit::WebResourceLoadStatisticsStore::isVeryPrevalentResource): >+ (WebKit::WebResourceLoadStatisticsStore::isRegisteredAsSubresourceUnder): >+ (WebKit::WebResourceLoadStatisticsStore::isRegisteredAsSubFrameUnder): >+ (WebKit::WebResourceLoadStatisticsStore::isRegisteredAsRedirectingTo): >+ (WebKit::WebResourceLoadStatisticsStore::clearPrevalentResource): >+ (WebKit::WebResourceLoadStatisticsStore::setGrandfathered): >+ (WebKit::WebResourceLoadStatisticsStore::isGrandfathered): >+ (WebKit::WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin): >+ (WebKit::WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin): >+ (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo): >+ (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectFrom): >+ (WebKit::WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectTo): >+ (WebKit::WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectFrom): >+ (WebKit::WebResourceLoadStatisticsStore::setTimeToLiveUserInteraction): >+ (WebKit::WebResourceLoadStatisticsStore::logTestingEvent): >+ (WebKit::WebResourceLoadStatisticsStore::notifyResourceLoadStatisticsProcessed): >+ (WebKit::WebResourceLoadStatisticsStore::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores): >+ (WebKit::WebResourceLoadStatisticsStore::topPrivatelyControlledDomainsWithWebsiteData): >+ (WebKit::WebResourceLoadStatisticsStore::sendDiagnosticMessageWithValue const): >+ (WebKit::WebResourceLoadStatisticsStore::notifyPageStatisticsTelemetryFinished const): >+ * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h: >+ * NetworkProcess/Classifier/WebResourceLoadStatisticsTelemetry.cpp: >+ (WebKit::submitTopList): >+ (WebKit::submitTopLists): >+ (WebKit::notifyPages): >+ (WebKit::WebResourceLoadStatisticsTelemetry::calculateAndSubmit): >+ (WebKit::nonEphemeralWebPageProxy): Deleted. >+ * NetworkProcess/NetworkConnectionToWebProcess.cpp: >+ (WebKit::NetworkConnectionToWebProcess::logUserInteraction): >+ * NetworkProcess/NetworkConnectionToWebProcess.h: >+ * NetworkProcess/NetworkConnectionToWebProcess.messages.in: >+ * NetworkProcess/NetworkProcess.cpp: >+ (WebKit::NetworkProcess::dumpResourceLoadStatistics): >+ (WebKit::NetworkProcess::isGrandfathered): >+ (WebKit::NetworkProcess::isPrevalentResource): >+ (WebKit::NetworkProcess::isVeryPrevalentResource): >+ (WebKit::NetworkProcess::setGrandfathered): >+ (WebKit::NetworkProcess::setPrevalentResource): >+ (WebKit::NetworkProcess::setPrevalentResourceForDebugMode): >+ (WebKit::NetworkProcess::setVeryPrevalentResource): >+ (WebKit::NetworkProcess::clearPrevalentResource): >+ (WebKit::NetworkProcess::submitTelemetry): >+ (WebKit::NetworkProcess::scheduleCookieBlockingUpdate): >+ (WebKit::NetworkProcess::scheduleClearInMemoryAndPersistent): >+ (WebKit::NetworkProcess::resetParametersToDefaultValues): >+ (WebKit::NetworkProcess::scheduleStatisticsAndDataRecordsProcessing): >+ (WebKit::NetworkProcess::setNotifyPagesWhenDataRecordsWereScanned): >+ (WebKit::NetworkProcess::setNotifyPagesWhenTelemetryWasCaptured): >+ (WebKit::NetworkProcess::setSubframeUnderTopFrameOrigin): >+ (WebKit::NetworkProcess::isRegisteredAsRedirectingTo): >+ (WebKit::NetworkProcess::isRegisteredAsSubFrameUnder): >+ (WebKit::NetworkProcess::setSubresourceUnderTopFrameOrigin): >+ (WebKit::NetworkProcess::setSubresourceUniqueRedirectTo): >+ (WebKit::NetworkProcess::setSubresourceUniqueRedirectFrom): >+ (WebKit::NetworkProcess::isRegisteredAsSubresourceUnder): >+ (WebKit::NetworkProcess::setTopFrameUniqueRedirectTo): >+ (WebKit::NetworkProcess::setTopFrameUniqueRedirectFrom): >+ (WebKit::NetworkProcess::setLastSeen): >+ (WebKit::NetworkProcess::hasStorageAccess): >+ (WebKit::NetworkProcess::requestStorageAccess): >+ (WebKit::NetworkProcess::grantStorageAccess): >+ (WebKit::NetworkProcess::logUserInteraction): >+ (WebKit::NetworkProcess::hadUserInteraction): >+ (WebKit::NetworkProcess::clearUserInteraction): >+ (WebKit::NetworkProcess::setGrandfatheringTime): >+ (WebKit::NetworkProcess::setMaxStatisticsEntries): >+ (WebKit::NetworkProcess::setMinimumTimeBetweenDataRecordsRemoval): >+ (WebKit::NetworkProcess::setPruneEntriesDownTo): >+ (WebKit::NetworkProcess::setTimeToLiveUserInteraction): >+ (WebKit::NetworkProcess::setShouldClassifyResourcesBeforeDataRecordsRemoval): >+ (WebKit::NetworkProcess::setResourceLoadStatisticsEnabled): >+ (WebKit::NetworkProcess::setResourceLoadStatisticsDebugMode): >+ (WebKit::NetworkProcess::resetCacheMaxAgeCapForPrevalentResources): >+ (WebKit::NetworkProcess::deleteWebsiteData): >+ (WebKit::filterForTopLevelDomains): >+ (WebKit::NetworkProcess::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores): >+ (WebKit::NetworkProcess::topPrivatelyControlledDomainsWithWebsiteData): >+ * NetworkProcess/NetworkProcess.h: >+ * NetworkProcess/NetworkProcess.messages.in: >+ * NetworkProcess/NetworkSession.cpp: >+ (WebKit::NetworkSession::setResourceLoadStatisticsEnabled): >+ (WebKit::NetworkSession::notifyResourceLoadStatisticsProcessed): >+ (WebKit::NetworkSession::logDiagnosticMessageWithValue): >+ (WebKit::NetworkSession::notifyPageStatisticsTelemetryFinished): >+ (WebKit::NetworkSession::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores): >+ (WebKit::NetworkSession::topPrivatelyControlledDomainsWithWebsiteData): >+ (WebKit::NetworkSession::enableResourceLoadStatistics): Deleted. >+ * NetworkProcess/NetworkSession.h: >+ * NetworkProcess/cocoa/NetworkSessionCocoa.mm: >+ (WebKit::NetworkSessionCocoa::NetworkSessionCocoa): >+ * UIProcess/API/C/WKWebsiteDataStoreRef.cpp: >+ (WKWebsiteDataStoreSetResourceLoadStatisticsDebugModeWithCompletionHandler): >+ (WKWebsiteDataStoreSetResourceLoadStatisticsPrevalentResourceForDebugMode): >+ (WKWebsiteDataStoreSetStatisticsLastSeen): >+ (WKWebsiteDataStoreSetStatisticsPrevalentResource): >+ (WKWebsiteDataStoreSetStatisticsVeryPrevalentResource): >+ (WKWebsiteDataStoreDumpResourceLoadStatistics): >+ (WKWebsiteDataStoreIsStatisticsPrevalentResource): >+ (WKWebsiteDataStoreIsStatisticsVeryPrevalentResource): >+ (WKWebsiteDataStoreIsStatisticsRegisteredAsSubresourceUnder): >+ (WKWebsiteDataStoreIsStatisticsRegisteredAsSubFrameUnder): >+ (WKWebsiteDataStoreIsStatisticsRegisteredAsRedirectingTo): >+ (WKWebsiteDataStoreSetStatisticsHasHadUserInteraction): >+ (WKWebsiteDataStoreIsStatisticsHasHadUserInteraction): >+ (WKWebsiteDataStoreSetStatisticsGrandfathered): >+ (WKWebsiteDataStoreIsStatisticsGrandfathered): >+ (WKWebsiteDataStoreSetStatisticsSubframeUnderTopFrameOrigin): >+ (WKWebsiteDataStoreSetStatisticsSubresourceUnderTopFrameOrigin): >+ (WKWebsiteDataStoreSetStatisticsSubresourceUniqueRedirectTo): >+ (WKWebsiteDataStoreSetStatisticsSubresourceUniqueRedirectFrom): >+ (WKWebsiteDataStoreSetStatisticsTopFrameUniqueRedirectTo): >+ (WKWebsiteDataStoreSetStatisticsTopFrameUniqueRedirectFrom): >+ (WKWebsiteDataStoreSetStatisticsTimeToLiveUserInteraction): >+ (WKWebsiteDataStoreStatisticsProcessStatisticsAndDataRecords): >+ (WKWebsiteDataStoreStatisticsUpdateCookieBlocking): >+ (WKWebsiteDataStoreStatisticsSubmitTelemetry): >+ (WKWebsiteDataStoreSetStatisticsNotifyPagesWhenDataRecordsWereScanned): >+ (WKWebsiteDataStoreSetStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval): >+ (WKWebsiteDataStoreSetStatisticsNotifyPagesWhenTelemetryWasCaptured): >+ (WKWebsiteDataStoreSetStatisticsMinimumTimeBetweenDataRecordsRemoval): >+ (WKWebsiteDataStoreSetStatisticsGrandfatheringTime): >+ (WKWebsiteDataStoreSetStatisticsMaxStatisticsEntries): >+ (WKWebsiteDataStoreSetStatisticsPruneEntriesDownTo): >+ (WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStore): >+ (WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours): >+ (WKWebsiteDataStoreStatisticsResetToConsistentState): >+ * UIProcess/API/Cocoa/WKWebsiteDataStore.mm: >+ (-[WKWebsiteDataStore _setResourceLoadStatisticsTestingCallback:]): >+ * UIProcess/Network/NetworkProcessProxy.cpp: >+ (WebKit::NetworkProcessProxy::clearCallbackStates): >+ (WebKit::NetworkProcessProxy::didClose): >+ (WebKit::nonEphemeralWebPageProxy): >+ (WebKit::NetworkProcessProxy::logGlobalDiagnosticMessageWithValue): >+ (WebKit::NetworkProcessProxy::dumpResourceLoadStatistics): >+ (WebKit::NetworkProcessProxy::didDumpResourceLoadStatistics): >+ (WebKit::NetworkProcessProxy::updatePrevalentDomainsToBlockCookiesFor): >+ (WebKit::NetworkProcessProxy::didUpdateBlockCookies): >+ (WebKit::NetworkProcessProxy::isPrevalentResource): >+ (WebKit::NetworkProcessProxy::isPrevalentResourceResult): >+ (WebKit::NetworkProcessProxy::isVeryPrevalentResource): >+ (WebKit::NetworkProcessProxy::setPrevalentResource): >+ (WebKit::NetworkProcessProxy::setPrevalentResourceForDebugMode): >+ (WebKit::NetworkProcessProxy::setVeryPrevalentResource): >+ (WebKit::NetworkProcessProxy::didSetResourceLoadStatisticData): >+ (WebKit::NetworkProcessProxy::setLastSeen): >+ (WebKit::NetworkProcessProxy::clearPrevalentResource): >+ (WebKit::NetworkProcessProxy::scheduleCookieBlockingUpdate): >+ (WebKit::NetworkProcessProxy::didScheduleCookieBlockingUpdate): >+ (WebKit::NetworkProcessProxy::scheduleClearInMemoryAndPersistent): >+ (WebKit::NetworkProcessProxy::didScheduleStatisticsProcessing): >+ (WebKit::NetworkProcessProxy::scheduleStatisticsAndDataRecordsProcessing): >+ (WebKit::NetworkProcessProxy::logUserInteraction): >+ (WebKit::NetworkProcessProxy::hasHadUserInteraction): >+ (WebKit::NetworkProcessProxy::didHaveUserInteraction): >+ (WebKit::NetworkProcessProxy::clearUserInteraction): >+ (WebKit::NetworkProcessProxy::setAgeCapForClientSideCookies): >+ (WebKit::NetworkProcessProxy::didSetAgeCapForClientSideCookies): >+ (WebKit::NetworkProcessProxy::setTimeToLiveUserInteraction): >+ (WebKit::NetworkProcessProxy::didUpdateRuntimeSettings): >+ (WebKit::NetworkProcessProxy::setNotifyPagesWhenTelemetryWasCaptured): >+ (WebKit::NetworkProcessProxy::setNotifyPagesWhenDataRecordsWereScanned): >+ (WebKit::NetworkProcessProxy::setSubframeUnderTopFrameOrigin): >+ (WebKit::NetworkProcessProxy::isRegisteredAsRedirectingTo): >+ (WebKit::NetworkProcessProxy::didIsRegisteredAsRedirectingTo): >+ (WebKit::NetworkProcessProxy::isRegisteredAsSubFrameUnder): >+ (WebKit::NetworkProcessProxy::didIsRegisteredAsSubFrameUnder): >+ (WebKit::NetworkProcessProxy::setSubresourceUnderTopFrameOrigin): >+ (WebKit::NetworkProcessProxy::isRegisteredAsSubresourceUnder): >+ (WebKit::NetworkProcessProxy::didIsRegisteredAsSubresourceUnder): >+ (WebKit::NetworkProcessProxy::setSubresourceUniqueRedirectTo): >+ (WebKit::NetworkProcessProxy::setSubresourceUniqueRedirectFrom): >+ (WebKit::NetworkProcessProxy::setTopFrameUniqueRedirectTo): >+ (WebKit::NetworkProcessProxy::setTopFrameUniqueRedirectFrom): >+ (WebKit::NetworkProcessProxy::isGrandfathered): >+ (WebKit::NetworkProcessProxy::didIsGrandfathered): >+ (WebKit::NetworkProcessProxy::setGrandfathered): >+ (WebKit::NetworkProcessProxy::hasStorageAccess): >+ (WebKit::NetworkProcessProxy::requestStorageAccess): >+ (WebKit::NetworkProcessProxy::grantStorageAccess): >+ (WebKit::NetworkProcessProxy::storageAccessRequestResult): >+ (WebKit::NetworkProcessProxy::storageAccessOperationResult): >+ (WebKit::NetworkProcessProxy::didRemoveAllStorageAccess): >+ (WebKit::NetworkProcessProxy::didSetCacheMaxAgeCapForPrevalentResources): >+ (WebKit::NetworkProcessProxy::setCacheMaxAgeCap): >+ (WebKit::NetworkProcessProxy::setGrandfatheringTime): >+ (WebKit::NetworkProcessProxy::setMaxStatisticsEntries): >+ (WebKit::NetworkProcessProxy::setMinimumTimeBetweenDataRecordsRemoval): >+ (WebKit::NetworkProcessProxy::setPruneEntriesDownTo): >+ (WebKit::NetworkProcessProxy::setShouldClassifyResourcesBeforeDataRecordsRemoval): >+ (WebKit::NetworkProcessProxy::setResourceLoadStatisticsDebugMode): >+ (WebKit::NetworkProcessProxy::resetParametersToDefaultValues): >+ (WebKit::NetworkProcessProxy::submitTelemetry): >+ (WebKit::NetworkProcessProxy::notifyResourceLoadStatisticsProcessed): >+ (WebKit::NetworkProcessProxy::notifyWebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished): >+ (WebKit::NetworkProcessProxy::notifyWebsiteDataScanForTopPrivatelyControlledDomainsFinished): >+ (WebKit::NetworkProcessProxy::notifyResourceLoadStatisticsTelemetryFinished): >+ (WebKit::NetworkProcessProxy::didLogUserInteraction): Deleted. >+ (WebKit::NetworkProcessProxy::didResetCacheMaxAgeCapForPrevalentResources): Deleted. >+ * UIProcess/Network/NetworkProcessProxy.h: >+ * UIProcess/Network/NetworkProcessProxy.messages.in: >+ * UIProcess/WebPageProxy.cpp: >+ (WebKit::WebPageProxy::nonEphemeralWebPageProxy): >+ * UIProcess/WebPageProxy.h: >+ * UIProcess/WebProcessPool.cpp: >+ (WebKit::WebProcessPool::ensureNetworkProcess): >+ * UIProcess/WebProcessProxy.cpp: >+ (WebKit::WebProcessProxy::notifyWebsiteDataScanForTopPrivatelyControlledDomainsFinished): >+ (WebKit::WebProcessProxy::notifyWebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished): >+ * UIProcess/WebProcessProxy.h: >+ * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: >+ (WebKit::WebsiteDataStore::parameters): >+ * UIProcess/WebsiteData/WebsiteDataStore.cpp: >+ (WebKit::WebsiteDataStore::removeData): >+ (WebKit::WebsiteDataStore::setMaxStatisticsEntries): >+ (WebKit::WebsiteDataStore::setPruneEntriesDownTo): >+ (WebKit::WebsiteDataStore::setGrandfatheringTime): >+ (WebKit::WebsiteDataStore::setCacheMaxAgeCap): >+ (WebKit::WebsiteDataStore::setMinimumTimeBetweenDataRecordsRemoval): >+ (WebKit::WebsiteDataStore::dumpResourceLoadStatistics): >+ (WebKit::WebsiteDataStore::isPrevalentResource): >+ (WebKit::WebsiteDataStore::setPrevalentResource): >+ (WebKit::WebsiteDataStore::setPrevalentResourceForDebugMode): >+ (WebKit::WebsiteDataStore::isVeryPrevalentResource): >+ (WebKit::WebsiteDataStore::setVeryPrevalentResource): >+ (WebKit::WebsiteDataStore::setShouldClassifyResourcesBeforeDataRecordsRemoval): >+ (WebKit::WebsiteDataStore::setSubframeUnderTopFrameOrigin): >+ (WebKit::WebsiteDataStore::isRegisteredAsSubFrameUnder): >+ (WebKit::WebsiteDataStore::setSubresourceUnderTopFrameOrigin): >+ (WebKit::WebsiteDataStore::isRegisteredAsSubresourceUnder): >+ (WebKit::WebsiteDataStore::setSubresourceUniqueRedirectTo): >+ (WebKit::WebsiteDataStore::setSubresourceUniqueRedirectFrom): >+ (WebKit::WebsiteDataStore::setTopFrameUniqueRedirectTo): >+ (WebKit::WebsiteDataStore::setTopFrameUniqueRedirectFrom): >+ (WebKit::WebsiteDataStore::isRegisteredAsRedirectingTo): >+ (WebKit::WebsiteDataStore::clearPrevalentResource): >+ (WebKit::WebsiteDataStore::resetParametersToDefaultValues): >+ (WebKit::WebsiteDataStore::submitTelemetry): >+ (WebKit::WebsiteDataStore::scheduleClearInMemoryAndPersistent): >+ (WebKit::WebsiteDataStore::scheduleCookieBlockingUpdate): >+ (WebKit::WebsiteDataStore::scheduleStatisticsAndDataRecordsProcessing): >+ (WebKit::WebsiteDataStore::updatePrevalentDomainsToBlockCookiesFor): >+ (WebKit::WebsiteDataStore::setAgeCapForClientSideCookies): >+ (WebKit::WebsiteDataStore::setLastSeen): >+ (WebKit::WebsiteDataStore::setNotifyPagesWhenDataRecordsWereScanned): >+ (WebKit::WebsiteDataStore::setNotifyPagesWhenTelemetryWasCaptured): >+ (WebKit::WebsiteDataStore::hasStorageAccessForFrameHandler): >+ (WebKit::WebsiteDataStore::getAllStorageAccessEntries): >+ (WebKit::WebsiteDataStore::grantStorageAccessHandler): >+ (WebKit::WebsiteDataStore::removeAllStorageAccessHandler): >+ (WebKit::WebsiteDataStore::removePrevalentDomains): >+ (WebKit::WebsiteDataStore::hasStorageAccess): >+ (WebKit::WebsiteDataStore::requestStorageAccess): >+ (WebKit::WebsiteDataStore::grantStorageAccess): >+ (WebKit::WebsiteDataStore::setTimeToLiveUserInteraction): >+ (WebKit::WebsiteDataStore::logUserInteraction): >+ (WebKit::WebsiteDataStore::hasHadUserInteraction): >+ (WebKit::WebsiteDataStore::clearUserInteraction): >+ (WebKit::WebsiteDataStore::isGrandfathered): >+ (WebKit::WebsiteDataStore::setGrandfathered): >+ (WebKit::WebsiteDataStore::setCacheMaxAgeCapForPrevalentResources): >+ (WebKit::WebsiteDataStore::resetCacheMaxAgeCapForPrevalentResources): >+ (WebKit::WebsiteDataStore::webPageWasAdded): >+ (WebKit::WebsiteDataStore::webPageWasInvalidated): >+ (WebKit::WebsiteDataStore::webProcessWillOpenConnection): >+ (WebKit::WebsiteDataStore::webPageWillOpenConnection): >+ (WebKit::WebsiteDataStore::webPageDidCloseConnection): >+ (WebKit::WebsiteDataStore::webProcessDidCloseConnection): >+ (WebKit::WebsiteDataStore::isAssociatedProcessPool const): >+ (WebKit::WebsiteDataStore::processPools const): >+ (WebKit::WebsiteDataStore::resourceLoadStatisticsEnabled const): >+ (WebKit::WebsiteDataStore::setResourceLoadStatisticsEnabled): >+ (WebKit::WebsiteDataStore::setResourceLoadStatisticsDebugMode): >+ (WebKit::WebsiteDataStore::enableResourceLoadStatisticsAndSetTestingCallback): >+ (WebKit::WebsiteDataStore::logTestingEvent): >+ * UIProcess/WebsiteData/WebsiteDataStore.h: >+ (WebKit::WebsiteDataStore::setStatisticsTestingCallback): >+ * WebProcess/WebProcess.cpp: >+ (WebKit::WebProcess::initializeWebProcess): >+ > 2019-01-17 Truitt Savell <tsavell@apple.com> > > Unreviewed, rolling out r240124. >diff --git a/Source/WebCore/loader/ResourceLoadObserver.cpp b/Source/WebCore/loader/ResourceLoadObserver.cpp >index 82fb35ee0cef7d2c13fbd40fa2ba6b0cac23d267..4f22b506f22c2ae9808556e0de3dbef5ac0be2c2 100644 >--- a/Source/WebCore/loader/ResourceLoadObserver.cpp >+++ b/Source/WebCore/loader/ResourceLoadObserver.cpp >@@ -69,6 +69,12 @@ void ResourceLoadObserver::setRequestStorageAccessUnderOpenerCallback(WTF::Funct > m_requestStorageAccessUnderOpenerCallback = WTFMove(callback); > } > >+void ResourceLoadObserver::setLogUserInteractionNotificationCallback(WTF::Function<void(PAL::SessionID, const String&)>&& callback) >+{ >+ ASSERT(!m_logUserInteractionNotificationCallback); >+ m_logUserInteractionNotificationCallback = WTFMove(callback); >+} >+ > ResourceLoadObserver::ResourceLoadObserver() > : m_notificationTimer(*this, &ResourceLoadObserver::notifyObserver) > { >@@ -190,6 +196,8 @@ void ResourceLoadObserver::logUserInteractionWithReducedTimeResolution(const Doc > } > } > } >+ >+ m_logUserInteractionNotificationCallback(document.sessionID(), domain); > #endif > > m_notificationTimer.stop(); >diff --git a/Source/WebCore/loader/ResourceLoadObserver.h b/Source/WebCore/loader/ResourceLoadObserver.h >index 2abfc50334c17d89e2b6ffbdc38a382a1f106e9d..a44f28c4f9fd7973b5b0fe204879b2a17931926b 100644 >--- a/Source/WebCore/loader/ResourceLoadObserver.h >+++ b/Source/WebCore/loader/ResourceLoadObserver.h >@@ -39,6 +39,10 @@ class WorkQueue; > class WallTime; > } > >+namespace PAL { >+class SessionID; >+} >+ > namespace WebCore { > > class Document; >@@ -69,6 +73,7 @@ public: > > WEBCORE_EXPORT void setNotificationCallback(WTF::Function<void (Vector<ResourceLoadStatistics>&&)>&&); > WEBCORE_EXPORT void setRequestStorageAccessUnderOpenerCallback(WTF::Function<void(const String&, uint64_t, const String&)>&&); >+ WEBCORE_EXPORT void setLogUserInteractionNotificationCallback(WTF::Function<void(PAL::SessionID, const String&)>&&); > > WEBCORE_EXPORT void notifyObserver(); > WEBCORE_EXPORT void clearState(); >@@ -95,6 +100,7 @@ private: > HashMap<String, WTF::WallTime> m_lastReportedUserInteractionMap; > WTF::Function<void (Vector<ResourceLoadStatistics>&&)> m_notificationCallback; > WTF::Function<void(const String&, uint64_t, const String&)> m_requestStorageAccessUnderOpenerCallback; >+ WTF::Function<void(PAL::SessionID, const String&)> m_logUserInteractionNotificationCallback; > Timer m_notificationTimer; > #if ENABLE(RESOURCE_LOAD_STATISTICS) && !RELEASE_LOG_DISABLED > uint64_t m_loggingCounter { 0 }; >diff --git a/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp b/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp >index 5db459629d196258b9bc07c5946469149b444564..b827c55b4089534952267e23bbc868e54ab824dc 100644 >--- a/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp >+++ b/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp >@@ -244,7 +244,12 @@ void ResourceLoadStatisticsMemoryStore::removeDataRecords(CompletionHandler<void > setDataRecordsBeingRemoved(true); > > RunLoop::main().dispatch([prevalentResourceDomains = crossThreadCopy(prevalentResourceDomains), callback = WTFMove(callback), weakThis = makeWeakPtr(*this), shouldNotifyPagesWhenDataRecordsWereScanned = m_parameters.shouldNotifyPagesWhenDataRecordsWereScanned, workQueue = m_workQueue.copyRef()] () mutable { >- WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(WebResourceLoadStatisticsStore::monitoredDataTypes(), WTFMove(prevalentResourceDomains), shouldNotifyPagesWhenDataRecordsWereScanned, [callback = WTFMove(callback), weakThis = WTFMove(weakThis), workQueue = workQueue.copyRef()](const HashSet<String>& domainsWithDeletedWebsiteData) mutable { >+ if (!weakThis) { >+ callback(); >+ return; >+ } >+ >+ weakThis->m_store.deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(WebResourceLoadStatisticsStore::monitoredDataTypes(), WTFMove(prevalentResourceDomains), shouldNotifyPagesWhenDataRecordsWereScanned, [callback = WTFMove(callback), weakThis = WTFMove(weakThis), workQueue = workQueue.copyRef()](const HashSet<String>& domainsWithDeletedWebsiteData) mutable { > workQueue->dispatch([topDomains = crossThreadCopy(domainsWithDeletedWebsiteData), callback = WTFMove(callback), weakThis = WTFMove(weakThis)] () mutable { > if (!weakThis) { > callback(); >@@ -358,8 +363,12 @@ void ResourceLoadStatisticsMemoryStore::processStatisticsAndDataRecords() > if (!m_parameters.shouldNotifyPagesWhenDataRecordsWereScanned) > return; > >- RunLoop::main().dispatch([] { >- WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed(); >+ RunLoop::main().dispatch([this, weakThis = makeWeakPtr(*this)] { >+ ASSERT(RunLoop::isMain()); >+ if (!weakThis) >+ return; >+ >+ m_store.notifyResourceLoadStatisticsProcessed(); > }); > }); > } >@@ -494,11 +503,9 @@ void ResourceLoadStatisticsMemoryStore::grandfatherExistingWebsiteData(Completio > { > ASSERT(!RunLoop::isMain()); > >- RunLoop::main().dispatch([weakThis = makeWeakPtr(*this), callback = WTFMove(callback), shouldNotifyPagesWhenDataRecordsWereScanned = m_parameters.shouldNotifyPagesWhenDataRecordsWereScanned, workQueue = m_workQueue.copyRef()] () mutable { >- // FIXME: This method being a static call on WebProcessProxy is wrong. >- // It should be on the data store that this object belongs to. >- WebProcessProxy::topPrivatelyControlledDomainsWithWebsiteData(WebResourceLoadStatisticsStore::monitoredDataTypes(), shouldNotifyPagesWhenDataRecordsWereScanned, [weakThis = WTFMove(weakThis), callback = WTFMove(callback), workQueue = workQueue.copyRef()] (HashSet<String>&& topPrivatelyControlledDomainsWithWebsiteData) mutable { >- workQueue->dispatch([weakThis = WTFMove(weakThis), topDomains = crossThreadCopy(topPrivatelyControlledDomainsWithWebsiteData), callback = WTFMove(callback)] () mutable { >+ RunLoop::main().dispatch([weakThis = makeWeakPtr(*this), callback = WTFMove(callback), shouldNotifyPagesWhenDataRecordsWereScanned = m_parameters.shouldNotifyPagesWhenDataRecordsWereScanned, workQueue = m_workQueue.copyRef(), store = makeRef(m_store)] () mutable { >+ store->topPrivatelyControlledDomainsWithWebsiteData(WebResourceLoadStatisticsStore::monitoredDataTypes(), shouldNotifyPagesWhenDataRecordsWereScanned, [weakThis = WTFMove(weakThis), callback = WTFMove(callback), workQueue = workQueue.copyRef()] (HashSet<String>&& topDomainsWithWebsiteData) mutable { >+ workQueue->dispatch([weakThis = WTFMove(weakThis), topDomains = crossThreadCopy(topDomainsWithWebsiteData), callback = WTFMove(callback)] () mutable { > if (!weakThis) { > callback(); > return; >diff --git a/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h b/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h >index f3a9a7b96a00d85d0c1ea7b1caa61c72bd1db0c4..f716d01cf1bb0b89aae2b6d8666dabfab7369b2f 100644 >--- a/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h >+++ b/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h >@@ -130,6 +130,8 @@ public: > > void didCreateNetworkProcess(); > >+ const WebResourceLoadStatisticsStore& store() const { return m_store; } >+ > private: > static bool shouldBlockAndKeepCookies(const WebCore::ResourceLoadStatistics&); > static bool shouldBlockAndPurgeCookies(const WebCore::ResourceLoadStatistics&); >diff --git a/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp b/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp >index f2d297392ad3d75ef285480bffcecb6492dacfee..495c9a4ed7a1990309919f2911b6a4fda37bbc84 100644 >--- a/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp >+++ b/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp >@@ -26,6 +26,7 @@ > #include "config.h" > #include "WebResourceLoadStatisticsStore.h" > >+#include "APIDictionary.h" > #include "Logging.h" > #include "NetworkSession.h" > #include "ResourceLoadStatisticsMemoryStore.h" >@@ -33,11 +34,14 @@ > #include "WebFrameProxy.h" > #include "WebPageProxy.h" > #include "WebProcessMessages.h" >+#include "WebProcessPool.h" > #include "WebProcessProxy.h" > #include "WebResourceLoadStatisticsStoreMessages.h" > #include "WebResourceLoadStatisticsTelemetry.h" > #include "WebsiteDataFetchOption.h" > #include "WebsiteDataStore.h" >+#include <WebCore/DiagnosticLoggingClient.h> >+#include <WebCore/DiagnosticLoggingKeys.h> > #include <WebCore/NetworkStorageSession.h> > #include <WebCore/ResourceLoadStatistics.h> > #include <wtf/CallbackAggregator.h> >@@ -88,6 +92,20 @@ void WebResourceLoadStatisticsStore::setNotifyPagesWhenDataRecordsWereScanned(bo > }); > } > >+void WebResourceLoadStatisticsStore::setNotifyPagesWhenDataRecordsWereScanned(bool value, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ postTask([this, value, completionHandler = WTFMove(completionHandler)] () mutable { >+ if (m_memoryStore) >+ m_memoryStore->setNotifyPagesWhenDataRecordsWereScanned(value); >+ >+ postTaskReply([completionHandler = WTFMove(completionHandler)] () mutable { >+ completionHandler(); >+ }); >+ }); >+} >+ > void WebResourceLoadStatisticsStore::setShouldClassifyResourcesBeforeDataRecordsRemoval(bool value) > { > ASSERT(RunLoop::isMain()); >@@ -108,6 +126,13 @@ void WebResourceLoadStatisticsStore::setShouldSubmitTelemetry(bool value) > }); > } > >+void WebResourceLoadStatisticsStore::setNotifyPagesWhenTelemetryWasCaptured(bool value) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ WebKit::WebResourceLoadStatisticsTelemetry::setNotifyPagesWhenTelemetryWasCaptured(value); >+} >+ > WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore(WebsiteDataStore& websiteDataStore) > : m_websiteDataStore(makeWeakPtr(websiteDataStore)) > , m_statisticsQueue(WorkQueue::create("WebResourceLoadStatisticsStore Process Data Queue", WorkQueue::Type::Serial, WorkQueue::QOS::Utility)) >@@ -133,6 +158,9 @@ WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore(NetworkSession& n > postTask([this, resourceLoadStatisticsDirectory = resourceLoadStatisticsDirectory.isolatedCopy()] { > m_memoryStore = std::make_unique<ResourceLoadStatisticsMemoryStore>(*this, m_statisticsQueue); > m_persistentStorage = std::make_unique<ResourceLoadStatisticsPersistentStorage>(*m_memoryStore, m_statisticsQueue, resourceLoadStatisticsDirectory); >+ >+ // FIXME(193297): This should be revised after the UIProcess version goes away. >+ m_memoryStore->didCreateNetworkProcess(); > }); > > m_dailyTasksTimer.startRepeating(24_h); >@@ -194,7 +222,14 @@ void WebResourceLoadStatisticsStore::setPrevalentResourceForDebugMode(const URL& > { > ASSERT(RunLoop::isMain()); > >- postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)]() mutable { >+ setPrevalentResourceForDebugMode(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler)); >+} >+ >+void WebResourceLoadStatisticsStore::setPrevalentResourceForDebugMode(const String& primaryDomain, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ postTask([this, primaryDomain = primaryDomain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { > if (m_memoryStore) > m_memoryStore->setPrevalentResourceForDebugMode(primaryDomain); > postTaskReply(WTFMove(completionHandler)); >@@ -203,11 +238,17 @@ void WebResourceLoadStatisticsStore::setPrevalentResourceForDebugMode(const URL& > > void WebResourceLoadStatisticsStore::scheduleStatisticsAndDataRecordsProcessing() > { >- ASSERT(RunLoop::isMain()); >+ scheduleStatisticsAndDataRecordsProcessing([] { }); >+} > >- postTask([this] { >+void WebResourceLoadStatisticsStore::scheduleStatisticsAndDataRecordsProcessing(CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ postTask([this, completionHandler = WTFMove(completionHandler)] () mutable { > if (m_memoryStore) > m_memoryStore->processStatisticsAndDataRecords(); >+ postTaskReply(WTFMove(completionHandler)); > }); > } > >@@ -233,19 +274,19 @@ void WebResourceLoadStatisticsStore::resourceLoadStatisticsUpdated(Vector<WebCor > }); > } > >-void WebResourceLoadStatisticsStore::hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, CompletionHandler<void (bool)>&& completionHandler) >+void WebResourceLoadStatisticsStore::hasStorageAccess(const String& subFrameHost, const String& topFrameHost, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler) > { > ASSERT(subFrameHost != topFrameHost); > ASSERT(RunLoop::isMain()); > >- postTask([this, subFramePrimaryDomain = isolatedPrimaryDomain(subFrameHost), topFramePrimaryDomain = isolatedPrimaryDomain(topFrameHost), frameID, pageID, completionHandler = WTFMove(completionHandler)] () mutable { >+ postTask([this, subFramePrimaryDomain = subFrameHost.isolatedCopy(), topFramePrimaryDomain = topFrameHost.isolatedCopy(), frameID, pageID, completionHandler = WTFMove(completionHandler)] () mutable { > if (!m_memoryStore) { > postTaskReply([completionHandler = WTFMove(completionHandler)] () mutable { > completionHandler(false); > }); > return; > } >- m_memoryStore->hasStorageAccess(subFramePrimaryDomain, topFramePrimaryDomain, frameID, pageID, [completionHandler = WTFMove(completionHandler)](bool hasStorageAccess) mutable { >+ m_memoryStore->hasStorageAccess(subFramePrimaryDomain, topFramePrimaryDomain, frameID.value(), pageID, [completionHandler = WTFMove(completionHandler)](bool hasStorageAccess) mutable { > postTaskReply([completionHandler = WTFMove(completionHandler), hasStorageAccess] () mutable { > completionHandler(hasStorageAccess); > }); >@@ -268,8 +309,10 @@ void WebResourceLoadStatisticsStore::callHasStorageAccessForFrameHandler(const S > if (m_websiteDataStore) { > m_websiteDataStore->hasStorageAccessForFrameHandler(resourceDomain, firstPartyDomain, frameID, pageID, WTFMove(callback)); > return; >- } else { >- callback(hasStorageAccessForFrame(resourceDomain, firstPartyDomain, frameID, pageID)); >+ } >+ >+ if (m_networkSession) { >+ callback(m_networkSession->networkStorageSession().hasStorageAccess(resourceDomain, firstPartyDomain, frameID, pageID)); > return; > } > #endif >@@ -281,6 +324,11 @@ void WebResourceLoadStatisticsStore::requestStorageAccess(String&& subFrameHost, > ASSERT(subFrameHost != topFrameHost); > ASSERT(RunLoop::isMain()); > >+ requestStorageAccess(subFrameHost, topFrameHost, frameID, pageID, promptEnabled, WTFMove(completionHandler)); >+} >+ >+void WebResourceLoadStatisticsStore::requestStorageAccess(const String& subFrameHost, const String& topFrameHost, Optional<uint64_t> frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&& completionHandler) >+{ > auto subFramePrimaryDomain = isolatedPrimaryDomain(subFrameHost); > auto topFramePrimaryDomain = isolatedPrimaryDomain(topFrameHost); > if (subFramePrimaryDomain == topFramePrimaryDomain) { >@@ -296,7 +344,7 @@ void WebResourceLoadStatisticsStore::requestStorageAccess(String&& subFrameHost, > return; > } > >- m_memoryStore->requestStorageAccess(WTFMove(subFramePrimaryDomain), WTFMove(topFramePrimaryDomain), frameID, pageID, promptEnabled, [completionHandler = WTFMove(completionHandler)](StorageAccessStatus status) mutable { >+ m_memoryStore->requestStorageAccess(WTFMove(subFramePrimaryDomain), WTFMove(topFramePrimaryDomain), frameID.value(), pageID, promptEnabled, [completionHandler = WTFMove(completionHandler)](StorageAccessStatus status) mutable { > postTaskReply([completionHandler = WTFMove(completionHandler), status] () mutable { > completionHandler(status); > }); >@@ -476,7 +524,7 @@ void WebResourceLoadStatisticsStore::logUserInteraction(const URL& url, Completi > return; > } > >- logUserInteraction(isolatedPrimaryDomain(url), WTFMove(completionHandler)); >+ logUserInteraction(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler)); > } > > void WebResourceLoadStatisticsStore::logUserInteraction(const String& targetPrimaryDomain, CompletionHandler<void()>&& completionHandler) >@@ -499,7 +547,14 @@ void WebResourceLoadStatisticsStore::clearUserInteraction(const URL& url, Comple > return; > } > >- postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)]() mutable { >+ clearUserInteraction(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler)); >+} >+ >+void WebResourceLoadStatisticsStore::clearUserInteraction(const String& targetPrimaryDomain, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ postTask([this, primaryDomain = targetPrimaryDomain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { > if (m_memoryStore) > m_memoryStore->clearUserInteraction(primaryDomain); > postTaskReply(WTFMove(completionHandler)); >@@ -515,7 +570,12 @@ void WebResourceLoadStatisticsStore::hasHadUserInteraction(const URL& url, Compl > return; > } > >- postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)] () mutable { >+ hasHadUserInteraction(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler)); >+} >+ >+void WebResourceLoadStatisticsStore::hasHadUserInteraction(const String& primaryDomain, CompletionHandler<void(bool)>&& completionHandler) >+{ >+ postTask([this, primaryDomain = primaryDomain.isolatedCopy(), completionHandler = WTFMove(completionHandler)] () mutable { > bool hadUserInteraction = m_memoryStore ? m_memoryStore->hasHadUserInteraction(primaryDomain) : false; > postTaskReply([hadUserInteraction, completionHandler = WTFMove(completionHandler)] () mutable { > completionHandler(hadUserInteraction); >@@ -532,9 +592,16 @@ void WebResourceLoadStatisticsStore::setLastSeen(const URL& url, Seconds seconds > return; > } > >- postTask([this, primaryDomain = isolatedPrimaryDomain(url), seconds, completionHandler = WTFMove(completionHandler)]() mutable { >+ setLastSeen(WebCore::ResourceLoadStatistics::primaryDomain(url), seconds, WTFMove(completionHandler)); >+} >+ >+void WebResourceLoadStatisticsStore::setLastSeen(const String& resourceDomain, Seconds seconds, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ postTask([this, resourceDomain = resourceDomain.isolatedCopy(), seconds, completionHandler = WTFMove(completionHandler)]() mutable { > if (m_memoryStore) >- m_memoryStore->setLastSeen(primaryDomain, seconds); >+ m_memoryStore->setLastSeen(resourceDomain, seconds); > postTaskReply(WTFMove(completionHandler)); > }); > } >@@ -548,9 +615,16 @@ void WebResourceLoadStatisticsStore::setPrevalentResource(const URL& url, Comple > return; > } > >- postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)]() mutable { >+ setPrevalentResource(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler)); >+} >+ >+void WebResourceLoadStatisticsStore::setPrevalentResource(const String& resourceDomain, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ postTask([this, resourceDomain = resourceDomain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { > if (m_memoryStore) >- m_memoryStore->setPrevalentResource(primaryDomain); >+ m_memoryStore->setPrevalentResource(resourceDomain); > postTaskReply(WTFMove(completionHandler)); > }); > } >@@ -564,7 +638,14 @@ void WebResourceLoadStatisticsStore::setVeryPrevalentResource(const URL& url, Co > return; > } > >- postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)]() mutable { >+ setVeryPrevalentResource(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler)); >+} >+ >+void WebResourceLoadStatisticsStore::setVeryPrevalentResource(const String& primaryDomain, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ postTask([this, primaryDomain = primaryDomain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { > if (m_memoryStore) > m_memoryStore->setVeryPrevalentResource(primaryDomain); > postTaskReply(WTFMove(completionHandler)); >@@ -592,14 +673,21 @@ void WebResourceLoadStatisticsStore::isPrevalentResource(const URL& url, Complet > return; > } > >- postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)] () mutable { >+ isPrevalentResource(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler)); >+} >+ >+void WebResourceLoadStatisticsStore::isPrevalentResource(const String& primaryDomain, CompletionHandler<void(bool)>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ postTask([this, primaryDomain = primaryDomain.isolatedCopy(), completionHandler = WTFMove(completionHandler)] () mutable { > bool isPrevalentResource = m_memoryStore ? m_memoryStore->isPrevalentResource(primaryDomain) : false; > postTaskReply([isPrevalentResource, completionHandler = WTFMove(completionHandler)] () mutable { > completionHandler(isPrevalentResource); > }); > }); > } >- >+ > void WebResourceLoadStatisticsStore::isVeryPrevalentResource(const URL& url, CompletionHandler<void(bool)>&& completionHandler) > { > ASSERT(RunLoop::isMain()); >@@ -609,7 +697,14 @@ void WebResourceLoadStatisticsStore::isVeryPrevalentResource(const URL& url, Com > return; > } > >- postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)] () mutable { >+ isVeryPrevalentResource(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler)); >+} >+ >+void WebResourceLoadStatisticsStore::isVeryPrevalentResource(const String& primaryDomain, CompletionHandler<void(bool)>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ postTask([this, primaryDomain = primaryDomain.isolatedCopy(), completionHandler = WTFMove(completionHandler)] () mutable { > bool isVeryPrevalentResource = m_memoryStore ? m_memoryStore->isVeryPrevalentResource(primaryDomain) : false; > postTaskReply([isVeryPrevalentResource, completionHandler = WTFMove(completionHandler)] () mutable { > completionHandler(isVeryPrevalentResource); >@@ -620,8 +715,15 @@ void WebResourceLoadStatisticsStore::isVeryPrevalentResource(const URL& url, Com > void WebResourceLoadStatisticsStore::isRegisteredAsSubresourceUnder(const URL& subresource, const URL& topFrame, CompletionHandler<void(bool)>&& completionHandler) > { > ASSERT(RunLoop::isMain()); >- >- postTask([this, subresourcePrimaryDomain = isolatedPrimaryDomain(subresource), topFramePrimaryDomain = isolatedPrimaryDomain(topFrame), completionHandler = WTFMove(completionHandler)] () mutable { >+ >+ isRegisteredAsSubresourceUnder(WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), WTFMove(completionHandler)); >+} >+ >+void WebResourceLoadStatisticsStore::isRegisteredAsSubresourceUnder(const String& subresource, const String& topFrame, CompletionHandler<void(bool)>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ postTask([this, subresourcePrimaryDomain = subresource.isolatedCopy(), topFramePrimaryDomain = topFrame.isolatedCopy(), completionHandler = WTFMove(completionHandler)] () mutable { > bool isRegisteredAsSubresourceUnder = m_memoryStore ? m_memoryStore->isRegisteredAsSubresourceUnder(subresourcePrimaryDomain, topFramePrimaryDomain) : false; > postTaskReply([isRegisteredAsSubresourceUnder, completionHandler = WTFMove(completionHandler)] () mutable { > completionHandler(isRegisteredAsSubresourceUnder); >@@ -633,7 +735,14 @@ void WebResourceLoadStatisticsStore::isRegisteredAsSubFrameUnder(const URL& subF > { > ASSERT(RunLoop::isMain()); > >- postTask([this, subFramePrimaryDomain = isolatedPrimaryDomain(subFrame), topFramePrimaryDomain = isolatedPrimaryDomain(topFrame), completionHandler = WTFMove(completionHandler)] () mutable { >+ isRegisteredAsSubFrameUnder(WebCore::ResourceLoadStatistics::primaryDomain(subFrame), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), WTFMove(completionHandler)); >+} >+ >+void WebResourceLoadStatisticsStore::isRegisteredAsSubFrameUnder(const String& subFrame, const String& topFrame, CompletionHandler<void(bool)>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ postTask([this, subFramePrimaryDomain = subFrame.isolatedCopy(), topFramePrimaryDomain = topFrame.isolatedCopy(), completionHandler = WTFMove(completionHandler)] () mutable { > bool isRegisteredAsSubFrameUnder = m_memoryStore ? m_memoryStore->isRegisteredAsSubFrameUnder(subFramePrimaryDomain, topFramePrimaryDomain) : false; > postTaskReply([isRegisteredAsSubFrameUnder, completionHandler = WTFMove(completionHandler)] () mutable { > completionHandler(isRegisteredAsSubFrameUnder); >@@ -645,7 +754,14 @@ void WebResourceLoadStatisticsStore::isRegisteredAsRedirectingTo(const URL& host > { > ASSERT(RunLoop::isMain()); > >- postTask([this, hostRedirectedFromPrimaryDomain = isolatedPrimaryDomain(hostRedirectedFrom), hostRedirectedToPrimaryDomain = isolatedPrimaryDomain(hostRedirectedTo), completionHandler = WTFMove(completionHandler)] () mutable { >+ isRegisteredAsRedirectingTo(WebCore::ResourceLoadStatistics::primaryDomain(hostRedirectedFrom), WebCore::ResourceLoadStatistics::primaryDomain(hostRedirectedTo), WTFMove(completionHandler)); >+} >+ >+void WebResourceLoadStatisticsStore::isRegisteredAsRedirectingTo(const String& hostRedirectedFrom, const String& hostRedirectedTo, CompletionHandler<void(bool)>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ postTask([this, hostRedirectedFromPrimaryDomain = hostRedirectedFrom.isolatedCopy(), hostRedirectedToPrimaryDomain = hostRedirectedTo.isolatedCopy(), completionHandler = WTFMove(completionHandler)] () mutable { > bool isRegisteredAsRedirectingTo = m_memoryStore ? m_memoryStore->isRegisteredAsRedirectingTo(hostRedirectedFromPrimaryDomain, hostRedirectedToPrimaryDomain) : false; > postTaskReply([isRegisteredAsRedirectingTo, completionHandler = WTFMove(completionHandler)] () mutable { > completionHandler(isRegisteredAsRedirectingTo); >@@ -662,9 +778,16 @@ void WebResourceLoadStatisticsStore::clearPrevalentResource(const URL& url, Comp > return; > } > >- postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)]() mutable { >+ clearPrevalentResource(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler)); >+} >+ >+void WebResourceLoadStatisticsStore::clearPrevalentResource(const String& resourceDomain, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ postTask([this, resourceDomain = resourceDomain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { > if (m_memoryStore) >- m_memoryStore->clearPrevalentResource(primaryDomain); >+ m_memoryStore->clearPrevalentResource(resourceDomain); > postTaskReply(WTFMove(completionHandler)); > }); > } >@@ -676,12 +799,20 @@ void WebResourceLoadStatisticsStore::setGrandfathered(const URL& url, bool value > if (url.protocolIsAbout() || url.isEmpty()) > return; > >- postTask([this, primaryDomain = isolatedPrimaryDomain(url), value] { >+ setGrandfathered(WebCore::ResourceLoadStatistics::primaryDomain(url), value, [] { }); >+} >+ >+void WebResourceLoadStatisticsStore::setGrandfathered(const String& domain, bool value, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ postTask([this, primaryDomain = domain.isolatedCopy(), value, completionHandler = WTFMove(completionHandler)] () mutable { > if (m_memoryStore) > m_memoryStore->setGrandfathered(primaryDomain, value); >+ postTaskReply(WTFMove(completionHandler)); > }); > } >- >+ > void WebResourceLoadStatisticsStore::isGrandfathered(const URL& url, CompletionHandler<void (bool)>&& completionHandler) > { > ASSERT(RunLoop::isMain()); >@@ -691,7 +822,14 @@ void WebResourceLoadStatisticsStore::isGrandfathered(const URL& url, CompletionH > return; > } > >- postTask([this, completionHandler = WTFMove(completionHandler), primaryDomain = isolatedPrimaryDomain(url)] () mutable { >+ isGrandfathered(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler)); >+} >+ >+void WebResourceLoadStatisticsStore::isGrandfathered(const String& primaryDomain, CompletionHandler<void(bool)>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ postTask([this, completionHandler = WTFMove(completionHandler), primaryDomain = primaryDomain.isolatedCopy()] () mutable { > bool isGrandFathered = m_memoryStore ? m_memoryStore->isGrandfathered(primaryDomain) : false; > postTaskReply([isGrandFathered, completionHandler = WTFMove(completionHandler)] () mutable { > completionHandler(isGrandFathered); >@@ -706,9 +844,17 @@ void WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin(const URL& s > if (subframe.protocolIsAbout() || subframe.isEmpty() || topFrame.protocolIsAbout() || topFrame.isEmpty()) > return; > >- postTask([this, primaryTopFrameDomain = isolatedPrimaryDomain(topFrame), primarySubFrameDomain = isolatedPrimaryDomain(subframe)] { >+ setSubframeUnderTopFrameOrigin(WebCore::ResourceLoadStatistics::primaryDomain(subframe), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), [] { }); >+} >+ >+void WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin(const String& subframe, const String& topFrame, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ postTask([this, completionHandler = WTFMove(completionHandler), primaryTopFrameDomain = topFrame.isolatedCopy(), primarySubFrameDomain = subframe.isolatedCopy()] () mutable { > if (m_memoryStore) > m_memoryStore->setSubframeUnderTopFrameOrigin(primarySubFrameDomain, primaryTopFrameDomain); >+ postTaskReply(WTFMove(completionHandler)); > }); > } > >@@ -719,9 +865,17 @@ void WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin(const URL > if (subresource.protocolIsAbout() || subresource.isEmpty() || topFrame.protocolIsAbout() || topFrame.isEmpty()) > return; > >- postTask([this, primaryTopFrameDomain = isolatedPrimaryDomain(topFrame), primarySubresourceDomain = isolatedPrimaryDomain(subresource)] { >+ setSubresourceUnderTopFrameOrigin(WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), [] { }); >+} >+ >+void WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin(const String& subresource, const String& topFrame, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ postTask([this, completionHandler = WTFMove(completionHandler), primaryTopFrameDomain = topFrame.isolatedCopy(), primarySubresourceDomain = subresource.isolatedCopy()] () mutable { > if (m_memoryStore) > m_memoryStore->setSubresourceUnderTopFrameOrigin(primarySubresourceDomain, primaryTopFrameDomain); >+ postTaskReply(WTFMove(completionHandler)); > }); > } > >@@ -732,9 +886,17 @@ void WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo(const URL& s > if (subresource.protocolIsAbout() || subresource.isEmpty() || hostNameRedirectedTo.protocolIsAbout() || hostNameRedirectedTo.isEmpty()) > return; > >- postTask([this, primaryRedirectDomain = isolatedPrimaryDomain(hostNameRedirectedTo), primarySubresourceDomain = isolatedPrimaryDomain(subresource)] { >+ setSubresourceUniqueRedirectTo(WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedTo), [] { }); >+} >+ >+void WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo(const String& subresource, const String& hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ postTask([this, completionHandler = WTFMove(completionHandler), primaryRedirectDomain = hostNameRedirectedTo.isolatedCopy(), primarySubresourceDomain = subresource.isolatedCopy()] () mutable { > if (m_memoryStore) > m_memoryStore->setSubresourceUniqueRedirectTo(primarySubresourceDomain, primaryRedirectDomain); >+ postTaskReply(WTFMove(completionHandler)); > }); > } > >@@ -744,10 +906,18 @@ void WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectFrom(const URL& > > if (subresource.protocolIsAbout() || subresource.isEmpty() || hostNameRedirectedFrom.protocolIsAbout() || hostNameRedirectedFrom.isEmpty()) > return; >+ >+ setSubresourceUniqueRedirectFrom(WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedFrom), [] { }); >+} >+ >+void WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectFrom(const String& subresource, const String& hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); > >- postTask([this, primaryRedirectDomain = isolatedPrimaryDomain(hostNameRedirectedFrom), primarySubresourceDomain = isolatedPrimaryDomain(subresource)] { >+ postTask([this, completionHandler = WTFMove(completionHandler), primaryRedirectDomain = hostNameRedirectedFrom.isolatedCopy(), primarySubresourceDomain = subresource.isolatedCopy()] () mutable { > if (m_memoryStore) > m_memoryStore->setSubresourceUniqueRedirectFrom(primarySubresourceDomain, primaryRedirectDomain); >+ postTaskReply(WTFMove(completionHandler)); > }); > } > >@@ -757,10 +927,18 @@ void WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectTo(const URL& topF > > if (topFrameHostName.protocolIsAbout() || topFrameHostName.isEmpty() || hostNameRedirectedTo.protocolIsAbout() || hostNameRedirectedTo.isEmpty()) > return; >+ >+ setTopFrameUniqueRedirectTo(WebCore::ResourceLoadStatistics::primaryDomain(topFrameHostName), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedTo), [] { }); >+} >+ >+void WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectTo(const String& topFrameHostName, const String& hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); > >- postTask([this, primaryRedirectDomain = isolatedPrimaryDomain(hostNameRedirectedTo), topFramePrimaryDomain = isolatedPrimaryDomain(topFrameHostName)] { >+ postTask([this, completionHandler = WTFMove(completionHandler), topFramePrimaryDomain = topFrameHostName.isolatedCopy(), primaryRedirectDomain = hostNameRedirectedTo.isolatedCopy()] () mutable { > if (m_memoryStore) > m_memoryStore->setTopFrameUniqueRedirectTo(topFramePrimaryDomain, primaryRedirectDomain); >+ postTaskReply(WTFMove(completionHandler)); > }); > } > >@@ -770,10 +948,18 @@ void WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectFrom(const URL& to > > if (topFrameHostName.protocolIsAbout() || topFrameHostName.isEmpty() || hostNameRedirectedFrom.protocolIsAbout() || hostNameRedirectedFrom.isEmpty()) > return; >+ >+ setTopFrameUniqueRedirectFrom(WebCore::ResourceLoadStatistics::primaryDomain(topFrameHostName), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedFrom), [] { }); >+} >+ >+void WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectFrom(const String& topFrameHostName, const String& hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); > >- postTask([this, primaryRedirectDomain = isolatedPrimaryDomain(hostNameRedirectedFrom), topFramePrimaryDomain = isolatedPrimaryDomain(topFrameHostName)] { >+ postTask([this, completionHandler = WTFMove(completionHandler), topFramePrimaryDomain = topFrameHostName.isolatedCopy(), primaryRedirectDomain = hostNameRedirectedFrom.isolatedCopy()] () mutable { > if (m_memoryStore) > m_memoryStore->setTopFrameUniqueRedirectFrom(topFramePrimaryDomain, primaryRedirectDomain); >+ postTaskReply(WTFMove(completionHandler)); > }); > } > >@@ -862,11 +1048,17 @@ void WebResourceLoadStatisticsStore::scheduleClearInMemoryAndPersistent(WallTime > } > > void WebResourceLoadStatisticsStore::setTimeToLiveUserInteraction(Seconds seconds) >+{ >+ setTimeToLiveUserInteraction(seconds, [] { }); >+} >+ >+void WebResourceLoadStatisticsStore::setTimeToLiveUserInteraction(Seconds seconds, CompletionHandler<void()>&& completionHandler) > { > ASSERT(RunLoop::isMain()); >- postTask([this, seconds] { >+ postTask([this, seconds, completionHandler = WTFMove(completionHandler)] () mutable { > if (m_memoryStore) > m_memoryStore->setTimeToLiveUserInteraction(seconds); >+ postTaskReply(WTFMove(completionHandler)); > }); > } > >@@ -987,8 +1179,81 @@ void WebResourceLoadStatisticsStore::logTestingEvent(const String& event) > { > ASSERT(RunLoop::isMain()); > >- if (m_statisticsTestingCallback) >- m_statisticsTestingCallback(event); >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ if (m_websiteDataStore) { >+ m_websiteDataStore->logTestingEvent(event); >+ return; >+ } >+ // FIXME(193297): Send message to UIProcess >+#endif >+} >+ >+void WebResourceLoadStatisticsStore::notifyResourceLoadStatisticsProcessed() >+{ >+ ASSERT(RunLoop::isMain()); >+ >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ if (m_websiteDataStore) >+ WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed(); >+ >+ if (m_networkSession) >+ m_networkSession->notifyResourceLoadStatisticsProcessed(); >+#endif >+} >+ >+void WebResourceLoadStatisticsStore::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType> dataTypes, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ if (m_websiteDataStore) >+ WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(dataTypes, WTFMove(topPrivatelyControlledDomains), shouldNotifyPage, WTFMove(completionHandler)); >+ >+ if (m_networkSession) >+ m_networkSession->deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(dataTypes, WTFMove(topPrivatelyControlledDomains), shouldNotifyPage, WTFMove(completionHandler)); >+#endif >+} >+ >+void WebResourceLoadStatisticsStore::topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType> dataTypes, bool shouldNotifyPage, CompletionHandler<void(HashSet<String>&&)>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ if (m_websiteDataStore) >+ WebProcessProxy::topPrivatelyControlledDomainsWithWebsiteData(dataTypes, shouldNotifyPage, WTFMove(completionHandler)); >+ >+ if (m_networkSession) >+ m_networkSession->topPrivatelyControlledDomainsWithWebsiteData(dataTypes, shouldNotifyPage, WTFMove(completionHandler)); >+#endif >+} >+ >+void WebResourceLoadStatisticsStore::sendDiagnosticMessageWithValue(const String& message, const String& description, unsigned value, unsigned sigDigits, WebCore::ShouldSample shouldSample) const >+{ >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ if (m_websiteDataStore) { >+ if (auto* webPageProxy = WebPageProxy::nonEphemeralWebPageProxy()) >+ webPageProxy->logDiagnosticMessageWithValue(message, description, value, sigDigits, shouldSample); >+ } >+ >+ if (m_networkSession) >+ const_cast<WebResourceLoadStatisticsStore*>(this)->networkSession()->logDiagnosticMessageWithValue(message, description, value, sigDigits, shouldSample); >+#endif >+} >+ >+void WebResourceLoadStatisticsStore::notifyPageStatisticsTelemetryFinished(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins) const >+{ >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ if (m_websiteDataStore) { >+ API::Dictionary::MapType messageBody; >+ messageBody.set("TotalPrevalentResources"_s, API::UInt64::create(totalPrevalentResources)); >+ messageBody.set("TotalPrevalentResourcesWithUserInteraction"_s, API::UInt64::create(totalPrevalentResourcesWithUserInteraction)); >+ messageBody.set("Top3SubframeUnderTopFrameOrigins"_s, API::UInt64::create(top3SubframeUnderTopFrameOrigins)); >+ WebProcessProxy::notifyPageStatisticsTelemetryFinished(API::Dictionary::create(messageBody).ptr()); >+ } >+ >+ if (m_networkSession) >+ const_cast<WebResourceLoadStatisticsStore*>(this)->networkSession()->notifyPageStatisticsTelemetryFinished(totalPrevalentResources, totalPrevalentResourcesWithUserInteraction, top3SubframeUnderTopFrameOrigins); >+#endif > } > > } // namespace WebKit >diff --git a/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h b/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h >index 00236a39553ec21cd184cc67255870fda57efad7..b0dd6a6b4a32fda39070ed6a3fdda140f43a6b58 100644 >--- a/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h >+++ b/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2016-2018 Apple Inc. All rights reserved. >+ * Copyright (C) 2016-2019 Apple Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -42,6 +42,7 @@ class WorkQueue; > namespace WebCore { > class ResourceRequest; > struct ResourceLoadStatistics; >+enum class ShouldSample : bool; > } > > namespace WebKit { >@@ -53,12 +54,17 @@ class WebFrameProxy; > class WebProcessProxy; > class WebsiteDataStore; > >-enum class StorageAccessStatus { >+enum class StorageAccessStatus : unsigned { > CannotRequestAccess, > RequiresUserPrompt, > HasAccess > }; > >+enum class ShouldGrandfather { >+ No, >+ Yes, >+}; >+ > class WebResourceLoadStatisticsStore final : public ThreadSafeRefCounted<WebResourceLoadStatisticsStore, WTF::DestructionThread::Main>, public IPC::MessageReceiver { > public: > static Ref<WebResourceLoadStatisticsStore> create(WebsiteDataStore& websiteDataStore) >@@ -78,10 +84,10 @@ public: > WorkQueue& statisticsQueue() { return m_statisticsQueue.get(); } > > void setNotifyPagesWhenDataRecordsWereScanned(bool); >+ void setNotifyPagesWhenTelemetryWasCaptured(bool); > void setShouldClassifyResourcesBeforeDataRecordsRemoval(bool); > void setShouldSubmitTelemetry(bool); > >- void hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback); > void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&&); > void grantStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPromptedNow, CompletionHandler<void(bool)>&&); > void requestStorageAccessCallback(bool wasGranted, uint64_t contextId); >@@ -93,45 +99,66 @@ public: > void logUserInteraction(const URL&, CompletionHandler<void()>&&); > void logUserInteraction(const String& targetPrimaryDomain, CompletionHandler<void()>&&); > void clearUserInteraction(const URL&, CompletionHandler<void()>&&); >+ void clearUserInteraction(const String& targetPrimaryDomain, CompletionHandler<void()>&&); >+ void deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType>, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&&); >+ void topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType>, bool shouldNotifyPage, CompletionHandler<void(HashSet<String>&&)>&&); > bool grantStorageAccess(const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID); > void hasHadUserInteraction(const URL&, CompletionHandler<void(bool)>&&); >+ void hasHadUserInteraction(const String& resourceDomain, CompletionHandler<void(bool)>&&); >+ void hasStorageAccess(const String& subFrameHost, const String& topFrameHost, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback); > bool hasStorageAccessForFrame(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID); >+ void requestStorageAccess(const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&&); > void setLastSeen(const URL&, Seconds, CompletionHandler<void()>&&); >+ void setLastSeen(const String& resourceDomain, Seconds, CompletionHandler<void()>&&); > void setPrevalentResource(const URL&, CompletionHandler<void()>&&); >+ void setPrevalentResource(const String& resourceDomain, CompletionHandler<void()>&&); > void setVeryPrevalentResource(const URL&, CompletionHandler<void()>&&); >+ void setVeryPrevalentResource(const String& resourceDomain, CompletionHandler<void()>&&); > void dumpResourceLoadStatistics(CompletionHandler<void(const String&)>&&); > void isPrevalentResource(const URL&, CompletionHandler<void(bool)>&&); >+ void isPrevalentResource(const String&, CompletionHandler<void(bool)>&&); > void isVeryPrevalentResource(const URL&, CompletionHandler<void(bool)>&&); >+ void isVeryPrevalentResource(const String&, CompletionHandler<void(bool)>&&); > void isRegisteredAsSubresourceUnder(const URL& subresource, const URL& topFrame, CompletionHandler<void(bool)>&&); >+ void isRegisteredAsSubresourceUnder(const String& subresource, const String& topFrame, CompletionHandler<void(bool)>&&); > void isRegisteredAsSubFrameUnder(const URL& subFrame, const URL& topFrame, CompletionHandler<void(bool)>&&); >+ void isRegisteredAsSubFrameUnder(const String& subFrame, const String& topFrame, CompletionHandler<void(bool)>&&); > void isRegisteredAsRedirectingTo(const URL& hostRedirectedFrom, const URL& hostRedirectedTo, CompletionHandler<void(bool)>&&); >+ void isRegisteredAsRedirectingTo(const String& hostRedirectedFrom, const String& hostRedirectedTo, CompletionHandler<void(bool)>&&); > void clearPrevalentResource(const URL&, CompletionHandler<void()>&&); >+ void clearPrevalentResource(const String&, CompletionHandler<void()>&&); > void setGrandfathered(const URL&, bool); >+ void setGrandfathered(const String&, bool, CompletionHandler<void()>&&); > void isGrandfathered(const URL&, CompletionHandler<void(bool)>&&); >+ void isGrandfathered(const String&, CompletionHandler<void(bool)>&&); > void removeAllStorageAccess(); > void removePrevalentDomains(const Vector<String>& domainsToBlock); > void setCacheMaxAgeCapForPrevalentResources(Seconds); >+ void setNotifyPagesWhenDataRecordsWereScanned(bool, CompletionHandler<void()>&&); > void setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame); >+ void setSubframeUnderTopFrameOrigin(const String& subframe, const String& topFrame, CompletionHandler<void()>&&); > void setSubresourceUnderTopFrameOrigin(const URL& subresource, const URL& topFrame); >+ void setSubresourceUnderTopFrameOrigin(const String& subresource, const String& topFrame, CompletionHandler<void()>&&); > void setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo); >+ void setSubresourceUniqueRedirectTo(const String& subresource, const String& hostNameRedirectedTo, CompletionHandler<void()>&&); > void setSubresourceUniqueRedirectFrom(const URL& subresource, const URL& hostNameRedirectedFrom); >+ void setSubresourceUniqueRedirectFrom(const String& subresource, const String& hostNameRedirectedFrom, CompletionHandler<void()>&&); > void setTopFrameUniqueRedirectTo(const URL& topFrameHostName, const URL& hostNameRedirectedTo); >+ void setTopFrameUniqueRedirectTo(const String& topFrameHostName, const String& hostNameRedirectedTo, CompletionHandler<void()>&&); > void setTopFrameUniqueRedirectFrom(const URL& topFrameHostName, const URL& hostNameRedirectedFrom); >+ void setTopFrameUniqueRedirectFrom(const String& topFrameHostName, const String& hostNameRedirectedFrom, CompletionHandler<void()>&&); > void scheduleCookieBlockingUpdate(CompletionHandler<void()>&&); > void scheduleCookieBlockingUpdateForDomains(const Vector<String>& domainsToBlock, CompletionHandler<void()>&&); > void scheduleClearBlockingStateForDomains(const Vector<String>& domains, CompletionHandler<void()>&&); > void scheduleStatisticsAndDataRecordsProcessing(); >+ void scheduleStatisticsAndDataRecordsProcessing(CompletionHandler<void()>&&); > void submitTelemetry(); > void updatePrevalentDomainsToBlockCookiesFor(const Vector<String>& domainsToBlock); >- >- enum class ShouldGrandfather { >- No, >- Yes, >- }; > void scheduleClearInMemoryAndPersistent(ShouldGrandfather, CompletionHandler<void()>&&); > void scheduleClearInMemoryAndPersistent(WallTime modifiedSince, ShouldGrandfather, CompletionHandler<void()>&&); > > void setTimeToLiveUserInteraction(Seconds); >+ void setTimeToLiveUserInteraction(Seconds, CompletionHandler<void()>&&); > void setMinimumTimeBetweenDataRecordsRemoval(Seconds); > void setGrandfatheringTime(Seconds); > void setCacheMaxAgeCap(Seconds, CompletionHandler<void()>&&); >@@ -142,8 +169,8 @@ public: > > void setResourceLoadStatisticsDebugMode(bool, CompletionHandler<void()>&&); > void setPrevalentResourceForDebugMode(const URL&, CompletionHandler<void()>&&); >- >- void setStatisticsTestingCallback(WTF::Function<void(const String&)>&& callback) { m_statisticsTestingCallback = WTFMove(callback); } >+ void setPrevalentResourceForDebugMode(const String& resourceDomain, CompletionHandler<void()>&&); >+ > void logTestingEvent(const String&); > void callGrantStorageAccessHandler(const String& subFramePrimaryDomain, const String& topFramePrimaryDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&&); > void removeAllStorageAccess(CompletionHandler<void()>&&); >@@ -153,9 +180,14 @@ public: > > void didCreateNetworkProcess(); > >+ void notifyResourceLoadStatisticsProcessed(); >+ > WebsiteDataStore* websiteDataStore() { return m_websiteDataStore.get(); } > NetworkSession* networkSession() { return m_networkSession.get(); } > >+ void sendDiagnosticMessageWithValue(const String& message, const String& description, unsigned value, unsigned sigDigits, WebCore::ShouldSample) const; >+ void notifyPageStatisticsTelemetryFinished(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins) const; >+ > private: > explicit WebResourceLoadStatisticsStore(WebsiteDataStore&); > explicit WebResourceLoadStatisticsStore(NetworkSession&, const String&); >@@ -186,8 +218,6 @@ private: > > bool m_hasScheduledProcessStats { false }; > >- WTF::Function<void(const String&)> m_statisticsTestingCallback; >- > bool m_firstNetworkProcessCreated { false }; > }; > >diff --git a/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsTelemetry.cpp b/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsTelemetry.cpp >index f9692e12912a6c1c098d3b9f60804ae2ff37df9a..8fc920a041d65a6a1efadd627a8ccb8c6afc3d22 100644 >--- a/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsTelemetry.cpp >+++ b/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsTelemetry.cpp >@@ -27,6 +27,7 @@ > #include "WebResourceLoadStatisticsTelemetry.h" > > #include "ResourceLoadStatisticsMemoryStore.h" >+#include "WebPageProxy.h" > #include "WebProcessPool.h" > #include "WebProcessProxy.h" > #include <WebCore/DiagnosticLoggingKeys.h> >@@ -127,27 +128,7 @@ static unsigned median(const Vector<PrevalentResourceTelemetry>& v, unsigned beg > return median(part); > } > >-static WebPageProxy* nonEphemeralWebPageProxy() >-{ >- auto processPools = WebProcessPool::allProcessPools(); >- if (processPools.isEmpty()) >- return nullptr; >- >- auto processPool = processPools[0]; >- if (!processPool) >- return nullptr; >- >- for (auto& webProcess : processPool->processes()) { >- for (auto& page : webProcess->pages()) { >- if (page->sessionID().isEphemeral()) >- continue; >- return page; >- } >- } >- return nullptr; >-} >- >-static void submitTopList(unsigned numberOfResourcesFromTheTop, const Vector<PrevalentResourceTelemetry>& sortedPrevalentResources, const Vector<PrevalentResourceTelemetry>& sortedPrevalentResourcesWithoutUserInteraction, WebPageProxy& webPageProxy) >+static void submitTopList(unsigned numberOfResourcesFromTheTop, const Vector<PrevalentResourceTelemetry>& sortedPrevalentResources, const Vector<PrevalentResourceTelemetry>& sortedPrevalentResourcesWithoutUserInteraction, const WebResourceLoadStatisticsStore& store) > { > WTF::Function<unsigned(const PrevalentResourceTelemetry& telemetry)> subframeUnderTopFrameOriginsGetter = [] (auto& t) { > return t.subframeUnderTopFrameOrigins; >@@ -181,63 +162,59 @@ static void submitTopList(unsigned numberOfResourcesFromTheTop, const Vector<Pre > preambleBuilder.appendNumber(numberOfResourcesFromTheTop); > String descriptionPreamble = preambleBuilder.toString(); > >- webPageProxy.logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "PrevalentResourcesWithUserInteraction", >+ store.sendDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "PrevalentResourcesWithUserInteraction", > topPrevalentResourcesWithUserInteraction, significantFiguresForLoggedValues, ShouldSample::No); >- webPageProxy.logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "SubframeUnderTopFrameOrigins", >+ store.sendDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "SubframeUnderTopFrameOrigins", > topSubframeUnderTopFrameOrigins, significantFiguresForLoggedValues, ShouldSample::No); >- webPageProxy.logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "SubresourceUnderTopFrameOrigins", >+ store.sendDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "SubresourceUnderTopFrameOrigins", > topSubresourceUnderTopFrameOrigins, significantFiguresForLoggedValues, ShouldSample::No); >- webPageProxy.logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "SubresourceUniqueRedirectsTo", >+ store.sendDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "SubresourceUniqueRedirectsTo", > topSubresourceUniqueRedirectsTo, significantFiguresForLoggedValues, ShouldSample::No); >- webPageProxy.logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "NumberOfTimesDataRecordsRemoved", >+ store.sendDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "NumberOfTimesDataRecordsRemoved", > topNumberOfTimesDataRecordsRemoved, significantFiguresForLoggedValues, ShouldSample::No); >- webPageProxy.logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "NumberOfTimesAccessedAsFirstPartyDueToUserInteraction", >+ store.sendDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "NumberOfTimesAccessedAsFirstPartyDueToUserInteraction", > topNumberOfTimesAccessedAsFirstPartyDueToUserInteraction, significantFiguresForLoggedValues, ShouldSample::No); >- webPageProxy.logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "NumberOfTimesAccessedAsFirstPartyDueToStorageAccessAPI", >+ store.sendDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "NumberOfTimesAccessedAsFirstPartyDueToStorageAccessAPI", > topNumberOfTimesAccessedAsFirstPartyDueToStorageAccessAPI, significantFiguresForLoggedValues, ShouldSample::No); > } > >-static void submitTopLists(const Vector<PrevalentResourceTelemetry>& sortedPrevalentResources, const Vector<PrevalentResourceTelemetry>& sortedPrevalentResourcesWithoutUserInteraction, WebPageProxy& webPageProxy) >+static void submitTopLists(const Vector<PrevalentResourceTelemetry>& sortedPrevalentResources, const Vector<PrevalentResourceTelemetry>& sortedPrevalentResourcesWithoutUserInteraction, const WebResourceLoadStatisticsStore& store) > { >- submitTopList(1, sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, webPageProxy); >+ submitTopList(1, sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, store); > > if (sortedPrevalentResourcesWithoutUserInteraction.size() < 3) > return; >- submitTopList(3, sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, webPageProxy); >+ submitTopList(3, sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, store); > > if (sortedPrevalentResourcesWithoutUserInteraction.size() < 10) > return; >- submitTopList(10, sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, webPageProxy); >+ submitTopList(10, sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, store); > > if (sortedPrevalentResourcesWithoutUserInteraction.size() < 50) > return; >- submitTopList(50, sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, webPageProxy); >+ submitTopList(50, sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, store); > > if (sortedPrevalentResourcesWithoutUserInteraction.size() < 100) > return; >- submitTopList(100, sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, webPageProxy); >+ submitTopList(100, sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, store); > } > > // This function is for testing purposes. >-void static notifyPages(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins) >+void static notifyPages(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins, const WebResourceLoadStatisticsStore& store) > { >- RunLoop::main().dispatch([totalPrevalentResources, totalPrevalentResourcesWithUserInteraction, top3SubframeUnderTopFrameOrigins] { >- API::Dictionary::MapType messageBody; >- messageBody.set("TotalPrevalentResources"_s, API::UInt64::create(totalPrevalentResources)); >- messageBody.set("TotalPrevalentResourcesWithUserInteraction"_s, API::UInt64::create(totalPrevalentResourcesWithUserInteraction)); >- messageBody.set("Top3SubframeUnderTopFrameOrigins"_s, API::UInt64::create(top3SubframeUnderTopFrameOrigins)); >- WebProcessProxy::notifyPageStatisticsTelemetryFinished(API::Dictionary::create(messageBody).ptr()); >+ RunLoop::main().dispatch([totalPrevalentResources, totalPrevalentResourcesWithUserInteraction, top3SubframeUnderTopFrameOrigins, store = makeRef(store)] { >+ store->notifyPageStatisticsTelemetryFinished(totalPrevalentResources, totalPrevalentResourcesWithUserInteraction, top3SubframeUnderTopFrameOrigins); > }); > } > > // This function is for testing purposes. >-void static notifyPages(const Vector<PrevalentResourceTelemetry>& sortedPrevalentResources, const Vector<PrevalentResourceTelemetry>& sortedPrevalentResourcesWithoutUserInteraction, unsigned totalNumberOfPrevalentResourcesWithUserInteraction) >+void static notifyPages(const Vector<PrevalentResourceTelemetry>& sortedPrevalentResources, const Vector<PrevalentResourceTelemetry>& sortedPrevalentResourcesWithoutUserInteraction, unsigned totalNumberOfPrevalentResourcesWithUserInteraction, const WebResourceLoadStatisticsStore& store) > { > WTF::Function<unsigned(const PrevalentResourceTelemetry& telemetry)> subframeUnderTopFrameOriginsGetter = [] (const PrevalentResourceTelemetry& t) { > return t.subframeUnderTopFrameOrigins; > }; > >- notifyPages(sortedPrevalentResources.size(), totalNumberOfPrevalentResourcesWithUserInteraction, median(sortedPrevalentResourcesWithoutUserInteraction, 0, 2, subframeUnderTopFrameOriginsGetter)); >+ notifyPages(sortedPrevalentResources.size(), totalNumberOfPrevalentResourcesWithUserInteraction, median(sortedPrevalentResourcesWithoutUserInteraction, 0, 2, subframeUnderTopFrameOriginsGetter), store); > } > > void WebResourceLoadStatisticsTelemetry::calculateAndSubmit(const ResourceLoadStatisticsMemoryStore& resourceLoadStatisticsStore) >@@ -246,7 +223,7 @@ void WebResourceLoadStatisticsTelemetry::calculateAndSubmit(const ResourceLoadSt > > auto sortedPrevalentResources = sortedPrevalentResourceTelemetry(resourceLoadStatisticsStore); > if (notifyPagesWhenTelemetryWasCaptured && sortedPrevalentResources.isEmpty()) { >- notifyPages(0, 0, 0); >+ notifyPages(0, 0, 0, resourceLoadStatisticsStore.store()); > return; > } > >@@ -262,16 +239,16 @@ void WebResourceLoadStatisticsTelemetry::calculateAndSubmit(const ResourceLoadSt > } > > // Dispatch on the main thread to make sure the WebPageProxy we're using doesn't go away. >- RunLoop::main().dispatch([sortedPrevalentResources = WTFMove(sortedPrevalentResources), sortedPrevalentResourcesWithoutUserInteraction = WTFMove(sortedPrevalentResourcesWithoutUserInteraction), prevalentResourcesDaysSinceUserInteraction = WTFMove(prevalentResourcesDaysSinceUserInteraction)] () { >- auto webPageProxy = nonEphemeralWebPageProxy(); >+ RunLoop::main().dispatch([sortedPrevalentResources = WTFMove(sortedPrevalentResources), sortedPrevalentResourcesWithoutUserInteraction = WTFMove(sortedPrevalentResourcesWithoutUserInteraction), prevalentResourcesDaysSinceUserInteraction = WTFMove(prevalentResourcesDaysSinceUserInteraction), &resourceLoadStatisticsStore] () { >+ auto webPageProxy = WebPageProxy::nonEphemeralWebPageProxy(); > if (!webPageProxy) { > if (notifyPagesWhenTelemetryWasCaptured) >- notifyPages(0, 0, 0); >+ notifyPages(0, 0, 0, resourceLoadStatisticsStore.store()); > return; > } > > if (notifyPagesWhenTelemetryWasCaptured) { >- notifyPages(sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, prevalentResourcesDaysSinceUserInteraction.size()); >+ notifyPages(sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, prevalentResourcesDaysSinceUserInteraction.size(), resourceLoadStatisticsStore.store()); > // The notify pages function is for testing so we don't need to do an actual submission. > return; > } >@@ -284,7 +261,7 @@ void WebResourceLoadStatisticsTelemetry::calculateAndSubmit(const ResourceLoadSt > if (prevalentResourcesDaysSinceUserInteraction.size() > 1) > webPageProxy->logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), "medianPrevalentResourcesWithUserInteractionDaysSinceUserInteraction"_s, median(prevalentResourcesDaysSinceUserInteraction), significantFiguresForLoggedValues, ShouldSample::No); > >- submitTopLists(sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, *webPageProxy); >+ submitTopLists(sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, resourceLoadStatisticsStore.store()); > }); > } > >diff --git a/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp b/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp >index 6413203565bf414307bbb83d54795249e32ec9b8..0666b1e465f930ccdc26a960cd6751f7ae34f74e 100644 >--- a/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp >+++ b/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2012-2018 Apple Inc. All rights reserved. >+ * Copyright (C) 2012-2019 Apple Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -49,6 +49,7 @@ > #include "WebErrors.h" > #include "WebIDBConnectionToClient.h" > #include "WebIDBConnectionToClientMessages.h" >+#include "WebResourceLoadStatisticsStore.h" > #include "WebSWServerConnection.h" > #include "WebSWServerConnectionMessages.h" > #include "WebSWServerToContextConnection.h" >@@ -581,6 +582,19 @@ void NetworkConnectionToWebProcess::removeStorageAccessForAllFramesOnPage(PAL::S > #endif > } > >+void NetworkConnectionToWebProcess::logUserInteraction(PAL::SessionID sessionID, const String& topLevelOrigin) >+{ >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ if (auto networkSession = networkProcess().networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) >+ resourceLoadStatistics->logUserInteraction(topLevelOrigin, [] { }); >+ } >+#else >+ UNUSED_PARAM(sessionID); >+ UNUSED_PARAM(topLevelOrigin); >+#endif >+} >+ > void NetworkConnectionToWebProcess::addOriginAccessWhitelistEntry(const String& sourceOrigin, const String& destinationProtocol, const String& destinationHost, bool allowDestinationSubdomains) > { > SecurityPolicy::addOriginAccessWhitelistEntry(SecurityOrigin::createFromString(sourceOrigin).get(), destinationProtocol, destinationHost, allowDestinationSubdomains); >diff --git a/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h b/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h >index e6119b17df9e62bb3138dad509b27fd03046e5b0..088de8fded14754838dfaa9d827f7e57e9291a88 100644 >--- a/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h >+++ b/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2012-2017 Apple Inc. All rights reserved. >+ * Copyright (C) 2012-2019 Apple Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -194,6 +194,7 @@ private: > > void removeStorageAccessForFrame(PAL::SessionID, uint64_t frameID, uint64_t pageID); > void removeStorageAccessForAllFramesOnPage(PAL::SessionID, uint64_t pageID); >+ void logUserInteraction(PAL::SessionID, const String& topLevelOrigin); > > void addOriginAccessWhitelistEntry(const String& sourceOrigin, const String& destinationProtocol, const String& destinationHost, bool allowDestinationSubdomains); > void removeOriginAccessWhitelistEntry(const String& sourceOrigin, const String& destinationProtocol, const String& destinationHost, bool allowDestinationSubdomains); >diff --git a/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in b/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in >index 932b9345202357d0f632a0915b51094c711fe55f..f245bca7dc6b2c71a79cc8a39059e9d14435df60 100644 >--- a/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in >+++ b/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in >@@ -58,6 +58,9 @@ messages -> NetworkConnectionToWebProcess LegacyReceiver { > > RemoveStorageAccessForFrame(PAL::SessionID sessionID, uint64_t frameID, uint64_t pageID); > RemoveStorageAccessForAllFramesOnPage(PAL::SessionID sessionID, uint64_t pageID); >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ LogUserInteraction(PAL::SessionID sessionID, String topLevelOrigin) >+#endif > > AddOriginAccessWhitelistEntry(String sourceOrigin, String destinationProtocol, String destinationHost, bool allowDestinationSubdomains); > RemoveOriginAccessWhitelistEntry(String sourceOrigin, String destinationProtocol, String destinationHost, bool allowDestinationSubdomains); >diff --git a/Source/WebKit/NetworkProcess/NetworkProcess.cpp b/Source/WebKit/NetworkProcess/NetworkProcess.cpp >index 1900efe0540855dc529225226e171addf1d0d68e..33f713235465efecf01fd482731a4727b284c2c4 100644 >--- a/Source/WebKit/NetworkProcess/NetworkProcess.cpp >+++ b/Source/WebKit/NetworkProcess/NetworkProcess.cpp >@@ -497,6 +497,18 @@ void NetworkProcess::writeBlobToFilePath(const URL& url, const String& path, San > } > > #if ENABLE(RESOURCE_LOAD_STATISTICS) >+void NetworkProcess::dumpResourceLoadStatistics(PAL::SessionID sessionID, uint64_t contextId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ resourceLoadStatistics->dumpResourceLoadStatistics([this, contextId](const String& dumpedStatistics) { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidDumpResourceLoadStatistics(dumpedStatistics, contextId), 0); >+ }); >+ } >+ } else >+ ASSERT_NOT_REACHED(); >+} >+ > void NetworkProcess::updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID sessionID, const Vector<String>& domainsToBlock, uint64_t contextId) > { > if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID)) >@@ -504,6 +516,42 @@ void NetworkProcess::updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID sess > parentProcessConnection()->send(Messages::NetworkProcessProxy::DidUpdateBlockCookies(contextId), 0); > } > >+void NetworkProcess::isGrandfathered(PAL::SessionID sessionID, const String& targetPrimaryDomain, uint64_t contextId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ resourceLoadStatistics->isGrandfathered(targetPrimaryDomain, [this, contextId](bool isGrandfathered) { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidIsGrandfathered(isGrandfathered, contextId), 0); >+ }); >+ } >+ } else >+ ASSERT_NOT_REACHED(); >+} >+ >+void NetworkProcess::isPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, uint64_t contextId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ resourceLoadStatistics->isPrevalentResource(resourceDomain, [this, contextId](bool isPrevalent) { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::IsPrevalentResourceResult(isPrevalent, contextId), 0); >+ }); >+ } >+ } else >+ ASSERT_NOT_REACHED(); >+} >+ >+void NetworkProcess::isVeryPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, uint64_t contextId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ resourceLoadStatistics->isVeryPrevalentResource(resourceDomain, [this, contextId](bool isPrevalent) { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::IsPrevalentResourceResult(isPrevalent, contextId), 0); >+ }); >+ } >+ } else >+ ASSERT_NOT_REACHED(); >+} >+ > void NetworkProcess::setAgeCapForClientSideCookies(PAL::SessionID sessionID, Optional<Seconds> seconds, uint64_t contextId) > { > if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID)) >@@ -511,10 +559,278 @@ void NetworkProcess::setAgeCapForClientSideCookies(PAL::SessionID sessionID, Opt > parentProcessConnection()->send(Messages::NetworkProcessProxy::DidSetAgeCapForClientSideCookies(contextId), 0); > } > >+void NetworkProcess::setGrandfathered(PAL::SessionID sessionID, const String& resourceDomain, bool isGrandfathered, uint64_t callbackId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ resourceLoadStatistics->setGrandfathered(resourceDomain, isGrandfathered, [this, callbackId]() { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidSetResourceLoadStatisticData(callbackId), 0); >+ }); >+ } >+ } else >+ ASSERT_NOT_REACHED(); >+} >+ >+void NetworkProcess::setPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, uint64_t contextId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ resourceLoadStatistics->setPrevalentResource(resourceDomain, [this, contextId]() { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidSetResourceLoadStatisticData(contextId), 0); >+ }); >+ } >+ } else >+ ASSERT_NOT_REACHED(); >+} >+ >+void NetworkProcess::setPrevalentResourceForDebugMode(PAL::SessionID sessionID, String resourceDomain, uint64_t callbackId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ resourceLoadStatistics->setPrevalentResourceForDebugMode(resourceDomain, [this, callbackId]() { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidSetResourceLoadStatisticData(callbackId), 0); >+ }); >+ } >+ } else >+ ASSERT_NOT_REACHED(); >+} >+ >+void NetworkProcess::setVeryPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, uint64_t callbackId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ resourceLoadStatistics->setVeryPrevalentResource(resourceDomain, [this, callbackId]() { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidSetResourceLoadStatisticData(callbackId), 0); >+ }); >+ } >+ } else >+ ASSERT_NOT_REACHED(); >+} >+ >+void NetworkProcess::clearPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, uint64_t contextId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ resourceLoadStatistics->clearPrevalentResource(resourceDomain, [this, contextId]() { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidSetResourceLoadStatisticData(contextId), 0); >+ }); >+ } >+ } else >+ ASSERT_NOT_REACHED(); >+} >+ >+void NetworkProcess::submitTelemetry(PAL::SessionID sessionID, uint64_t callbackId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) >+ resourceLoadStatistics->submitTelemetry(); >+ } else >+ ASSERT_NOT_REACHED(); >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidScheduleStatisticsProcessing(callbackId), 0); >+} >+ >+void NetworkProcess::scheduleCookieBlockingUpdate(PAL::SessionID sessionID, uint64_t contextId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ resourceLoadStatistics->scheduleCookieBlockingUpdate([this, contextId]() { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidScheduleStatisticsProcessing(contextId), 0); >+ }); >+ } >+ } else >+ ASSERT_NOT_REACHED(); >+} >+ >+void NetworkProcess::scheduleClearInMemoryAndPersistent(PAL::SessionID sessionID, Optional<WallTime> modifiedSince, bool shouldGrandfather, uint64_t contextId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ auto grandfather = shouldGrandfather ? ShouldGrandfather::Yes : ShouldGrandfather::No; >+ if (modifiedSince) { >+ resourceLoadStatistics->scheduleClearInMemoryAndPersistent(modifiedSince.value(), grandfather, [this, contextId]() { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidScheduleStatisticsProcessing(contextId), 0); >+ }); >+ } else { >+ resourceLoadStatistics->scheduleClearInMemoryAndPersistent(grandfather, [this, contextId]() { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidScheduleStatisticsProcessing(contextId), 0); >+ }); >+ } >+ } >+ } else >+ ASSERT_NOT_REACHED(); >+} >+ >+void NetworkProcess::resetParametersToDefaultValues(PAL::SessionID sessionID, uint64_t contextId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ resourceLoadStatistics->resetParametersToDefaultValues([this, contextId]() { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidUpdateRuntimeSettings(contextId), 0); >+ }); >+ } >+ } else >+ ASSERT_NOT_REACHED(); >+} >+ >+void NetworkProcess::scheduleStatisticsAndDataRecordsProcessing(PAL::SessionID sessionID, uint64_t contextId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ resourceLoadStatistics->scheduleStatisticsAndDataRecordsProcessing([this, contextId]() { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidScheduleStatisticsProcessing(contextId), 0); >+ }); >+ } >+ } else >+ ASSERT_NOT_REACHED(); >+} >+ >+void NetworkProcess::setNotifyPagesWhenDataRecordsWereScanned(PAL::SessionID sessionID, bool value, uint64_t contextId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ resourceLoadStatistics->setNotifyPagesWhenDataRecordsWereScanned(value, [this, contextId]() { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidUpdateRuntimeSettings(contextId), 0); >+ }); >+ } >+ } else >+ ASSERT_NOT_REACHED(); >+} >+ >+void NetworkProcess::setNotifyPagesWhenTelemetryWasCaptured(PAL::SessionID sessionID, bool value, uint64_t callbackId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) >+ resourceLoadStatistics->setNotifyPagesWhenTelemetryWasCaptured(value); >+ } else >+ ASSERT_NOT_REACHED(); >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidUpdateRuntimeSettings(callbackId), 0); >+} >+ >+void NetworkProcess::setSubframeUnderTopFrameOrigin(PAL::SessionID sessionID, String subframe, String topFrame, uint64_t contextId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ resourceLoadStatistics->setSubframeUnderTopFrameOrigin(subframe, topFrame, [this, contextId]() { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidSetResourceLoadStatisticData(contextId), 0); >+ }); >+ } >+ } else >+ ASSERT_NOT_REACHED(); >+} >+ >+void NetworkProcess::isRegisteredAsRedirectingTo(PAL::SessionID sessionID, const String& redirectedFrom, const String& redirectedTo, uint64_t callbackId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ resourceLoadStatistics->isRegisteredAsRedirectingTo(redirectedFrom, redirectedTo, [this, callbackId](bool isRegistered) { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidIsRegisteredAsRedirectingTo(isRegistered, callbackId), 0); >+ }); >+ } >+ } else >+ ASSERT_NOT_REACHED(); >+} >+ >+void NetworkProcess::isRegisteredAsSubFrameUnder(PAL::SessionID sessionID, const String& subframe, const String& topFrame, uint64_t contextId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ resourceLoadStatistics->isRegisteredAsSubFrameUnder(subframe, topFrame, [this, contextId](bool isSubframe) { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidIsRegisteredAsSubFrameUnder(isSubframe, contextId), 0); >+ }); >+ } >+ } else >+ ASSERT_NOT_REACHED(); >+} >+ >+void NetworkProcess::setSubresourceUnderTopFrameOrigin(PAL::SessionID sessionID, String subresource, String topFrame, uint64_t callbackId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ resourceLoadStatistics->setSubresourceUnderTopFrameOrigin(subresource, topFrame, [this, callbackId]() { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidSetResourceLoadStatisticData(callbackId), 0); >+ }); >+ } >+ } else >+ ASSERT_NOT_REACHED(); >+} >+ >+void NetworkProcess::setSubresourceUniqueRedirectTo(PAL::SessionID sessionID, String subresource, String hostNameRedirectedTo, uint64_t callbackId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ resourceLoadStatistics->setSubresourceUniqueRedirectTo(subresource, hostNameRedirectedTo, [this, callbackId]() { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidSetResourceLoadStatisticData(callbackId), 0); >+ }); >+ } >+ } else >+ ASSERT_NOT_REACHED(); >+} >+ >+void NetworkProcess::setSubresourceUniqueRedirectFrom(PAL::SessionID sessionID, String subresource, String hostNameRedirectedFrom, uint64_t callbackId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ resourceLoadStatistics->setSubresourceUniqueRedirectFrom(subresource, hostNameRedirectedFrom, [this, callbackId]() { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidSetResourceLoadStatisticData(callbackId), 0); >+ }); >+ } >+ } else >+ ASSERT_NOT_REACHED(); >+} >+ >+void NetworkProcess::isRegisteredAsSubresourceUnder(PAL::SessionID sessionID, const String& subresource, const String& topFrame, uint64_t contextId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ resourceLoadStatistics->isRegisteredAsSubresourceUnder(subresource, topFrame, [this, contextId](bool isSubresource) { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidIsRegisteredAsSubresourceUnder(isSubresource, contextId), 0); >+ }); >+ } >+ } else >+ ASSERT_NOT_REACHED(); >+} >+ >+void NetworkProcess::setTopFrameUniqueRedirectTo(PAL::SessionID sessionID, String topFrameHostName, String hostNameRedirectedTo, uint64_t callbackId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ resourceLoadStatistics->setTopFrameUniqueRedirectTo(topFrameHostName, hostNameRedirectedTo, [this, callbackId]() { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidSetResourceLoadStatisticData(callbackId), 0); >+ }); >+ } >+ } else >+ ASSERT_NOT_REACHED(); >+} >+ >+void NetworkProcess::setTopFrameUniqueRedirectFrom(PAL::SessionID sessionID, String topFrameHostName, String hostNameRedirectedFrom, uint64_t callbackId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ resourceLoadStatistics->setTopFrameUniqueRedirectFrom(topFrameHostName, hostNameRedirectedFrom, [this, callbackId]() { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidSetResourceLoadStatisticData(callbackId), 0); >+ }); >+ } >+ } else >+ ASSERT_NOT_REACHED(); >+} >+ >+ >+void NetworkProcess::setLastSeen(PAL::SessionID sessionID, const String& resourceDomain, Seconds seconds, uint64_t contextId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ resourceLoadStatistics->setLastSeen(resourceDomain, seconds, [this, contextId]() { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidSetResourceLoadStatisticData(contextId), 0); >+ }); >+ } >+ } else >+ ASSERT_NOT_REACHED(); >+} >+ > void NetworkProcess::hasStorageAccessForFrame(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId) > { > if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID)) >- parentProcessConnection()->send(Messages::NetworkProcessProxy::StorageAccessRequestResult(networkStorageSession->hasStorageAccess(resourceDomain, firstPartyDomain, frameID, pageID), contextId), 0); >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::StorageAccessOperationResult(networkStorageSession->hasStorageAccess(resourceDomain, firstPartyDomain, frameID, pageID), contextId), 0); > else > ASSERT_NOT_REACHED(); > } >@@ -527,7 +843,31 @@ void NetworkProcess::getAllStorageAccessEntries(PAL::SessionID sessionID, uint64 > ASSERT_NOT_REACHED(); > } > >-void NetworkProcess::grantStorageAccess(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, uint64_t contextId) >+void NetworkProcess::hasStorageAccess(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, uint64_t contextId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ resourceLoadStatistics->hasStorageAccess(resourceDomain, firstPartyDomain, frameID, pageID, [this, contextId](bool hasAccess) { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::StorageAccessOperationResult(hasAccess, contextId), 0); >+ }); >+ } >+ } else >+ ASSERT_NOT_REACHED(); >+} >+ >+void NetworkProcess::requestStorageAccess(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool promptEnabled, uint64_t contextId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ resourceLoadStatistics->requestStorageAccess(resourceDomain, firstPartyDomain, frameID, pageID, promptEnabled, [this, contextId](StorageAccessStatus promptAccepted) { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::StorageAccessRequestResult(static_cast<unsigned>(promptAccepted), contextId), 0); >+ }); >+ } >+ } else >+ ASSERT_NOT_REACHED(); >+} >+ >+void NetworkProcess::grantStorageAccess(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool userWasPrompted, uint64_t contextId) > { > bool isStorageGranted = false; > if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID)) { >@@ -537,7 +877,7 @@ void NetworkProcess::grantStorageAccess(PAL::SessionID sessionID, const String& > } else > ASSERT_NOT_REACHED(); > >- parentProcessConnection()->send(Messages::NetworkProcessProxy::StorageAccessRequestResult(isStorageGranted, contextId), 0); >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::StorageAccessOperationResult(isStorageGranted, contextId), 0); > } > > void NetworkProcess::logFrameNavigation(PAL::SessionID sessionID, const String& targetPrimaryDomain, const String& mainFramePrimaryDomain, const String& sourcePrimaryDomain, const String& targetHost, const String& mainFrameHost, bool isRedirect, bool isMainFrame) >@@ -554,13 +894,37 @@ void NetworkProcess::logUserInteraction(PAL::SessionID sessionID, const String& > if (auto* networkSession = this->networkSession(sessionID)) { > if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { > resourceLoadStatistics->logUserInteraction(targetPrimaryDomain, [this, contextId] { >- parentProcessConnection()->send(Messages::NetworkProcessProxy::DidLogUserInteraction(contextId), 0); >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidSetResourceLoadStatisticData(contextId), 0); > }); > } > } else > ASSERT_NOT_REACHED(); > } > >+void NetworkProcess::hadUserInteraction(PAL::SessionID sessionID, const String& resourceDomain, uint64_t contextId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ resourceLoadStatistics->hasHadUserInteraction(resourceDomain, [this, contextId](bool hadInteraction) { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidHaveUserInteraction(hadInteraction, contextId), 0); >+ }); >+ } >+ } else >+ ASSERT_NOT_REACHED(); >+} >+ >+void NetworkProcess::clearUserInteraction(PAL::SessionID sessionID, const String& resourceDomain, uint64_t contextId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ resourceLoadStatistics->clearUserInteraction(resourceDomain, [this, contextId]() { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidSetResourceLoadStatisticData(contextId), 0); >+ }); >+ } >+ } else >+ ASSERT_NOT_REACHED(); >+} >+ > void NetworkProcess::removeAllStorageAccess(PAL::SessionID sessionID, uint64_t contextId) > { > if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID)) >@@ -585,13 +949,93 @@ void NetworkProcess::setCacheMaxAgeCapForPrevalentResources(PAL::SessionID sessi > parentProcessConnection()->send(Messages::NetworkProcessProxy::DidSetCacheMaxAgeCapForPrevalentResources(contextId), 0); > } > >+void NetworkProcess::setGrandfatheringTime(PAL::SessionID sessionID, Seconds seconds, uint64_t contextId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) >+ resourceLoadStatistics->setGrandfatheringTime(seconds); >+ } else >+ ASSERT_NOT_REACHED(); >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidSetCacheMaxAgeCapForPrevalentResources(contextId), 0); >+} >+ >+void NetworkProcess::setMaxStatisticsEntries(PAL::SessionID sessionID, uint64_t maximumEntryCount, uint64_t contextId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) >+ resourceLoadStatistics->setMaxStatisticsEntries(maximumEntryCount); >+ } else >+ ASSERT_NOT_REACHED(); >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidUpdateRuntimeSettings(contextId), 0); >+} >+ >+void NetworkProcess::setMinimumTimeBetweenDataRecordsRemoval(PAL::SessionID sessionID, Seconds seconds, uint64_t contextId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) >+ resourceLoadStatistics->setMinimumTimeBetweenDataRecordsRemoval(seconds); >+ } else >+ ASSERT_NOT_REACHED(); >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidUpdateRuntimeSettings(contextId), 0); >+} >+ >+void NetworkProcess::setPruneEntriesDownTo(PAL::SessionID sessionID, uint64_t pruneTargetCount, uint64_t contextId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) >+ resourceLoadStatistics->setPruneEntriesDownTo(pruneTargetCount); >+ } else >+ ASSERT_NOT_REACHED(); >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidUpdateRuntimeSettings(contextId), 0); >+} >+ >+void NetworkProcess::setTimeToLiveUserInteraction(PAL::SessionID sessionID, Seconds seconds, uint64_t contextId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ resourceLoadStatistics->setTimeToLiveUserInteraction(seconds, [this, contextId] { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidUpdateRuntimeSettings(contextId), 0); >+ }); >+ } >+ } else >+ ASSERT_NOT_REACHED(); >+} >+ >+void NetworkProcess::setShouldClassifyResourcesBeforeDataRecordsRemoval(PAL::SessionID sessionID, bool value, uint64_t contextId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) >+ resourceLoadStatistics->setShouldClassifyResourcesBeforeDataRecordsRemoval(value); >+ } else >+ ASSERT_NOT_REACHED(); >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidUpdateRuntimeSettings(contextId), 0); >+} >+ >+void NetworkProcess::setResourceLoadStatisticsEnabled(bool enabled) >+{ >+ for (auto& networkSession : m_networkSessions.values()) >+ networkSession.get().setResourceLoadStatisticsEnabled(enabled); >+} >+ >+void NetworkProcess::setResourceLoadStatisticsDebugMode(PAL::SessionID sessionID, bool debugMode, uint64_t callbackId) >+{ >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ resourceLoadStatistics->setResourceLoadStatisticsDebugMode(debugMode, [this, callbackId] { >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidUpdateRuntimeSettings(callbackId), 0); >+ }); >+ } >+ } else >+ ASSERT_NOT_REACHED(); >+} >+ > void NetworkProcess::resetCacheMaxAgeCapForPrevalentResources(PAL::SessionID sessionID, uint64_t contextId) > { > if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID)) > networkStorageSession->resetCacheMaxAgeCapForPrevalentResources(); > else > ASSERT_NOT_REACHED(); >- parentProcessConnection()->send(Messages::NetworkProcessProxy::DidResetCacheMaxAgeCapForPrevalentResources(contextId), 0); >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::DidUpdateRuntimeSettings(contextId), 0); > } > #endif // ENABLE(RESOURCE_LOAD_STATISTICS) > >@@ -650,8 +1094,6 @@ void NetworkProcess::fetchWebsiteData(PAL::SessionID sessionID, OptionSet<Websit > > ~CallbackAggregator() > { >- ASSERT(RunLoop::isMain()); >- > RunLoop::main().dispatch([completionHandler = WTFMove(m_completionHandler), websiteData = WTFMove(m_websiteData)] () mutable { > completionHandler(websiteData); > }); >@@ -756,6 +1198,21 @@ void NetworkProcess::deleteWebsiteData(PAL::SessionID sessionID, OptionSet<Websi > > if (websiteDataTypes.contains(WebsiteDataType::DiskCache) && !sessionID.isEphemeral()) > clearDiskCache(modifiedSince, [clearTasksHandler = WTFMove(clearTasksHandler)] { }); >+ >+ if (websiteDataTypes.contains(WebsiteDataType::ResourceLoadStatistics)) { >+ if (auto* networkSession = this->networkSession(sessionID)) { >+ if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) { >+ auto deletedTypesRaw = websiteDataTypes.toRaw(); >+ auto monitoredTypesRaw = WebResourceLoadStatisticsStore::monitoredDataTypes().toRaw(); >+ >+ // If we are deleting all of the data types that the resource load statistics store monitors >+ // we do not need to re-grandfather old data. >+ auto shouldGrandfather = ((monitoredTypesRaw & deletedTypesRaw) == monitoredTypesRaw) ? ShouldGrandfather::No : ShouldGrandfather::Yes; >+ >+ resourceLoadStatistics->scheduleClearInMemoryAndPersistent(modifiedSince, shouldGrandfather, [clearTasksHandler = clearTasksHandler.copyRef()] { }); >+ } >+ } >+ } > } > > static void clearDiskCacheEntries(NetworkCache::Cache* cache, const Vector<SecurityOriginData>& origins, CompletionHandler<void()>&& completionHandler) >@@ -822,6 +1279,259 @@ void NetworkProcess::deleteWebsiteDataForOrigins(PAL::SessionID sessionID, Optio > clearDiskCacheEntries(cache(), originDatas, [clearTasksHandler = WTFMove(clearTasksHandler)] { }); > } > >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+static Vector<String> filterForTopLevelDomains(const Vector<String>& topLevelDomains, const HashSet<String>& foundValues) >+{ >+ Vector<String> result; >+ for (const auto& hostname : topLevelDomains) { >+ if (foundValues.contains(hostname)) >+ result.append(hostname); >+ } >+ >+ return result; >+} >+ >+static Vector<WebsiteData::Entry> filterForTopLevelDomains(const Vector<String>& topLevelDomains, const Vector<WebsiteData::Entry>& foundValues) >+{ >+ Vector<WebsiteData::Entry> result; >+ for (const auto& value : foundValues) { >+ if (topLevelDomains.contains(value.origin.host)) >+ result.append(value); >+ } >+ >+ return result; >+} >+ >+void NetworkProcess::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(PAL::SessionID sessionID, OptionSet<WebsiteDataType> websiteDataTypes, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&& completionHandler) >+{ >+ OptionSet<WebsiteDataFetchOption> fetchOptions = WebsiteDataFetchOption::DoNotCreateProcesses; >+ >+ struct CallbackAggregator final : public RefCounted<CallbackAggregator> { >+ explicit CallbackAggregator(CompletionHandler<void(const HashSet<String>&)>&& completionHandler) >+ : m_completionHandler(WTFMove(completionHandler)) >+ { >+ } >+ >+ ~CallbackAggregator() >+ { >+ RunLoop::main().dispatch([completionHandler = WTFMove(m_completionHandler), websiteData = WTFMove(m_websiteData)] () mutable { >+ HashSet<String> origins; >+ for (const auto& hostnameWithCookies : websiteData.hostNamesWithCookies) >+ origins.add(hostnameWithCookies); >+ >+ for (const auto& hostnameWithHSTS : websiteData.hostNamesWithHSTSCache) >+ origins.add(hostnameWithHSTS); >+ >+ for (const auto& entry : websiteData.entries) >+ origins.add(entry.origin.host); >+ >+ completionHandler(origins); >+ }); >+ } >+ >+ CompletionHandler<void(const HashSet<String>&)> m_completionHandler; >+ WebsiteData m_websiteData; >+ }; >+ >+ auto callbackAggregator = adoptRef(*new CallbackAggregator([this, completionHandler = WTFMove(completionHandler), shouldNotifyPage] (const HashSet<String>& originsWithData) mutable { >+ if (shouldNotifyPage) >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::NotifyWebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished(), 0); >+ >+ RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler), originsWithData = crossThreadCopy(originsWithData)] () mutable { >+ completionHandler(originsWithData); >+ }); >+ })); >+ >+ auto& websiteDataStore = callbackAggregator->m_websiteData; >+ >+ Vector<String> hostnamesWithCookiesToDelete; >+ if (websiteDataTypes.contains(WebsiteDataType::Cookies)) { >+ if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID)) { >+ networkStorageSession->getHostnamesWithCookies(websiteDataStore.hostNamesWithCookies); >+ hostnamesWithCookiesToDelete = filterForTopLevelDomains(topPrivatelyControlledDomains, websiteDataStore.hostNamesWithCookies); >+ networkStorageSession->deleteCookiesForHostnames(hostnamesWithCookiesToDelete); >+ } >+ } >+ >+ Vector<String> hostnamesWithHSTSToDelete; >+#if PLATFORM(COCOA) >+ if (websiteDataTypes.contains(WebsiteDataType::HSTSCache)) { >+ if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID)) { >+ getHostNamesWithHSTSCache(*networkStorageSession, websiteDataStore.hostNamesWithHSTSCache); >+ hostnamesWithHSTSToDelete = filterForTopLevelDomains(topPrivatelyControlledDomains, websiteDataStore.hostNamesWithHSTSCache); >+ deleteHSTSCacheForHostNames(*networkStorageSession, hostnamesWithHSTSToDelete); >+ } >+ } >+#endif >+ >+ /* >+ // FIXME: No API to delete credentials by origin >+ if (websiteDataTypes.contains(WebsiteDataType::Credentials)) { >+ if (NetworkStorageSession::storageSession(sessionID)) >+ websiteDataStore.originsWithCredentials = NetworkStorageSession::storageSession(sessionID)->credentialStorage().originsWithCredentials(); >+ } >+ */ >+ >+ if (websiteDataTypes.contains(WebsiteDataType::DOMCache)) { >+ CacheStorage::Engine::fetchEntries(*this, sessionID, fetchOptions.contains(WebsiteDataFetchOption::ComputeSizes), [this, topPrivatelyControlledDomains, sessionID, callbackAggregator = callbackAggregator.copyRef()](auto entries) mutable { >+ >+ auto entriesToDelete = filterForTopLevelDomains(topPrivatelyControlledDomains, entries); >+ >+ callbackAggregator->m_websiteData.entries.appendVector(entriesToDelete); >+ >+ for (auto& entry : entriesToDelete) >+ CacheStorage::Engine::clearCachesForOrigin(*this, sessionID, SecurityOriginData { entry.origin }, [callbackAggregator = callbackAggregator.copyRef()] { }); >+ }); >+ } >+ >+#if ENABLE(INDEXED_DATABASE) >+ auto path = m_idbDatabasePaths.get(sessionID); >+ if (!path.isEmpty() && websiteDataTypes.contains(WebsiteDataType::IndexedDBDatabases)) { >+ // FIXME: Pick the right database store based on the session ID. >+ postStorageTask(CrossThreadTask([this, sessionID, callbackAggregator = callbackAggregator.copyRef(), path = WTFMove(path), topPrivatelyControlledDomains]() mutable { >+ RunLoop::main().dispatch([this, sessionID, topPrivatelyControlledDomains = crossThreadCopy(topPrivatelyControlledDomains), callbackAggregator = callbackAggregator.copyRef(), securityOrigins = indexedDatabaseOrigins(path)] { >+ Vector<SecurityOriginData> entriesToDelete; >+ for (const auto& securityOrigin : securityOrigins) { >+ if (!topPrivatelyControlledDomains.contains(securityOrigin.host)) >+ continue; >+ >+ entriesToDelete.append(securityOrigin); >+ callbackAggregator->m_websiteData.entries.append({ securityOrigin, WebsiteDataType::IndexedDBDatabases, 0 }); >+ } >+ >+ idbServer(sessionID).closeAndDeleteDatabasesForOrigins(entriesToDelete, [callbackAggregator = callbackAggregator.copyRef()] { }); >+ }); >+ })); >+ } >+#endif >+ >+#if ENABLE(SERVICE_WORKER) >+ path = m_swDatabasePaths.get(sessionID); >+ if (!path.isEmpty() && websiteDataTypes.contains(WebsiteDataType::ServiceWorkerRegistrations)) { >+ swServerForSession(sessionID).getOriginsWithRegistrations([this, sessionID, topPrivatelyControlledDomains, callbackAggregator = callbackAggregator.copyRef()](const HashSet<SecurityOriginData>& securityOrigins) mutable { >+ for (auto& securityOrigin : securityOrigins) { >+ if (!topPrivatelyControlledDomains.contains(securityOrigin.host)) >+ continue; >+ callbackAggregator->m_websiteData.entries.append({ securityOrigin, WebsiteDataType::ServiceWorkerRegistrations, 0 }); >+ swServerForSession(sessionID).clear(securityOrigin, [callbackAggregator = callbackAggregator.copyRef()] { }); >+ } >+ }); >+ } >+#endif >+ >+ if (websiteDataTypes.contains(WebsiteDataType::DiskCache)) { >+ fetchDiskCacheEntries(cache(), sessionID, fetchOptions, [this, topPrivatelyControlledDomains, callbackAggregator = callbackAggregator.copyRef()](auto entries) mutable { >+ >+ Vector<SecurityOriginData> entriesToDelete; >+ for (auto& entry : entries) { >+ if (!topPrivatelyControlledDomains.contains(entry.origin.host)) >+ continue; >+ entriesToDelete.append(entry.origin); >+ callbackAggregator->m_websiteData.entries.append(entry); >+ } >+ clearDiskCacheEntries(cache(), entriesToDelete, [callbackAggregator = callbackAggregator.copyRef()] { }); >+ }); >+ } >+} >+ >+void NetworkProcess::topPrivatelyControlledDomainsWithWebsiteData(PAL::SessionID sessionID, OptionSet<WebsiteDataType> websiteDataTypes, bool shouldNotifyPage, CompletionHandler<void(HashSet<String>&&)>&& completionHandler) >+{ >+ OptionSet<WebsiteDataFetchOption> fetchOptions = WebsiteDataFetchOption::DoNotCreateProcesses; >+ >+ struct CallbackAggregator final : public RefCounted<CallbackAggregator> { >+ explicit CallbackAggregator(CompletionHandler<void(HashSet<String>&&)>&& completionHandler) >+ : m_completionHandler(WTFMove(completionHandler)) >+ { >+ } >+ >+ ~CallbackAggregator() >+ { >+ RunLoop::main().dispatch([completionHandler = WTFMove(m_completionHandler), websiteData = WTFMove(m_websiteData)] () mutable { >+ HashSet<String> origins; >+ for (const auto& hostnameWithCookies : websiteData.hostNamesWithCookies) >+ origins.add(hostnameWithCookies); >+ >+ for (const auto& hostnameWithHSTS : websiteData.hostNamesWithHSTSCache) >+ origins.add(hostnameWithHSTS); >+ >+ for (const auto& entry : websiteData.entries) >+ origins.add(entry.origin.host); >+ >+ completionHandler(WTFMove(origins)); >+ }); >+ } >+ >+ CompletionHandler<void(HashSet<String>&&)> m_completionHandler; >+ WebsiteData m_websiteData; >+ }; >+ >+ auto callbackAggregator = adoptRef(*new CallbackAggregator([this, completionHandler = WTFMove(completionHandler), shouldNotifyPage] (HashSet<String>&& originsWithData) mutable { >+ if (shouldNotifyPage) >+ parentProcessConnection()->send(Messages::NetworkProcessProxy::NotifyWebsiteDataScanForTopPrivatelyControlledDomainsFinished(), 0); >+ >+ RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler), originsWithData = crossThreadCopy(originsWithData)] () mutable { >+ completionHandler(WTFMove(originsWithData)); >+ }); >+ })); >+ >+ auto& websiteDataStore = callbackAggregator->m_websiteData; >+ >+ Vector<String> hostnamesWithCookiesToDelete; >+ if (websiteDataTypes.contains(WebsiteDataType::Cookies)) { >+ if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID)) >+ networkStorageSession->getHostnamesWithCookies(websiteDataStore.hostNamesWithCookies); >+ } >+ >+ Vector<String> hostnamesWithHSTSToDelete; >+#if PLATFORM(COCOA) >+ if (websiteDataTypes.contains(WebsiteDataType::HSTSCache)) { >+ if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID)) >+ getHostNamesWithHSTSCache(*networkStorageSession, websiteDataStore.hostNamesWithHSTSCache); >+ } >+#endif >+ >+ if (websiteDataTypes.contains(WebsiteDataType::Credentials)) { >+ if (NetworkStorageSession::storageSession(sessionID)) >+ websiteDataStore.originsWithCredentials = NetworkStorageSession::storageSession(sessionID)->credentialStorage().originsWithCredentials(); >+ } >+ >+ if (websiteDataTypes.contains(WebsiteDataType::DOMCache)) { >+ CacheStorage::Engine::fetchEntries(*this, sessionID, fetchOptions.contains(WebsiteDataFetchOption::ComputeSizes), [callbackAggregator = callbackAggregator.copyRef()](auto entries) mutable { >+ callbackAggregator->m_websiteData.entries.appendVector(entries); >+ }); >+ } >+ >+#if ENABLE(INDEXED_DATABASE) >+ auto path = m_idbDatabasePaths.get(sessionID); >+ if (!path.isEmpty() && websiteDataTypes.contains(WebsiteDataType::IndexedDBDatabases)) { >+ // FIXME: Pick the right database store based on the session ID. >+ postStorageTask(CrossThreadTask([this, callbackAggregator = callbackAggregator.copyRef(), path = WTFMove(path)]() mutable { >+ RunLoop::main().dispatch([callbackAggregator = callbackAggregator.copyRef(), securityOrigins = indexedDatabaseOrigins(path)] { >+ for (const auto& securityOrigin : securityOrigins) >+ callbackAggregator->m_websiteData.entries.append({ securityOrigin, WebsiteDataType::IndexedDBDatabases, 0 }); >+ }); >+ })); >+ } >+#endif >+ >+#if ENABLE(SERVICE_WORKER) >+ path = m_swDatabasePaths.get(sessionID); >+ if (!path.isEmpty() && websiteDataTypes.contains(WebsiteDataType::ServiceWorkerRegistrations)) { >+ swServerForSession(sessionID).getOriginsWithRegistrations([callbackAggregator = callbackAggregator.copyRef()](const HashSet<SecurityOriginData>& securityOrigins) mutable { >+ for (auto& securityOrigin : securityOrigins) >+ callbackAggregator->m_websiteData.entries.append({ securityOrigin, WebsiteDataType::ServiceWorkerRegistrations, 0 }); >+ }); >+ } >+#endif >+ >+ if (websiteDataTypes.contains(WebsiteDataType::DiskCache)) { >+ fetchDiskCacheEntries(cache(), sessionID, fetchOptions, [callbackAggregator = callbackAggregator.copyRef()](auto entries) mutable { >+ callbackAggregator->m_websiteData.entries.appendVector(entries); >+ }); >+ } >+} >+#endif // ENABLE(RESOURCE_LOAD_STATISTICS) >+ > CacheStorage::Engine* NetworkProcess::findCacheEngine(const PAL::SessionID& sessionID) > { > return m_cacheEngines.get(sessionID); >diff --git a/Source/WebKit/NetworkProcess/NetworkProcess.h b/Source/WebKit/NetworkProcess/NetworkProcess.h >index aec3ea40dacb16049550e771bd800b69fa5861e9..19e8fb9cc2ca54620f8eba92d78f059c01bcadf8 100644 >--- a/Source/WebKit/NetworkProcess/NetworkProcess.h >+++ b/Source/WebKit/NetworkProcess/NetworkProcess.h >@@ -159,17 +159,57 @@ public: > void addWebsiteDataStore(WebsiteDataStoreParameters&&); > > #if ENABLE(RESOURCE_LOAD_STATISTICS) >+ void clearPrevalentResource(PAL::SessionID, const String& resourceDomain, uint64_t contextId); >+ void clearUserInteraction(PAL::SessionID, const String& resourceDomain, uint64_t contextId); >+ void deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(PAL::SessionID, OptionSet<WebsiteDataType>, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&&); >+ void dumpResourceLoadStatistics(PAL::SessionID, uint64_t contextId); > void updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID, const Vector<String>& domainsToBlock, uint64_t contextId); >+ void isGrandfathered(PAL::SessionID, const String& targetPrimaryDomain, uint64_t contextId); >+ void isPrevalentResource(PAL::SessionID, const String& resourceDomain, uint64_t contextId); >+ void isVeryPrevalentResource(PAL::SessionID, const String& resourceDomain, uint64_t contextId); > void setAgeCapForClientSideCookies(PAL::SessionID, Optional<Seconds>, uint64_t contextId); >+ void isRegisteredAsRedirectingTo(PAL::SessionID, const String& redirectedFrom, const String& redirectedTo, uint64_t callbackId); >+ void isRegisteredAsSubFrameUnder(PAL::SessionID, const String& subframe, const String& topFrame, uint64_t contextId); >+ void isRegisteredAsSubresourceUnder(PAL::SessionID, const String& subresource, const String& topFrame, uint64_t contextId); >+ void setGrandfathered(PAL::SessionID, const String& resourceDomain, bool isGrandfathered, uint64_t callbackId); >+ void setMaxStatisticsEntries(PAL::SessionID, uint64_t maximumEntryCount, uint64_t contextId); >+ void setPrevalentResource(PAL::SessionID, const String& resourceDomain, uint64_t contextId); >+ void setPrevalentResourceForDebugMode(PAL::SessionID, String resourceDomain, uint64_t callbackId); >+ void setVeryPrevalentResource(PAL::SessionID, const String& resourceDomain, uint64_t callbackId); >+ void setPruneEntriesDownTo(PAL::SessionID, uint64_t pruneTargetCount, uint64_t contextId); >+ void hadUserInteraction(PAL::SessionID, const String& resourceDomain, uint64_t contextId); > void hasStorageAccessForFrame(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId); > void getAllStorageAccessEntries(PAL::SessionID, uint64_t contextId); >- void grantStorageAccess(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, uint64_t contextId); >+ void grantStorageAccess(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool userWasPrompted, uint64_t contextId); >+ void hasStorageAccess(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, uint64_t contextId); > void logFrameNavigation(PAL::SessionID, const String& targetPrimaryDomain, const String& mainFramePrimaryDomain, const String& sourcePrimaryDomain, const String& targetHost, const String& mainFrameHost, bool isRedirect, bool isMainFrame); > void logUserInteraction(PAL::SessionID, const String& targetPrimaryDomain, uint64_t contextId); > void removeAllStorageAccess(PAL::SessionID, uint64_t contextId); > void removePrevalentDomains(PAL::SessionID, const Vector<String>& domains); >- void setCacheMaxAgeCapForPrevalentResources(PAL::SessionID, Seconds, uint64_t contextId); >+ void requestStorageAccess(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool promptEnabled, uint64_t contextId); > void resetCacheMaxAgeCapForPrevalentResources(PAL::SessionID, uint64_t contextId); >+ void resetParametersToDefaultValues(PAL::SessionID, uint64_t contextId); >+ void scheduleClearInMemoryAndPersistent(PAL::SessionID, Optional<WallTime> modifiedSince, bool shouldGrandfather, uint64_t contextId); >+ void scheduleCookieBlockingUpdate(PAL::SessionID, uint64_t contextId); >+ void scheduleStatisticsAndDataRecordsProcessing(PAL::SessionID, uint64_t contextId); >+ void submitTelemetry(PAL::SessionID, uint64_t callbackId); >+ void setCacheMaxAgeCapForPrevalentResources(PAL::SessionID, Seconds, uint64_t contextId); >+ void setGrandfatheringTime(PAL::SessionID, Seconds, uint64_t contextId); >+ void setLastSeen(PAL::SessionID, const String& resourceDomain, Seconds, uint64_t contextId); >+ void setMinimumTimeBetweenDataRecordsRemoval(PAL::SessionID, Seconds, uint64_t contextId); >+ void setNotifyPagesWhenDataRecordsWereScanned(PAL::SessionID, bool value, uint64_t contextId); >+ void setNotifyPagesWhenTelemetryWasCaptured(PAL::SessionID, bool value, uint64_t callbackId); >+ void setResourceLoadStatisticsEnabled(bool); >+ void setResourceLoadStatisticsDebugMode(PAL::SessionID, bool debugMode, uint64_t callbackId); >+ void setShouldClassifyResourcesBeforeDataRecordsRemoval(PAL::SessionID, bool value, uint64_t contextId); >+ void setSubframeUnderTopFrameOrigin(PAL::SessionID, String subframe, String topFrame, uint64_t contextId); >+ void setSubresourceUnderTopFrameOrigin(PAL::SessionID, String subresource, String topFrame, uint64_t callbackId); >+ void setSubresourceUniqueRedirectTo(PAL::SessionID, String subresource, String hostNameRedirectedTo, uint64_t callbackId); >+ void setSubresourceUniqueRedirectFrom(PAL::SessionID, String subresource, String hostNameRedirectedFrom, uint64_t callbackId); >+ void setTimeToLiveUserInteraction(PAL::SessionID, Seconds, uint64_t contextId); >+ void setTopFrameUniqueRedirectTo(PAL::SessionID, String topFrameHostName, String hostNameRedirectedTo, uint64_t callbackId); >+ void setTopFrameUniqueRedirectFrom(PAL::SessionID, String topFrameHostName, String hostNameRedirectedFrom, uint64_t callbackId); >+ void topPrivatelyControlledDomainsWithWebsiteData(PAL::SessionID, OptionSet<WebsiteDataType>, bool shouldNotifyPage, CompletionHandler<void(HashSet<String>&&)>&&); > #endif > > using CacheStorageParametersCallback = CompletionHandler<void(const String&, uint64_t quota)>; >diff --git a/Source/WebKit/NetworkProcess/NetworkProcess.messages.in b/Source/WebKit/NetworkProcess/NetworkProcess.messages.in >index 8ba1675dc88e64b659acc9f413e86a5c1c36e7d9..4473283fae36884db4b221540408773390666082 100644 >--- a/Source/WebKit/NetworkProcess/NetworkProcess.messages.in >+++ b/Source/WebKit/NetworkProcess/NetworkProcess.messages.in >@@ -85,16 +85,54 @@ messages -> NetworkProcess LegacyReceiver { > PreconnectTo(URL url, enum:bool WebCore::StoredCredentialsPolicy storedCredentialsPolicy); > > #if ENABLE(RESOURCE_LOAD_STATISTICS) >+ ClearPrevalentResource(PAL::SessionID sessionID, String resourceDomain, uint64_t contextId) >+ ClearUserInteraction(PAL::SessionID sessionID, String resourceDomain, uint64_t contextId) >+ DumpResourceLoadStatistics(PAL::SessionID sessionID, uint64_t contextId) >+ SetResourceLoadStatisticsEnabled(bool enabled) > UpdatePrevalentDomainsToBlockCookiesFor(PAL::SessionID sessionID, Vector<String> domainsToBlock, uint64_t contextId) >+ IsGrandfathered(PAL::SessionID sessionID, String targetPrimaryDomain, uint64_t contextId) >+ IsPrevalentResource(PAL::SessionID sessionID, String targetPrimaryDomain, uint64_t contextId) >+ IsVeryPrevalentResource(PAL::SessionID sessionID, String targetPrimaryDomain, uint64_t contextId) > SetAgeCapForClientSideCookies(PAL::SessionID sessionID, Optional<Seconds> seconds, uint64_t contextId) >+ SetLastSeen(PAL::SessionID sessionID, String resourceDomain, Seconds seconds, uint64_t contextId) >+ SetPrevalentResource(PAL::SessionID sessionID, String resourceDomain, uint64_t contextId) >+ SetPrevalentResourceForDebugMode(PAL::SessionID sessionID, String resourceDomain, uint64_t callbackId); >+ HadUserInteraction(PAL::SessionID sessionID, String resourceDomain, uint64_t contextId) > HasStorageAccessForFrame(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId) >+ HasStorageAccess(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, uint64_t contextId) > GetAllStorageAccessEntries(PAL::SessionID sessionID, uint64_t contextId) >- GrantStorageAccess(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, uint64_t contextId) >+ GrantStorageAccess(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool userWasPrompted, uint64_t contextId) >+ IsRegisteredAsRedirectingTo(PAL::SessionID sessionID, String redirectedFrom, String redirectedTo, uint64_t callbackId) >+ IsRegisteredAsSubFrameUnder(PAL::SessionID sessionID, String subframe, String topFrame, uint64_t contextId) >+ IsRegisteredAsSubresourceUnder(PAL::SessionID sessionID, String subresource, String topFrame, uint64_t contextId) > LogFrameNavigation(PAL::SessionID sessionID, String targetPrimaryDomain, String mainFramePrimaryDomain, String sourcePrimaryDomain, String targetHost, String mainFrameHost, bool isRedirect, bool isMainFrame) > LogUserInteraction(PAL::SessionID sessionID, String targetPrimaryDomain, uint64_t contextId) > RemoveAllStorageAccess(PAL::SessionID sessionID, uint64_t contextId) > RemovePrevalentDomains(PAL::SessionID sessionID, Vector<String> domainsWithInteraction) >+ RequestStorageAccess(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool promptEnabled, uint64_t contextId) >+ ResetParametersToDefaultValues(PAL::SessionID sessionID, uint64_t contextId) >+ ScheduleClearInMemoryAndPersistent(PAL::SessionID sessionID, Optional<WallTime> modifiedSince, bool shouldGrandfather, uint64_t contextId) >+ ScheduleCookieBlockingUpdate(PAL::SessionID sessionID, uint64_t contextId) >+ ScheduleStatisticsAndDataRecordsProcessing(PAL::SessionID sessionID, uint64_t contextId) >+ SubmitTelemetry(PAL::SessionID sessionID, uint64_t callbackId) > SetCacheMaxAgeCapForPrevalentResources(PAL::SessionID sessionID, Seconds seconds, uint64_t contextId) >+ SetGrandfathered(PAL::SessionID sessionID, String resourceDomain, bool isGrandfathered, uint64_t callbackId) >+ SetGrandfatheringTime(PAL::SessionID sessionID, Seconds seconds, uint64_t contextId) >+ SetMaxStatisticsEntries(PAL::SessionID sessionID, uint64_t maximumEntryCount, uint64_t contextId) >+ SetMinimumTimeBetweenDataRecordsRemoval(PAL::SessionID sessionID, Seconds seconds, uint64_t contextId) >+ SetPruneEntriesDownTo(PAL::SessionID sessionID, uint64_t maximumEntryCount, uint64_t contextId) >+ SetShouldClassifyResourcesBeforeDataRecordsRemoval(PAL::SessionID sessionID, bool value, uint64_t contextId) >+ SetNotifyPagesWhenDataRecordsWereScanned(PAL::SessionID sessionID, bool value, uint64_t contextId) >+ SetNotifyPagesWhenTelemetryWasCaptured(PAL::SessionID sessionID, bool value, uint64_t callbackId) >+ SetResourceLoadStatisticsDebugMode(PAL::SessionID sessionID, bool debugMode, uint64_t callbackId) >+ SetVeryPrevalentResource(PAL::SessionID sessionID, String resourceDomain, uint64_t callbackId) >+ SetSubframeUnderTopFrameOrigin(PAL::SessionID sessionID, String subframe, String topFrame, uint64_t contextId) >+ SetSubresourceUnderTopFrameOrigin(PAL::SessionID sessionID, String subresource, String topFrame, uint64_t callbackId) >+ SetSubresourceUniqueRedirectTo(PAL::SessionID sessionID, String subresource, String hostNameRedirectedTo, uint64_t callbackId) >+ SetSubresourceUniqueRedirectFrom(PAL::SessionID sessionID, String subresource, String hostNameRedirectedFrom, uint64_t callbackId) >+ SetTimeToLiveUserInteraction(PAL::SessionID sessionID, Seconds seconds, uint64_t contextId) >+ SetTopFrameUniqueRedirectTo(PAL::SessionID sessionID, String topFrameHostName, String hostNameRedirectedTo, uint64_t callbackId) >+ SetTopFrameUniqueRedirectFrom(PAL::SessionID sessionID, String topFrameHostName, String hostNameRedirectedFrom, uint64_t callbackId) > ResetCacheMaxAgeCapForPrevalentResources(PAL::SessionID sessionID, uint64_t contextId) > #endif > >diff --git a/Source/WebKit/NetworkProcess/NetworkSession.cpp b/Source/WebKit/NetworkProcess/NetworkSession.cpp >index 820546d85abfad43a9d690338cba4919b145c386..a1fde2864f4717736d96fd7d1b55d831922b2e33 100644 >--- a/Source/WebKit/NetworkProcess/NetworkSession.cpp >+++ b/Source/WebKit/NetworkProcess/NetworkSession.cpp >@@ -26,6 +26,9 @@ > #include "config.h" > #include "NetworkSession.h" > >+#include "NetworkProcess.h" >+#include "NetworkProcessProxyMessages.h" >+#include "WebProcessProxy.h" > #include "WebResourceLoadStatisticsStore.h" > #include <WebCore/NetworkStorageSession.h> > >@@ -78,12 +81,52 @@ void NetworkSession::invalidateAndCancel() > task->invalidateAndCancel(); > } > >-void NetworkSession::enableResourceLoadStatistics() >+void NetworkSession::setResourceLoadStatisticsEnabled(bool enable) > { >+ if (!enable) { >+ m_resourceLoadStatistics = nullptr; >+ return; >+ } >+ > if (m_resourceLoadStatistics) > return; > > m_resourceLoadStatistics = WebResourceLoadStatisticsStore::create(*this, m_resourceLoadStatisticsDirectory); > } > >+void NetworkSession::notifyResourceLoadStatisticsProcessed() >+{ >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ m_networkProcess->parentProcessConnection()->send(Messages::NetworkProcessProxy::NotifyResourceLoadStatisticsProcessed(), 0); >+#endif >+} >+ >+void NetworkSession::logDiagnosticMessageWithValue(const String& message, const String& description, unsigned value, unsigned significantFigures, WebCore::ShouldSample shouldSample) >+{ >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ m_networkProcess->parentProcessConnection()->send(Messages::WebPageProxy::LogDiagnosticMessageWithValue(message, description, value, significantFigures, shouldSample), 0); >+#endif >+} >+ >+void NetworkSession::notifyPageStatisticsTelemetryFinished(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins) >+{ >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ m_networkProcess->parentProcessConnection()->send(Messages::NetworkProcessProxy::NotifyResourceLoadStatisticsTelemetryFinished(totalPrevalentResources, totalPrevalentResourcesWithUserInteraction, top3SubframeUnderTopFrameOrigins), 0); >+#endif >+} >+ >+void NetworkSession::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType> dataTypes, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&& completionHandler) >+{ >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ m_networkProcess->deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(m_sessionID, dataTypes, WTFMove(topPrivatelyControlledDomains), shouldNotifyPage, WTFMove(completionHandler)); >+#endif >+} >+ >+void NetworkSession::topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType> dataTypes, bool shouldNotifyPage, CompletionHandler<void(HashSet<String>&&)>&& completionHandler) >+{ >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ m_networkProcess->topPrivatelyControlledDomainsWithWebsiteData(m_sessionID, dataTypes, shouldNotifyPage, WTFMove(completionHandler)); >+#endif >+} >+ > } // namespace WebKit >diff --git a/Source/WebKit/NetworkProcess/NetworkSession.h b/Source/WebKit/NetworkProcess/NetworkSession.h >index 4292db757a9381b85a4b95ce325659a7fa39c7be..0ca6564511a2759c606d903489d0e531d668e873 100644 >--- a/Source/WebKit/NetworkProcess/NetworkSession.h >+++ b/Source/WebKit/NetworkProcess/NetworkSession.h >@@ -35,6 +35,7 @@ > > namespace WebCore { > class NetworkStorageSession; >+enum class ShouldSample : bool; > } > > namespace WebKit { >@@ -44,6 +45,8 @@ class NetworkProcess; > class WebResourceLoadStatisticsStore; > struct NetworkSessionCreationParameters; > >+enum class WebsiteDataType; >+ > class NetworkSession : public RefCounted<NetworkSession>, public CanMakeWeakPtr<NetworkSession> { > public: > static Ref<NetworkSession> create(NetworkProcess&, NetworkSessionCreationParameters&&); >@@ -62,8 +65,13 @@ public: > void unregisterNetworkDataTask(NetworkDataTask& task) { m_dataTaskSet.remove(&task); } > > WebResourceLoadStatisticsStore* resourceLoadStatistics() const { return m_resourceLoadStatistics.get(); } >- void enableResourceLoadStatistics(); >- >+ void setResourceLoadStatisticsEnabled(bool); >+ void notifyResourceLoadStatisticsProcessed(); >+ void deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType>, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&&); >+ void topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType>, bool shouldNotifyPage, CompletionHandler<void(HashSet<String>&&)>&&); >+ void logDiagnosticMessageWithValue(const String& message, const String& description, unsigned value, unsigned significantFigures, WebCore::ShouldSample); >+ void notifyPageStatisticsTelemetryFinished(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins); >+ > protected: > NetworkSession(NetworkProcess&, PAL::SessionID); > >diff --git a/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm b/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm >index 0ecd886eb40f0802b112cb77796152f518937442..ca9da915fade57d892aca4ca49983f5247121abb 100644 >--- a/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm >+++ b/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm >@@ -945,8 +945,7 @@ NetworkSessionCocoa::NetworkSessionCocoa(NetworkProcess& networkProcess, Network > m_statelessSession = [NSURLSession sessionWithConfiguration:configuration delegate:static_cast<id>(m_statelessSessionDelegate.get()) delegateQueue:[NSOperationQueue mainQueue]]; > > m_resourceLoadStatisticsDirectory = parameters.resourceLoadStatisticsDirectory; >- if (parameters.enableResourceLoadStatistics) >- enableResourceLoadStatistics(); >+ setResourceLoadStatisticsEnabled(parameters.enableResourceLoadStatistics); > } > > NetworkSessionCocoa::~NetworkSessionCocoa() >diff --git a/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp b/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp >index 61e93c84fd46babf72325424874550d11e7a5c54..23df9bacd0ef440d3657d55ae64694eb5103f038 100644 >--- a/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp >+++ b/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp >@@ -36,7 +36,6 @@ > #include "WKSecurityOriginRef.h" > #include "WKString.h" > #include "WebResourceLoadStatisticsStore.h" >-#include "WebResourceLoadStatisticsTelemetry.h" > #include "WebsiteData.h" > #include "WebsiteDataFetchOption.h" > #include "WebsiteDataRecord.h" >@@ -76,386 +75,324 @@ void WKWebsiteDataStoreSetResourceLoadStatisticsDebugMode(WKWebsiteDataStoreRef > > void WKWebsiteDataStoreSetResourceLoadStatisticsDebugModeWithCompletionHandler(WKWebsiteDataStoreRef dataStoreRef, bool enable, void* context, WKWebsiteDataStoreStatisticsDebugModeFunction completionHandler) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) { >- completionHandler(context); >- return; >- } >- >- store->setResourceLoadStatisticsDebugMode(enable, [context, completionHandler] { >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().setResourceLoadStatisticsDebugMode(enable, [context, completionHandler] { > completionHandler(context); > }); >+#else >+ completionHandler(context); >+#endif > } > > void WKWebsiteDataStoreSetResourceLoadStatisticsPrevalentResourceForDebugMode(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreStatisticsDebugModeFunction completionHandler) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) { >- completionHandler(context); >- return; >- } >- >- store->setPrevalentResourceForDebugMode(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] { >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().setPrevalentResourceForDebugMode(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] { > completionHandler(context); > }); >+#else >+ completionHandler(context); >+#endif > } > void WKWebsiteDataStoreSetStatisticsLastSeen(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, double seconds, void* context, WKWebsiteDataStoreStatisticsLastSeenFunction completionHandler) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) { >- completionHandler(context); >- return; >- } >- >- store->setLastSeen(URL(URL(), WebKit::toImpl(host)->string()), Seconds { seconds }, [context, completionHandler] { >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().setLastSeen(URL(URL(), WebKit::toImpl(host)->string()), Seconds { seconds }, [context, completionHandler] { > completionHandler(context); > }); >+#else >+ completionHandler(context); >+#endif > } > > void WKWebsiteDataStoreSetStatisticsPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value, void* context, WKWebsiteDataStoreStatisticsPrevalentResourceFunction completionHandler) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) { >- completionHandler(context); >- return; >- } >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ auto& websiteDataStore = WebKit::toImpl(dataStoreRef)->websiteDataStore(); > > if (value) >- store->setPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] { >+ websiteDataStore.setPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] { > completionHandler(context); > }); > else >- store->clearPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] { >+ websiteDataStore.clearPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] { > completionHandler(context); > }); >+#else >+ completionHandler(context); >+#endif > } > > void WKWebsiteDataStoreSetStatisticsVeryPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value, void* context, WKWebsiteDataStoreStatisticsVeryPrevalentResourceFunction completionHandler) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) { >- completionHandler(context); >- return; >- } >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ auto& websiteDataStore = WebKit::toImpl(dataStoreRef)->websiteDataStore(); > > if (value) >- store->setVeryPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] { >+ websiteDataStore.setVeryPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] { > completionHandler(context); > }); > else >- store->clearPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] { >+ websiteDataStore.clearPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] { > completionHandler(context); > }); >+#else >+ completionHandler(context); >+#endif > } > > void WKWebsiteDataStoreDumpResourceLoadStatistics(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreDumpResourceLoadStatisticsFunction callback) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) { >- callback(WebKit::toAPI(emptyString().impl()), context); >- return; >- } >- >- store->dumpResourceLoadStatistics([context, callback] (const String& resourceLoadStatistics) { >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().dumpResourceLoadStatistics([context, callback] (const String& resourceLoadStatistics) { > callback(WebKit::toAPI(resourceLoadStatistics.impl()), context); > }); >+#else >+ callback(WebKit::toAPI(emptyString().impl()), context); >+#endif > } > > void WKWebsiteDataStoreIsStatisticsPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsPrevalentResourceFunction callback) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) { >- callback(false, context); >- return; >- } >- >- store->isPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, callback](bool isPrevalentResource) { >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().isPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, callback](bool isPrevalentResource) { > callback(isPrevalentResource, context); > }); >+#else >+ callback(false, context); >+#endif > } > > void WKWebsiteDataStoreIsStatisticsVeryPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsPrevalentResourceFunction callback) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) { >- callback(false, context); >- return; >- } >- >- store->isVeryPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, callback](bool isVeryPrevalentResource) { >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().isVeryPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, callback](bool isVeryPrevalentResource) { > callback(isVeryPrevalentResource, context); > }); >+#else >+ callback(false, context); >+#endif > } > > void WKWebsiteDataStoreIsStatisticsRegisteredAsSubresourceUnder(WKWebsiteDataStoreRef dataStoreRef, WKStringRef subresourceHost, WKStringRef topFrameHost, void* context, WKWebsiteDataStoreIsStatisticsRegisteredAsSubresourceUnderFunction callback) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) { >- callback(false, context); >- return; >- } >- >- store->isRegisteredAsSubresourceUnder(URL(URL(), WebKit::toImpl(subresourceHost)->string()), URL(URL(), WebKit::toImpl(topFrameHost)->string()), [context, callback](bool isRegisteredAsSubresourceUnder) { >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().isRegisteredAsSubresourceUnder(URL(URL(), WebKit::toImpl(subresourceHost)->string()), URL(URL(), WebKit::toImpl(topFrameHost)->string()), [context, callback](bool isRegisteredAsSubresourceUnder) { > callback(isRegisteredAsSubresourceUnder, context); > }); >+#else >+ callback(false, context); >+#endif > } > > void WKWebsiteDataStoreIsStatisticsRegisteredAsSubFrameUnder(WKWebsiteDataStoreRef dataStoreRef, WKStringRef subFrameHost, WKStringRef topFrameHost, void* context, WKWebsiteDataStoreIsStatisticsRegisteredAsSubFrameUnderFunction callback) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) { >- callback(false, context); >- return; >- } >- >- store->isRegisteredAsSubFrameUnder(URL(URL(), WebKit::toImpl(subFrameHost)->string()), URL(URL(), WebKit::toImpl(topFrameHost)->string()), [context, callback](bool isRegisteredAsSubFrameUnder) { >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().isRegisteredAsSubFrameUnder(URL(URL(), WebKit::toImpl(subFrameHost)->string()), URL(URL(), WebKit::toImpl(topFrameHost)->string()), [context, callback](bool isRegisteredAsSubFrameUnder) { > callback(isRegisteredAsSubFrameUnder, context); > }); >+#else >+ callback(false, context); >+#endif > } > > void WKWebsiteDataStoreIsStatisticsRegisteredAsRedirectingTo(WKWebsiteDataStoreRef dataStoreRef, WKStringRef hostRedirectedFrom, WKStringRef hostRedirectedTo, void* context, WKWebsiteDataStoreIsStatisticsRegisteredAsRedirectingToFunction callback) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) { >- callback(false, context); >- return; >- } >- >- store->isRegisteredAsRedirectingTo(URL(URL(), WebKit::toImpl(hostRedirectedFrom)->string()), URL(URL(), WebKit::toImpl(hostRedirectedTo)->string()), [context, callback](bool isRegisteredAsRedirectingTo) { >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().isRegisteredAsRedirectingTo(URL(URL(), WebKit::toImpl(hostRedirectedFrom)->string()), URL(URL(), WebKit::toImpl(hostRedirectedTo)->string()), [context, callback](bool isRegisteredAsRedirectingTo) { > callback(isRegisteredAsRedirectingTo, context); > }); >+#else >+ callback(false, context); >+#endif > } > > void WKWebsiteDataStoreSetStatisticsHasHadUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value, void* context, WKWebsiteDataStoreStatisticsHasHadUserInteractionFunction completionHandler) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) { >- completionHandler(context); >- return; >- } >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ auto& dataStore = WebKit::toImpl(dataStoreRef)->websiteDataStore(); > > if (value) >- store->logUserInteraction(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] { >+ dataStore.logUserInteraction(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] { > completionHandler(context); > }); > else >- store->clearUserInteraction(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] { >+ dataStore.clearUserInteraction(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] { > completionHandler(context); > }); >+#else >+ completionHandler(context); >+#endif > } > > void WKWebsiteDataStoreIsStatisticsHasHadUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsHasHadUserInteractionFunction callback) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) { >- callback(false, context); >- return; >- } >- >- store->hasHadUserInteraction(URL(URL(), WebKit::toImpl(host)->string()), [context, callback](bool hasHadUserInteraction) { >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().hasHadUserInteraction(URL(URL(), WebKit::toImpl(host)->string()), [context, callback](bool hasHadUserInteraction) { > callback(hasHadUserInteraction, context); > }); >+#else >+ callback(false, context); >+#endif > } > > void WKWebsiteDataStoreSetStatisticsGrandfathered(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) >- return; >- >- store->setGrandfathered(URL(URL(), WebKit::toImpl(host)->string()), value); >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().setGrandfathered(URL(URL(), WebKit::toImpl(host)->string()), value, [] { }); >+#endif > } > > void WKWebsiteDataStoreIsStatisticsGrandfathered(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsGrandfatheredFunction callback) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) { >- callback(false, context); >- return; >- } >- >- store->hasHadUserInteraction(URL(URL(), WebKit::toImpl(host)->string()), [context, callback](bool isGrandfathered) { >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().hasHadUserInteraction(URL(URL(), WebKit::toImpl(host)->string()), [context, callback](bool isGrandfathered) { > callback(isGrandfathered, context); > }); >+#else >+ callback(false, context); >+#endif > } > > void WKWebsiteDataStoreSetStatisticsSubframeUnderTopFrameOrigin(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef topFrameHost) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) >- return; >- >- store->setSubframeUnderTopFrameOrigin(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(topFrameHost)->string())); >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().setSubframeUnderTopFrameOrigin(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(topFrameHost)->string()), [] { }); >+#endif > } > > void WKWebsiteDataStoreSetStatisticsSubresourceUnderTopFrameOrigin(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef topFrameHost) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) >- return; >- >- store->setSubresourceUnderTopFrameOrigin(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(topFrameHost)->string())); >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().setSubresourceUnderTopFrameOrigin(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(topFrameHost)->string()), [] { }); >+#endif > } > > void WKWebsiteDataStoreSetStatisticsSubresourceUniqueRedirectTo(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef hostRedirectedTo) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) >- return; >- >- store->setSubresourceUniqueRedirectTo(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(hostRedirectedTo)->string())); >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().setSubresourceUniqueRedirectTo(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(hostRedirectedTo)->string()), [] { }); >+#endif > } > > void WKWebsiteDataStoreSetStatisticsSubresourceUniqueRedirectFrom(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef hostRedirectedFrom) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) >- return; >- >- store->setSubresourceUniqueRedirectFrom(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(hostRedirectedFrom)->string())); >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().setSubresourceUniqueRedirectFrom(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(hostRedirectedFrom)->string()), [] { }); >+#endif > } > > void WKWebsiteDataStoreSetStatisticsTopFrameUniqueRedirectTo(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef hostRedirectedTo) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) >- return; >- >- store->setTopFrameUniqueRedirectTo(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(hostRedirectedTo)->string())); >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().setTopFrameUniqueRedirectTo(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(hostRedirectedTo)->string()), [] { }); >+#endif > } > > void WKWebsiteDataStoreSetStatisticsTopFrameUniqueRedirectFrom(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef hostRedirectedFrom) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) >- return; >- >- store->setTopFrameUniqueRedirectFrom(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(hostRedirectedFrom)->string())); >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().setTopFrameUniqueRedirectFrom(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(hostRedirectedFrom)->string()), [] { }); >+#endif > } > > void WKWebsiteDataStoreSetStatisticsTimeToLiveUserInteraction(WKWebsiteDataStoreRef dataStoreRef, double seconds) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) >- return; >- >- store->setTimeToLiveUserInteraction(Seconds { seconds }); >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().setTimeToLiveUserInteraction(Seconds { seconds }, [] { }); >+#endif > } > > void WKWebsiteDataStoreStatisticsProcessStatisticsAndDataRecords(WKWebsiteDataStoreRef dataStoreRef) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) >- return; >- >- store->scheduleStatisticsAndDataRecordsProcessing(); >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().scheduleStatisticsAndDataRecordsProcessing([] { }); >+#endif > } > > void WKWebsiteDataStoreStatisticsUpdateCookieBlocking(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreStatisticsUpdateCookieBlockingFunction completionHandler) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) { >- completionHandler(context); >- return; >- } >- >- store->scheduleCookieBlockingUpdate([context, completionHandler]() { >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().scheduleCookieBlockingUpdate([context, completionHandler]() { > completionHandler(context); > }); >+#endif > } > > void WKWebsiteDataStoreStatisticsSubmitTelemetry(WKWebsiteDataStoreRef dataStoreRef) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) >- return; >- >- store->submitTelemetry(); >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().submitTelemetry(); >+#endif > } > > void WKWebsiteDataStoreSetStatisticsNotifyPagesWhenDataRecordsWereScanned(WKWebsiteDataStoreRef dataStoreRef, bool value) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) >- return; >- >- store->setNotifyPagesWhenDataRecordsWereScanned(value); >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().setNotifyPagesWhenDataRecordsWereScanned(value, [] { }); >+#endif > } > > void WKWebsiteDataStoreSetStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(WKWebsiteDataStoreRef dataStoreRef, bool value) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) >- return; >- >- store->setShouldClassifyResourcesBeforeDataRecordsRemoval(value); >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().setShouldClassifyResourcesBeforeDataRecordsRemoval(value, []() { }); >+#endif > } > >-void WKWebsiteDataStoreSetStatisticsNotifyPagesWhenTelemetryWasCaptured(WKWebsiteDataStoreRef, bool value) >+void WKWebsiteDataStoreSetStatisticsNotifyPagesWhenTelemetryWasCaptured(WKWebsiteDataStoreRef dataStoreRef, bool value) > { >- WebKit::WebResourceLoadStatisticsTelemetry::setNotifyPagesWhenTelemetryWasCaptured(value); >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().setNotifyPagesWhenTelemetryWasCaptured(value, []() { }); >+#endif > } > > void WKWebsiteDataStoreSetStatisticsMinimumTimeBetweenDataRecordsRemoval(WKWebsiteDataStoreRef dataStoreRef, double seconds) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) >- return; >- >- store->setMinimumTimeBetweenDataRecordsRemoval(Seconds { seconds }); >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().setMinimumTimeBetweenDataRecordsRemoval(Seconds { seconds }, []() { }); >+#endif > } > > void WKWebsiteDataStoreSetStatisticsGrandfatheringTime(WKWebsiteDataStoreRef dataStoreRef, double seconds) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) >- return; >- >- store->setGrandfatheringTime(Seconds {seconds }); >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().setGrandfatheringTime(Seconds { seconds }, []() { }); >+#endif > } > > void WKWebsiteDataStoreSetStatisticsMaxStatisticsEntries(WKWebsiteDataStoreRef dataStoreRef, unsigned entries) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) >- return; >- >- store->setMaxStatisticsEntries(entries); >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().setMaxStatisticsEntries(entries, []() { }); >+#endif > } > > void WKWebsiteDataStoreSetStatisticsPruneEntriesDownTo(WKWebsiteDataStoreRef dataStoreRef, unsigned entries) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) >- return; >- >- store->setPruneEntriesDownTo(entries); >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().setPruneEntriesDownTo(entries, []() { }); >+#endif > } > > void WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStore(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStoreFunction callback) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) { >- callback(context); >- return; >- } >- >- store->scheduleClearInMemoryAndPersistent(WebKit::WebResourceLoadStatisticsStore::ShouldGrandfather::Yes, [context, callback]() { >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().scheduleClearInMemoryAndPersistent(ShouldGrandfather::Yes, [context, callback]() { > callback(context); > }); >+#else >+ callback(context); >+#endif > } > > void WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours(WKWebsiteDataStoreRef dataStoreRef, unsigned hours, void* context, WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStoreModifiedSinceHoursFunction callback) > { >- auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); >- if (!store) { >- callback(context); >- return; >- } >- >- store->scheduleClearInMemoryAndPersistent(WallTime::now() - Seconds::fromHours(hours), WebKit::WebResourceLoadStatisticsStore::ShouldGrandfather::Yes, [context, callback]() { >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ WebKit::toImpl(dataStoreRef)->websiteDataStore().scheduleClearInMemoryAndPersistent(WallTime::now() - Seconds::fromHours(hours), ShouldGrandfather::Yes, [context, callback]() { > callback(context); > }); >+#endif > } > > void WKWebsiteDataStoreStatisticsClearThroughWebsiteDataRemoval(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreStatisticsClearThroughWebsiteDataRemovalFunction callback) >@@ -482,13 +419,10 @@ void WKWebsiteDataStoreStatisticsResetToConsistentState(WKWebsiteDataStoreRef da > auto& store = WebKit::toImpl(dataStoreRef)->websiteDataStore(); > store.clearResourceLoadStatisticsInWebProcesses([callbackAggregator = callbackAggregator.copyRef()] { }); > store.resetCacheMaxAgeCapForPrevalentResources([callbackAggregator = callbackAggregator.copyRef()] { }); >- >- auto* statisticsStore = store.resourceLoadStatistics(); >- if (!statisticsStore) >- return; >- >- statisticsStore->resetParametersToDefaultValues([callbackAggregator = callbackAggregator.copyRef()] { }); >- statisticsStore->scheduleClearInMemoryAndPersistent(WebKit::WebResourceLoadStatisticsStore::ShouldGrandfather::No, [callbackAggregator = callbackAggregator.copyRef()] { }); >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ store.resetParametersToDefaultValues([callbackAggregator = callbackAggregator.copyRef()] { }); >+ store.scheduleClearInMemoryAndPersistent(ShouldGrandfather::No, [callbackAggregator = callbackAggregator.copyRef()] { }); >+#endif > } > > void WKWebsiteDataStoreRemoveAllFetchCaches(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreRemoveFetchCacheRemovalFunction callback) >diff --git a/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm b/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm >index 2d160ea3b1288fe84dc1d8293c0a328381feb26a..b1a35adf0d1abebc040556ce6916041cf89cf3bb 100644 >--- a/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm >+++ b/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm >@@ -344,11 +344,7 @@ - (void)_setResourceLoadStatisticsTestingCallback:(void (^)(WKWebsiteDataStore * > return; > } > >- auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics(); >- if (!store) >- return; >- >- store->setStatisticsTestingCallback(nullptr); >+ _websiteDataStore->websiteDataStore().setStatisticsTestingCallback(nullptr); > } > > + (void)_allowWebsiteDataRecordsForAllOrigins >diff --git a/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp b/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp >index 600c0bc39aec39269a8dfed9f5aece90e34224b9..e1666ff958aca78eaaef16831215ab991a8b50e4 100644 >--- a/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp >+++ b/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2012-2018 Apple Inc. All rights reserved. >+ * Copyright (C) 2012-2019 Apple Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -41,6 +41,8 @@ > #include "WebPageProxy.h" > #include "WebProcessMessages.h" > #include "WebProcessPool.h" >+#include "WebProcessProxy.h" >+#include "WebResourceLoadStatisticsStore.h" > #include "WebUserContentControllerProxy.h" > #include "WebsiteData.h" > #include <wtf/CompletionHandler.h> >@@ -231,8 +233,8 @@ void NetworkProcessProxy::clearCallbackStates() > while (!m_pendingDeleteWebsiteDataForOriginsCallbacks.isEmpty()) > m_pendingDeleteWebsiteDataForOriginsCallbacks.take(m_pendingDeleteWebsiteDataForOriginsCallbacks.begin()->key)(); > >- while (!m_updateBlockCookiesCallbackMap.isEmpty()) >- m_updateBlockCookiesCallbackMap.take(m_updateBlockCookiesCallbackMap.begin()->key)(); >+ while (!m_scheduleStatisticsProcessingCallbackMap.isEmpty()) >+ m_scheduleStatisticsProcessingCallbackMap.take(m_scheduleStatisticsProcessingCallbackMap.begin()->key)(); > > while (!m_storageAccessResponseCallbackMap.isEmpty()) > m_storageAccessResponseCallbackMap.take(m_storageAccessResponseCallbackMap.begin()->key)(false); >@@ -276,9 +278,9 @@ void NetworkProcessProxy::didClose(IPC::Connection&) > callback(); > m_removeAllStorageAccessCallbackMap.clear(); > >- for (auto& callback : m_updateBlockCookiesCallbackMap.values()) >+ for (auto& callback : m_scheduleStatisticsProcessingCallbackMap.values()) > callback(); >- m_updateBlockCookiesCallbackMap.clear(); >+ m_scheduleStatisticsProcessingCallbackMap.clear(); > > // This will cause us to be deleted. > networkProcessCrashed(); >@@ -398,7 +400,33 @@ void NetworkProcessProxy::logDiagnosticMessageWithValue(uint64_t pageID, const S > page->logDiagnosticMessageWithValue(message, description, value, significantFigures, shouldSample); > } > >+void NetworkProcessProxy::logGlobalDiagnosticMessageWithValue(const String& message, const String& description, double value, unsigned significantFigures, WebCore::ShouldSample shouldSample) >+{ >+ if (auto* page = WebPageProxy::nonEphemeralWebPageProxy()) >+ page->logDiagnosticMessageWithValue(message, description, value, significantFigures, shouldSample); >+} >+ > #if ENABLE(RESOURCE_LOAD_STATISTICS) >+void NetworkProcessProxy::dumpResourceLoadStatistics(PAL::SessionID sessionID, CompletionHandler<void(const String&)>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler({ }); >+ return; >+ } >+ >+ auto callbackId = generateCallbackID(); >+ auto addResult = m_dumpStatisticsCallbackMap.add(callbackId, [protectedProcessPool = makeRef(m_processPool), token = throttler().backgroundActivityToken(), completionHandler = WTFMove(completionHandler)](const String& dumpedStatistics) mutable { >+ completionHandler(dumpedStatistics); >+ }); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::DumpResourceLoadStatistics(sessionID, callbackId), 0); >+} >+ >+void NetworkProcessProxy::didDumpResourceLoadStatistics(String dumpedStatistics, uint64_t callbackId) >+{ >+ m_dumpStatisticsCallbackMap.take(callbackId)(dumpedStatistics); >+} >+ > void NetworkProcessProxy::updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID sessionID, const Vector<String>& domainsToBlock, CompletionHandler<void()>&& completionHandler) > { > if (!canSendMessage()) { >@@ -407,7 +435,7 @@ void NetworkProcessProxy::updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID > } > > auto callbackId = generateCallbackID(); >- auto addResult = m_updateBlockCookiesCallbackMap.add(callbackId, [protectedProcessPool = makeRef(m_processPool), token = throttler().backgroundActivityToken(), completionHandler = WTFMove(completionHandler)]() mutable { >+ auto addResult = m_scheduleStatisticsProcessingCallbackMap.add(callbackId, [protectedProcessPool = makeRef(m_processPool), token = throttler().backgroundActivityToken(), completionHandler = WTFMove(completionHandler)]() mutable { > completionHandler(); > }); > ASSERT_UNUSED(addResult, addResult.isNewEntry); >@@ -416,13 +444,206 @@ void NetworkProcessProxy::updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID > > void NetworkProcessProxy::didUpdateBlockCookies(uint64_t callbackId) > { >- m_updateBlockCookiesCallbackMap.take(callbackId)(); >+ m_scheduleStatisticsProcessingCallbackMap.take(callbackId)(); >+} >+ >+void NetworkProcessProxy::isPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void(bool)>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(false); >+ return; >+ } >+ >+ auto callbackId = generateCallbackID(); >+ auto addResult = m_isPrevalentResourceCallbackMap.add(callbackId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::IsPrevalentResource(sessionID, resourceDomain, callbackId), 0); > } > >-void NetworkProcessProxy::didLogUserInteraction(uint64_t contextId) >+void NetworkProcessProxy::isPrevalentResourceResult(bool isPrevalent, uint64_t callbackId) > { >- // FIXME(193297): Implement when activating automated test cases. >- UNUSED_PARAM(contextId); >+ m_isPrevalentResourceCallbackMap.take(callbackId)(isPrevalent); >+} >+ >+void NetworkProcessProxy::isVeryPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void(bool)>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(false); >+ return; >+ } >+ >+ auto callbackId = generateCallbackID(); >+ auto addResult = m_isPrevalentResourceCallbackMap.add(callbackId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::IsVeryPrevalentResource(sessionID, resourceDomain, callbackId), 0); >+} >+ >+void NetworkProcessProxy::setPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackId = generateCallbackID(); >+ auto addResult = m_setResourceLoadStatisticDataCallbackMap.add(callbackId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::SetPrevalentResource(sessionID, resourceDomain, callbackId), 0); >+} >+ >+void NetworkProcessProxy::setPrevalentResourceForDebugMode(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackId = generateCallbackID(); >+ auto addResult = m_setResourceLoadStatisticDataCallbackMap.add(callbackId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::SetPrevalentResourceForDebugMode(sessionID, resourceDomain, callbackId), 0); >+} >+ >+void NetworkProcessProxy::setVeryPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackId = generateCallbackID(); >+ auto addResult = m_setResourceLoadStatisticDataCallbackMap.add(callbackId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::SetVeryPrevalentResource(sessionID, resourceDomain, callbackId), 0); >+} >+ >+void NetworkProcessProxy::didSetResourceLoadStatisticData(uint64_t callbackId) >+{ >+ m_setResourceLoadStatisticDataCallbackMap.take(callbackId)(); >+} >+ >+void NetworkProcessProxy::setLastSeen(PAL::SessionID sessionID, const String& resourceDomain, Seconds lastSeen, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackId = generateCallbackID(); >+ auto addResult = m_setResourceLoadStatisticDataCallbackMap.add(callbackId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::SetLastSeen(sessionID, resourceDomain, lastSeen, callbackId), 0); >+} >+ >+void NetworkProcessProxy::clearPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackId = generateCallbackID(); >+ auto addResult = m_setResourceLoadStatisticDataCallbackMap.add(callbackId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::ClearPrevalentResource(sessionID, resourceDomain, callbackId), 0); >+} >+ >+void NetworkProcessProxy::scheduleCookieBlockingUpdate(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackId = generateCallbackID(); >+ auto addResult = m_scheduleStatisticsProcessingCallbackMap.add(callbackId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::ScheduleCookieBlockingUpdate(sessionID, callbackId), 0); >+} >+ >+void NetworkProcessProxy::didScheduleCookieBlockingUpdate(uint64_t callbackId) >+{ >+ m_scheduleStatisticsProcessingCallbackMap.take(callbackId)(); >+} >+ >+void NetworkProcessProxy::scheduleClearInMemoryAndPersistent(PAL::SessionID sessionID, Optional<WallTime> modifiedSince, ShouldGrandfather shouldGrandfather, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackId = generateCallbackID(); >+ auto addResult = m_scheduleStatisticsProcessingCallbackMap.add(callbackId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ bool shouldGrandfatherBool = shouldGrandfather == ShouldGrandfather::Yes; >+ send(Messages::NetworkProcess::ScheduleClearInMemoryAndPersistent(sessionID, modifiedSince, shouldGrandfatherBool, callbackId), 0); >+} >+ >+void NetworkProcessProxy::didScheduleStatisticsProcessing(uint64_t callbackId) >+{ >+ m_scheduleStatisticsProcessingCallbackMap.take(callbackId)(); >+} >+ >+void NetworkProcessProxy::scheduleStatisticsAndDataRecordsProcessing(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackId = generateCallbackID(); >+ auto addResult = m_scheduleStatisticsProcessingCallbackMap.add(callbackId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::ScheduleStatisticsAndDataRecordsProcessing(sessionID, callbackId), 0); >+} >+ >+void NetworkProcessProxy::logUserInteraction(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackId = generateCallbackID(); >+ auto addResult = m_setResourceLoadStatisticDataCallbackMap.add(callbackId, [protectedProcessPool = makeRef(m_processPool), token = throttler().backgroundActivityToken(), completionHandler = WTFMove(completionHandler)]() mutable { >+ completionHandler(); >+ }); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::LogUserInteraction(sessionID, resourceDomain, callbackId), 0); >+} >+ >+void NetworkProcessProxy::hasHadUserInteraction(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void(bool)>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(false); >+ return; >+ } >+ >+ auto callbackId = generateCallbackID(); >+ auto addResult = m_isPrevalentResourceCallbackMap.add(callbackId, [protectedProcessPool = makeRef(m_processPool), token = throttler().backgroundActivityToken(), completionHandler = WTFMove(completionHandler)](bool hadInteraction) mutable { >+ completionHandler(hadInteraction); >+ }); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::HadUserInteraction(sessionID, resourceDomain, callbackId), 0); >+} >+ >+void NetworkProcessProxy::didHaveUserInteraction(bool hadInteraction, uint64_t callbackId) >+{ >+ m_isPrevalentResourceCallbackMap.take(callbackId)(hadInteraction); >+} >+ >+void NetworkProcessProxy::clearUserInteraction(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackId = generateCallbackID(); >+ auto addResult = m_setResourceLoadStatisticDataCallbackMap.add(callbackId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::ClearUserInteraction(sessionID, resourceDomain, callbackId), 0); > } > > void NetworkProcessProxy::setAgeCapForClientSideCookies(PAL::SessionID sessionID, Optional<Seconds> seconds, CompletionHandler<void()>&& completionHandler) >@@ -433,7 +654,7 @@ void NetworkProcessProxy::setAgeCapForClientSideCookies(PAL::SessionID sessionID > } > > auto callbackId = generateCallbackID(); >- auto addResult = m_updateBlockCookiesCallbackMap.add(callbackId, [protectedProcessPool = makeRef(m_processPool), token = throttler().backgroundActivityToken(), completionHandler = WTFMove(completionHandler)]() mutable { >+ auto addResult = m_scheduleStatisticsProcessingCallbackMap.add(callbackId, [protectedProcessPool = makeRef(m_processPool), token = throttler().backgroundActivityToken(), completionHandler = WTFMove(completionHandler)]() mutable { > completionHandler(); > }); > ASSERT_UNUSED(addResult, addResult.isNewEntry); >@@ -442,7 +663,214 @@ void NetworkProcessProxy::setAgeCapForClientSideCookies(PAL::SessionID sessionID > > void NetworkProcessProxy::didSetAgeCapForClientSideCookies(uint64_t callbackId) > { >- m_updateBlockCookiesCallbackMap.take(callbackId)(); >+ m_scheduleStatisticsProcessingCallbackMap.take(callbackId)(); >+} >+ >+void NetworkProcessProxy::setTimeToLiveUserInteraction(PAL::SessionID sessionID, Seconds seconds, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackId = generateCallbackID(); >+ auto addResult = m_updateRuntimeSettingsCallbackMap.add(callbackId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::SetTimeToLiveUserInteraction(sessionID, seconds, callbackId), 0); >+} >+ >+void NetworkProcessProxy::didUpdateRuntimeSettings(uint64_t callbackId) >+{ >+ m_updateRuntimeSettingsCallbackMap.take(callbackId)(); >+} >+ >+void NetworkProcessProxy::setNotifyPagesWhenTelemetryWasCaptured(PAL::SessionID sessionID, bool value, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackId = generateCallbackID(); >+ auto addResult = m_updateRuntimeSettingsCallbackMap.add(callbackId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::SetNotifyPagesWhenTelemetryWasCaptured(sessionID, value, callbackId), 0); >+} >+ >+void NetworkProcessProxy::setNotifyPagesWhenDataRecordsWereScanned(PAL::SessionID sessionID, bool value, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackId = generateCallbackID(); >+ auto addResult = m_updateRuntimeSettingsCallbackMap.add(callbackId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::SetNotifyPagesWhenDataRecordsWereScanned(sessionID, value, callbackId), 0); >+} >+ >+void NetworkProcessProxy::setSubframeUnderTopFrameOrigin(PAL::SessionID sessionID, const String& subframe, const String& topFrame, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackId = generateCallbackID(); >+ auto addResult = m_setResourceLoadStatisticDataCallbackMap.add(callbackId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::SetSubframeUnderTopFrameOrigin(sessionID, subframe, topFrame, callbackId), 0); >+} >+ >+void NetworkProcessProxy::isRegisteredAsRedirectingTo(PAL::SessionID sessionID, const String& redirectedFrom, const String& redirectedTo, CompletionHandler<void(bool)>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(false); >+ return; >+ } >+ >+ auto callbackId = generateCallbackID(); >+ auto addResult = m_isPrevalentResourceCallbackMap.add(callbackId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::IsRegisteredAsRedirectingTo(sessionID, redirectedFrom, redirectedTo, callbackId), 0); >+} >+ >+void NetworkProcessProxy::didIsRegisteredAsRedirectingTo(bool isRegistered, uint64_t callbackId) >+{ >+ m_isPrevalentResourceCallbackMap.take(callbackId)(isRegistered); >+} >+ >+void NetworkProcessProxy::isRegisteredAsSubFrameUnder(PAL::SessionID sessionID, const String& subFrame, const String& topFrame, CompletionHandler<void(bool)>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(false); >+ return; >+ } >+ >+ auto callbackId = generateCallbackID(); >+ auto addResult = m_isPrevalentResourceCallbackMap.add(callbackId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::IsRegisteredAsSubFrameUnder(sessionID, subFrame, topFrame, callbackId), 0); >+} >+ >+void NetworkProcessProxy::didIsRegisteredAsSubFrameUnder(bool isRegistered, uint64_t callbackId) >+{ >+ m_isPrevalentResourceCallbackMap.take(callbackId)(isRegistered); >+} >+ >+void NetworkProcessProxy::setSubresourceUnderTopFrameOrigin(PAL::SessionID sessionID, const String& subresource, const String& topFrame, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackId = generateCallbackID(); >+ auto addResult = m_setResourceLoadStatisticDataCallbackMap.add(callbackId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::SetSubresourceUnderTopFrameOrigin(sessionID, subresource, topFrame, callbackId), 0); >+} >+ >+void NetworkProcessProxy::isRegisteredAsSubresourceUnder(PAL::SessionID sessionID, const String& subresource, const String& topFrame, CompletionHandler<void(bool)>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(false); >+ return; >+ } >+ >+ auto callbackId = generateCallbackID(); >+ auto addResult = m_isPrevalentResourceCallbackMap.add(callbackId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::IsRegisteredAsSubresourceUnder(sessionID, subresource, topFrame, callbackId), 0); >+} >+ >+void NetworkProcessProxy::didIsRegisteredAsSubresourceUnder(bool isRegistered, uint64_t callbackId) >+{ >+ m_isPrevalentResourceCallbackMap.take(callbackId)(isRegistered); >+} >+ >+void NetworkProcessProxy::setSubresourceUniqueRedirectTo(PAL::SessionID sessionID, const String& subresource, const String& hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackId = generateCallbackID(); >+ auto addResult = m_setResourceLoadStatisticDataCallbackMap.add(callbackId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::SetSubresourceUniqueRedirectTo(sessionID, subresource, hostNameRedirectedTo, callbackId), 0); >+} >+ >+void NetworkProcessProxy::setSubresourceUniqueRedirectFrom(PAL::SessionID sessionID, const String& subresource, const String& hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackId = generateCallbackID(); >+ auto addResult = m_setResourceLoadStatisticDataCallbackMap.add(callbackId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::SetSubresourceUniqueRedirectFrom(sessionID, subresource, hostNameRedirectedFrom, callbackId), 0); >+} >+ >+void NetworkProcessProxy::setTopFrameUniqueRedirectTo(PAL::SessionID sessionID, const String& topFrameHostName, const String& hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackId = generateCallbackID(); >+ auto addResult = m_setResourceLoadStatisticDataCallbackMap.add(callbackId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::SetTopFrameUniqueRedirectTo(sessionID, topFrameHostName, hostNameRedirectedTo, callbackId), 0); >+} >+ >+void NetworkProcessProxy::setTopFrameUniqueRedirectFrom(PAL::SessionID sessionID, const String& topFrameHostName, const String& hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackId = generateCallbackID(); >+ auto addResult = m_setResourceLoadStatisticDataCallbackMap.add(callbackId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::SetTopFrameUniqueRedirectFrom(sessionID, topFrameHostName, hostNameRedirectedFrom, callbackId), 0); >+} >+ >+void NetworkProcessProxy::isGrandfathered(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void(bool)>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(false); >+ return; >+ } >+ >+ auto callbackId = generateCallbackID(); >+ auto addResult = m_isPrevalentResourceCallbackMap.add(callbackId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::IsGrandfathered(sessionID, resourceDomain, callbackId), 0); >+} >+ >+void NetworkProcessProxy::didIsGrandfathered(bool isGrandfathered, uint64_t callbackId) >+{ >+ m_isPrevalentResourceCallbackMap.take(callbackId)(isGrandfathered); >+} >+ >+void NetworkProcessProxy::setGrandfathered(PAL::SessionID sessionID, const String& resourceDomain, bool isGrandfathered, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackId = generateCallbackID(); >+ auto addResult = m_setResourceLoadStatisticDataCallbackMap.add(callbackId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::SetGrandfathered(sessionID, resourceDomain, isGrandfathered, callbackId), 0); > } > > void NetworkProcessProxy::hasStorageAccessForFrame(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void(bool)>&& callback) >@@ -453,18 +881,38 @@ void NetworkProcessProxy::hasStorageAccessForFrame(PAL::SessionID sessionID, con > send(Messages::NetworkProcess::HasStorageAccessForFrame(sessionID, resourceDomain, firstPartyDomain, frameID, pageID, contextId), 0); > } > >-void NetworkProcessProxy::grantStorageAccess(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, WTF::CompletionHandler<void(bool)>&& callback) >+void NetworkProcessProxy::hasStorageAccess(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler) > { > auto contextId = generateCallbackID(); >- auto addResult = m_storageAccessResponseCallbackMap.add(contextId, WTFMove(callback)); >+ auto addResult = m_storageAccessResponseCallbackMap.add(contextId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::HasStorageAccess(sessionID, resourceDomain, firstPartyDomain, frameID, pageID, contextId), 0); >+} >+ >+void NetworkProcessProxy::requestStorageAccess(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&& completionHandler) >+{ >+ auto contextId = generateCallbackID(); >+ auto addResult = m_storageAccessRequestResponseCallbackMap.add(contextId, WTFMove(completionHandler)); > ASSERT_UNUSED(addResult, addResult.isNewEntry); >- send(Messages::NetworkProcess::GrantStorageAccess(sessionID, resourceDomain, firstPartyDomain, frameID, pageID, contextId), 0); >+ send(Messages::NetworkProcess::RequestStorageAccess(sessionID, resourceDomain, firstPartyDomain, frameID, pageID, promptEnabled, contextId), 0); > } > >-void NetworkProcessProxy::storageAccessRequestResult(bool wasGranted, uint64_t contextId) >+void NetworkProcessProxy::grantStorageAccess(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool userWasPrompted, WTF::CompletionHandler<void(bool)>&& completionHandler) > { >- auto callback = m_storageAccessResponseCallbackMap.take(contextId); >- callback(wasGranted); >+ auto contextId = generateCallbackID(); >+ auto addResult = m_storageAccessResponseCallbackMap.add(contextId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::GrantStorageAccess(sessionID, resourceDomain, firstPartyDomain, frameID.value(), pageID, userWasPrompted, contextId), 0); >+} >+ >+void NetworkProcessProxy::storageAccessRequestResult(unsigned status, uint64_t contextId) >+{ >+ m_storageAccessRequestResponseCallbackMap.take(contextId)(static_cast<StorageAccessStatus>(status)); >+} >+ >+void NetworkProcessProxy::storageAccessOperationResult(bool wasGranted, uint64_t contextId) >+{ >+ m_storageAccessResponseCallbackMap.take(contextId)(wasGranted); > } > > void NetworkProcessProxy::removeAllStorageAccess(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler) >@@ -482,8 +930,7 @@ void NetworkProcessProxy::removeAllStorageAccess(PAL::SessionID sessionID, Compl > > void NetworkProcessProxy::didRemoveAllStorageAccess(uint64_t contextId) > { >- auto completionHandler = m_removeAllStorageAccessCallbackMap.take(contextId); >- completionHandler(); >+ m_removeAllStorageAccessCallbackMap.take(contextId)(); > } > > void NetworkProcessProxy::getAllStorageAccessEntries(PAL::SessionID sessionID, CompletionHandler<void(Vector<String>&& domains)>&& callback) >@@ -515,8 +962,97 @@ void NetworkProcessProxy::setCacheMaxAgeCapForPrevalentResources(PAL::SessionID > > void NetworkProcessProxy::didSetCacheMaxAgeCapForPrevalentResources(uint64_t contextId) > { >- auto completionHandler = m_updateRuntimeSettingsCallbackMap.take(contextId); >- completionHandler(); >+ m_updateRuntimeSettingsCallbackMap.take(contextId)(); >+} >+ >+void NetworkProcessProxy::setCacheMaxAgeCap(PAL::SessionID sessionID, Seconds seconds, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(); >+ return; >+ } >+ >+ auto contextId = generateCallbackID(); >+ auto addResult = m_updateRuntimeSettingsCallbackMap.add(contextId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::SetCacheMaxAgeCapForPrevalentResources(sessionID, seconds, contextId), 0); >+} >+ >+void NetworkProcessProxy::setGrandfatheringTime(PAL::SessionID sessionID, Seconds seconds, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(); >+ return; >+ } >+ >+ auto contextId = generateCallbackID(); >+ auto addResult = m_updateRuntimeSettingsCallbackMap.add(contextId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::SetGrandfatheringTime(sessionID, seconds, contextId), 0); >+} >+ >+void NetworkProcessProxy::setMaxStatisticsEntries(PAL::SessionID sessionID, size_t maximumEntryCount, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) >+ return; >+ >+ auto contextId = generateCallbackID(); >+ auto addResult = m_updateRuntimeSettingsCallbackMap.add(contextId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::SetMaxStatisticsEntries(sessionID, maximumEntryCount, contextId), 0); >+} >+ >+void NetworkProcessProxy::setMinimumTimeBetweenDataRecordsRemoval(PAL::SessionID sessionID, Seconds seconds, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(); >+ return; >+ } >+ >+ auto contextId = generateCallbackID(); >+ auto addResult = m_updateRuntimeSettingsCallbackMap.add(contextId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::SetMinimumTimeBetweenDataRecordsRemoval(sessionID, seconds, contextId), 0); >+} >+ >+void NetworkProcessProxy::setPruneEntriesDownTo(PAL::SessionID sessionID, size_t pruneTargetCount, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(); >+ return; >+ } >+ >+ auto contextId = generateCallbackID(); >+ auto addResult = m_updateRuntimeSettingsCallbackMap.add(contextId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::SetPruneEntriesDownTo(sessionID, pruneTargetCount, contextId), 0); >+} >+ >+void NetworkProcessProxy::setShouldClassifyResourcesBeforeDataRecordsRemoval(PAL::SessionID sessionID, bool value, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(); >+ return; >+ } >+ >+ auto contextId = generateCallbackID(); >+ auto addResult = m_updateRuntimeSettingsCallbackMap.add(contextId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::SetShouldClassifyResourcesBeforeDataRecordsRemoval(sessionID, value, contextId), 0); >+ >+} >+ >+void NetworkProcessProxy::setResourceLoadStatisticsDebugMode(PAL::SessionID sessionID, bool debugMode, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(); >+ return; >+ } >+ >+ auto contextId = generateCallbackID(); >+ auto addResult = m_updateRuntimeSettingsCallbackMap.add(contextId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::SetResourceLoadStatisticsDebugMode(sessionID, debugMode, contextId), 0); > } > > void NetworkProcessProxy::resetCacheMaxAgeCapForPrevalentResources(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler) >@@ -532,10 +1068,68 @@ void NetworkProcessProxy::resetCacheMaxAgeCapForPrevalentResources(PAL::SessionI > send(Messages::NetworkProcess::ResetCacheMaxAgeCapForPrevalentResources(sessionID, contextId), 0); > } > >-void NetworkProcessProxy::didResetCacheMaxAgeCapForPrevalentResources(uint64_t contextId) >+void NetworkProcessProxy::resetParametersToDefaultValues(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(); >+ return; >+ } >+ >+ auto contextId = generateCallbackID(); >+ auto addResult = m_updateRuntimeSettingsCallbackMap.add(contextId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::ResetParametersToDefaultValues(sessionID, contextId), 0); >+} >+ >+void NetworkProcessProxy::submitTelemetry(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(); >+ return; >+ } >+ >+ auto contextId = generateCallbackID(); >+ auto addResult = m_scheduleStatisticsProcessingCallbackMap.add(contextId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::SubmitTelemetry(sessionID, contextId), 0); >+} >+ >+void NetworkProcessProxy::scheduleClearInMemoryAndPersistent(PAL::SessionID sessionID, bool shouldGrandfather, CompletionHandler<void()>&& completionHandler) >+{ >+ if (!canSendMessage()) { >+ completionHandler(); >+ return; >+ } >+ >+ auto contextId = generateCallbackID(); >+ auto addResult = m_scheduleStatisticsProcessingCallbackMap.add(contextId, WTFMove(completionHandler)); >+ ASSERT_UNUSED(addResult, addResult.isNewEntry); >+ send(Messages::NetworkProcess::ScheduleClearInMemoryAndPersistent(sessionID, { }, shouldGrandfather, contextId), 0); >+} >+ >+void NetworkProcessProxy::notifyResourceLoadStatisticsProcessed() >+{ >+ WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed(); >+} >+ >+void NetworkProcessProxy::notifyWebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished() > { >- auto completionHandler = m_updateRuntimeSettingsCallbackMap.take(contextId); >- completionHandler(); >+ WebProcessProxy::notifyWebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished(); >+} >+ >+void NetworkProcessProxy::notifyWebsiteDataScanForTopPrivatelyControlledDomainsFinished() >+{ >+ WebProcessProxy::notifyWebsiteDataScanForTopPrivatelyControlledDomainsFinished(); >+} >+ >+void NetworkProcessProxy::notifyResourceLoadStatisticsTelemetryFinished(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins) >+{ >+ API::Dictionary::MapType messageBody; >+ messageBody.set("TotalPrevalentResources"_s, API::UInt64::create(totalPrevalentResources)); >+ messageBody.set("TotalPrevalentResourcesWithUserInteraction"_s, API::UInt64::create(totalPrevalentResourcesWithUserInteraction)); >+ messageBody.set("Top3SubframeUnderTopFrameOrigins"_s, API::UInt64::create(top3SubframeUnderTopFrameOrigins)); >+ >+ WebProcessProxy::notifyPageStatisticsTelemetryFinished(API::Dictionary::create(messageBody).ptr()); > } > #endif // ENABLE(RESOURCE_LOAD_STATISTICS) > >diff --git a/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h b/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h >index bfa8b8c57a0bf16cfe04b37388453be0ed978cd2..ed55805f7b3dcf2ddccd36286af534786d945a23 100644 >--- a/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h >+++ b/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h >@@ -57,6 +57,7 @@ namespace WebKit { > class DownloadProxy; > class DownloadProxyMap; > class WebProcessPool; >+enum class StorageAccessStatus : unsigned; > enum class WebsiteDataFetchOption; > enum class WebsiteDataType; > struct NetworkProcessCreationParameters; >@@ -77,13 +78,53 @@ public: > void deleteWebsiteDataForOrigins(PAL::SessionID, OptionSet<WebKit::WebsiteDataType>, const Vector<WebCore::SecurityOriginData>& origins, const Vector<String>& cookieHostNames, const Vector<String>& HSTSCacheHostNames, CompletionHandler<void()>&&); > > #if ENABLE(RESOURCE_LOAD_STATISTICS) >+ void clearPrevalentResource(PAL::SessionID, const String& resourceDomain, CompletionHandler<void()>&&); >+ void clearUserInteraction(PAL::SessionID, const String& resourceDomain, CompletionHandler<void()>&&); >+ void dumpResourceLoadStatistics(PAL::SessionID, CompletionHandler<void(const String&)>&&); > void updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID, const Vector<String>& domainsToBlock, CompletionHandler<void()>&&); >+ void hasHadUserInteraction(PAL::SessionID, const String& resourceDomain, CompletionHandler<void(bool)>&&); >+ void isGrandfathered(PAL::SessionID, const String& resourceDomain, CompletionHandler<void(bool)>&&); >+ void isPrevalentResource(PAL::SessionID, const String& resourceDomain, CompletionHandler<void(bool)>&&); >+ void isRegisteredAsRedirectingTo(PAL::SessionID, const String& redirectedFrom, const String& redirectedTo, CompletionHandler<void(bool)>&&); >+ void isRegisteredAsSubFrameUnder(PAL::SessionID, const String& subFrame, const String& topFrame, CompletionHandler<void(bool)>&&); >+ void isRegisteredAsSubresourceUnder(PAL::SessionID, const String& subresource, const String& topFrame, CompletionHandler<void(bool)>&&); >+ void isVeryPrevalentResource(PAL::SessionID, const String& resourceDomain, CompletionHandler<void(bool)>&&); >+ void logUserInteraction(PAL::SessionID, const String& resourceDomain, CompletionHandler<void()>&&); >+ void scheduleStatisticsAndDataRecordsProcessing(PAL::SessionID, CompletionHandler<void()>&&); >+ void setLastSeen(PAL::SessionID, const String& resourceDomain, Seconds, CompletionHandler<void()>&&); > void setAgeCapForClientSideCookies(PAL::SessionID, Optional<Seconds>, CompletionHandler<void()>&&); >+ void setCacheMaxAgeCap(PAL::SessionID, Seconds, CompletionHandler<void()>&&); >+ void setGrandfathered(PAL::SessionID, const String& resourceDomain, bool isGrandfathered, CompletionHandler<void()>&&); >+ void setNotifyPagesWhenDataRecordsWereScanned(PAL::SessionID, bool, CompletionHandler<void()>&&); >+ void setNotifyPagesWhenTelemetryWasCaptured(PAL::SessionID, bool, CompletionHandler<void()>&&); >+ void setSubframeUnderTopFrameOrigin(PAL::SessionID, const String& subframe, const String& topFrame, CompletionHandler<void()>&&); >+ void setSubresourceUnderTopFrameOrigin(PAL::SessionID, const String& subresource, const String& topFrame, CompletionHandler<void()>&&); >+ void setSubresourceUniqueRedirectTo(PAL::SessionID, const String& subresource, const String& hostNameRedirectedTo, CompletionHandler<void()>&&); >+ void setSubresourceUniqueRedirectFrom(PAL::SessionID, const String& subresource, const String& hostNameRedirectedFrom, CompletionHandler<void()>&&); >+ void setTimeToLiveUserInteraction(PAL::SessionID, Seconds, CompletionHandler<void()>&&); >+ void setTopFrameUniqueRedirectTo(PAL::SessionID, const String& topFrameHostName, const String& hostNameRedirectedTo, CompletionHandler<void()>&&); >+ void setTopFrameUniqueRedirectFrom(PAL::SessionID, const String& topFrameHostName, const String& hostNameRedirectedFrom, CompletionHandler<void()>&&); >+ void setPrevalentResource(PAL::SessionID, const String& resourceDomain, CompletionHandler<void()>&&); >+ void setPrevalentResourceForDebugMode(PAL::SessionID, const String& resourceDomain, CompletionHandler<void()>&&); >+ void setVeryPrevalentResource(PAL::SessionID, const String& resourceDomain, CompletionHandler<void()>&&); > void hasStorageAccessForFrame(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback); > void getAllStorageAccessEntries(PAL::SessionID, CompletionHandler<void(Vector<String>&& domains)>&&); >- void grantStorageAccess(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback); >+ void grantStorageAccess(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool userWasPrompted, WTF::CompletionHandler<void(bool)>&&); >+ void hasStorageAccess(PAL::SessionID, const String& subFrameHost, const String& topFrameHost, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&&); >+ void requestStorageAccess(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&&); >+ void resetParametersToDefaultValues(PAL::SessionID, CompletionHandler<void()>&&); > void removeAllStorageAccess(PAL::SessionID, CompletionHandler<void()>&&); >+ void scheduleClearInMemoryAndPersistent(PAL::SessionID, bool shouldGrandfather, CompletionHandler<void()>&&); >+ void scheduleClearInMemoryAndPersistent(PAL::SessionID, Optional<WallTime> modifiedSince, ShouldGrandfather, CompletionHandler<void()>&&); >+ void scheduleCookieBlockingUpdate(PAL::SessionID, CompletionHandler<void()>&&); >+ void submitTelemetry(PAL::SessionID, CompletionHandler<void()>&&); > void setCacheMaxAgeCapForPrevalentResources(PAL::SessionID, Seconds, CompletionHandler<void()>&&); >+ void setGrandfatheringTime(PAL::SessionID, Seconds, CompletionHandler<void()>&&); >+ void setMaxStatisticsEntries(PAL::SessionID, size_t maximumEntryCount, CompletionHandler<void()>&&); >+ void setMinimumTimeBetweenDataRecordsRemoval(PAL::SessionID, Seconds, CompletionHandler<void()>&&); >+ void setPruneEntriesDownTo(PAL::SessionID, size_t pruneTargetCount, CompletionHandler<void()>&&); >+ void setResourceLoadStatisticsDebugMode(PAL::SessionID, bool debugMode, CompletionHandler<void()>&&); >+ void setShouldClassifyResourcesBeforeDataRecordsRemoval(PAL::SessionID, bool, CompletionHandler<void()>&&); > void resetCacheMaxAgeCapForPrevalentResources(PAL::SessionID, CompletionHandler<void()>&&); > #endif > >@@ -141,15 +182,37 @@ private: > void logDiagnosticMessage(uint64_t pageID, const String& message, const String& description, WebCore::ShouldSample); > void logDiagnosticMessageWithResult(uint64_t pageID, const String& message, const String& description, uint32_t result, WebCore::ShouldSample); > void logDiagnosticMessageWithValue(uint64_t pageID, const String& message, const String& description, double value, unsigned significantFigures, WebCore::ShouldSample); >+ void logGlobalDiagnosticMessageWithValue(const String& message, const String& description, double value, unsigned significantFigures, WebCore::ShouldSample); > #if ENABLE(RESOURCE_LOAD_STATISTICS) >- void didLogUserInteraction(uint64_t contextId); >+ void didDumpResourceLoadStatistics(String dumpedStatistics, uint64_t callbackId); >+ void didHaveUserInteraction(bool hadInteraction, uint64_t callbackId); >+ void didIsGrandfathered(bool isGrandfathered, uint64_t callbackId); >+ void didIsRegisteredAsRedirectingTo(bool isRegistered, uint64_t callbackId); >+ void didIsRegisteredAsSubFrameUnder(bool isRegistered, uint64_t callbackId); >+ void didIsRegisteredAsSubresourceUnder(bool isRegistered, uint64_t callbackId); > void didUpdateBlockCookies(uint64_t contextId); >+ void didScheduleStatisticsProcessing(uint64_t contextId); >+ void didScheduleCookieBlockingUpdate(uint64_t callbackId); > void didSetAgeCapForClientSideCookies(uint64_t contextId); >- void storageAccessRequestResult(bool wasGranted, uint64_t contextId); >+ void didSetLastSeen(uint64_t callbackId); >+ void didSetResourceLoadStatisticData(uint64_t callbackId); >+ void didSetSubframeUnderTopFrameOrigin(uint64_t contextId); >+ void didSetSubresourceUnderTopFrameOrigin(uint64_t contextId); >+ void didSetSubresourceUniqueRedirectTo(uint64_t contextId); >+ void didSetSubresourceUniqueRedirectFrom(uint64_t contextId); >+ void didSetTopFrameUniqueRedirectTo(uint64_t contextId); >+ void didSetTopFrameUniqueRedirectFrom(uint64_t contextId); >+ void storageAccessOperationResult(bool wasGranted, uint64_t contextId); >+ void storageAccessRequestResult(unsigned wasGranted, uint64_t contextId); > void allStorageAccessEntriesResult(Vector<String>&& domains, uint64_t contextId); > void didRemoveAllStorageAccess(uint64_t contextId); > void didSetCacheMaxAgeCapForPrevalentResources(uint64_t contextId); >- void didResetCacheMaxAgeCapForPrevalentResources(uint64_t contextId); >+ void didUpdateRuntimeSettings(uint64_t contextId); >+ void isPrevalentResourceResult(bool isPrevalent, uint64_t contextId); >+ void notifyResourceLoadStatisticsProcessed(); >+ void notifyWebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished(); >+ void notifyWebsiteDataScanForTopPrivatelyControlledDomainsFinished(); >+ void notifyResourceLoadStatisticsTelemetryFinished(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins); > #endif > void retrieveCacheStorageParameters(PAL::SessionID); > >@@ -192,10 +255,16 @@ private: > > unsigned m_syncAllCookiesCounter { 0 }; > >- HashMap<uint64_t, CompletionHandler<void()>> m_updateBlockCookiesCallbackMap; >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ HashMap<uint64_t, CompletionHandler<void()>> m_scheduleStatisticsProcessingCallbackMap; > HashMap<uint64_t, CompletionHandler<void(bool wasGranted)>> m_storageAccessResponseCallbackMap; >+ HashMap<uint64_t, CompletionHandler<void(StorageAccessStatus wasGranted)>> m_storageAccessRequestResponseCallbackMap; > HashMap<uint64_t, CompletionHandler<void()>> m_removeAllStorageAccessCallbackMap; > HashMap<uint64_t, CompletionHandler<void(Vector<String>&& domains)>> m_allStorageAccessEntriesCallbackMap; >+ HashMap<uint64_t, CompletionHandler<void(bool isPrevalent)>> m_isPrevalentResourceCallbackMap; >+ HashMap<uint64_t, CompletionHandler<void()>> m_setResourceLoadStatisticDataCallbackMap; >+ HashMap<uint64_t, CompletionHandler<void(const String&)>> m_dumpStatisticsCallbackMap; >+#endif > > HashMap<uint64_t, CompletionHandler<void()>> m_updateRuntimeSettingsCallbackMap; > >diff --git a/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in b/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in >index 959267cc4fbc2815eec06d7ad5b7216ddb4ce837..9a74aad3de4bc7809f6e56fe8f806da497ee6379 100644 >--- a/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in >+++ b/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in >@@ -38,16 +38,30 @@ messages -> NetworkProcessProxy LegacyReceiver { > LogDiagnosticMessage(uint64_t pageID, String message, String description, enum:bool WebCore::ShouldSample shouldSample) > LogDiagnosticMessageWithResult(uint64_t pageID, String message, String description, uint32_t result, enum:bool WebCore::ShouldSample shouldSample) > LogDiagnosticMessageWithValue(uint64_t pageID, String message, String description, double value, unsigned significantFigures, enum:bool WebCore::ShouldSample shouldSample) >+ LogGlobalDiagnosticMessageWithValue(String message, String description, double value, unsigned significantFigures, enum:bool WebCore::ShouldSample shouldSample) > > #if ENABLE(RESOURCE_LOAD_STATISTICS) >- DidLogUserInteraction(uint64_t callbackId) >+ DidDumpResourceLoadStatistics(String dumpedStatistics, uint64_t callbackId) >+ DidHaveUserInteraction(bool hadInteraction, uint64_t callbackId); >+ DidIsGrandfathered(bool isGrandfathered, uint64_t callbackId) > DidUpdateBlockCookies(uint64_t callbackId) >+ DidScheduleStatisticsProcessing(uint64_t callbackId) > DidSetAgeCapForClientSideCookies(uint64_t callbackId) >- StorageAccessRequestResult(bool wasGranted, uint64_t contextId) >+ DidSetResourceLoadStatisticData(uint64_t callbackId) >+ IsPrevalentResourceResult(bool isPrevalent, uint64_t callbackId) >+ DidIsRegisteredAsRedirectingTo(bool isRegistered, uint64_t callbackId) >+ DidIsRegisteredAsSubFrameUnder(bool isRegistered, uint64_t callbackId) >+ DidIsRegisteredAsSubresourceUnder(bool isRegistered, uint64_t callbackId) >+ StorageAccessOperationResult(bool wasGranted, uint64_t contextId) >+ StorageAccessRequestResult(unsigned wasGranted, uint64_t contextId) > AllStorageAccessEntriesResult(Vector<String> domains, uint64_t contextId) > DidRemoveAllStorageAccess(uint64_t contextId) > DidSetCacheMaxAgeCapForPrevalentResources(uint64_t contextId) >- DidResetCacheMaxAgeCapForPrevalentResources(uint64_t contextId) >+ DidUpdateRuntimeSettings(uint64_t contextId) >+ NotifyResourceLoadStatisticsProcessed() >+ NotifyWebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished() >+ NotifyWebsiteDataScanForTopPrivatelyControlledDomainsFinished() >+ NotifyResourceLoadStatisticsTelemetryFinished(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins) > #endif > #if ENABLE(CONTENT_EXTENSIONS) > ContentExtensionRules(WebKit::UserContentControllerIdentifier identifier) >diff --git a/Source/WebKit/UIProcess/WebPageProxy.cpp b/Source/WebKit/UIProcess/WebPageProxy.cpp >index b91faaf74493bc9859f4c1d6b437f150e5328f5a..e74f38dc59b400d4026e2cad3c659e0525b43c9a 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.cpp >+++ b/Source/WebKit/UIProcess/WebPageProxy.cpp >@@ -4480,6 +4480,26 @@ void WebPageProxy::decidePolicyForNavigationAction(Ref<WebProcessProxy>&& proces > m_shouldSuppressAppLinksInNextNavigationPolicyDecision = false; > } > >+WebPageProxy* WebPageProxy::nonEphemeralWebPageProxy() >+{ >+ auto processPools = WebProcessPool::allProcessPools(); >+ if (processPools.isEmpty()) >+ return nullptr; >+ >+ auto processPool = processPools[0]; >+ if (!processPool) >+ return nullptr; >+ >+ for (auto& webProcess : processPool->processes()) { >+ for (auto& page : webProcess->pages()) { >+ if (page->sessionID().isEphemeral()) >+ continue; >+ return page; >+ } >+ } >+ return nullptr; >+} >+ > #if ENABLE(RESOURCE_LOAD_STATISTICS) > void WebPageProxy::logFrameNavigation(const WebFrameProxy& frame, const URL& pageURL, const WebCore::ResourceRequest& request, const URL& redirectURL) > { >diff --git a/Source/WebKit/UIProcess/WebPageProxy.h b/Source/WebKit/UIProcess/WebPageProxy.h >index 2286b35c9fb9794a9e3d7d437b49c38862dfffed..e002e4b00517d793e078e4b9220fdd80548d9057 100644 >--- a/Source/WebKit/UIProcess/WebPageProxy.h >+++ b/Source/WebKit/UIProcess/WebPageProxy.h >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2010-2018 Apple Inc. All rights reserved. >+ * Copyright (C) 2010-2019 Apple Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -1382,6 +1382,8 @@ public: > void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t webProcessContextId, bool prompt); > #endif > >+ static WebPageProxy* nonEphemeralWebPageProxy(); >+ > #if ENABLE(ATTACHMENT_ELEMENT) > RefPtr<API::Attachment> attachmentForIdentifier(const String& identifier) const; > void insertAttachment(Ref<API::Attachment>&&, Function<void(CallbackBase::Error)>&&); >diff --git a/Source/WebKit/UIProcess/WebProcessPool.cpp b/Source/WebKit/UIProcess/WebProcessPool.cpp >index a628aff568e876097d1b9756c03f366a60abaf0a..23c58fa9d1058dc0e0c5af3b31c678fe4cfb27fd 100644 >--- a/Source/WebKit/UIProcess/WebProcessPool.cpp >+++ b/Source/WebKit/UIProcess/WebProcessPool.cpp >@@ -560,7 +560,7 @@ NetworkProcessProxy& WebProcessPool::ensureNetworkProcess(WebsiteDataStore* with > > SandboxExtension::createHandleForReadWriteDirectory(parameters.defaultDataStoreParameters.networkSessionParameters.resourceLoadStatisticsDirectory, parameters.defaultDataStoreParameters.networkSessionParameters.resourceLoadStatisticsDirectoryExtensionHandle); > >- parameters.defaultDataStoreParameters.networkSessionParameters.enableResourceLoadStatistics = false; // FIXME(193297): Turn on when the feature is on. >+ parameters.defaultDataStoreParameters.networkSessionParameters.enableResourceLoadStatistics = false; // FIXME(193297): Turn on when the feature is on. (m_configuration->resourceLoadStatisticsEnabled()?) > > // Add any platform specific parameters > platformInitializeNetworkProcess(parameters); >diff --git a/Source/WebKit/UIProcess/WebProcessProxy.cpp b/Source/WebKit/UIProcess/WebProcessProxy.cpp >index 6be9dc399e01488da678fb4568ef36b21f3c4876..125499dc601844e487ec7f9a8515f1effca41d09 100644 >--- a/Source/WebKit/UIProcess/WebProcessProxy.cpp >+++ b/Source/WebKit/UIProcess/WebProcessProxy.cpp >@@ -417,13 +417,25 @@ void WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed() > for (auto& page : globalPageMap()) > page.value->postMessageToInjectedBundle("WebsiteDataScanForTopPrivatelyControlledDomainsFinished", nullptr); > } >- >+ >+void WebProcessProxy::notifyWebsiteDataScanForTopPrivatelyControlledDomainsFinished() >+{ >+ for (auto& page : globalPageMap()) >+ page.value->postMessageToInjectedBundle("WebsiteDataScanForTopPrivatelyControlledDomainsFinished", nullptr); >+} >+ >+void WebProcessProxy::notifyWebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished() >+{ >+ for (auto& page : globalPageMap()) >+ page.value->postMessageToInjectedBundle("WebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished", nullptr); >+} >+ > void WebProcessProxy::notifyPageStatisticsTelemetryFinished(API::Object* messageBody) > { > for (auto& page : globalPageMap()) > page.value->postMessageToInjectedBundle("ResourceLoadStatisticsTelemetryFinished", messageBody); > } >- >+ > Ref<WebPageProxy> WebProcessProxy::createWebPage(PageClient& pageClient, Ref<API::PageConfiguration>&& pageConfiguration) > { > uint64_t pageID = generatePageID(); >diff --git a/Source/WebKit/UIProcess/WebProcessProxy.h b/Source/WebKit/UIProcess/WebProcessProxy.h >index 5042630de371d85a828374348aa9691739c9cd70..0a0f4a2a3bea9534df342131e76eeebfd36f8e76 100644 >--- a/Source/WebKit/UIProcess/WebProcessProxy.h >+++ b/Source/WebKit/UIProcess/WebProcessProxy.h >@@ -171,11 +171,16 @@ public: > void fetchWebsiteData(PAL::SessionID, OptionSet<WebsiteDataType>, CompletionHandler<void(WebsiteData)>&&); > void deleteWebsiteData(PAL::SessionID, OptionSet<WebsiteDataType>, WallTime modifiedSince, CompletionHandler<void()>&&); > void deleteWebsiteDataForOrigins(PAL::SessionID, OptionSet<WebsiteDataType>, const Vector<WebCore::SecurityOriginData>&, CompletionHandler<void()>&&); >+ > static void deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType>, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPages, CompletionHandler<void (const HashSet<String>&)>&&); > static void topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType> dataTypes, bool shouldNotifyPage, CompletionHandler<void(HashSet<String>&&)>&&); >+ > static void notifyPageStatisticsAndDataRecordsProcessed(); > static void notifyPageStatisticsTelemetryFinished(API::Object* messageBody); > >+ static void notifyWebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished(); >+ static void notifyWebsiteDataScanForTopPrivatelyControlledDomainsFinished(); >+ > void enableSuddenTermination(); > void disableSuddenTermination(); > bool isSuddenTerminationEnabled() { return !m_numberOfTimesSuddenTerminationWasDisabled; } >@@ -266,7 +271,7 @@ protected: > #endif > > bool isJITEnabled() const final; >- >+ > private: > // IPC message handlers. > void updateBackForwardItem(const BackForwardListItemState&); >diff --git a/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp b/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp >index 0aabbe48db135d86bf284b05542143a17bd8e9a0..fdbb6023282bceca34d7d02a71f9afb54b6d8782 100644 >--- a/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp >+++ b/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2014-2017 Apple Inc. All rights reserved. >+ * Copyright (C) 2014-2019 Apple Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -922,27 +922,37 @@ void WebsiteDataStore::removeData(OptionSet<WebsiteDataType> dataTypes, WallTime > } > #endif > >- if (dataTypes.contains(WebsiteDataType::ResourceLoadStatistics) && m_resourceLoadStatistics) { >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+ if (dataTypes.contains(WebsiteDataType::ResourceLoadStatistics)) { > auto deletedTypesRaw = dataTypes.toRaw(); > auto monitoredTypesRaw = WebResourceLoadStatisticsStore::monitoredDataTypes().toRaw(); > > // If we are deleting all of the data types that the resource load statistics store monitors > // we do not need to re-grandfather old data. >+ auto shouldGrandfather = ((monitoredTypesRaw & deletedTypesRaw) == monitoredTypesRaw) ? ShouldGrandfather::No : ShouldGrandfather::Yes; >+ > callbackAggregator->addPendingCallback(); >- if ((monitoredTypesRaw & deletedTypesRaw) == monitoredTypesRaw) >- m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(modifiedSince, WebResourceLoadStatisticsStore::ShouldGrandfather::No, [callbackAggregator] { >- callbackAggregator->removePendingCallback(); >- }); >- else >- m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(modifiedSince, WebResourceLoadStatisticsStore::ShouldGrandfather::Yes, [callbackAggregator] { >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(modifiedSince, shouldGrandfather, [callbackAggregator] { > callbackAggregator->removePendingCallback(); > }); >+ } else { >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) { >+ process->deleteWebsiteData(m_sessionID, dataTypes, modifiedSince, [callbackAggregator] { >+ callbackAggregator->removePendingCallback(); >+ }); >+ } >+ } >+ } > > callbackAggregator->addPendingCallback(); > clearResourceLoadStatisticsInWebProcesses([callbackAggregator] { > callbackAggregator->removePendingCallback(); > }); > } >+#endif > > // There's a chance that we don't have any pending callbacks. If so, we want to dispatch the completion handler right away. > callbackAggregator->callIfNeeded(); >@@ -1218,6 +1228,7 @@ void WebsiteDataStore::removeData(OptionSet<WebsiteDataType> dataTypes, const Ve > } > #endif > >+#if ENABLE(RESOURCE_LOAD_STATISTICS) > // FIXME <rdar://problem/33491222>; scheduleClearInMemoryAndPersistent does not have a completion handler, > // so the completion handler for this removeData() call can be called prematurely. > if (dataTypes.contains(WebsiteDataType::ResourceLoadStatistics) && m_resourceLoadStatistics) { >@@ -1228,34 +1239,587 @@ void WebsiteDataStore::removeData(OptionSet<WebsiteDataType> dataTypes, const Ve > // we do not need to re-grandfather old data. > callbackAggregator->addPendingCallback(); > if ((monitoredTypesRaw & deletedTypesRaw) == monitoredTypesRaw) >- m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(WebResourceLoadStatisticsStore::ShouldGrandfather::No, [callbackAggregator] { >+ m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(ShouldGrandfather::No, [callbackAggregator] { > callbackAggregator->removePendingCallback(); > }); > else >- m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(WebResourceLoadStatisticsStore::ShouldGrandfather::Yes, [callbackAggregator] { >+ m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(ShouldGrandfather::Yes, [callbackAggregator] { > callbackAggregator->removePendingCallback(); > }); > >- callbackAggregator->addPendingCallback(); >- clearResourceLoadStatisticsInWebProcesses([callbackAggregator] { >- callbackAggregator->removePendingCallback(); >- }); >+ callbackAggregator->addPendingCallback(); >+ clearResourceLoadStatisticsInWebProcesses([callbackAggregator] { >+ callbackAggregator->removePendingCallback(); >+ }); >+ } >+#endif >+ >+ // There's a chance that we don't have any pending callbacks. If so, we want to dispatch the completion handler right away. >+ callbackAggregator->callIfNeeded(); >+} >+ >+void WebsiteDataStore::removeDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType> dataTypes, OptionSet<WebsiteDataFetchOption> fetchOptions, const Vector<String>& topPrivatelyControlledDomains, Function<void(HashSet<String>&&)>&& completionHandler) >+{ >+ fetchDataForTopPrivatelyControlledDomains(dataTypes, fetchOptions, topPrivatelyControlledDomains, [dataTypes, completionHandler = WTFMove(completionHandler), this, protectedThis = makeRef(*this)](Vector<WebsiteDataRecord>&& websiteDataRecords, HashSet<String>&& domainsWithDataRecords) mutable { >+ this->removeData(dataTypes, websiteDataRecords, [domainsWithDataRecords = WTFMove(domainsWithDataRecords), completionHandler = WTFMove(completionHandler)]() mutable { >+ completionHandler(WTFMove(domainsWithDataRecords)); >+ }); >+ }); >+} >+ >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+void WebsiteDataStore::setMaxStatisticsEntries(size_t maximumEntryCount, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->setMaxStatisticsEntries(maximumEntryCount); >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) >+ process->setMaxStatisticsEntries(m_sessionID, maximumEntryCount, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); >+ } >+} >+ >+void WebsiteDataStore::setPruneEntriesDownTo(size_t pruneTargetCount, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->setPruneEntriesDownTo(pruneTargetCount); >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) >+ process->setPruneEntriesDownTo(m_sessionID, pruneTargetCount, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); >+ } >+} >+ >+void WebsiteDataStore::setGrandfatheringTime(Seconds seconds, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->setGrandfatheringTime(seconds); >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) >+ process->setGrandfatheringTime(m_sessionID, seconds, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); >+ } >+} >+ >+void WebsiteDataStore::setCacheMaxAgeCap(Seconds seconds, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ ASSERT(seconds >= 0_s); >+ >+ if (m_resourceLoadStatistics) { >+ setCacheMaxAgeCap(seconds, WTFMove(completionHandler)); >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) >+ process->setCacheMaxAgeCap(m_sessionID, seconds, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); >+ } >+} >+ >+void WebsiteDataStore::setMinimumTimeBetweenDataRecordsRemoval(Seconds seconds, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->setMinimumTimeBetweenDataRecordsRemoval(seconds); >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) >+ process->setMinimumTimeBetweenDataRecordsRemoval(m_sessionID, seconds, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); >+ } >+} >+ >+void WebsiteDataStore::dumpResourceLoadStatistics(CompletionHandler<void(const String&)>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->dumpResourceLoadStatistics(WTFMove(completionHandler)); >+ return; >+ } >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) { >+ process->dumpResourceLoadStatistics(m_sessionID, WTFMove(completionHandler)); >+ RELEASE_ASSERT(processPools().size() == 1); >+ break; >+ } >+ } >+} >+ >+void WebsiteDataStore::isPrevalentResource(const URL& url, CompletionHandler<void(bool isPrevalent)>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (url.protocolIsAbout() || url.isEmpty()) { >+ completionHandler(false); >+ return; >+ } >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->isPrevalentResource(url, WTFMove(completionHandler)); >+ return; >+ } >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) { >+ process->isPrevalentResource(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler)); >+ RELEASE_ASSERT(processPools().size() == 1); >+ break; >+ } >+ } >+} >+ >+void WebsiteDataStore::setPrevalentResource(const URL& url, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (url.protocolIsAbout() || url.isEmpty()) { >+ completionHandler(); >+ return; >+ } >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->setPrevalentResource(url, WTFMove(completionHandler)); >+ return; >+ } >+ >+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) >+ process->setPrevalentResource(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); >+ } >+} >+ >+void WebsiteDataStore::setPrevalentResourceForDebugMode(const URL& url, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (url.protocolIsAbout() || url.isEmpty()) { >+ completionHandler(); >+ return; >+ } >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->setPrevalentResourceForDebugMode(url, WTFMove(completionHandler)); >+ return; >+ } >+ >+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) >+ process->setPrevalentResourceForDebugMode(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); >+ } >+} >+ >+void WebsiteDataStore::isVeryPrevalentResource(const URL& url, CompletionHandler<void(bool isVeryPrevalent)>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (url.protocolIsAbout() || url.isEmpty()) { >+ completionHandler(false); >+ return; >+ } >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->isVeryPrevalentResource(url, WTFMove(completionHandler)); >+ return; >+ } >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) { >+ process->isVeryPrevalentResource(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler)); >+ ASSERT(processPools().size() == 1); >+ break; >+ } >+ } >+} >+ >+void WebsiteDataStore::setVeryPrevalentResource(const URL& url, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (url.protocolIsAbout() || url.isEmpty()) { >+ completionHandler(); >+ return; >+ } >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->setVeryPrevalentResource(url, WTFMove(completionHandler)); >+ return; >+ } >+ >+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) >+ process->setVeryPrevalentResource(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); >+ } >+} >+ >+void WebsiteDataStore::setShouldClassifyResourcesBeforeDataRecordsRemoval(bool value, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->setShouldClassifyResourcesBeforeDataRecordsRemoval(value); >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) >+ process->setShouldClassifyResourcesBeforeDataRecordsRemoval(m_sessionID, value, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); >+ } >+} >+ >+void WebsiteDataStore::setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (subframe.protocolIsAbout() || subframe.isEmpty() || topFrame.protocolIsAbout() || topFrame.isEmpty()) { >+ completionHandler(); >+ return; >+ } >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->setSubframeUnderTopFrameOrigin(subframe, topFrame); >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) >+ process->setSubframeUnderTopFrameOrigin(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(subframe), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); >+ } >+} >+ >+void WebsiteDataStore::isRegisteredAsSubFrameUnder(const URL& subFrame, const URL& topFrame, CompletionHandler<void(bool)>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->isRegisteredAsSubFrameUnder(subFrame, topFrame, WTFMove(completionHandler)); >+ return; >+ } >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) { >+ process->isRegisteredAsSubFrameUnder(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(subFrame), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), WTFMove(completionHandler)); >+ ASSERT(processPools().size() == 1); >+ break; >+ } >+ } >+} >+ >+void WebsiteDataStore::setSubresourceUnderTopFrameOrigin(const URL& subresource, const URL& topFrame, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (subresource.protocolIsAbout() || subresource.isEmpty() || topFrame.protocolIsAbout() || topFrame.isEmpty()) { >+ completionHandler(); >+ return; >+ } >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->setSubresourceUnderTopFrameOrigin(subresource, topFrame); >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) >+ process->setSubresourceUnderTopFrameOrigin(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); >+ } >+} >+ >+void WebsiteDataStore::isRegisteredAsSubresourceUnder(const URL& subresource, const URL& topFrame, CompletionHandler<void(bool)>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->isRegisteredAsSubresourceUnder(subresource, topFrame, WTFMove(completionHandler)); >+ return; >+ } >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) { >+ process->isRegisteredAsSubresourceUnder(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), WTFMove(completionHandler)); >+ ASSERT(processPools().size() == 1); >+ break; >+ } >+ } >+} >+ >+void WebsiteDataStore::setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (subresource.protocolIsAbout() || subresource.isEmpty() || hostNameRedirectedTo.protocolIsAbout() || hostNameRedirectedTo.isEmpty()) { >+ completionHandler(); >+ return; >+ } >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->setSubresourceUniqueRedirectTo(subresource, hostNameRedirectedTo); >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) >+ process->setSubresourceUniqueRedirectTo(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedTo), [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); >+ } >+} >+ >+void WebsiteDataStore::setSubresourceUniqueRedirectFrom(const URL& subresource, const URL& hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (subresource.protocolIsAbout() || subresource.isEmpty() || hostNameRedirectedFrom.protocolIsAbout() || hostNameRedirectedFrom.isEmpty()) { >+ completionHandler(); >+ return; >+ } >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->setSubresourceUniqueRedirectFrom(subresource, hostNameRedirectedFrom); >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) >+ process->setSubresourceUniqueRedirectFrom(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedFrom), [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); >+ } >+} >+ >+void WebsiteDataStore::setTopFrameUniqueRedirectTo(const URL& topFrameHostName, const URL& hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (topFrameHostName.protocolIsAbout() || topFrameHostName.isEmpty() || hostNameRedirectedTo.protocolIsAbout() || hostNameRedirectedTo.isEmpty()) { >+ completionHandler(); >+ return; >+ } >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->setTopFrameUniqueRedirectTo(topFrameHostName, hostNameRedirectedTo); >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) >+ process->setTopFrameUniqueRedirectTo(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(topFrameHostName), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedTo), [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); >+ } >+} >+ >+void WebsiteDataStore::setTopFrameUniqueRedirectFrom(const URL& topFrameHostName, const URL& hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (topFrameHostName.protocolIsAbout() || topFrameHostName.isEmpty() || hostNameRedirectedFrom.protocolIsAbout() || hostNameRedirectedFrom.isEmpty()) { >+ completionHandler(); >+ return; >+ } >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->setTopFrameUniqueRedirectFrom(topFrameHostName, hostNameRedirectedFrom); >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) >+ process->setTopFrameUniqueRedirectFrom(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(topFrameHostName), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedFrom), [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); >+ } >+} >+ >+void WebsiteDataStore::isRegisteredAsRedirectingTo(const URL& hostRedirectedFrom, const URL& hostRedirectedTo, CompletionHandler<void(bool)>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->isRegisteredAsRedirectingTo(hostRedirectedFrom, hostRedirectedTo, WTFMove(completionHandler)); >+ return; >+ } >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) { >+ process->isRegisteredAsRedirectingTo(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(hostRedirectedFrom), WebCore::ResourceLoadStatistics::primaryDomain(hostRedirectedTo), WTFMove(completionHandler)); >+ ASSERT(processPools().size() == 1); >+ break; >+ } >+ } >+} >+ >+void WebsiteDataStore::clearPrevalentResource(const URL& url, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (url.protocolIsAbout() || url.isEmpty()) { >+ completionHandler(); >+ return; >+ } >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->clearPrevalentResource(url, WTFMove(completionHandler)); >+ return; >+ } >+ >+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); >+ >+ const auto& primaryDomain = WebCore::ResourceLoadStatistics::primaryDomain(url); >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) >+ process->clearPrevalentResource(m_sessionID, primaryDomain, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); >+ } >+} >+ >+void WebsiteDataStore::resetParametersToDefaultValues(CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->resetParametersToDefaultValues(WTFMove(completionHandler)); >+ return; >+ } >+ >+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) >+ process->resetParametersToDefaultValues(m_sessionID, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); >+ } >+} >+ >+void WebsiteDataStore::submitTelemetry() >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->submitTelemetry(); >+ return; >+ } >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) >+ process->submitTelemetry(m_sessionID, [] { }); >+ } >+} >+ >+void WebsiteDataStore::scheduleClearInMemoryAndPersistent(WallTime modifiedSince, ShouldGrandfather shouldGrandfather, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(modifiedSince, shouldGrandfather, WTFMove(completionHandler)); >+ return; >+ } >+ >+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) >+ process->scheduleClearInMemoryAndPersistent(m_sessionID, modifiedSince, shouldGrandfather, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); >+ } >+} >+ >+void WebsiteDataStore::scheduleClearInMemoryAndPersistent(ShouldGrandfather shouldGrandfather, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(shouldGrandfather, WTFMove(completionHandler)); >+ return; >+ } >+ >+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) >+ process->scheduleClearInMemoryAndPersistent(m_sessionID, { }, shouldGrandfather, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); > } >+} > >- // There's a chance that we don't have any pending callbacks. If so, we want to dispatch the completion handler right away. >- callbackAggregator->callIfNeeded(); >+void WebsiteDataStore::scheduleCookieBlockingUpdate(CompletionHandler<void()>&& completionHandler) >+{ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->scheduleCookieBlockingUpdate(WTFMove(completionHandler)); >+ return; >+ } >+ >+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) >+ process->scheduleCookieBlockingUpdate(m_sessionID, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); >+ } > } > >-void WebsiteDataStore::removeDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType> dataTypes, OptionSet<WebsiteDataFetchOption> fetchOptions, const Vector<String>& topPrivatelyControlledDomains, Function<void(HashSet<String>&&)>&& completionHandler) >+void WebsiteDataStore::scheduleStatisticsAndDataRecordsProcessing(CompletionHandler<void()>&& completionHandler) > { >- fetchDataForTopPrivatelyControlledDomains(dataTypes, fetchOptions, topPrivatelyControlledDomains, [dataTypes, completionHandler = WTFMove(completionHandler), this, protectedThis = makeRef(*this)](Vector<WebsiteDataRecord>&& websiteDataRecords, HashSet<String>&& domainsWithDataRecords) mutable { >- this->removeData(dataTypes, websiteDataRecords, [domainsWithDataRecords = WTFMove(domainsWithDataRecords), completionHandler = WTFMove(completionHandler)]() mutable { >- completionHandler(WTFMove(domainsWithDataRecords)); >- }); >- }); >+ ASSERT(RunLoop::isMain()); >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->scheduleStatisticsAndDataRecordsProcessing(WTFMove(completionHandler)); >+ return; >+ } >+ >+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) >+ process->scheduleStatisticsAndDataRecordsProcessing(m_sessionID, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); >+ } > } > >-#if ENABLE(RESOURCE_LOAD_STATISTICS) > void WebsiteDataStore::updatePrevalentDomainsToBlockCookiesFor(const Vector<String>& domainsToBlock, CompletionHandler<void()>&& completionHandler) > { > auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); >@@ -1276,6 +1840,58 @@ void WebsiteDataStore::setAgeCapForClientSideCookies(Optional<Seconds> seconds, > } > } > >+void WebsiteDataStore::setLastSeen(const URL& url, Seconds seconds, CompletionHandler<void()>&& completionHandler) >+{ >+ if (url.protocolIsAbout() || url.isEmpty()) { >+ completionHandler(); >+ return; >+ } >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->setLastSeen(url, seconds, WTFMove(completionHandler)); >+ return; >+ } >+ >+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); >+ >+ const auto& primaryDomain = WebCore::ResourceLoadStatistics::primaryDomain(url); >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) >+ process->setLastSeen(m_sessionID, primaryDomain, seconds, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); >+ } >+} >+ >+void WebsiteDataStore::setNotifyPagesWhenDataRecordsWereScanned(bool value, CompletionHandler<void()>&& completionHandler) >+{ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->setNotifyPagesWhenDataRecordsWereScanned(value, WTFMove(completionHandler)); >+ return; >+ } >+ >+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) >+ process->setNotifyPagesWhenDataRecordsWereScanned(m_sessionID, value, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); >+ } >+} >+ >+void WebsiteDataStore::setNotifyPagesWhenTelemetryWasCaptured(bool value, CompletionHandler<void()>&& completionHandler) >+{ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->setNotifyPagesWhenTelemetryWasCaptured(value); >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) >+ process->setNotifyPagesWhenTelemetryWasCaptured(m_sessionID, value, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); >+ } >+} >+ > void WebsiteDataStore::hasStorageAccessForFrameHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool hasAccess)>&& completionHandler) > { > auto* webPage = WebProcessProxy::webPage(pageID); >@@ -1309,7 +1925,7 @@ void WebsiteDataStore::grantStorageAccessHandler(const String& resourceDomain, c > } > > auto& networkProcess = webPage->process().processPool().ensureNetworkProcess(); >- networkProcess.grantStorageAccess(m_sessionID, resourceDomain, firstPartyDomain, frameID, pageID, WTFMove(completionHandler)); >+ networkProcess.grantStorageAccess(m_sessionID, resourceDomain, firstPartyDomain, frameID, pageID, false, WTFMove(completionHandler)); > } > > void WebsiteDataStore::removeAllStorageAccessHandler(CompletionHandler<void()>&& completionHandler) >@@ -1334,8 +1950,20 @@ void WebsiteDataStore::hasStorageAccess(String&& subFrameHost, String&& topFrame > completionHandler(false); > return; > } >- >- m_resourceLoadStatistics->hasStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, WTFMove(completionHandler)); >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->hasStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, WTFMove(completionHandler)); >+ return; >+ } >+ >+ auto* webPage = WebProcessProxy::webPage(pageID); >+ if (!webPage) { >+ completionHandler(false); >+ return; >+ } >+ >+ if (auto networkProcess = webPage->process().processPool().networkProcess()) >+ networkProcess->hasStorageAccess(m_sessionID, WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, WTFMove(completionHandler)); > } > > void WebsiteDataStore::requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&& completionHandler) >@@ -1345,7 +1973,19 @@ void WebsiteDataStore::requestStorageAccess(String&& subFrameHost, String&& topF > return; > } > >- m_resourceLoadStatistics->requestStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, promptEnabled, WTFMove(completionHandler)); >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->requestStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, promptEnabled, WTFMove(completionHandler)); >+ return; >+ } >+ >+ auto* webPage = WebProcessProxy::webPage(pageID); >+ if (!webPage) { >+ completionHandler(StorageAccessStatus::CannotRequestAccess); >+ return; >+ } >+ >+ if (auto networkProcess = webPage->process().processPool().networkProcess()) >+ networkProcess->requestStorageAccess(m_sessionID, WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, promptEnabled, WTFMove(completionHandler)); > } > > void WebsiteDataStore::grantStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPrompted, CompletionHandler<void(bool)>&& completionHandler) >@@ -1355,7 +1995,142 @@ void WebsiteDataStore::grantStorageAccess(String&& subFrameHost, String&& topFra > return; > } > >- m_resourceLoadStatistics->grantStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, userWasPrompted, WTFMove(completionHandler)); >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->grantStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, userWasPrompted, WTFMove(completionHandler)); >+ return; >+ } >+ >+ auto* webPage = WebProcessProxy::webPage(pageID); >+ if (!webPage) { >+ completionHandler(false); >+ return; >+ } >+ >+ if (auto networkProcess = webPage->process().processPool().networkProcess()) >+ networkProcess->grantStorageAccess(m_sessionID, WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, userWasPrompted, WTFMove(completionHandler)); >+} >+ >+void WebsiteDataStore::setTimeToLiveUserInteraction(Seconds seconds, CompletionHandler<void()>&& completionHandler) >+{ >+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); >+ >+ for (auto& processPool : processPools()) { >+ if (auto* networkProcess = processPool->networkProcess()) >+ networkProcess->setTimeToLiveUserInteraction(m_sessionID, seconds, [callbackAggregator = callbackAggregator.copyRef()] { }); >+ } >+} >+ >+void WebsiteDataStore::logUserInteraction(const URL& url, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (url.protocolIsAbout() || url.isEmpty()) { >+ completionHandler(); >+ return; >+ } >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->logUserInteraction(url, WTFMove(completionHandler)); >+ return; >+ } >+ >+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) >+ process->logUserInteraction(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), [callbackAggregator = callbackAggregator.copyRef()] { }); >+ } >+} >+ >+void WebsiteDataStore::hasHadUserInteraction(const URL& url, CompletionHandler<void(bool)>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (url.protocolIsAbout() || url.isEmpty()) { >+ completionHandler(false); >+ return; >+ } >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->hasHadUserInteraction(url, WTFMove(completionHandler)); >+ return; >+ } >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) { >+ process->hasHadUserInteraction(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler)); >+ ASSERT(processPools().size() == 1); >+ break; >+ } >+ } >+} >+ >+void WebsiteDataStore::clearUserInteraction(const URL& url, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (url.protocolIsAbout() || url.isEmpty()) { >+ completionHandler(); >+ return; >+ } >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->clearUserInteraction(url, WTFMove(completionHandler)); >+ return; >+ } >+ >+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) >+ process->clearUserInteraction(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), [callbackAggregator = callbackAggregator.copyRef()] { }); >+ } >+} >+ >+void WebsiteDataStore::isGrandfathered(const URL& url, CompletionHandler<void(bool)>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (url.protocolIsAbout() || url.isEmpty()) { >+ completionHandler(false); >+ return; >+ } >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->isGrandfathered(url, WTFMove(completionHandler)); >+ return; >+ } >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) { >+ process->isGrandfathered(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler)); >+ ASSERT(processPools().size() == 1); >+ break; >+ } >+ } >+} >+ >+void WebsiteDataStore::setGrandfathered(const URL& url, bool isGrandfathered, CompletionHandler<void()>&& completionHandler) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (url.protocolIsAbout() || url.isEmpty()) { >+ completionHandler(); >+ return; >+ } >+ >+ if (m_resourceLoadStatistics) { >+ m_resourceLoadStatistics->setGrandfathered(url, isGrandfathered); >+ completionHandler(); >+ return; >+ } >+ >+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) >+ process->setGrandfathered(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), isGrandfathered, [callbackAggregator = callbackAggregator.copyRef()] { }); >+ } > } > #endif // ENABLE(RESOURCE_LOAD_STATISTICS) > >@@ -1405,8 +2180,10 @@ void WebsiteDataStore::webProcessWillOpenConnection(WebProcessProxy& webProcessP > if (m_storageManager) > m_storageManager->processWillOpenConnection(webProcessProxy, connection); > >+#if ENABLE(RESOURCE_LOAD_STATISTICS) > if (m_resourceLoadStatistics) > webProcessProxy.addMessageReceiver(Messages::WebResourceLoadStatisticsStore::messageReceiverName(), *m_resourceLoadStatistics); >+#endif > } > > void WebsiteDataStore::webPageWillOpenConnection(WebPageProxy& webPageProxy, IPC::Connection& connection) >@@ -1423,8 +2200,10 @@ void WebsiteDataStore::webPageDidCloseConnection(WebPageProxy& webPageProxy, IPC > > void WebsiteDataStore::webProcessDidCloseConnection(WebProcessProxy& webProcessProxy, IPC::Connection& connection) > { >+#if ENABLE(RESOURCE_LOAD_STATISTICS) > if (m_resourceLoadStatistics) > webProcessProxy.removeMessageReceiver(Messages::WebResourceLoadStatisticsStore::messageReceiverName()); >+#endif > > if (m_storageManager) > m_storageManager->processDidCloseConnection(webProcessProxy, connection); >@@ -1537,92 +2316,135 @@ void WebsiteDataStore::removeMediaKeys(const String& mediaKeysStorageDirectory, > > bool WebsiteDataStore::resourceLoadStatisticsEnabled() const > { >- return !!m_resourceLoadStatistics; >+ return m_resourceLoadStatisticsEnabled; > } > > void WebsiteDataStore::setResourceLoadStatisticsEnabled(bool enabled) > { >+#if ENABLE(RESOURCE_LOAD_STATISTICS) > if (m_sessionID.isEphemeral() || enabled == resourceLoadStatisticsEnabled()) > return; > > if (enabled) { >+ // FIXME(193297): Remove this assert > ASSERT(!m_resourceLoadStatistics); > enableResourceLoadStatisticsAndSetTestingCallback(nullptr); > return; > } > >- >+ // FIXME(193297): Remove these two lines > unregisterWebResourceLoadStatisticsStoreAsMessageReceiver(); > m_resourceLoadStatistics = nullptr; > >- auto existingProcessPools = processPools(std::numeric_limits<size_t>::max(), false); >- for (auto& processPool : existingProcessPools) >+ for (auto& processPool : processPools(std::numeric_limits<size_t>::max(), false)) { > processPool->setResourceLoadStatisticsEnabled(false); >+ processPool->sendToNetworkingProcess(Messages::NetworkProcess::SetResourceLoadStatisticsEnabled(false)); >+ } >+#else >+ UNUSED_PARAM(enabled); >+#endif > } > > void WebsiteDataStore::unregisterWebResourceLoadStatisticsStoreAsMessageReceiver() > { >+#if ENABLE(RESOURCE_LOAD_STATISTICS) > if (!m_resourceLoadStatistics) > return; > > for (auto* webProcessProxy : processes()) > webProcessProxy->removeMessageReceiver(Messages::WebResourceLoadStatisticsStore::messageReceiverName()); >+#endif > } > > void WebsiteDataStore::registerWebResourceLoadStatisticsStoreAsMessageReceiver() > { >+#if ENABLE(RESOURCE_LOAD_STATISTICS) > ASSERT(m_resourceLoadStatistics); > if (!m_resourceLoadStatistics) > return; > > for (auto* webProcessProxy : processes()) > webProcessProxy->addMessageReceiver(Messages::WebResourceLoadStatisticsStore::messageReceiverName(), *m_resourceLoadStatistics); >+#endif > } > > bool WebsiteDataStore::resourceLoadStatisticsDebugMode() const > { >+#if ENABLE(RESOURCE_LOAD_STATISTICS) > return m_resourceLoadStatisticsDebugMode; >+#endif > } > > void WebsiteDataStore::setResourceLoadStatisticsDebugMode(bool enabled) > { >+#if ENABLE(RESOURCE_LOAD_STATISTICS) > setResourceLoadStatisticsDebugMode(enabled, []() { }); >+#endif > } > > void WebsiteDataStore::setResourceLoadStatisticsDebugMode(bool enabled, CompletionHandler<void()>&& completionHandler) > { >+#if ENABLE(RESOURCE_LOAD_STATISTICS) > m_resourceLoadStatisticsDebugMode = enabled; >- if (m_resourceLoadStatistics) >+ if (m_resourceLoadStatistics) { > m_resourceLoadStatistics->setResourceLoadStatisticsDebugMode(enabled, WTFMove(completionHandler)); >- else >- completionHandler(); >+ return; >+ } >+ >+ auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); >+ >+ for (auto& processPool : processPools()) { >+ if (auto* process = processPool->networkProcess()) >+ process->setResourceLoadStatisticsDebugMode(m_sessionID, enabled, [callbackAggregator = callbackAggregator.copyRef()] { }); >+ } >+#endif > } > > void WebsiteDataStore::enableResourceLoadStatisticsAndSetTestingCallback(Function<void (const String&)>&& callback) > { >+#if ENABLE(RESOURCE_LOAD_STATISTICS) > ASSERT(!m_sessionID.isEphemeral()); > >- if (m_resourceLoadStatistics) { >- m_resourceLoadStatistics->setStatisticsTestingCallback(WTFMove(callback)); >+ m_resourceLoadStatisticsEnabled = true; >+ setStatisticsTestingCallback(WTFMove(callback)); >+ >+ // FIXME(193297): Remove this check >+ if (m_resourceLoadStatistics) > return; >- } > > resolveDirectoriesIfNecessary(); >- m_resourceLoadStatistics = WebResourceLoadStatisticsStore::create(*this); >- m_resourceLoadStatistics->setStatisticsTestingCallback(WTFMove(callback)); > >+ // FIXME(193297): Remove these two lines >+ m_resourceLoadStatistics = WebResourceLoadStatisticsStore::create(*this); > registerWebResourceLoadStatisticsStoreAsMessageReceiver(); > >- for (auto& processPool : processPools(std::numeric_limits<size_t>::max(), false)) >+ for (auto& processPool : processPools(std::numeric_limits<size_t>::max(), false)) { > processPool->setResourceLoadStatisticsEnabled(true); >+ processPool->sendToNetworkingProcess(Messages::NetworkProcess::SetResourceLoadStatisticsEnabled(true)); >+ } >+#else >+ UNUSED_PARAM(callback); >+#endif >+} >+ >+#if ENABLE(RESOURCE_LOAD_STATISTICS) >+void WebsiteDataStore::logTestingEvent(const String& event) >+{ >+ ASSERT(RunLoop::isMain()); >+ >+ if (m_statisticsTestingCallback) >+ m_statisticsTestingCallback(event); > } >+#endif > > void WebsiteDataStore::clearResourceLoadStatisticsInWebProcesses(CompletionHandler<void()>&& callback) > { >+#if ENABLE(RESOURCE_LOAD_STATISTICS) > if (resourceLoadStatisticsEnabled()) { > for (auto& processPool : processPools()) > processPool->clearResourceLoadStatistics(); > } >+#endif > callback(); > } > >@@ -1695,8 +2517,10 @@ void WebsiteDataStore::setMockWebAuthenticationConfiguration(MockWebAuthenticati > > void WebsiteDataStore::didCreateNetworkProcess() > { >+#if ENABLE(RESOURCE_LOAD_STATISTICS) > if (m_resourceLoadStatistics) > m_resourceLoadStatistics->didCreateNetworkProcess(); >+#endif > } > > } >diff --git a/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h b/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h >index 912d8e475cd6a217999a090178eb658fc2179c69..3373a8ce0027f973d54c3a1f6c2725ba95f3ae18 100644 >--- a/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h >+++ b/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2014-2017 Apple Inc. All rights reserved. >+ * Copyright (C) 2014-2019 Apple Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -71,7 +71,8 @@ struct WebsiteDataRecord; > struct WebsiteDataStoreParameters; > > #if ENABLE(RESOURCE_LOAD_STATISTICS) >-enum class StorageAccessStatus; >+enum class ShouldGrandfather; >+enum class StorageAccessStatus : unsigned; > enum class StorageAccessPromptStatus; > #endif > >@@ -103,7 +104,9 @@ public: > const String& serviceWorkerRegistrationDirectory() const { return m_resolvedConfiguration->serviceWorkerRegistrationDirectory(); } > void setServiceWorkerRegistrationDirectory(String&& directory) { m_resolvedConfiguration->setServiceWorkerRegistrationDirectory(WTFMove(directory)); } > >+#if ENABLE(RESOURCE_LOAD_STATISTICS) > WebResourceLoadStatisticsStore* resourceLoadStatistics() const { return m_resourceLoadStatistics.get(); } >+#endif > void clearResourceLoadStatisticsInWebProcesses(CompletionHandler<void()>&&); > > static void cloneSessionData(WebPageProxy& sourcePage, WebPageProxy& newPage); >@@ -116,16 +119,57 @@ public: > void removeDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, const Vector<String>& topPrivatelyControlledDomains, Function<void(HashSet<String>&&)>&& completionHandler); > > #if ENABLE(RESOURCE_LOAD_STATISTICS) >+ void clearPrevalentResource(const URL&, CompletionHandler<void()>&&); >+ void clearUserInteraction(const URL&, CompletionHandler<void()>&&); >+ void deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType>, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPages, CompletionHandler<void(const HashSet<String>&)>&&); >+ void dumpResourceLoadStatistics(CompletionHandler<void(const String&)>&&); >+ void logTestingEvent(const String&); >+ void logUserInteraction(const URL&, CompletionHandler<void()>&&); > void updatePrevalentDomainsToBlockCookiesFor(const Vector<String>& domainsToBlock, CompletionHandler<void()>&&); > void setAgeCapForClientSideCookies(Optional<Seconds>, CompletionHandler<void()>&&); > void hasStorageAccessForFrameHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool hasAccess)>&&); > void getAllStorageAccessEntries(uint64_t pageID, CompletionHandler<void(Vector<String>&& domains)>&&); > void grantStorageAccessHandler(const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool wasGranted)>&&); >+ void hasHadUserInteraction(const URL&, CompletionHandler<void(bool)>&&); >+ void isGrandfathered(const URL&, CompletionHandler<void(bool)>&&); >+ void isPrevalentResource(const URL&, CompletionHandler<void(bool)>&&); >+ void isRegisteredAsRedirectingTo(const URL& hostRedirectedFrom, const URL& hostRedirectedTo, CompletionHandler<void(bool)>&&); >+ void isRegisteredAsSubresourceUnder(const URL& subresource, const URL& topFrame, CompletionHandler<void(bool)>&&); >+ void isRegisteredAsSubFrameUnder(const URL& subFrame, const URL& topFrame, CompletionHandler<void(bool)>&&); >+ void isVeryPrevalentResource(const URL&, CompletionHandler<void(bool)>&&); > void removeAllStorageAccessHandler(CompletionHandler<void()>&&); > void removePrevalentDomains(const Vector<String>& domains); >+ void resetParametersToDefaultValues(CompletionHandler<void()>&&); >+ void scheduleCookieBlockingUpdate(CompletionHandler<void()>&&); >+ void scheduleClearInMemoryAndPersistent(WallTime modifiedSince, ShouldGrandfather, CompletionHandler<void()>&&); >+ void scheduleClearInMemoryAndPersistent(ShouldGrandfather, CompletionHandler<void()>&&); >+ void scheduleStatisticsAndDataRecordsProcessing(CompletionHandler<void()>&&); >+ void submitTelemetry(); >+ void setCacheMaxAgeCap(Seconds, CompletionHandler<void()>&&); >+ void setGrandfathered(const URL&, bool, CompletionHandler<void()>&&); >+ void setGrandfatheringTime(Seconds, CompletionHandler<void()>&&); >+ void setLastSeen(const URL&, Seconds, CompletionHandler<void()>&&); >+ void setNotifyPagesWhenDataRecordsWereScanned(bool, CompletionHandler<void()>&&); >+ void setPruneEntriesDownTo(size_t, CompletionHandler<void()>&&); >+ void setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame, CompletionHandler<void()>&&); >+ void setSubresourceUnderTopFrameOrigin(const URL& subresource, const URL& topFrame, CompletionHandler<void()>&&); >+ void setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo, CompletionHandler<void()>&&); >+ void setSubresourceUniqueRedirectFrom(const URL& subresource, const URL& hostNameRedirectedFrom, CompletionHandler<void()>&&); >+ void setTimeToLiveUserInteraction(Seconds, CompletionHandler<void()>&&); >+ void setTopFrameUniqueRedirectTo(const URL& topFrameHostName, const URL& hostNameRedirectedTo, CompletionHandler<void()>&&); >+ void setTopFrameUniqueRedirectFrom(const URL& topFrameHostName, const URL& hostNameRedirectedFrom, CompletionHandler<void()>&&); >+ void setMaxStatisticsEntries(size_t, CompletionHandler<void()>&&); >+ void setMinimumTimeBetweenDataRecordsRemoval(Seconds, CompletionHandler<void()>&&); >+ void setNotifyPagesWhenTelemetryWasCaptured(bool, CompletionHandler<void()>&&); >+ void setPrevalentResource(const URL&, CompletionHandler<void()>&&); >+ void setPrevalentResourceForDebugMode(const URL&, CompletionHandler<void()>&&); >+ void setShouldClassifyResourcesBeforeDataRecordsRemoval(bool, CompletionHandler<void()>&&); >+ void setStatisticsTestingCallback(WTF::Function<void(const String&)>&& callback) { m_statisticsTestingCallback = WTFMove(callback); } >+ void setVeryPrevalentResource(const URL&, CompletionHandler<void()>&&); > void hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&&); > void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&&); > void grantStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPrompted, CompletionHandler<void(bool)>&&); >+ void setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame); > #endif > void setCacheMaxAgeCapForPrevalentResources(Seconds, CompletionHandler<void()>&&); > void resetCacheMaxAgeCapForPrevalentResources(CompletionHandler<void()>&&); >@@ -229,8 +273,13 @@ private: > > const RefPtr<StorageManager> m_storageManager; > const Ref<DeviceIdHashSaltStorage> m_deviceIdHashSaltStorage; >+ >+#if ENABLE(RESOURCE_LOAD_STATISTICS) > RefPtr<WebResourceLoadStatisticsStore> m_resourceLoadStatistics; > bool m_resourceLoadStatisticsDebugMode { false }; >+ bool m_resourceLoadStatisticsEnabled { false }; >+ WTF::Function<void(const String&)> m_statisticsTestingCallback; >+#endif > > Ref<WorkQueue> m_queue; > >diff --git a/Source/WebKit/WebProcess/WebProcess.cpp b/Source/WebKit/WebProcess/WebProcess.cpp >index 023065cde8ef20533001b933681e701948b25f10..a6b2315800dce5c3bc4495d015505ed18fa1db24 100644 >--- a/Source/WebKit/WebProcess/WebProcess.cpp >+++ b/Source/WebKit/WebProcess/WebProcess.cpp >@@ -382,6 +382,10 @@ void WebProcess::initializeWebProcess(WebProcessCreationParameters&& parameters) > > ensureNetworkProcessConnection(); > >+ ResourceLoadObserver::shared().setLogUserInteractionNotificationCallback([this] (PAL::SessionID sessionID, const String& topLevelOrigin) { >+ m_networkProcessConnection->connection().send(Messages::NetworkConnectionToWebProcess::LogUserInteraction(sessionID, topLevelOrigin), 0); >+ }); >+ > setTerminationTimeout(parameters.terminationTimeout); > > resetPlugInAutoStartOriginHashes(parameters.plugInAutoStartOriginHashes);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 193556
:
359429
|
359440
|
359443
|
359446
|
359450
|
359455
|
359493
|
359509
|
359512
|
359521
|
359543
|
359548
|
359565
|
359708