Changeset 240243 in webkit


Ignore:
Timestamp:
Jan 21, 2019 2:28:04 PM (5 years ago)
Author:
Brent Fulgham
Message:

Implement message handlers for NetworkProcess-based ResourceLoadStatistics
https://bugs.webkit.org/show_bug.cgi?id=193556
<rdar://problem/47368501>

Reviewed by Alex Christensen.

Source/WebCore:

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:
  • platform/network/cocoa/NetworkStorageSessionCocoa.mm:

(WebCore::NetworkStorageSession::setCookiesFromDOM):

Source/WebKit:

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):

Location:
trunk/Source
Files:
39 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r240240 r240243  
     12019-01-21  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Implement message handlers for NetworkProcess-based ResourceLoadStatistics
     4        https://bugs.webkit.org/show_bug.cgi?id=193556
     5        <rdar://problem/47368501>
     6
     7        Reviewed by Alex Christensen.
     8
     9        This patch adds a new observer callback used to message the NetworkProcess when
     10        user interaction events are received. This is needed when the ResourceLoadStatistics
     11        data is not being managed by the UIProcess.
     12
     13        Tested by existing ResourceLoadStatistics and storageAccess tests.
     14
     15        * loader/ResourceLoadObserver.cpp:
     16        (WebCore::ResourceLoadObserver::setLogUserInteractionNotificationCallback):
     17        (WebCore::ResourceLoadObserver::logUserInteractionWithReducedTimeResolution):
     18        * loader/ResourceLoadObserver.h:
     19        * platform/network/cocoa/NetworkStorageSessionCocoa.mm:
     20        (WebCore::NetworkStorageSession::setCookiesFromDOM):
     21
    1222019-01-21  Zalan Bujtas  <zalan@apple.com>
    223
  • trunk/Source/WebCore/loader/ResourceLoadObserver.cpp

    r239888 r240243  
    7070}
    7171
     72void ResourceLoadObserver::setLogUserInteractionNotificationCallback(Function<void(PAL::SessionID, const String&)>&& callback)
     73{
     74    ASSERT(!m_logUserInteractionNotificationCallback);
     75    m_logUserInteractionNotificationCallback = WTFMove(callback);
     76}
     77
    7278ResourceLoadObserver::ResourceLoadObserver()
    7379    : m_notificationTimer(*this, &ResourceLoadObserver::notifyObserver)
     
    191197        }
    192198    }
     199
     200    // FIXME(193297): Uncomment this line when ResourceLoadStatistics are no longer gathered in the UI Process.
     201    // m_logUserInteractionNotificationCallback(document.sessionID(), domain);
    193202#endif
    194203
  • trunk/Source/WebCore/loader/ResourceLoadObserver.h

    r238771 r240243  
    4040}
    4141
     42namespace PAL {
     43class SessionID;
     44}
     45
    4246namespace WebCore {
    4347
     
    7074    WEBCORE_EXPORT void setNotificationCallback(WTF::Function<void (Vector<ResourceLoadStatistics>&&)>&&);
    7175    WEBCORE_EXPORT void setRequestStorageAccessUnderOpenerCallback(WTF::Function<void(const String&, uint64_t, const String&)>&&);
     76    WEBCORE_EXPORT void setLogUserInteractionNotificationCallback(WTF::Function<void(PAL::SessionID, const String&)>&&);
    7277
    7378    WEBCORE_EXPORT void notifyObserver();
     
    96101    WTF::Function<void (Vector<ResourceLoadStatistics>&&)> m_notificationCallback;
    97102    WTF::Function<void(const String&, uint64_t, const String&)> m_requestStorageAccessUnderOpenerCallback;
     103    WTF::Function<void(PAL::SessionID, const String&)> m_logUserInteractionNotificationCallback;
    98104    Timer m_notificationTimer;
    99105#if ENABLE(RESOURCE_LOAD_STATISTICS) && !RELEASE_LOG_DISABLED
  • trunk/Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm

    r240014 r240243  
    406406    RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies, m_ageCapForClientSideCookies);
    407407#else
    408     RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies, false);
     408    RetainPtr<NSArray> filteredCookies = filterCookies(unfilteredCookies, WTF::nullopt);
    409409#endif
    410410    ASSERT([filteredCookies.get() count] <= 1);
  • trunk/Source/WebKit/ChangeLog

    r240237 r240243  
     12019-01-21  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Implement message handlers for NetworkProcess-based ResourceLoadStatistics
     4        https://bugs.webkit.org/show_bug.cgi?id=193556
     5        <rdar://problem/47368501>
     6
     7        Reviewed by Alex Christensen.
     8
     9        This patch adds a number of sibling methods for tracking ResourceLoadStatistics when the
     10        observations are being handled in the NetworkProcess, rather than the UIProcess. The
     11        original versions of these methods will be removed as part of Bug 193303.
     12
     13        * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
     14        (WebKit::ResourceLoadStatisticsMemoryStore::removeDataRecords):
     15        (WebKit::ResourceLoadStatisticsMemoryStore::processStatisticsAndDataRecords):
     16        (WebKit::ResourceLoadStatisticsMemoryStore::grandfatherExistingWebsiteData):
     17        * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h:
     18        (WebKit::ResourceLoadStatisticsMemoryStore::store const):
     19        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
     20        (WebKit::WebResourceLoadStatisticsStore::setNotifyPagesWhenDataRecordsWereScanned):
     21        (WebKit::WebResourceLoadStatisticsStore::setNotifyPagesWhenTelemetryWasCaptured):
     22        (WebKit::WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore):
     23        (WebKit::WebResourceLoadStatisticsStore::setPrevalentResourceForDebugMode):
     24        (WebKit::WebResourceLoadStatisticsStore::scheduleStatisticsAndDataRecordsProcessing):
     25        (WebKit::WebResourceLoadStatisticsStore::hasStorageAccess):
     26        (WebKit::WebResourceLoadStatisticsStore::callHasStorageAccessForFrameHandler):
     27        (WebKit::WebResourceLoadStatisticsStore::requestStorageAccess):
     28        (WebKit::WebResourceLoadStatisticsStore::logUserInteraction):
     29        (WebKit::WebResourceLoadStatisticsStore::clearUserInteraction):
     30        (WebKit::WebResourceLoadStatisticsStore::hasHadUserInteraction):
     31        (WebKit::WebResourceLoadStatisticsStore::setLastSeen):
     32        (WebKit::WebResourceLoadStatisticsStore::setPrevalentResource):
     33        (WebKit::WebResourceLoadStatisticsStore::setVeryPrevalentResource):
     34        (WebKit::WebResourceLoadStatisticsStore::isPrevalentResource):
     35        (WebKit::WebResourceLoadStatisticsStore::isVeryPrevalentResource):
     36        (WebKit::WebResourceLoadStatisticsStore::isRegisteredAsSubresourceUnder):
     37        (WebKit::WebResourceLoadStatisticsStore::isRegisteredAsSubFrameUnder):
     38        (WebKit::WebResourceLoadStatisticsStore::isRegisteredAsRedirectingTo):
     39        (WebKit::WebResourceLoadStatisticsStore::clearPrevalentResource):
     40        (WebKit::WebResourceLoadStatisticsStore::setGrandfathered):
     41        (WebKit::WebResourceLoadStatisticsStore::isGrandfathered):
     42        (WebKit::WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin):
     43        (WebKit::WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin):
     44        (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo):
     45        (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectFrom):
     46        (WebKit::WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectTo):
     47        (WebKit::WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectFrom):
     48        (WebKit::WebResourceLoadStatisticsStore::setTimeToLiveUserInteraction):
     49        (WebKit::WebResourceLoadStatisticsStore::logTestingEvent):
     50        (WebKit::WebResourceLoadStatisticsStore::notifyResourceLoadStatisticsProcessed):
     51        (WebKit::WebResourceLoadStatisticsStore::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores):
     52        (WebKit::WebResourceLoadStatisticsStore::topPrivatelyControlledDomainsWithWebsiteData):
     53        (WebKit::WebResourceLoadStatisticsStore::sendDiagnosticMessageWithValue const):
     54        (WebKit::WebResourceLoadStatisticsStore::notifyPageStatisticsTelemetryFinished const):
     55        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
     56        * NetworkProcess/Classifier/WebResourceLoadStatisticsTelemetry.cpp:
     57        (WebKit::submitTopList):
     58        (WebKit::submitTopLists):
     59        (WebKit::notifyPages):
     60        (WebKit::WebResourceLoadStatisticsTelemetry::calculateAndSubmit):
     61        (WebKit::nonEphemeralWebPageProxy): Deleted.
     62        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
     63        (WebKit::NetworkConnectionToWebProcess::logUserInteraction):
     64        * NetworkProcess/NetworkConnectionToWebProcess.h:
     65        * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
     66        * NetworkProcess/NetworkProcess.cpp:
     67        (WebKit::NetworkProcess::dumpResourceLoadStatistics):
     68        (WebKit::NetworkProcess::isGrandfathered):
     69        (WebKit::NetworkProcess::isPrevalentResource):
     70        (WebKit::NetworkProcess::isVeryPrevalentResource):
     71        (WebKit::NetworkProcess::setGrandfathered):
     72        (WebKit::NetworkProcess::setPrevalentResource):
     73        (WebKit::NetworkProcess::setPrevalentResourceForDebugMode):
     74        (WebKit::NetworkProcess::setVeryPrevalentResource):
     75        (WebKit::NetworkProcess::clearPrevalentResource):
     76        (WebKit::NetworkProcess::submitTelemetry):
     77        (WebKit::NetworkProcess::scheduleCookieBlockingUpdate):
     78        (WebKit::NetworkProcess::scheduleClearInMemoryAndPersistent):
     79        (WebKit::NetworkProcess::resetParametersToDefaultValues):
     80        (WebKit::NetworkProcess::scheduleStatisticsAndDataRecordsProcessing):
     81        (WebKit::NetworkProcess::setNotifyPagesWhenDataRecordsWereScanned):
     82        (WebKit::NetworkProcess::setNotifyPagesWhenTelemetryWasCaptured):
     83        (WebKit::NetworkProcess::setSubframeUnderTopFrameOrigin):
     84        (WebKit::NetworkProcess::isRegisteredAsRedirectingTo):
     85        (WebKit::NetworkProcess::isRegisteredAsSubFrameUnder):
     86        (WebKit::NetworkProcess::setSubresourceUnderTopFrameOrigin):
     87        (WebKit::NetworkProcess::setSubresourceUniqueRedirectTo):
     88        (WebKit::NetworkProcess::setSubresourceUniqueRedirectFrom):
     89        (WebKit::NetworkProcess::isRegisteredAsSubresourceUnder):
     90        (WebKit::NetworkProcess::setTopFrameUniqueRedirectTo):
     91        (WebKit::NetworkProcess::setTopFrameUniqueRedirectFrom):
     92        (WebKit::NetworkProcess::setLastSeen):
     93        (WebKit::NetworkProcess::hasStorageAccess):
     94        (WebKit::NetworkProcess::requestStorageAccess):
     95        (WebKit::NetworkProcess::grantStorageAccess):
     96        (WebKit::NetworkProcess::logUserInteraction):
     97        (WebKit::NetworkProcess::hadUserInteraction):
     98        (WebKit::NetworkProcess::clearUserInteraction):
     99        (WebKit::NetworkProcess::setGrandfatheringTime):
     100        (WebKit::NetworkProcess::setMaxStatisticsEntries):
     101        (WebKit::NetworkProcess::setMinimumTimeBetweenDataRecordsRemoval):
     102        (WebKit::NetworkProcess::setPruneEntriesDownTo):
     103        (WebKit::NetworkProcess::setTimeToLiveUserInteraction):
     104        (WebKit::NetworkProcess::setShouldClassifyResourcesBeforeDataRecordsRemoval):
     105        (WebKit::NetworkProcess::setResourceLoadStatisticsEnabled):
     106        (WebKit::NetworkProcess::setResourceLoadStatisticsDebugMode):
     107        (WebKit::NetworkProcess::resetCacheMaxAgeCapForPrevalentResources):
     108        (WebKit::NetworkProcess::deleteWebsiteData):
     109        (WebKit::filterForTopLevelDomains):
     110        (WebKit::NetworkProcess::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores):
     111        (WebKit::NetworkProcess::topPrivatelyControlledDomainsWithWebsiteData):
     112        * NetworkProcess/NetworkProcess.h:
     113        * NetworkProcess/NetworkProcess.messages.in:
     114        * NetworkProcess/NetworkSession.cpp:
     115        (WebKit::NetworkSession::setResourceLoadStatisticsEnabled):
     116        (WebKit::NetworkSession::notifyResourceLoadStatisticsProcessed):
     117        (WebKit::NetworkSession::logDiagnosticMessageWithValue):
     118        (WebKit::NetworkSession::notifyPageStatisticsTelemetryFinished):
     119        (WebKit::NetworkSession::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores):
     120        (WebKit::NetworkSession::topPrivatelyControlledDomainsWithWebsiteData):
     121        (WebKit::NetworkSession::enableResourceLoadStatistics): Deleted.
     122        * NetworkProcess/NetworkSession.h:
     123        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
     124        (WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
     125        * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
     126        (WKWebsiteDataStoreSetResourceLoadStatisticsDebugModeWithCompletionHandler):
     127        (WKWebsiteDataStoreSetResourceLoadStatisticsPrevalentResourceForDebugMode):
     128        (WKWebsiteDataStoreSetStatisticsLastSeen):
     129        (WKWebsiteDataStoreSetStatisticsPrevalentResource):
     130        (WKWebsiteDataStoreSetStatisticsVeryPrevalentResource):
     131        (WKWebsiteDataStoreDumpResourceLoadStatistics):
     132        (WKWebsiteDataStoreIsStatisticsPrevalentResource):
     133        (WKWebsiteDataStoreIsStatisticsVeryPrevalentResource):
     134        (WKWebsiteDataStoreIsStatisticsRegisteredAsSubresourceUnder):
     135        (WKWebsiteDataStoreIsStatisticsRegisteredAsSubFrameUnder):
     136        (WKWebsiteDataStoreIsStatisticsRegisteredAsRedirectingTo):
     137        (WKWebsiteDataStoreSetStatisticsHasHadUserInteraction):
     138        (WKWebsiteDataStoreIsStatisticsHasHadUserInteraction):
     139        (WKWebsiteDataStoreSetStatisticsGrandfathered):
     140        (WKWebsiteDataStoreIsStatisticsGrandfathered):
     141        (WKWebsiteDataStoreSetStatisticsSubframeUnderTopFrameOrigin):
     142        (WKWebsiteDataStoreSetStatisticsSubresourceUnderTopFrameOrigin):
     143        (WKWebsiteDataStoreSetStatisticsSubresourceUniqueRedirectTo):
     144        (WKWebsiteDataStoreSetStatisticsSubresourceUniqueRedirectFrom):
     145        (WKWebsiteDataStoreSetStatisticsTopFrameUniqueRedirectTo):
     146        (WKWebsiteDataStoreSetStatisticsTopFrameUniqueRedirectFrom):
     147        (WKWebsiteDataStoreSetStatisticsTimeToLiveUserInteraction):
     148        (WKWebsiteDataStoreStatisticsProcessStatisticsAndDataRecords):
     149        (WKWebsiteDataStoreStatisticsUpdateCookieBlocking):
     150        (WKWebsiteDataStoreStatisticsSubmitTelemetry):
     151        (WKWebsiteDataStoreSetStatisticsNotifyPagesWhenDataRecordsWereScanned):
     152        (WKWebsiteDataStoreSetStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval):
     153        (WKWebsiteDataStoreSetStatisticsNotifyPagesWhenTelemetryWasCaptured):
     154        (WKWebsiteDataStoreSetStatisticsMinimumTimeBetweenDataRecordsRemoval):
     155        (WKWebsiteDataStoreSetStatisticsGrandfatheringTime):
     156        (WKWebsiteDataStoreSetStatisticsMaxStatisticsEntries):
     157        (WKWebsiteDataStoreSetStatisticsPruneEntriesDownTo):
     158        (WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStore):
     159        (WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours):
     160        (WKWebsiteDataStoreStatisticsResetToConsistentState):
     161        * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
     162        (-[WKWebsiteDataStore _setResourceLoadStatisticsTestingCallback:]):
     163        * UIProcess/Network/NetworkProcessProxy.cpp:
     164        (WebKit::NetworkProcessProxy::clearCallbackStates):
     165        (WebKit::NetworkProcessProxy::didClose):
     166        (WebKit::nonEphemeralWebPageProxy):
     167        (WebKit::NetworkProcessProxy::logGlobalDiagnosticMessageWithValue):
     168        (WebKit::NetworkProcessProxy::dumpResourceLoadStatistics):
     169        (WebKit::NetworkProcessProxy::didDumpResourceLoadStatistics):
     170        (WebKit::NetworkProcessProxy::updatePrevalentDomainsToBlockCookiesFor):
     171        (WebKit::NetworkProcessProxy::didUpdateBlockCookies):
     172        (WebKit::NetworkProcessProxy::isPrevalentResource):
     173        (WebKit::NetworkProcessProxy::isPrevalentResourceResult):
     174        (WebKit::NetworkProcessProxy::isVeryPrevalentResource):
     175        (WebKit::NetworkProcessProxy::setPrevalentResource):
     176        (WebKit::NetworkProcessProxy::setPrevalentResourceForDebugMode):
     177        (WebKit::NetworkProcessProxy::setVeryPrevalentResource):
     178        (WebKit::NetworkProcessProxy::didSetResourceLoadStatisticData):
     179        (WebKit::NetworkProcessProxy::setLastSeen):
     180        (WebKit::NetworkProcessProxy::clearPrevalentResource):
     181        (WebKit::NetworkProcessProxy::scheduleCookieBlockingUpdate):
     182        (WebKit::NetworkProcessProxy::didScheduleCookieBlockingUpdate):
     183        (WebKit::NetworkProcessProxy::scheduleClearInMemoryAndPersistent):
     184        (WebKit::NetworkProcessProxy::didScheduleStatisticsProcessing):
     185        (WebKit::NetworkProcessProxy::scheduleStatisticsAndDataRecordsProcessing):
     186        (WebKit::NetworkProcessProxy::logUserInteraction):
     187        (WebKit::NetworkProcessProxy::hasHadUserInteraction):
     188        (WebKit::NetworkProcessProxy::didHaveUserInteraction):
     189        (WebKit::NetworkProcessProxy::clearUserInteraction):
     190        (WebKit::NetworkProcessProxy::setAgeCapForClientSideCookies):
     191        (WebKit::NetworkProcessProxy::didSetAgeCapForClientSideCookies):
     192        (WebKit::NetworkProcessProxy::setTimeToLiveUserInteraction):
     193        (WebKit::NetworkProcessProxy::didUpdateRuntimeSettings):
     194        (WebKit::NetworkProcessProxy::setNotifyPagesWhenTelemetryWasCaptured):
     195        (WebKit::NetworkProcessProxy::setNotifyPagesWhenDataRecordsWereScanned):
     196        (WebKit::NetworkProcessProxy::setSubframeUnderTopFrameOrigin):
     197        (WebKit::NetworkProcessProxy::isRegisteredAsRedirectingTo):
     198        (WebKit::NetworkProcessProxy::didIsRegisteredAsRedirectingTo):
     199        (WebKit::NetworkProcessProxy::isRegisteredAsSubFrameUnder):
     200        (WebKit::NetworkProcessProxy::didIsRegisteredAsSubFrameUnder):
     201        (WebKit::NetworkProcessProxy::setSubresourceUnderTopFrameOrigin):
     202        (WebKit::NetworkProcessProxy::isRegisteredAsSubresourceUnder):
     203        (WebKit::NetworkProcessProxy::didIsRegisteredAsSubresourceUnder):
     204        (WebKit::NetworkProcessProxy::setSubresourceUniqueRedirectTo):
     205        (WebKit::NetworkProcessProxy::setSubresourceUniqueRedirectFrom):
     206        (WebKit::NetworkProcessProxy::setTopFrameUniqueRedirectTo):
     207        (WebKit::NetworkProcessProxy::setTopFrameUniqueRedirectFrom):
     208        (WebKit::NetworkProcessProxy::isGrandfathered):
     209        (WebKit::NetworkProcessProxy::didIsGrandfathered):
     210        (WebKit::NetworkProcessProxy::setGrandfathered):
     211        (WebKit::NetworkProcessProxy::hasStorageAccess):
     212        (WebKit::NetworkProcessProxy::requestStorageAccess):
     213        (WebKit::NetworkProcessProxy::grantStorageAccess):
     214        (WebKit::NetworkProcessProxy::storageAccessRequestResult):
     215        (WebKit::NetworkProcessProxy::storageAccessOperationResult):
     216        (WebKit::NetworkProcessProxy::didRemoveAllStorageAccess):
     217        (WebKit::NetworkProcessProxy::didSetCacheMaxAgeCapForPrevalentResources):
     218        (WebKit::NetworkProcessProxy::setCacheMaxAgeCap):
     219        (WebKit::NetworkProcessProxy::setGrandfatheringTime):
     220        (WebKit::NetworkProcessProxy::setMaxStatisticsEntries):
     221        (WebKit::NetworkProcessProxy::setMinimumTimeBetweenDataRecordsRemoval):
     222        (WebKit::NetworkProcessProxy::setPruneEntriesDownTo):
     223        (WebKit::NetworkProcessProxy::setShouldClassifyResourcesBeforeDataRecordsRemoval):
     224        (WebKit::NetworkProcessProxy::setResourceLoadStatisticsDebugMode):
     225        (WebKit::NetworkProcessProxy::resetParametersToDefaultValues):
     226        (WebKit::NetworkProcessProxy::submitTelemetry):
     227        (WebKit::NetworkProcessProxy::notifyResourceLoadStatisticsProcessed):
     228        (WebKit::NetworkProcessProxy::notifyWebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished):
     229        (WebKit::NetworkProcessProxy::notifyWebsiteDataScanForTopPrivatelyControlledDomainsFinished):
     230        (WebKit::NetworkProcessProxy::notifyResourceLoadStatisticsTelemetryFinished):
     231        (WebKit::NetworkProcessProxy::didLogUserInteraction): Deleted.
     232        (WebKit::NetworkProcessProxy::didResetCacheMaxAgeCapForPrevalentResources): Deleted.
     233        * UIProcess/Network/NetworkProcessProxy.h:
     234        * UIProcess/Network/NetworkProcessProxy.messages.in:
     235        * UIProcess/WebPageProxy.cpp:
     236        (WebKit::WebPageProxy::nonEphemeralWebPageProxy):
     237        * UIProcess/WebPageProxy.h:
     238        * UIProcess/WebProcessPool.cpp:
     239        (WebKit::WebProcessPool::ensureNetworkProcess):
     240        * UIProcess/WebProcessProxy.cpp:
     241        (WebKit::WebProcessProxy::notifyWebsiteDataScanForTopPrivatelyControlledDomainsFinished):
     242        (WebKit::WebProcessProxy::notifyWebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished):
     243        * UIProcess/WebProcessProxy.h:
     244        * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
     245        (WebKit::WebsiteDataStore::parameters):
     246        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
     247        (WebKit::WebsiteDataStore::removeData):
     248        (WebKit::WebsiteDataStore::setMaxStatisticsEntries):
     249        (WebKit::WebsiteDataStore::setPruneEntriesDownTo):
     250        (WebKit::WebsiteDataStore::setGrandfatheringTime):
     251        (WebKit::WebsiteDataStore::setCacheMaxAgeCap):
     252        (WebKit::WebsiteDataStore::setMinimumTimeBetweenDataRecordsRemoval):
     253        (WebKit::WebsiteDataStore::dumpResourceLoadStatistics):
     254        (WebKit::WebsiteDataStore::isPrevalentResource):
     255        (WebKit::WebsiteDataStore::setPrevalentResource):
     256        (WebKit::WebsiteDataStore::setPrevalentResourceForDebugMode):
     257        (WebKit::WebsiteDataStore::isVeryPrevalentResource):
     258        (WebKit::WebsiteDataStore::setVeryPrevalentResource):
     259        (WebKit::WebsiteDataStore::setShouldClassifyResourcesBeforeDataRecordsRemoval):
     260        (WebKit::WebsiteDataStore::setSubframeUnderTopFrameOrigin):
     261        (WebKit::WebsiteDataStore::isRegisteredAsSubFrameUnder):
     262        (WebKit::WebsiteDataStore::setSubresourceUnderTopFrameOrigin):
     263        (WebKit::WebsiteDataStore::isRegisteredAsSubresourceUnder):
     264        (WebKit::WebsiteDataStore::setSubresourceUniqueRedirectTo):
     265        (WebKit::WebsiteDataStore::setSubresourceUniqueRedirectFrom):
     266        (WebKit::WebsiteDataStore::setTopFrameUniqueRedirectTo):
     267        (WebKit::WebsiteDataStore::setTopFrameUniqueRedirectFrom):
     268        (WebKit::WebsiteDataStore::isRegisteredAsRedirectingTo):
     269        (WebKit::WebsiteDataStore::clearPrevalentResource):
     270        (WebKit::WebsiteDataStore::resetParametersToDefaultValues):
     271        (WebKit::WebsiteDataStore::submitTelemetry):
     272        (WebKit::WebsiteDataStore::scheduleClearInMemoryAndPersistent):
     273        (WebKit::WebsiteDataStore::scheduleCookieBlockingUpdate):
     274        (WebKit::WebsiteDataStore::scheduleStatisticsAndDataRecordsProcessing):
     275        (WebKit::WebsiteDataStore::updatePrevalentDomainsToBlockCookiesFor):
     276        (WebKit::WebsiteDataStore::setAgeCapForClientSideCookies):
     277        (WebKit::WebsiteDataStore::setLastSeen):
     278        (WebKit::WebsiteDataStore::setNotifyPagesWhenDataRecordsWereScanned):
     279        (WebKit::WebsiteDataStore::setNotifyPagesWhenTelemetryWasCaptured):
     280        (WebKit::WebsiteDataStore::hasStorageAccessForFrameHandler):
     281        (WebKit::WebsiteDataStore::getAllStorageAccessEntries):
     282        (WebKit::WebsiteDataStore::grantStorageAccessHandler):
     283        (WebKit::WebsiteDataStore::removeAllStorageAccessHandler):
     284        (WebKit::WebsiteDataStore::removePrevalentDomains):
     285        (WebKit::WebsiteDataStore::hasStorageAccess):
     286        (WebKit::WebsiteDataStore::requestStorageAccess):
     287        (WebKit::WebsiteDataStore::grantStorageAccess):
     288        (WebKit::WebsiteDataStore::setTimeToLiveUserInteraction):
     289        (WebKit::WebsiteDataStore::logUserInteraction):
     290        (WebKit::WebsiteDataStore::hasHadUserInteraction):
     291        (WebKit::WebsiteDataStore::clearUserInteraction):
     292        (WebKit::WebsiteDataStore::isGrandfathered):
     293        (WebKit::WebsiteDataStore::setGrandfathered):
     294        (WebKit::WebsiteDataStore::setCacheMaxAgeCapForPrevalentResources):
     295        (WebKit::WebsiteDataStore::resetCacheMaxAgeCapForPrevalentResources):
     296        (WebKit::WebsiteDataStore::webPageWasAdded):
     297        (WebKit::WebsiteDataStore::webPageWasInvalidated):
     298        (WebKit::WebsiteDataStore::webProcessWillOpenConnection):
     299        (WebKit::WebsiteDataStore::webPageWillOpenConnection):
     300        (WebKit::WebsiteDataStore::webPageDidCloseConnection):
     301        (WebKit::WebsiteDataStore::webProcessDidCloseConnection):
     302        (WebKit::WebsiteDataStore::isAssociatedProcessPool const):
     303        (WebKit::WebsiteDataStore::processPools const):
     304        (WebKit::WebsiteDataStore::resourceLoadStatisticsEnabled const):
     305        (WebKit::WebsiteDataStore::setResourceLoadStatisticsEnabled):
     306        (WebKit::WebsiteDataStore::setResourceLoadStatisticsDebugMode):
     307        (WebKit::WebsiteDataStore::enableResourceLoadStatisticsAndSetTestingCallback):
     308        (WebKit::WebsiteDataStore::logTestingEvent):
     309        * UIProcess/WebsiteData/WebsiteDataStore.h:
     310        (WebKit::WebsiteDataStore::setStatisticsTestingCallback):
     311        * WebProcess/WebProcess.cpp:
     312        (WebKit::WebProcess::initializeWebProcess):
     313
    13142019-01-15  Darin Adler  <darin@apple.com>
    2315
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp

    r240129 r240243  
    2727#include "ResourceLoadStatisticsMemoryStore.h"
    2828
     29#if ENABLE(RESOURCE_LOAD_STATISTICS)
     30
    2931#include "Logging.h"
    3032#include "NetworkSession.h"
     
    245247
    246248    RunLoop::main().dispatch([prevalentResourceDomains = crossThreadCopy(prevalentResourceDomains), callback = WTFMove(callback), weakThis = makeWeakPtr(*this), shouldNotifyPagesWhenDataRecordsWereScanned = m_parameters.shouldNotifyPagesWhenDataRecordsWereScanned, workQueue = m_workQueue.copyRef()] () mutable {
    247         WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(WebResourceLoadStatisticsStore::monitoredDataTypes(), WTFMove(prevalentResourceDomains), shouldNotifyPagesWhenDataRecordsWereScanned, [callback = WTFMove(callback), weakThis = WTFMove(weakThis), workQueue = workQueue.copyRef()](const HashSet<String>& domainsWithDeletedWebsiteData) mutable {
     249        if (!weakThis) {
     250            callback();
     251            return;
     252        }
     253
     254        weakThis->m_store.deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(WebResourceLoadStatisticsStore::monitoredDataTypes(), WTFMove(prevalentResourceDomains), shouldNotifyPagesWhenDataRecordsWereScanned, [callback = WTFMove(callback), weakThis = WTFMove(weakThis), workQueue = workQueue.copyRef()](const HashSet<String>& domainsWithDeletedWebsiteData) mutable {
    248255            workQueue->dispatch([topDomains = crossThreadCopy(domainsWithDeletedWebsiteData), callback = WTFMove(callback), weakThis = WTFMove(weakThis)] () mutable {
    249256                if (!weakThis) {
     
    359366            return;
    360367
    361         RunLoop::main().dispatch([] {
    362             WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed();
     368        RunLoop::main().dispatch([this, weakThis = makeWeakPtr(*this)] {
     369            ASSERT(RunLoop::isMain());
     370            if (!weakThis)
     371                return;
     372
     373            m_store.notifyResourceLoadStatisticsProcessed();
    363374        });
    364375    });
    365376}
    366377
    367 void ResourceLoadStatisticsMemoryStore::hasStorageAccess(const String& subFramePrimaryDomain, const String& topFramePrimaryDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler)
     378void ResourceLoadStatisticsMemoryStore::hasStorageAccess(const String& subFramePrimaryDomain, const String& topFramePrimaryDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler)
    368379{
    369380    ASSERT(!RunLoop::isMain());
     
    381392
    382393    RunLoop::main().dispatch([store = makeRef(m_store), subFramePrimaryDomain = subFramePrimaryDomain.isolatedCopy(), topFramePrimaryDomain = topFramePrimaryDomain.isolatedCopy(), frameID, pageID, completionHandler = WTFMove(completionHandler)]() mutable {
    383         store->callHasStorageAccessForFrameHandler(subFramePrimaryDomain, topFramePrimaryDomain, frameID, pageID, [store = store.copyRef(), completionHandler = WTFMove(completionHandler)](bool result) mutable {
     394        store->callHasStorageAccessForFrameHandler(subFramePrimaryDomain, topFramePrimaryDomain, frameID.value(), pageID, [store = store.copyRef(), completionHandler = WTFMove(completionHandler)](bool result) mutable {
    384395            store->statisticsQueue().dispatch([completionHandler = WTFMove(completionHandler), result] () mutable {
    385396                completionHandler(result);
     
    495506    ASSERT(!RunLoop::isMain());
    496507
    497     RunLoop::main().dispatch([weakThis = makeWeakPtr(*this), callback = WTFMove(callback), shouldNotifyPagesWhenDataRecordsWereScanned = m_parameters.shouldNotifyPagesWhenDataRecordsWereScanned, workQueue = m_workQueue.copyRef()] () mutable {
    498         // FIXME: This method being a static call on WebProcessProxy is wrong.
    499         // It should be on the data store that this object belongs to.
    500         WebProcessProxy::topPrivatelyControlledDomainsWithWebsiteData(WebResourceLoadStatisticsStore::monitoredDataTypes(), shouldNotifyPagesWhenDataRecordsWereScanned, [weakThis = WTFMove(weakThis), callback = WTFMove(callback), workQueue = workQueue.copyRef()] (HashSet<String>&& topPrivatelyControlledDomainsWithWebsiteData) mutable {
    501             workQueue->dispatch([weakThis = WTFMove(weakThis), topDomains = crossThreadCopy(topPrivatelyControlledDomainsWithWebsiteData), callback = WTFMove(callback)] () mutable {
     508    RunLoop::main().dispatch([weakThis = makeWeakPtr(*this), callback = WTFMove(callback), shouldNotifyPagesWhenDataRecordsWereScanned = m_parameters.shouldNotifyPagesWhenDataRecordsWereScanned, workQueue = m_workQueue.copyRef(), store = makeRef(m_store)] () mutable {
     509        store->topPrivatelyControlledDomainsWithWebsiteData(WebResourceLoadStatisticsStore::monitoredDataTypes(), shouldNotifyPagesWhenDataRecordsWereScanned, [weakThis = WTFMove(weakThis), callback = WTFMove(callback), workQueue = workQueue.copyRef()] (HashSet<String>&& topDomainsWithWebsiteData) mutable {
     510            workQueue->dispatch([weakThis = WTFMove(weakThis), topDomains = crossThreadCopy(topDomainsWithWebsiteData), callback = WTFMove(callback)] () mutable {
    502511                if (!weakThis) {
    503512                    callback();
     
    12991308
    13001309} // namespace WebKit
     1310
     1311#endif
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h

    r239747 r240243  
    2626#pragma once
    2727
     28#if ENABLE(RESOURCE_LOAD_STATISTICS)
     29
    2830#include "ResourceLoadStatisticsClassifier.h"
    2931#include "WebResourceLoadStatisticsStore.h"
     
    117119    void setPrevalentResourceForDebugMode(const String& domain);
    118120
    119     void hasStorageAccess(const String& subFramePrimaryDomain, const String& topFramePrimaryDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&&);
     121    void hasStorageAccess(const String& subFramePrimaryDomain, const String& topFramePrimaryDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&&);
    120122    void requestStorageAccess(String&& subFramePrimaryDomain, String&& topFramePrimaryDomain, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&&);
    121123    void grantStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPromptedNow, CompletionHandler<void(bool)>&&);
     
    130132
    131133    void didCreateNetworkProcess();
     134
     135    const WebResourceLoadStatisticsStore& store() const { return m_store; }
    132136
    133137private:
     
    202206
    203207} // namespace WebKit
     208
     209#endif
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsPersistentStorage.cpp

    r239747 r240243  
    2727#include "ResourceLoadStatisticsPersistentStorage.h"
    2828
     29#if ENABLE(RESOURCE_LOAD_STATISTICS)
     30
    2931#include "Logging.h"
    3032#include "PersistencyUtils.h"
     
    271273
    272274} // namespace WebKit
     275
     276#endif
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsPersistentStorage.h

    r239747 r240243  
    2525
    2626#pragma once
     27
     28#if ENABLE(RESOURCE_LOAD_STATISTICS)
    2729
    2830#include <wtf/Forward.h>
     
    7678
    7779}
     80
     81#endif
  • trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp

    r239816 r240243  
    2727#include "WebResourceLoadStatisticsStore.h"
    2828
     29#if ENABLE(RESOURCE_LOAD_STATISTICS)
     30
     31#include "APIDictionary.h"
    2932#include "Logging.h"
    3033#include "NetworkSession.h"
     
    3437#include "WebPageProxy.h"
    3538#include "WebProcessMessages.h"
     39#include "WebProcessPool.h"
    3640#include "WebProcessProxy.h"
    3741#include "WebResourceLoadStatisticsStoreMessages.h"
     
    3943#include "WebsiteDataFetchOption.h"
    4044#include "WebsiteDataStore.h"
     45#include <WebCore/DiagnosticLoggingClient.h>
     46#include <WebCore/DiagnosticLoggingKeys.h>
    4147#include <WebCore/NetworkStorageSession.h>
    4248#include <WebCore/ResourceLoadStatistics.h>
     
    8995}
    9096
    91 void WebResourceLoadStatisticsStore::setShouldClassifyResourcesBeforeDataRecordsRemoval(bool value)
     97void WebResourceLoadStatisticsStore::setNotifyPagesWhenDataRecordsWereScanned(bool value, CompletionHandler<void()>&& completionHandler)
     98{
     99    ASSERT(RunLoop::isMain());
     100   
     101    postTask([this, value, completionHandler = WTFMove(completionHandler)]() mutable {
     102        if (m_memoryStore)
     103            m_memoryStore->setNotifyPagesWhenDataRecordsWereScanned(value);
     104       
     105        postTaskReply(WTFMove(completionHandler));
     106    });
     107}
     108
     109void WebResourceLoadStatisticsStore::setShouldClassifyResourcesBeforeDataRecordsRemoval(bool value, CompletionHandler<void()>&& completionHandler)
     110{
     111    ASSERT(RunLoop::isMain());
     112
     113    postTask([this, value, completionHandler = WTFMove(completionHandler)]() mutable {
     114        if (m_memoryStore)
     115            m_memoryStore->setShouldClassifyResourcesBeforeDataRecordsRemoval(value);
     116
     117        postTaskReply(WTFMove(completionHandler));
     118    });
     119}
     120
     121void WebResourceLoadStatisticsStore::setShouldSubmitTelemetry(bool value)
    92122{
    93123    ASSERT(RunLoop::isMain());
     
    95125    postTask([this, value] {
    96126        if (m_memoryStore)
    97             m_memoryStore->setShouldClassifyResourcesBeforeDataRecordsRemoval(value);
    98     });
    99 }
    100 
    101 void WebResourceLoadStatisticsStore::setShouldSubmitTelemetry(bool value)
    102 {
    103     ASSERT(RunLoop::isMain());
    104 
    105     postTask([this, value] {
    106         if (m_memoryStore)
    107127            m_memoryStore->setShouldSubmitTelemetry(value);
    108128    });
     129}
     130
     131void WebResourceLoadStatisticsStore::setNotifyPagesWhenTelemetryWasCaptured(bool value, CompletionHandler<void()>&& completionHandler)
     132{
     133    ASSERT(RunLoop::isMain());
     134
     135    WebKit::WebResourceLoadStatisticsTelemetry::setNotifyPagesWhenTelemetryWasCaptured(value);
     136    completionHandler();
    109137}
    110138
     
    134162        m_memoryStore = std::make_unique<ResourceLoadStatisticsMemoryStore>(*this, m_statisticsQueue);
    135163        m_persistentStorage = std::make_unique<ResourceLoadStatisticsPersistentStorage>(*m_memoryStore, m_statisticsQueue, resourceLoadStatisticsDirectory);
     164
     165        // FIXME(193297): This should be revised after the UIProcess version goes away.
     166        m_memoryStore->didCreateNetworkProcess();
    136167    });
    137168   
     
    195226    ASSERT(RunLoop::isMain());
    196227
    197     postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)]() mutable {
     228    setPrevalentResourceForDebugMode(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler));
     229}
     230
     231void WebResourceLoadStatisticsStore::setPrevalentResourceForDebugMode(const String& primaryDomain, CompletionHandler<void()>&& completionHandler)
     232{
     233    ASSERT(RunLoop::isMain());
     234   
     235    postTask([this, primaryDomain = primaryDomain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable {
    198236        if (m_memoryStore)
    199237            m_memoryStore->setPrevalentResourceForDebugMode(primaryDomain);
     
    202240}
    203241
    204 void WebResourceLoadStatisticsStore::scheduleStatisticsAndDataRecordsProcessing()
    205 {
    206     ASSERT(RunLoop::isMain());
    207 
    208     postTask([this] {
     242void WebResourceLoadStatisticsStore::scheduleStatisticsAndDataRecordsProcessing(CompletionHandler<void()>&& completionHandler)
     243{
     244    ASSERT(RunLoop::isMain());
     245   
     246    postTask([this, completionHandler = WTFMove(completionHandler)]() mutable {
    209247        if (m_memoryStore)
    210248            m_memoryStore->processStatisticsAndDataRecords();
     249        postTaskReply(WTFMove(completionHandler));
    211250    });
    212251}
     
    234273}
    235274
    236 void WebResourceLoadStatisticsStore::hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, CompletionHandler<void (bool)>&& completionHandler)
     275void WebResourceLoadStatisticsStore::hasStorageAccess(const String& subFrameHost, const String& topFrameHost, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler)
    237276{
    238277    ASSERT(subFrameHost != topFrameHost);
    239278    ASSERT(RunLoop::isMain());
    240279
    241     postTask([this, subFramePrimaryDomain = isolatedPrimaryDomain(subFrameHost), topFramePrimaryDomain = isolatedPrimaryDomain(topFrameHost), frameID, pageID, completionHandler = WTFMove(completionHandler)] () mutable {
     280    postTask([this, subFramePrimaryDomain = subFrameHost.isolatedCopy(), topFramePrimaryDomain = topFrameHost.isolatedCopy(), frameID, pageID, completionHandler = WTFMove(completionHandler)]() mutable {
    242281        if (!m_memoryStore) {
    243             postTaskReply([completionHandler = WTFMove(completionHandler)] () mutable {
     282            postTaskReply([completionHandler = WTFMove(completionHandler)]() mutable {
    244283                completionHandler(false);
    245284            });
     
    247286        }
    248287        m_memoryStore->hasStorageAccess(subFramePrimaryDomain, topFramePrimaryDomain, frameID, pageID, [completionHandler = WTFMove(completionHandler)](bool hasStorageAccess) mutable {
    249             postTaskReply([completionHandler = WTFMove(completionHandler), hasStorageAccess] () mutable {
     288            postTaskReply([completionHandler = WTFMove(completionHandler), hasStorageAccess]() mutable {
    250289                completionHandler(hasStorageAccess);
    251290            });
     
    254293}
    255294
    256 #if ENABLE(RESOURCE_LOAD_STATISTICS)
    257295bool WebResourceLoadStatisticsStore::hasStorageAccessForFrame(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID)
    258296{
    259297    return m_networkSession ? m_networkSession->networkStorageSession().hasStorageAccess(resourceDomain, firstPartyDomain, frameID, pageID) : false;
    260298}
    261 #endif
    262299
    263300void WebResourceLoadStatisticsStore::callHasStorageAccessForFrameHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool hasAccess)>&& callback)
     
    265302    ASSERT(RunLoop::isMain());
    266303
    267 #if ENABLE(RESOURCE_LOAD_STATISTICS)
    268304    if (m_websiteDataStore) {
    269305        m_websiteDataStore->hasStorageAccessForFrameHandler(resourceDomain, firstPartyDomain, frameID, pageID, WTFMove(callback));
    270306        return;
    271     } else {
    272         callback(hasStorageAccessForFrame(resourceDomain, firstPartyDomain, frameID, pageID));
    273         return;
    274     }
    275 #endif
     307    }
     308
     309    if (m_networkSession) {
     310        callback(m_networkSession->networkStorageSession().hasStorageAccess(resourceDomain, firstPartyDomain, frameID, pageID));
     311        return;
     312    }
     313
    276314    callback(false);
    277315}
     
    282320    ASSERT(RunLoop::isMain());
    283321
     322    requestStorageAccess(subFrameHost, topFrameHost, frameID, pageID, promptEnabled, WTFMove(completionHandler));
     323}
     324   
     325void WebResourceLoadStatisticsStore::requestStorageAccess(const String& subFrameHost, const String& topFrameHost, Optional<uint64_t> frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&& completionHandler)
     326{
    284327    auto subFramePrimaryDomain = isolatedPrimaryDomain(subFrameHost);
    285328    auto topFramePrimaryDomain = isolatedPrimaryDomain(topFrameHost);
     
    289332    }
    290333
    291     postTask([this, subFramePrimaryDomain = crossThreadCopy(subFramePrimaryDomain), topFramePrimaryDomain = crossThreadCopy(topFramePrimaryDomain), frameID, pageID, promptEnabled, completionHandler = WTFMove(completionHandler)] () mutable {
     334    postTask([this, subFramePrimaryDomain = crossThreadCopy(subFramePrimaryDomain), topFramePrimaryDomain = crossThreadCopy(topFramePrimaryDomain), frameID, pageID, promptEnabled, completionHandler = WTFMove(completionHandler)]() mutable {
    292335        if (!m_memoryStore) {
    293             postTaskReply([completionHandler = WTFMove(completionHandler)] () mutable {
     336            postTaskReply([completionHandler = WTFMove(completionHandler)]() mutable {
    294337                completionHandler(StorageAccessStatus::CannotRequestAccess);
    295338            });
     
    297340        }
    298341
    299         m_memoryStore->requestStorageAccess(WTFMove(subFramePrimaryDomain), WTFMove(topFramePrimaryDomain), frameID, pageID, promptEnabled, [completionHandler = WTFMove(completionHandler)](StorageAccessStatus status) mutable {
    300             postTaskReply([completionHandler = WTFMove(completionHandler), status] () mutable {
     342        m_memoryStore->requestStorageAccess(WTFMove(subFramePrimaryDomain), WTFMove(topFramePrimaryDomain), frameID.value(), pageID, promptEnabled, [completionHandler = WTFMove(completionHandler)](StorageAccessStatus status) mutable {
     343            postTaskReply([completionHandler = WTFMove(completionHandler), status]() mutable {
    301344                completionHandler(status);
    302345            });
     
    321364{
    322365    ASSERT(RunLoop::isMain());
    323     postTask([this, subFrameHost = crossThreadCopy(subFrameHost), topFrameHost = crossThreadCopy(topFrameHost), frameID, pageID, userWasPromptedNow, completionHandler = WTFMove(completionHandler)] () mutable {
     366    postTask([this, subFrameHost = crossThreadCopy(subFrameHost), topFrameHost = crossThreadCopy(topFrameHost), frameID, pageID, userWasPromptedNow, completionHandler = WTFMove(completionHandler)]() mutable {
    324367        if (!m_memoryStore) {
    325             postTaskReply([completionHandler = WTFMove(completionHandler)] () mutable {
     368            postTaskReply([completionHandler = WTFMove(completionHandler)]() mutable {
    326369                completionHandler(false);
    327370            });
     
    330373
    331374        m_memoryStore->grantStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, userWasPromptedNow, [completionHandler = WTFMove(completionHandler)](bool wasGrantedAccess) mutable {
    332             postTaskReply([completionHandler = WTFMove(completionHandler), wasGrantedAccess] () mutable {
     375            postTaskReply([completionHandler = WTFMove(completionHandler), wasGrantedAccess]() mutable {
    333376                completionHandler(wasGrantedAccess);
    334377            });
     
    337380}
    338381
    339 #if ENABLE(RESOURCE_LOAD_STATISTICS)
    340382bool WebResourceLoadStatisticsStore::grantStorageAccess(const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID)
    341383{
     
    350392    return isStorageGranted;
    351393}
    352 #endif
    353394
    354395void WebResourceLoadStatisticsStore::callGrantStorageAccessHandler(const String& subFramePrimaryDomain, const String& topFramePrimaryDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback)
     
    356397    ASSERT(RunLoop::isMain());
    357398
    358 #if ENABLE(RESOURCE_LOAD_STATISTICS)
    359399    if (m_websiteDataStore) {
    360400        m_websiteDataStore->grantStorageAccessHandler(subFramePrimaryDomain, topFramePrimaryDomain, frameID, pageID, WTFMove(callback));
    361401        return;
    362     } else {
    363         callback(grantStorageAccess(subFramePrimaryDomain, topFramePrimaryDomain, frameID, pageID));
    364         return;
    365     }
    366 #endif
    367     callback(false);
     402    }
     403
     404    callback(grantStorageAccess(subFramePrimaryDomain, topFramePrimaryDomain, frameID, pageID));
    368405}
    369406
     
    379416}
    380417
    381 #if ENABLE(RESOURCE_LOAD_STATISTICS)
    382418void WebResourceLoadStatisticsStore::removeAllStorageAccess()
    383419{
     
    385421        m_networkSession->networkStorageSession().removeAllStorageAccess();
    386422}
    387 #endif
    388423
    389424void WebResourceLoadStatisticsStore::removeAllStorageAccess(CompletionHandler<void()>&& completionHandler)
     
    391426    ASSERT(RunLoop::isMain());
    392427
    393 #if ENABLE(RESOURCE_LOAD_STATISTICS)
    394428    if (m_websiteDataStore) {
    395429        m_websiteDataStore->removeAllStorageAccessHandler(WTFMove(completionHandler));
     
    397431    }
    398432    removeAllStorageAccess();
    399 #endif
    400433    completionHandler();
    401434}
     
    419452}
    420453
    421 void WebResourceLoadStatisticsStore::submitTelemetry()
    422 {
    423     ASSERT(RunLoop::isMain());
    424 
    425     postTask([this] {
     454void WebResourceLoadStatisticsStore::submitTelemetry(CompletionHandler<void()>&& completionHandler)
     455{
     456    ASSERT(RunLoop::isMain());
     457
     458    postTask([this, completionHandler = WTFMove(completionHandler)]() mutable {
    426459        if (m_memoryStore)
    427460            WebResourceLoadStatisticsTelemetry::calculateAndSubmit(*m_memoryStore);
     461
     462        postTaskReply(WTFMove(completionHandler));
    428463    });
    429464}
     
    477512    }
    478513
    479     logUserInteraction(isolatedPrimaryDomain(url), WTFMove(completionHandler));
     514    logUserInteraction(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler));
    480515}
    481516
     
    500535    }
    501536
    502     postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)]() mutable {
     537    clearUserInteraction(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler));
     538}
     539
     540void WebResourceLoadStatisticsStore::clearUserInteraction(const String& targetPrimaryDomain, CompletionHandler<void()>&& completionHandler)
     541{
     542    ASSERT(RunLoop::isMain());
     543   
     544    postTask([this, primaryDomain = targetPrimaryDomain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable {
    503545        if (m_memoryStore)
    504546            m_memoryStore->clearUserInteraction(primaryDomain);
     
    516558    }
    517559
    518     postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)] () mutable {
     560    hasHadUserInteraction(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler));
     561}
     562
     563void WebResourceLoadStatisticsStore::hasHadUserInteraction(const String& primaryDomain, CompletionHandler<void(bool)>&& completionHandler)
     564{
     565    postTask([this, primaryDomain = primaryDomain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable {
    519566        bool hadUserInteraction = m_memoryStore ? m_memoryStore->hasHadUserInteraction(primaryDomain) : false;
    520         postTaskReply([hadUserInteraction, completionHandler = WTFMove(completionHandler)] () mutable {
     567        postTaskReply([hadUserInteraction, completionHandler = WTFMove(completionHandler)]() mutable {
    521568            completionHandler(hadUserInteraction);
    522569        });
     
    533580    }
    534581
    535     postTask([this, primaryDomain = isolatedPrimaryDomain(url), seconds, completionHandler = WTFMove(completionHandler)]() mutable {
    536         if (m_memoryStore)
    537             m_memoryStore->setLastSeen(primaryDomain, seconds);
     582    setLastSeen(WebCore::ResourceLoadStatistics::primaryDomain(url), seconds, WTFMove(completionHandler));
     583}
     584
     585void WebResourceLoadStatisticsStore::setLastSeen(const String& resourceDomain, Seconds seconds, CompletionHandler<void()>&& completionHandler)
     586{
     587    ASSERT(RunLoop::isMain());
     588   
     589    postTask([this, resourceDomain = resourceDomain.isolatedCopy(), seconds, completionHandler = WTFMove(completionHandler)]() mutable {
     590        if (m_memoryStore)
     591            m_memoryStore->setLastSeen(resourceDomain, seconds);
    538592        postTaskReply(WTFMove(completionHandler));
    539593    });
     
    549603    }
    550604
    551     postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)]() mutable {
    552         if (m_memoryStore)
    553             m_memoryStore->setPrevalentResource(primaryDomain);
     605    setPrevalentResource(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler));
     606}
     607
     608void WebResourceLoadStatisticsStore::setPrevalentResource(const String& resourceDomain, CompletionHandler<void()>&& completionHandler)
     609{
     610    ASSERT(RunLoop::isMain());
     611
     612    postTask([this, resourceDomain = resourceDomain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable {
     613        if (m_memoryStore)
     614            m_memoryStore->setPrevalentResource(resourceDomain);
    554615        postTaskReply(WTFMove(completionHandler));
    555616    });
     
    565626    }
    566627
    567     postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)]() mutable {
     628    setVeryPrevalentResource(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler));
     629}
     630
     631void WebResourceLoadStatisticsStore::setVeryPrevalentResource(const String& primaryDomain, CompletionHandler<void()>&& completionHandler)
     632{
     633    ASSERT(RunLoop::isMain());
     634
     635    postTask([this, primaryDomain = primaryDomain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable {
    568636        if (m_memoryStore)
    569637            m_memoryStore->setVeryPrevalentResource(primaryDomain);
     
    576644    ASSERT(RunLoop::isMain());
    577645
    578     postTask([this, completionHandler = WTFMove(completionHandler)] () mutable {
     646    postTask([this, completionHandler = WTFMove(completionHandler)]() mutable {
    579647        String result = m_memoryStore ? m_memoryStore->dumpResourceLoadStatistics() : emptyString();
    580         postTaskReply([result = result.isolatedCopy(), completionHandler = WTFMove(completionHandler)] () mutable {
     648        postTaskReply([result = result.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable {
    581649            completionHandler(result);
    582650        });
     
    593661    }
    594662
    595     postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)] () mutable {
     663    isPrevalentResource(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler));
     664}
     665
     666void WebResourceLoadStatisticsStore::isPrevalentResource(const String& primaryDomain, CompletionHandler<void(bool)>&& completionHandler)
     667{
     668    ASSERT(RunLoop::isMain());
     669   
     670    postTask([this, primaryDomain = primaryDomain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable {
    596671        bool isPrevalentResource = m_memoryStore ? m_memoryStore->isPrevalentResource(primaryDomain) : false;
    597         postTaskReply([isPrevalentResource, completionHandler = WTFMove(completionHandler)] () mutable {
     672        postTaskReply([isPrevalentResource, completionHandler = WTFMove(completionHandler)]() mutable {
    598673            completionHandler(isPrevalentResource);
    599674        });
    600675    });
    601676}
    602 
     677   
    603678void WebResourceLoadStatisticsStore::isVeryPrevalentResource(const URL& url, CompletionHandler<void(bool)>&& completionHandler)
    604679{
     
    610685    }
    611686   
    612     postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)] () mutable {
     687    isVeryPrevalentResource(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler));
     688}
     689
     690void WebResourceLoadStatisticsStore::isVeryPrevalentResource(const String& primaryDomain, CompletionHandler<void(bool)>&& completionHandler)
     691{
     692    ASSERT(RunLoop::isMain());
     693   
     694    postTask([this, primaryDomain = primaryDomain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable {
    613695        bool isVeryPrevalentResource = m_memoryStore ? m_memoryStore->isVeryPrevalentResource(primaryDomain) : false;
    614         postTaskReply([isVeryPrevalentResource, completionHandler = WTFMove(completionHandler)] () mutable {
     696        postTaskReply([isVeryPrevalentResource, completionHandler = WTFMove(completionHandler)]() mutable {
    615697            completionHandler(isVeryPrevalentResource);
    616698        });
     
    621703{
    622704    ASSERT(RunLoop::isMain());
    623    
    624     postTask([this, subresourcePrimaryDomain = isolatedPrimaryDomain(subresource), topFramePrimaryDomain = isolatedPrimaryDomain(topFrame), completionHandler = WTFMove(completionHandler)] () mutable {
     705
     706    isRegisteredAsSubresourceUnder(WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), WTFMove(completionHandler));
     707}
     708
     709void WebResourceLoadStatisticsStore::isRegisteredAsSubresourceUnder(const String& subresource, const String& topFrame, CompletionHandler<void(bool)>&& completionHandler)
     710{
     711    ASSERT(RunLoop::isMain());
     712
     713    postTask([this, subresourcePrimaryDomain = subresource.isolatedCopy(), topFramePrimaryDomain = topFrame.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable {
    625714        bool isRegisteredAsSubresourceUnder = m_memoryStore ? m_memoryStore->isRegisteredAsSubresourceUnder(subresourcePrimaryDomain, topFramePrimaryDomain) : false;
    626         postTaskReply([isRegisteredAsSubresourceUnder, completionHandler = WTFMove(completionHandler)] () mutable {
     715        postTaskReply([isRegisteredAsSubresourceUnder, completionHandler = WTFMove(completionHandler)]() mutable {
    627716            completionHandler(isRegisteredAsSubresourceUnder);
    628717        });
     
    634723    ASSERT(RunLoop::isMain());
    635724
    636     postTask([this, subFramePrimaryDomain = isolatedPrimaryDomain(subFrame), topFramePrimaryDomain = isolatedPrimaryDomain(topFrame), completionHandler = WTFMove(completionHandler)] () mutable {
     725    isRegisteredAsSubFrameUnder(WebCore::ResourceLoadStatistics::primaryDomain(subFrame), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), WTFMove(completionHandler));
     726}
     727
     728void WebResourceLoadStatisticsStore::isRegisteredAsSubFrameUnder(const String& subFrame, const String& topFrame, CompletionHandler<void(bool)>&& completionHandler)
     729{
     730    ASSERT(RunLoop::isMain());
     731
     732    postTask([this, subFramePrimaryDomain = subFrame.isolatedCopy(), topFramePrimaryDomain = topFrame.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable {
    637733        bool isRegisteredAsSubFrameUnder = m_memoryStore ? m_memoryStore->isRegisteredAsSubFrameUnder(subFramePrimaryDomain, topFramePrimaryDomain) : false;
    638         postTaskReply([isRegisteredAsSubFrameUnder, completionHandler = WTFMove(completionHandler)] () mutable {
     734        postTaskReply([isRegisteredAsSubFrameUnder, completionHandler = WTFMove(completionHandler)]() mutable {
    639735            completionHandler(isRegisteredAsSubFrameUnder);
    640736        });
     
    646742    ASSERT(RunLoop::isMain());
    647743
    648     postTask([this, hostRedirectedFromPrimaryDomain = isolatedPrimaryDomain(hostRedirectedFrom), hostRedirectedToPrimaryDomain = isolatedPrimaryDomain(hostRedirectedTo), completionHandler = WTFMove(completionHandler)] () mutable {
     744    isRegisteredAsRedirectingTo(WebCore::ResourceLoadStatistics::primaryDomain(hostRedirectedFrom), WebCore::ResourceLoadStatistics::primaryDomain(hostRedirectedTo), WTFMove(completionHandler));
     745}
     746
     747void WebResourceLoadStatisticsStore::isRegisteredAsRedirectingTo(const String& hostRedirectedFrom, const String& hostRedirectedTo, CompletionHandler<void(bool)>&& completionHandler)
     748{
     749    ASSERT(RunLoop::isMain());
     750
     751    postTask([this, hostRedirectedFromPrimaryDomain = hostRedirectedFrom.isolatedCopy(), hostRedirectedToPrimaryDomain = hostRedirectedTo.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable {
    649752        bool isRegisteredAsRedirectingTo = m_memoryStore ? m_memoryStore->isRegisteredAsRedirectingTo(hostRedirectedFromPrimaryDomain, hostRedirectedToPrimaryDomain) : false;
    650         postTaskReply([isRegisteredAsRedirectingTo, completionHandler = WTFMove(completionHandler)] () mutable {
     753        postTaskReply([isRegisteredAsRedirectingTo, completionHandler = WTFMove(completionHandler)]() mutable {
    651754            completionHandler(isRegisteredAsRedirectingTo);
    652755        });
     
    663766    }
    664767
    665     postTask([this, primaryDomain = isolatedPrimaryDomain(url), completionHandler = WTFMove(completionHandler)]() mutable {
    666         if (m_memoryStore)
    667             m_memoryStore->clearPrevalentResource(primaryDomain);
    668         postTaskReply(WTFMove(completionHandler));
    669     });
    670 }
    671 
    672 void WebResourceLoadStatisticsStore::setGrandfathered(const URL& url, bool value)
     768    clearPrevalentResource(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler));
     769}
     770
     771void WebResourceLoadStatisticsStore::clearPrevalentResource(const String& resourceDomain, CompletionHandler<void()>&& completionHandler)
     772{
     773    ASSERT(RunLoop::isMain());
     774   
     775    postTask([this, resourceDomain = resourceDomain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable {
     776        if (m_memoryStore)
     777            m_memoryStore->clearPrevalentResource(resourceDomain);
     778        postTaskReply(WTFMove(completionHandler));
     779    });
     780}
     781
     782void WebResourceLoadStatisticsStore::setGrandfathered(const URL& url, bool value, CompletionHandler<void()>&& completionHandler)
    673783{
    674784    ASSERT(RunLoop::isMain());
     
    677787        return;
    678788
    679     postTask([this, primaryDomain = isolatedPrimaryDomain(url), value] {
     789    setGrandfathered(WebCore::ResourceLoadStatistics::primaryDomain(url), value, WTFMove(completionHandler));
     790}
     791
     792void WebResourceLoadStatisticsStore::setGrandfathered(const String& domain, bool value, CompletionHandler<void()>&& completionHandler)
     793{
     794    ASSERT(RunLoop::isMain());
     795
     796    postTask([this, primaryDomain = domain.isolatedCopy(), value, completionHandler = WTFMove(completionHandler)]() mutable {
    680797        if (m_memoryStore)
    681798            m_memoryStore->setGrandfathered(primaryDomain, value);
    682     });
    683 }
    684 
     799        postTaskReply(WTFMove(completionHandler));
     800    });
     801}
     802   
    685803void WebResourceLoadStatisticsStore::isGrandfathered(const URL& url, CompletionHandler<void (bool)>&& completionHandler)
    686804{
     
    692810    }
    693811
    694     postTask([this, completionHandler = WTFMove(completionHandler), primaryDomain = isolatedPrimaryDomain(url)] () mutable {
     812    isGrandfathered(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler));
     813}
     814
     815void WebResourceLoadStatisticsStore::isGrandfathered(const String& primaryDomain, CompletionHandler<void(bool)>&& completionHandler)
     816{
     817    ASSERT(RunLoop::isMain());
     818
     819    postTask([this, completionHandler = WTFMove(completionHandler), primaryDomain = primaryDomain.isolatedCopy()]() mutable {
    695820        bool isGrandFathered = m_memoryStore ? m_memoryStore->isGrandfathered(primaryDomain) : false;
    696         postTaskReply([isGrandFathered, completionHandler = WTFMove(completionHandler)] () mutable {
     821        postTaskReply([isGrandFathered, completionHandler = WTFMove(completionHandler)]() mutable {
    697822            completionHandler(isGrandFathered);
    698823        });
     
    700825}
    701826
    702 void WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame)
    703 {
    704     ASSERT(RunLoop::isMain());
    705 
    706     if (subframe.protocolIsAbout() || subframe.isEmpty() || topFrame.protocolIsAbout() || topFrame.isEmpty())
    707         return;
    708 
    709     postTask([this, primaryTopFrameDomain = isolatedPrimaryDomain(topFrame), primarySubFrameDomain = isolatedPrimaryDomain(subframe)] {
     827void WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame, CompletionHandler<void()>&& completionHandler)
     828{
     829    ASSERT(RunLoop::isMain());
     830
     831    if (subframe.protocolIsAbout() || subframe.isEmpty() || topFrame.protocolIsAbout() || topFrame.isEmpty()) {
     832        completionHandler();
     833        return;
     834    }
     835
     836    setSubframeUnderTopFrameOrigin(WebCore::ResourceLoadStatistics::primaryDomain(subframe), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), WTFMove(completionHandler));
     837}
     838
     839void WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin(const String& subframe, const String& topFrame, CompletionHandler<void()>&& completionHandler)
     840{
     841    ASSERT(RunLoop::isMain());
     842   
     843    postTask([this, completionHandler = WTFMove(completionHandler), primaryTopFrameDomain = topFrame.isolatedCopy(), primarySubFrameDomain = subframe.isolatedCopy()]() mutable {
    710844        if (m_memoryStore)
    711845            m_memoryStore->setSubframeUnderTopFrameOrigin(primarySubFrameDomain, primaryTopFrameDomain);
    712     });
    713 }
    714 
    715 void WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin(const URL& subresource, const URL& topFrame)
    716 {
    717     ASSERT(RunLoop::isMain());
    718 
    719     if (subresource.protocolIsAbout() || subresource.isEmpty() || topFrame.protocolIsAbout() || topFrame.isEmpty())
    720         return;
    721 
    722     postTask([this, primaryTopFrameDomain = isolatedPrimaryDomain(topFrame), primarySubresourceDomain = isolatedPrimaryDomain(subresource)] {
     846        postTaskReply(WTFMove(completionHandler));
     847    });
     848}
     849
     850void WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin(const URL& subresource, const URL& topFrame, CompletionHandler<void()>&& completionHandler)
     851{
     852    ASSERT(RunLoop::isMain());
     853
     854    if (subresource.protocolIsAbout() || subresource.isEmpty() || topFrame.protocolIsAbout() || topFrame.isEmpty()) {
     855        completionHandler();
     856        return;
     857    }
     858
     859    setSubresourceUnderTopFrameOrigin(WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), WTFMove(completionHandler));
     860}
     861
     862void WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin(const String& subresource, const String& topFrame, CompletionHandler<void()>&& completionHandler)
     863{
     864    ASSERT(RunLoop::isMain());
     865   
     866    postTask([this, completionHandler = WTFMove(completionHandler), primaryTopFrameDomain = topFrame.isolatedCopy(), primarySubresourceDomain = subresource.isolatedCopy()]() mutable {
    723867        if (m_memoryStore)
    724868            m_memoryStore->setSubresourceUnderTopFrameOrigin(primarySubresourceDomain, primaryTopFrameDomain);
    725     });
    726 }
    727 
    728 void WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo)
    729 {
    730     ASSERT(RunLoop::isMain());
    731 
    732     if (subresource.protocolIsAbout() || subresource.isEmpty() || hostNameRedirectedTo.protocolIsAbout() || hostNameRedirectedTo.isEmpty())
    733         return;
    734 
    735     postTask([this, primaryRedirectDomain = isolatedPrimaryDomain(hostNameRedirectedTo), primarySubresourceDomain = isolatedPrimaryDomain(subresource)] {
     869        postTaskReply(WTFMove(completionHandler));
     870    });
     871}
     872
     873void WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler)
     874{
     875    ASSERT(RunLoop::isMain());
     876
     877    if (subresource.protocolIsAbout() || subresource.isEmpty() || hostNameRedirectedTo.protocolIsAbout() || hostNameRedirectedTo.isEmpty()) {
     878        completionHandler();
     879        return;
     880    }
     881
     882    setSubresourceUniqueRedirectTo(WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedTo), WTFMove(completionHandler));
     883}
     884
     885void WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo(const String& subresource, const String& hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler)
     886{
     887    ASSERT(RunLoop::isMain());
     888   
     889    postTask([this, completionHandler = WTFMove(completionHandler), primaryRedirectDomain = hostNameRedirectedTo.isolatedCopy(), primarySubresourceDomain = subresource.isolatedCopy()]() mutable {
    736890        if (m_memoryStore)
    737891            m_memoryStore->setSubresourceUniqueRedirectTo(primarySubresourceDomain, primaryRedirectDomain);
    738     });
    739 }
    740 
    741 void WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectFrom(const URL& subresource, const URL& hostNameRedirectedFrom)
    742 {
    743     ASSERT(RunLoop::isMain());
    744 
    745     if (subresource.protocolIsAbout() || subresource.isEmpty() || hostNameRedirectedFrom.protocolIsAbout() || hostNameRedirectedFrom.isEmpty())
    746         return;
    747    
    748     postTask([this, primaryRedirectDomain = isolatedPrimaryDomain(hostNameRedirectedFrom), primarySubresourceDomain = isolatedPrimaryDomain(subresource)] {
     892        postTaskReply(WTFMove(completionHandler));
     893    });
     894}
     895
     896void WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectFrom(const URL& subresource, const URL& hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler)
     897{
     898    ASSERT(RunLoop::isMain());
     899
     900    if (subresource.protocolIsAbout() || subresource.isEmpty() || hostNameRedirectedFrom.protocolIsAbout() || hostNameRedirectedFrom.isEmpty()) {
     901        completionHandler();
     902        return;
     903    }
     904
     905    setSubresourceUniqueRedirectFrom(WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedFrom), WTFMove(completionHandler));
     906}
     907
     908void WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectFrom(const String& subresource, const String& hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler)
     909{
     910    ASSERT(RunLoop::isMain());
     911   
     912    postTask([this, completionHandler = WTFMove(completionHandler), primaryRedirectDomain = hostNameRedirectedFrom.isolatedCopy(), primarySubresourceDomain = subresource.isolatedCopy()]() mutable {
    749913        if (m_memoryStore)
    750914            m_memoryStore->setSubresourceUniqueRedirectFrom(primarySubresourceDomain, primaryRedirectDomain);
    751     });
    752 }
    753 
    754 void WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectTo(const URL& topFrameHostName, const URL& hostNameRedirectedTo)
    755 {
    756     ASSERT(RunLoop::isMain());
    757 
    758     if (topFrameHostName.protocolIsAbout() || topFrameHostName.isEmpty() || hostNameRedirectedTo.protocolIsAbout() || hostNameRedirectedTo.isEmpty())
    759         return;
    760    
    761     postTask([this, primaryRedirectDomain = isolatedPrimaryDomain(hostNameRedirectedTo), topFramePrimaryDomain = isolatedPrimaryDomain(topFrameHostName)] {
     915        postTaskReply(WTFMove(completionHandler));
     916    });
     917}
     918
     919void WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectTo(const URL& topFrameHostName, const URL& hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler)
     920{
     921    ASSERT(RunLoop::isMain());
     922
     923    if (topFrameHostName.protocolIsAbout() || topFrameHostName.isEmpty() || hostNameRedirectedTo.protocolIsAbout() || hostNameRedirectedTo.isEmpty()) {
     924        completionHandler();
     925        return;
     926    }
     927
     928    setTopFrameUniqueRedirectTo(WebCore::ResourceLoadStatistics::primaryDomain(topFrameHostName), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedTo), WTFMove(completionHandler));
     929}
     930
     931void WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectTo(const String& topFrameHostName, const String& hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler)
     932{
     933    ASSERT(RunLoop::isMain());
     934   
     935    postTask([this, completionHandler = WTFMove(completionHandler), topFramePrimaryDomain = topFrameHostName.isolatedCopy(), primaryRedirectDomain = hostNameRedirectedTo.isolatedCopy()]() mutable {
    762936        if (m_memoryStore)
    763937            m_memoryStore->setTopFrameUniqueRedirectTo(topFramePrimaryDomain, primaryRedirectDomain);
    764     });
    765 }
    766 
    767 void WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectFrom(const URL& topFrameHostName, const URL& hostNameRedirectedFrom)
    768 {
    769     ASSERT(RunLoop::isMain());
    770 
    771     if (topFrameHostName.protocolIsAbout() || topFrameHostName.isEmpty() || hostNameRedirectedFrom.protocolIsAbout() || hostNameRedirectedFrom.isEmpty())
    772         return;
    773    
    774     postTask([this, primaryRedirectDomain = isolatedPrimaryDomain(hostNameRedirectedFrom), topFramePrimaryDomain = isolatedPrimaryDomain(topFrameHostName)] {
     938        postTaskReply(WTFMove(completionHandler));
     939    });
     940}
     941
     942void WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectFrom(const URL& topFrameHostName, const URL& hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler)
     943{
     944    ASSERT(RunLoop::isMain());
     945
     946    if (topFrameHostName.protocolIsAbout() || topFrameHostName.isEmpty() || hostNameRedirectedFrom.protocolIsAbout() || hostNameRedirectedFrom.isEmpty()) {
     947        completionHandler();
     948        return;
     949    }
     950
     951    setTopFrameUniqueRedirectFrom(WebCore::ResourceLoadStatistics::primaryDomain(topFrameHostName), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedFrom), WTFMove(completionHandler));
     952}
     953
     954void WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectFrom(const String& topFrameHostName, const String& hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler)
     955{
     956    ASSERT(RunLoop::isMain());
     957   
     958    postTask([this, completionHandler = WTFMove(completionHandler), topFramePrimaryDomain = topFrameHostName.isolatedCopy(), primaryRedirectDomain = hostNameRedirectedFrom.isolatedCopy()]() mutable {
    775959        if (m_memoryStore)
    776960            m_memoryStore->setTopFrameUniqueRedirectFrom(topFramePrimaryDomain, primaryRedirectDomain);
     961        postTaskReply(WTFMove(completionHandler));
    777962    });
    778963}
     
    783968    ASSERT(RunLoop::isMain());
    784969
    785     postTask([this, completionHandler = WTFMove(completionHandler)] () mutable {
     970    postTask([this, completionHandler = WTFMove(completionHandler)]() mutable {
    786971        if (!m_memoryStore) {
    787972            postTaskReply(WTFMove(completionHandler));
    788973            return;
    789974        }
    790         m_memoryStore->updateCookieBlocking([completionHandler = WTFMove(completionHandler)] () mutable {
     975        m_memoryStore->updateCookieBlocking([completionHandler = WTFMove(completionHandler)]() mutable {
    791976            postTaskReply(WTFMove(completionHandler));
    792977        });
     
    798983    // Helper function used by testing system. Should only be called from the main thread.
    799984    ASSERT(RunLoop::isMain());
    800     postTask([this, domainsToBlock = crossThreadCopy(domainsToBlock), completionHandler = WTFMove(completionHandler)] () mutable {
     985    postTask([this, domainsToBlock = crossThreadCopy(domainsToBlock), completionHandler = WTFMove(completionHandler)]() mutable {
    801986        if (!m_memoryStore) {
    802987            postTaskReply(WTFMove(completionHandler));
     
    814999    // Helper function used by testing system. Should only be called from the main thread.
    8151000    ASSERT(RunLoop::isMain());
    816     postTask([this, domains = crossThreadCopy(domains), completionHandler = WTFMove(completionHandler)] () mutable {
     1001    postTask([this, domains = crossThreadCopy(domains), completionHandler = WTFMove(completionHandler)]() mutable {
    8171002        if (!m_memoryStore) {
    8181003            postTaskReply(WTFMove(completionHandler));
     
    8291014{
    8301015    ASSERT(RunLoop::isMain());
    831     postTask([this, protectedThis = makeRef(*this), shouldGrandfather, completionHandler = WTFMove(completionHandler)] () mutable {
     1016    postTask([this, protectedThis = makeRef(*this), shouldGrandfather, completionHandler = WTFMove(completionHandler)]() mutable {
    8321017        if (m_persistentStorage)
    8331018            m_persistentStorage->clear();
     
    8621047}
    8631048
    864 void WebResourceLoadStatisticsStore::setTimeToLiveUserInteraction(Seconds seconds)
    865 {
    866     ASSERT(RunLoop::isMain());
    867     postTask([this, seconds] {
     1049void WebResourceLoadStatisticsStore::setTimeToLiveUserInteraction(Seconds seconds, CompletionHandler<void()>&& completionHandler)
     1050{
     1051    ASSERT(RunLoop::isMain());
     1052    postTask([this, seconds, completionHandler = WTFMove(completionHandler)]() mutable {
    8681053        if (m_memoryStore)
    8691054            m_memoryStore->setTimeToLiveUserInteraction(seconds);
    870     });
    871 }
    872 
    873 void WebResourceLoadStatisticsStore::setMinimumTimeBetweenDataRecordsRemoval(Seconds seconds)
    874 {
    875     ASSERT(RunLoop::isMain());
    876     postTask([this, seconds] {
     1055        postTaskReply(WTFMove(completionHandler));
     1056    });
     1057}
     1058
     1059void WebResourceLoadStatisticsStore::setMinimumTimeBetweenDataRecordsRemoval(Seconds seconds, CompletionHandler<void()>&& completionHandler)
     1060{
     1061    ASSERT(RunLoop::isMain());
     1062    postTask([this, seconds, completionHandler = WTFMove(completionHandler)]() mutable  {
    8771063        if (m_memoryStore)
    8781064            m_memoryStore->setMinimumTimeBetweenDataRecordsRemoval(seconds);
    879     });
    880 }
    881 
    882 void WebResourceLoadStatisticsStore::setGrandfatheringTime(Seconds seconds)
    883 {
    884     ASSERT(RunLoop::isMain());
    885     postTask([this, seconds] {
     1065
     1066        postTaskReply(WTFMove(completionHandler));
     1067    });
     1068}
     1069
     1070void WebResourceLoadStatisticsStore::setGrandfatheringTime(Seconds seconds, CompletionHandler<void()>&& completionHandler)
     1071{
     1072    ASSERT(RunLoop::isMain());
     1073    postTask([this, seconds, completionHandler = WTFMove(completionHandler)]() mutable  {
    8861074        if (m_memoryStore)
    8871075            m_memoryStore->setGrandfatheringTime(seconds);
    888     });
    889 }
    890 
    891 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     1076
     1077        postTaskReply(WTFMove(completionHandler));
     1078    });
     1079}
     1080
    8921081void WebResourceLoadStatisticsStore::setCacheMaxAgeCapForPrevalentResources(Seconds seconds)
    8931082{
     
    8951084        m_networkSession->networkStorageSession().setCacheMaxAgeCapForPrevalentResources(seconds);
    8961085}
    897 #endif
    8981086
    8991087void WebResourceLoadStatisticsStore::setCacheMaxAgeCap(Seconds seconds, CompletionHandler<void()>&& completionHandler)
     
    9021090    ASSERT(seconds >= 0_s);
    9031091   
    904 #if ENABLE(RESOURCE_LOAD_STATISTICS)
    9051092    if (m_websiteDataStore) {
    9061093        m_websiteDataStore->setCacheMaxAgeCapForPrevalentResources(seconds, WTFMove(completionHandler));
     
    9081095    }
    9091096    setCacheMaxAgeCapForPrevalentResources(seconds);
    910 #endif
    9111097    completionHandler();
    9121098}
    9131099
    914 #if ENABLE(RESOURCE_LOAD_STATISTICS)
    9151100void WebResourceLoadStatisticsStore::updatePrevalentDomainsToBlockCookiesFor(const Vector<String>& domainsToBlock)
    9161101{
     
    9181103        m_networkSession->networkStorageSession().setPrevalentDomainsToBlockCookiesFor(domainsToBlock);
    9191104}
    920 #endif
    9211105
    9221106void WebResourceLoadStatisticsStore::callUpdatePrevalentDomainsToBlockCookiesForHandler(const Vector<String>& domainsToBlock, CompletionHandler<void()>&& completionHandler)
     
    9241108    ASSERT(RunLoop::isMain());
    9251109
    926 #if ENABLE(RESOURCE_LOAD_STATISTICS)
    9271110    if (m_websiteDataStore) {
    9281111        m_websiteDataStore->updatePrevalentDomainsToBlockCookiesFor(domainsToBlock, WTFMove(completionHandler));
     
    9301113    }
    9311114    updatePrevalentDomainsToBlockCookiesFor(domainsToBlock);
    932 #endif
    9331115    completionHandler();
    9341116}
    9351117
    936 #if ENABLE(RESOURCE_LOAD_STATISTICS)
    9371118void WebResourceLoadStatisticsStore::removePrevalentDomains(const Vector<String>& domains)
    9381119{
     
    9401121        m_networkSession->networkStorageSession().removePrevalentDomains(domains);
    9411122}
    942 #endif
    9431123
    9441124void WebResourceLoadStatisticsStore::callRemoveDomainsHandler(const Vector<String>& domains)
     
    9461126    ASSERT(RunLoop::isMain());
    9471127
    948 #if ENABLE(RESOURCE_LOAD_STATISTICS)
    9491128    if (m_websiteDataStore)
    9501129        m_websiteDataStore->removePrevalentDomains(domains);
    9511130    removePrevalentDomains(domains);
     1131}
     1132   
     1133void WebResourceLoadStatisticsStore::setMaxStatisticsEntries(size_t maximumEntryCount, CompletionHandler<void()>&& completionHandler)
     1134{
     1135    ASSERT(RunLoop::isMain());
     1136    postTask([this, maximumEntryCount, completionHandler = WTFMove(completionHandler)]() mutable  {
     1137        if (m_memoryStore)
     1138            m_memoryStore->setMaxStatisticsEntries(maximumEntryCount);
     1139
     1140        postTaskReply(WTFMove(completionHandler));
     1141    });
     1142}
     1143   
     1144void WebResourceLoadStatisticsStore::setPruneEntriesDownTo(size_t pruneTargetCount, CompletionHandler<void()>&& completionHandler)
     1145{
     1146    ASSERT(RunLoop::isMain());
     1147
     1148    postTask([this, pruneTargetCount, completionHandler = WTFMove(completionHandler)]() mutable  {
     1149        if (m_memoryStore)
     1150            m_memoryStore->setPruneEntriesDownTo(pruneTargetCount);
     1151
     1152        postTaskReply(WTFMove(completionHandler));
     1153    });
     1154}
     1155
     1156void WebResourceLoadStatisticsStore::resetParametersToDefaultValues(CompletionHandler<void()>&& completionHandler)
     1157{
     1158    ASSERT(RunLoop::isMain());
     1159
     1160    postTask([this, completionHandler = WTFMove(completionHandler)]() mutable {
     1161        if (m_memoryStore)
     1162            m_memoryStore->resetParametersToDefaultValues();
     1163
     1164        postTaskReply(WTFMove(completionHandler));
     1165    });
     1166}
     1167
     1168void WebResourceLoadStatisticsStore::logTestingEvent(const String& event)
     1169{
     1170    ASSERT(RunLoop::isMain());
     1171
     1172    if (m_websiteDataStore) {
     1173        m_websiteDataStore->logTestingEvent(event);
     1174        return;
     1175    }
     1176    // FIXME(193297): Send message to UIProcess
     1177}
     1178
     1179void WebResourceLoadStatisticsStore::notifyResourceLoadStatisticsProcessed()
     1180{
     1181    ASSERT(RunLoop::isMain());
     1182   
     1183    if (m_websiteDataStore)
     1184        WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed();
     1185
     1186    if (m_networkSession)
     1187        m_networkSession->notifyResourceLoadStatisticsProcessed();
     1188}
     1189
     1190void WebResourceLoadStatisticsStore::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType> dataTypes, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&& completionHandler)
     1191{
     1192    ASSERT(RunLoop::isMain());
     1193   
     1194    if (m_websiteDataStore) {
     1195        WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(dataTypes, WTFMove(topPrivatelyControlledDomains), shouldNotifyPage, WTFMove(completionHandler));
     1196        return;
     1197    }
     1198
     1199    if (m_networkSession) {
     1200        m_networkSession->deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(dataTypes, WTFMove(topPrivatelyControlledDomains), shouldNotifyPage, WTFMove(completionHandler));
     1201        return;
     1202    }
     1203
     1204    completionHandler({ });
     1205}
     1206
     1207void WebResourceLoadStatisticsStore::topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType> dataTypes, bool shouldNotifyPage, CompletionHandler<void(HashSet<String>&&)>&& completionHandler)
     1208{
     1209    ASSERT(RunLoop::isMain());
     1210   
     1211    if (m_websiteDataStore) {
     1212        WebProcessProxy::topPrivatelyControlledDomainsWithWebsiteData(dataTypes, shouldNotifyPage, WTFMove(completionHandler));
     1213        return;
     1214    }
     1215
     1216    if (m_networkSession) {
     1217        m_networkSession->topPrivatelyControlledDomainsWithWebsiteData(dataTypes, shouldNotifyPage, WTFMove(completionHandler));
     1218        return;
     1219    }
     1220
     1221    completionHandler({ });
     1222}
     1223
     1224void WebResourceLoadStatisticsStore::sendDiagnosticMessageWithValue(const String& message, const String& description, unsigned value, unsigned sigDigits, WebCore::ShouldSample shouldSample) const
     1225{
     1226    if (m_websiteDataStore) {
     1227        if (auto* webPageProxy = WebPageProxy::nonEphemeralWebPageProxy())
     1228            webPageProxy->logDiagnosticMessageWithValue(message, description, value, sigDigits, shouldSample);
     1229    }
     1230
     1231    if (m_networkSession)
     1232        const_cast<WebResourceLoadStatisticsStore*>(this)->networkSession()->logDiagnosticMessageWithValue(message, description, value, sigDigits, shouldSample);
     1233}
     1234
     1235void WebResourceLoadStatisticsStore::notifyPageStatisticsTelemetryFinished(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins) const
     1236{
     1237    if (m_websiteDataStore) {
     1238        API::Dictionary::MapType messageBody;
     1239        messageBody.set("TotalPrevalentResources"_s, API::UInt64::create(totalPrevalentResources));
     1240        messageBody.set("TotalPrevalentResourcesWithUserInteraction"_s, API::UInt64::create(totalPrevalentResourcesWithUserInteraction));
     1241        messageBody.set("Top3SubframeUnderTopFrameOrigins"_s, API::UInt64::create(top3SubframeUnderTopFrameOrigins));
     1242        WebProcessProxy::notifyPageStatisticsTelemetryFinished(API::Dictionary::create(messageBody).ptr());
     1243    }
     1244
     1245    if (m_networkSession)
     1246        const_cast<WebResourceLoadStatisticsStore*>(this)->networkSession()->notifyPageStatisticsTelemetryFinished(totalPrevalentResources, totalPrevalentResourcesWithUserInteraction, top3SubframeUnderTopFrameOrigins);
     1247}
     1248
     1249} // namespace WebKit
     1250
    9521251#endif
    953 }
    954    
    955 void WebResourceLoadStatisticsStore::setMaxStatisticsEntries(size_t maximumEntryCount)
    956 {
    957     ASSERT(RunLoop::isMain());
    958     postTask([this, maximumEntryCount] {
    959         if (m_memoryStore)
    960             m_memoryStore->setMaxStatisticsEntries(maximumEntryCount);
    961     });
    962 }
    963    
    964 void WebResourceLoadStatisticsStore::setPruneEntriesDownTo(size_t pruneTargetCount)
    965 {
    966     ASSERT(RunLoop::isMain());
    967 
    968     postTask([this, pruneTargetCount] {
    969         if (m_memoryStore)
    970             m_memoryStore->setPruneEntriesDownTo(pruneTargetCount);
    971     });
    972 }
    973 
    974 void WebResourceLoadStatisticsStore::resetParametersToDefaultValues(CompletionHandler<void()>&& completionHandler)
    975 {
    976     ASSERT(RunLoop::isMain());
    977 
    978     postTask([this, completionHandler = WTFMove(completionHandler)]() mutable {
    979         if (m_memoryStore)
    980             m_memoryStore->resetParametersToDefaultValues();
    981 
    982         postTaskReply(WTFMove(completionHandler));
    983     });
    984 }
    985 
    986 void WebResourceLoadStatisticsStore::logTestingEvent(const String& event)
    987 {
    988     ASSERT(RunLoop::isMain());
    989 
    990     if (m_statisticsTestingCallback)
    991         m_statisticsTestingCallback(event);
    992 }
    993 
    994 } // namespace WebKit
  • trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h

    r239816 r240243  
    11/*
    2  * Copyright (C) 2016-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#pragma once
    2727
     28#if ENABLE(RESOURCE_LOAD_STATISTICS)
     29
    2830#include "Connection.h"
    2931#include "WebsiteDataType.h"
     
    4345class ResourceRequest;
    4446struct ResourceLoadStatistics;
     47enum class ShouldSample : bool;
    4548}
    4649
     
    5457class WebsiteDataStore;
    5558
    56 enum class StorageAccessStatus {
     59enum class StorageAccessStatus : unsigned {
    5760    CannotRequestAccess,
    5861    RequiresUserPrompt,
    5962    HasAccess
     63};
     64
     65enum class ShouldGrandfather {
     66    No,
     67    Yes,
    6068};
    6169
     
    7987
    8088    void setNotifyPagesWhenDataRecordsWereScanned(bool);
    81     void setShouldClassifyResourcesBeforeDataRecordsRemoval(bool);
     89    void setNotifyPagesWhenTelemetryWasCaptured(bool, CompletionHandler<void()>&&);
     90    void setShouldClassifyResourcesBeforeDataRecordsRemoval(bool, CompletionHandler<void()>&&);
    8291    void setShouldSubmitTelemetry(bool);
    8392
    84     void hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback);
    8593    void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&&);
    8694    void grantStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPromptedNow, CompletionHandler<void(bool)>&&);
     
    94102    void logUserInteraction(const String& targetPrimaryDomain, CompletionHandler<void()>&&);
    95103    void clearUserInteraction(const URL&, CompletionHandler<void()>&&);
     104    void clearUserInteraction(const String& targetPrimaryDomain, CompletionHandler<void()>&&);
     105    void deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType>, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&&);
     106    void topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType>, bool shouldNotifyPage, CompletionHandler<void(HashSet<String>&&)>&&);
    96107    bool grantStorageAccess(const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID);
    97108    void hasHadUserInteraction(const URL&, CompletionHandler<void(bool)>&&);
     109    void hasHadUserInteraction(const String& resourceDomain, CompletionHandler<void(bool)>&&);
     110    void hasStorageAccess(const String& subFrameHost, const String& topFrameHost, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback);
    98111    bool hasStorageAccessForFrame(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID);
     112    void requestStorageAccess(const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&&);
    99113    void setLastSeen(const URL&, Seconds, CompletionHandler<void()>&&);
     114    void setLastSeen(const String& resourceDomain, Seconds, CompletionHandler<void()>&&);
    100115    void setPrevalentResource(const URL&, CompletionHandler<void()>&&);
     116    void setPrevalentResource(const String& resourceDomain, CompletionHandler<void()>&&);
    101117    void setVeryPrevalentResource(const URL&, CompletionHandler<void()>&&);
     118    void setVeryPrevalentResource(const String& resourceDomain, CompletionHandler<void()>&&);
    102119    void dumpResourceLoadStatistics(CompletionHandler<void(const String&)>&&);
    103120    void isPrevalentResource(const URL&, CompletionHandler<void(bool)>&&);
     121    void isPrevalentResource(const String&, CompletionHandler<void(bool)>&&);
    104122    void isVeryPrevalentResource(const URL&, CompletionHandler<void(bool)>&&);
     123    void isVeryPrevalentResource(const String&, CompletionHandler<void(bool)>&&);
    105124    void isRegisteredAsSubresourceUnder(const URL& subresource, const URL& topFrame, CompletionHandler<void(bool)>&&);
     125    void isRegisteredAsSubresourceUnder(const String& subresource, const String& topFrame, CompletionHandler<void(bool)>&&);
    106126    void isRegisteredAsSubFrameUnder(const URL& subFrame, const URL& topFrame, CompletionHandler<void(bool)>&&);
     127    void isRegisteredAsSubFrameUnder(const String& subFrame, const String& topFrame, CompletionHandler<void(bool)>&&);
    107128    void isRegisteredAsRedirectingTo(const URL& hostRedirectedFrom, const URL& hostRedirectedTo, CompletionHandler<void(bool)>&&);
     129    void isRegisteredAsRedirectingTo(const String& hostRedirectedFrom, const String& hostRedirectedTo, CompletionHandler<void(bool)>&&);
    108130    void clearPrevalentResource(const URL&, CompletionHandler<void()>&&);
    109     void setGrandfathered(const URL&, bool);
     131    void clearPrevalentResource(const String&, CompletionHandler<void()>&&);
     132    void setGrandfathered(const URL&, bool, CompletionHandler<void()>&&);
     133    void setGrandfathered(const String&, bool, CompletionHandler<void()>&&);
    110134    void isGrandfathered(const URL&, CompletionHandler<void(bool)>&&);
     135    void isGrandfathered(const String&, CompletionHandler<void(bool)>&&);
    111136    void removeAllStorageAccess();
    112137    void removePrevalentDomains(const Vector<String>& domainsToBlock);
    113138    void setCacheMaxAgeCapForPrevalentResources(Seconds);
    114     void setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame);
    115     void setSubresourceUnderTopFrameOrigin(const URL& subresource, const URL& topFrame);
    116     void setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo);
    117     void setSubresourceUniqueRedirectFrom(const URL& subresource, const URL& hostNameRedirectedFrom);
    118     void setTopFrameUniqueRedirectTo(const URL& topFrameHostName, const URL& hostNameRedirectedTo);
    119     void setTopFrameUniqueRedirectFrom(const URL& topFrameHostName, const URL& hostNameRedirectedFrom);
     139    void setNotifyPagesWhenDataRecordsWereScanned(bool, CompletionHandler<void()>&&);
     140    void setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame, CompletionHandler<void()>&&);
     141    void setSubframeUnderTopFrameOrigin(const String& subframe, const String& topFrame, CompletionHandler<void()>&&);
     142    void setSubresourceUnderTopFrameOrigin(const URL& subresource, const URL& topFrame, CompletionHandler<void()>&&);
     143    void setSubresourceUnderTopFrameOrigin(const String& subresource, const String& topFrame, CompletionHandler<void()>&&);
     144    void setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo, CompletionHandler<void()>&&);
     145    void setSubresourceUniqueRedirectTo(const String& subresource, const String& hostNameRedirectedTo, CompletionHandler<void()>&&);
     146    void setSubresourceUniqueRedirectFrom(const URL& subresource, const URL& hostNameRedirectedFrom, CompletionHandler<void()>&&);
     147    void setSubresourceUniqueRedirectFrom(const String& subresource, const String& hostNameRedirectedFrom, CompletionHandler<void()>&&);
     148    void setTopFrameUniqueRedirectTo(const URL& topFrameHostName, const URL& hostNameRedirectedTo, CompletionHandler<void()>&&);
     149    void setTopFrameUniqueRedirectTo(const String& topFrameHostName, const String& hostNameRedirectedTo, CompletionHandler<void()>&&);
     150    void setTopFrameUniqueRedirectFrom(const URL& topFrameHostName, const URL& hostNameRedirectedFrom, CompletionHandler<void()>&&);
     151    void setTopFrameUniqueRedirectFrom(const String& topFrameHostName, const String& hostNameRedirectedFrom, CompletionHandler<void()>&&);
    120152    void scheduleCookieBlockingUpdate(CompletionHandler<void()>&&);
    121153    void scheduleCookieBlockingUpdateForDomains(const Vector<String>& domainsToBlock, CompletionHandler<void()>&&);
    122154    void scheduleClearBlockingStateForDomains(const Vector<String>& domains, CompletionHandler<void()>&&);
    123     void scheduleStatisticsAndDataRecordsProcessing();
    124     void submitTelemetry();
     155    void scheduleStatisticsAndDataRecordsProcessing(CompletionHandler<void()>&&);
     156    void submitTelemetry(CompletionHandler<void()>&&);
    125157    void updatePrevalentDomainsToBlockCookiesFor(const Vector<String>& domainsToBlock);
    126 
    127     enum class ShouldGrandfather {
    128         No,
    129         Yes,
    130     };
    131158    void scheduleClearInMemoryAndPersistent(ShouldGrandfather, CompletionHandler<void()>&&);
    132159    void scheduleClearInMemoryAndPersistent(WallTime modifiedSince, ShouldGrandfather, CompletionHandler<void()>&&);
    133160
    134     void setTimeToLiveUserInteraction(Seconds);
    135     void setMinimumTimeBetweenDataRecordsRemoval(Seconds);
    136     void setGrandfatheringTime(Seconds);
     161    void setTimeToLiveUserInteraction(Seconds, CompletionHandler<void()>&&);
     162    void setMinimumTimeBetweenDataRecordsRemoval(Seconds, CompletionHandler<void()>&&);
     163    void setGrandfatheringTime(Seconds, CompletionHandler<void()>&&);
    137164    void setCacheMaxAgeCap(Seconds, CompletionHandler<void()>&&);
    138     void setMaxStatisticsEntries(size_t);
    139     void setPruneEntriesDownTo(size_t);
     165    void setMaxStatisticsEntries(size_t, CompletionHandler<void()>&&);
     166    void setPruneEntriesDownTo(size_t, CompletionHandler<void()>&&);
    140167
    141168    void resetParametersToDefaultValues(CompletionHandler<void()>&&);
     
    143170    void setResourceLoadStatisticsDebugMode(bool, CompletionHandler<void()>&&);
    144171    void setPrevalentResourceForDebugMode(const URL&, CompletionHandler<void()>&&);
    145    
    146     void setStatisticsTestingCallback(WTF::Function<void(const String&)>&& callback) { m_statisticsTestingCallback = WTFMove(callback); }
     172    void setPrevalentResourceForDebugMode(const String& resourceDomain, CompletionHandler<void()>&&);
     173
    147174    void logTestingEvent(const String&);
    148175    void callGrantStorageAccessHandler(const String& subFramePrimaryDomain, const String& topFramePrimaryDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&&);
     
    154181    void didCreateNetworkProcess();
    155182
     183    void notifyResourceLoadStatisticsProcessed();
     184
    156185    WebsiteDataStore* websiteDataStore() { return m_websiteDataStore.get(); }
    157186    NetworkSession* networkSession() { return m_networkSession.get(); }
     187
     188    void sendDiagnosticMessageWithValue(const String& message, const String& description, unsigned value, unsigned sigDigits, WebCore::ShouldSample) const;
     189    void notifyPageStatisticsTelemetryFinished(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins) const;
    158190
    159191private:
     
    187219    bool m_hasScheduledProcessStats { false };
    188220
    189     WTF::Function<void(const String&)> m_statisticsTestingCallback;
    190 
    191221    bool m_firstNetworkProcessCreated { false };
    192222};
    193223
    194224} // namespace WebKit
     225
     226#endif
  • trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsTelemetry.cpp

    r239747 r240243  
    2727#include "WebResourceLoadStatisticsTelemetry.h"
    2828
     29#if ENABLE(RESOURCE_LOAD_STATISTICS)
     30
    2931#include "ResourceLoadStatisticsMemoryStore.h"
     32#include "WebPageProxy.h"
    3033#include "WebProcessPool.h"
    3134#include "WebProcessProxy.h"
     
    128131}
    129132   
    130 static WebPageProxy* nonEphemeralWebPageProxy()
    131 {
    132     auto processPools = WebProcessPool::allProcessPools();
    133     if (processPools.isEmpty())
    134         return nullptr;
    135    
    136     auto processPool = processPools[0];
    137     if (!processPool)
    138         return nullptr;
    139    
    140     for (auto& webProcess : processPool->processes()) {
    141         for (auto& page : webProcess->pages()) {
    142             if (page->sessionID().isEphemeral())
    143                 continue;
    144             return page;
    145         }
    146     }
    147     return nullptr;
    148 }
    149    
    150 static void submitTopList(unsigned numberOfResourcesFromTheTop, const Vector<PrevalentResourceTelemetry>& sortedPrevalentResources, const Vector<PrevalentResourceTelemetry>& sortedPrevalentResourcesWithoutUserInteraction, WebPageProxy& webPageProxy)
     133static void submitTopList(unsigned numberOfResourcesFromTheTop, const Vector<PrevalentResourceTelemetry>& sortedPrevalentResources, const Vector<PrevalentResourceTelemetry>& sortedPrevalentResourcesWithoutUserInteraction, const WebResourceLoadStatisticsStore& store)
    151134{
    152135    WTF::Function<unsigned(const PrevalentResourceTelemetry& telemetry)> subframeUnderTopFrameOriginsGetter = [] (auto& t) {
     
    182165    String descriptionPreamble = preambleBuilder.toString();
    183166   
    184     webPageProxy.logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "PrevalentResourcesWithUserInteraction",
     167    store.sendDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "PrevalentResourcesWithUserInteraction",
    185168        topPrevalentResourcesWithUserInteraction, significantFiguresForLoggedValues, ShouldSample::No);
    186     webPageProxy.logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "SubframeUnderTopFrameOrigins",
     169    store.sendDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "SubframeUnderTopFrameOrigins",
    187170        topSubframeUnderTopFrameOrigins, significantFiguresForLoggedValues, ShouldSample::No);
    188     webPageProxy.logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "SubresourceUnderTopFrameOrigins",
     171    store.sendDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "SubresourceUnderTopFrameOrigins",
    189172        topSubresourceUnderTopFrameOrigins, significantFiguresForLoggedValues, ShouldSample::No);
    190     webPageProxy.logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "SubresourceUniqueRedirectsTo",
     173    store.sendDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "SubresourceUniqueRedirectsTo",
    191174        topSubresourceUniqueRedirectsTo, significantFiguresForLoggedValues, ShouldSample::No);
    192     webPageProxy.logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "NumberOfTimesDataRecordsRemoved",
     175    store.sendDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "NumberOfTimesDataRecordsRemoved",
    193176        topNumberOfTimesDataRecordsRemoved, significantFiguresForLoggedValues, ShouldSample::No);
    194     webPageProxy.logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "NumberOfTimesAccessedAsFirstPartyDueToUserInteraction",
     177    store.sendDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "NumberOfTimesAccessedAsFirstPartyDueToUserInteraction",
    195178        topNumberOfTimesAccessedAsFirstPartyDueToUserInteraction, significantFiguresForLoggedValues, ShouldSample::No);
    196     webPageProxy.logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "NumberOfTimesAccessedAsFirstPartyDueToStorageAccessAPI",
     179    store.sendDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), descriptionPreamble + "NumberOfTimesAccessedAsFirstPartyDueToStorageAccessAPI",
    197180        topNumberOfTimesAccessedAsFirstPartyDueToStorageAccessAPI, significantFiguresForLoggedValues, ShouldSample::No);
    198181}
    199182   
    200 static void submitTopLists(const Vector<PrevalentResourceTelemetry>& sortedPrevalentResources, const Vector<PrevalentResourceTelemetry>& sortedPrevalentResourcesWithoutUserInteraction, WebPageProxy& webPageProxy)
    201 {
    202     submitTopList(1, sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, webPageProxy);
     183static void submitTopLists(const Vector<PrevalentResourceTelemetry>& sortedPrevalentResources, const Vector<PrevalentResourceTelemetry>& sortedPrevalentResourcesWithoutUserInteraction, const WebResourceLoadStatisticsStore& store)
     184{
     185    submitTopList(1, sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, store);
    203186   
    204187    if (sortedPrevalentResourcesWithoutUserInteraction.size() < 3)
    205188        return;
    206     submitTopList(3, sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, webPageProxy);
     189    submitTopList(3, sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, store);
    207190   
    208191    if (sortedPrevalentResourcesWithoutUserInteraction.size() < 10)
    209192        return;
    210     submitTopList(10, sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, webPageProxy);
     193    submitTopList(10, sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, store);
    211194   
    212195    if (sortedPrevalentResourcesWithoutUserInteraction.size() < 50)
    213196        return;
    214     submitTopList(50, sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, webPageProxy);
     197    submitTopList(50, sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, store);
    215198   
    216199    if (sortedPrevalentResourcesWithoutUserInteraction.size() < 100)
    217200        return;
    218     submitTopList(100, sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, webPageProxy);
     201    submitTopList(100, sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, store);
    219202}
    220203   
    221204// This function is for testing purposes.
    222 void static notifyPages(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins)
    223 {
    224     RunLoop::main().dispatch([totalPrevalentResources, totalPrevalentResourcesWithUserInteraction, top3SubframeUnderTopFrameOrigins] {
    225         API::Dictionary::MapType messageBody;
    226         messageBody.set("TotalPrevalentResources"_s, API::UInt64::create(totalPrevalentResources));
    227         messageBody.set("TotalPrevalentResourcesWithUserInteraction"_s, API::UInt64::create(totalPrevalentResourcesWithUserInteraction));
    228         messageBody.set("Top3SubframeUnderTopFrameOrigins"_s, API::UInt64::create(top3SubframeUnderTopFrameOrigins));
    229         WebProcessProxy::notifyPageStatisticsTelemetryFinished(API::Dictionary::create(messageBody).ptr());
     205void static notifyPages(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins, const WebResourceLoadStatisticsStore& store)
     206{
     207    RunLoop::main().dispatch([totalPrevalentResources, totalPrevalentResourcesWithUserInteraction, top3SubframeUnderTopFrameOrigins, store = makeRef(store)] {
     208        store->notifyPageStatisticsTelemetryFinished(totalPrevalentResources, totalPrevalentResourcesWithUserInteraction, top3SubframeUnderTopFrameOrigins);
    230209    });
    231210}
    232211   
    233212// This function is for testing purposes.
    234 void static notifyPages(const Vector<PrevalentResourceTelemetry>& sortedPrevalentResources, const Vector<PrevalentResourceTelemetry>& sortedPrevalentResourcesWithoutUserInteraction, unsigned totalNumberOfPrevalentResourcesWithUserInteraction)
     213void static notifyPages(const Vector<PrevalentResourceTelemetry>& sortedPrevalentResources, const Vector<PrevalentResourceTelemetry>& sortedPrevalentResourcesWithoutUserInteraction, unsigned totalNumberOfPrevalentResourcesWithUserInteraction, const WebResourceLoadStatisticsStore& store)
    235214{
    236215    WTF::Function<unsigned(const PrevalentResourceTelemetry& telemetry)> subframeUnderTopFrameOriginsGetter = [] (const PrevalentResourceTelemetry& t) {
     
    238217    };
    239218   
    240     notifyPages(sortedPrevalentResources.size(), totalNumberOfPrevalentResourcesWithUserInteraction, median(sortedPrevalentResourcesWithoutUserInteraction, 0, 2, subframeUnderTopFrameOriginsGetter));
     219    notifyPages(sortedPrevalentResources.size(), totalNumberOfPrevalentResourcesWithUserInteraction, median(sortedPrevalentResourcesWithoutUserInteraction, 0, 2, subframeUnderTopFrameOriginsGetter), store);
    241220}
    242221   
     
    247226    auto sortedPrevalentResources = sortedPrevalentResourceTelemetry(resourceLoadStatisticsStore);
    248227    if (notifyPagesWhenTelemetryWasCaptured && sortedPrevalentResources.isEmpty()) {
    249         notifyPages(0, 0, 0);
     228        notifyPages(0, 0, 0, resourceLoadStatisticsStore.store());
    250229        return;
    251230    }
     
    263242   
    264243    // Dispatch on the main thread to make sure the WebPageProxy we're using doesn't go away.
    265     RunLoop::main().dispatch([sortedPrevalentResources = WTFMove(sortedPrevalentResources), sortedPrevalentResourcesWithoutUserInteraction = WTFMove(sortedPrevalentResourcesWithoutUserInteraction), prevalentResourcesDaysSinceUserInteraction = WTFMove(prevalentResourcesDaysSinceUserInteraction)] () {
    266         auto webPageProxy = nonEphemeralWebPageProxy();
     244    RunLoop::main().dispatch([sortedPrevalentResources = WTFMove(sortedPrevalentResources), sortedPrevalentResourcesWithoutUserInteraction = WTFMove(sortedPrevalentResourcesWithoutUserInteraction), prevalentResourcesDaysSinceUserInteraction = WTFMove(prevalentResourcesDaysSinceUserInteraction), &resourceLoadStatisticsStore] () {
     245        auto webPageProxy = WebPageProxy::nonEphemeralWebPageProxy();
    267246        if (!webPageProxy) {
    268247            if (notifyPagesWhenTelemetryWasCaptured)
    269                 notifyPages(0, 0, 0);
     248                notifyPages(0, 0, 0, resourceLoadStatisticsStore.store());
    270249            return;
    271250        }
    272251       
    273252        if (notifyPagesWhenTelemetryWasCaptured) {
    274             notifyPages(sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, prevalentResourcesDaysSinceUserInteraction.size());
     253            notifyPages(sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, prevalentResourcesDaysSinceUserInteraction.size(), resourceLoadStatisticsStore.store());
    275254            // The notify pages function is for testing so we don't need to do an actual submission.
    276255            return;
     
    285264            webPageProxy->logDiagnosticMessageWithValue(DiagnosticLoggingKeys::resourceLoadStatisticsTelemetryKey(), "medianPrevalentResourcesWithUserInteractionDaysSinceUserInteraction"_s, median(prevalentResourcesDaysSinceUserInteraction), significantFiguresForLoggedValues, ShouldSample::No);
    286265       
    287         submitTopLists(sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, *webPageProxy);
     266        submitTopLists(sortedPrevalentResources, sortedPrevalentResourcesWithoutUserInteraction, resourceLoadStatisticsStore.store());
    288267    });
    289268}
     
    295274   
    296275}
     276
     277#endif
  • trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsTelemetry.h

    r239747 r240243  
    2626#pragma once
    2727
     28#if ENABLE(RESOURCE_LOAD_STATISTICS)
     29
    2830#include <wtf/text/WTFString.h>
    2931
     
    3941}
    4042}
     43
     44#endif
  • trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp

    r240117 r240243  
    11/*
    2  * Copyright (C) 2012-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    5050#include "WebIDBConnectionToClient.h"
    5151#include "WebIDBConnectionToClientMessages.h"
     52#include "WebResourceLoadStatisticsStore.h"
    5253#include "WebSWServerConnection.h"
    5354#include "WebSWServerConnectionMessages.h"
     
    582583}
    583584
     585void NetworkConnectionToWebProcess::logUserInteraction(PAL::SessionID sessionID, const String& topLevelOrigin)
     586{
     587#if ENABLE(RESOURCE_LOAD_STATISTICS)
     588    if (auto networkSession = networkProcess().networkSession(sessionID)) {
     589        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     590            resourceLoadStatistics->logUserInteraction(topLevelOrigin, [] { });
     591    }
     592#else
     593    UNUSED_PARAM(sessionID);
     594    UNUSED_PARAM(topLevelOrigin);
     595#endif
     596}
     597
    584598void NetworkConnectionToWebProcess::addOriginAccessWhitelistEntry(const String& sourceOrigin, const String& destinationProtocol, const String& destinationHost, bool allowDestinationSubdomains)
    585599{
  • trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h

    r239835 r240243  
    11/*
    2  * Copyright (C) 2012-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    195195    void removeStorageAccessForFrame(PAL::SessionID, uint64_t frameID, uint64_t pageID);
    196196    void removeStorageAccessForAllFramesOnPage(PAL::SessionID, uint64_t pageID);
     197    void logUserInteraction(PAL::SessionID, const String& topLevelOrigin);
    197198
    198199    void addOriginAccessWhitelistEntry(const String& sourceOrigin, const String& destinationProtocol, const String& destinationHost, bool allowDestinationSubdomains);
  • trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in

    r239835 r240243  
    5959    RemoveStorageAccessForFrame(PAL::SessionID sessionID, uint64_t frameID, uint64_t pageID);
    6060    RemoveStorageAccessForAllFramesOnPage(PAL::SessionID sessionID, uint64_t pageID);
     61#if ENABLE(RESOURCE_LOAD_STATISTICS)
     62    LogUserInteraction(PAL::SessionID sessionID, String topLevelOrigin)
     63#endif
    6164
    6265    AddOriginAccessWhitelistEntry(String sourceOrigin, String destinationProtocol, String destinationHost, bool allowDestinationSubdomains);
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp

    r240099 r240243  
    11/*
    2  * Copyright (C) 2012-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2019 Apple Inc. All rights reserved.
    33 * Copyright (C) 2018 Sony Interactive Entertainment Inc.
    44 *
     
    498498
    499499#if ENABLE(RESOURCE_LOAD_STATISTICS)
     500void NetworkProcess::dumpResourceLoadStatistics(PAL::SessionID sessionID, uint64_t contextId)
     501{
     502    if (auto* networkSession = this->networkSession(sessionID)) {
     503        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) {
     504            resourceLoadStatistics->dumpResourceLoadStatistics([this, contextId](const String& dumpedStatistics) {
     505                parentProcessConnection()->send(Messages::NetworkProcessProxy::DidDumpResourceLoadStatistics(dumpedStatistics, contextId), 0);
     506            });
     507        }
     508    } else
     509        ASSERT_NOT_REACHED();
     510}
     511
    500512void NetworkProcess::updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID sessionID, const Vector<String>& domainsToBlock, uint64_t contextId)
    501513{
     
    505517}
    506518
     519void NetworkProcess::isGrandfathered(PAL::SessionID sessionID, const String& targetPrimaryDomain, CompletionHandler<void(bool)>&& completionHandler)
     520{
     521    if (auto* networkSession = this->networkSession(sessionID)) {
     522        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     523            resourceLoadStatistics->isGrandfathered(targetPrimaryDomain, WTFMove(completionHandler));
     524    } else
     525        ASSERT_NOT_REACHED();
     526}
     527
     528void NetworkProcess::isPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void(bool)>&& completionHandler)
     529{
     530    if (auto* networkSession = this->networkSession(sessionID)) {
     531        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     532            resourceLoadStatistics->isPrevalentResource(resourceDomain, WTFMove(completionHandler));
     533    } else
     534        ASSERT_NOT_REACHED();
     535}
     536
     537void NetworkProcess::isVeryPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void(bool)>&& completionHandler)
     538{
     539    if (auto* networkSession = this->networkSession(sessionID)) {
     540        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     541            resourceLoadStatistics->isVeryPrevalentResource(resourceDomain, WTFMove(completionHandler));
     542    } else
     543        ASSERT_NOT_REACHED();
     544}
     545
    507546void NetworkProcess::setAgeCapForClientSideCookies(PAL::SessionID sessionID, Optional<Seconds> seconds, uint64_t contextId)
    508547{
     
    512551}
    513552
     553void NetworkProcess::setGrandfathered(PAL::SessionID sessionID, const String& resourceDomain, bool isGrandfathered, CompletionHandler<void()>&& completionHandler)
     554{
     555    if (auto* networkSession = this->networkSession(sessionID)) {
     556        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     557            resourceLoadStatistics->setGrandfathered(resourceDomain, isGrandfathered, WTFMove(completionHandler));
     558    } else
     559        ASSERT_NOT_REACHED();
     560}
     561
     562void NetworkProcess::setPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void()>&& completionHandler)
     563{
     564    if (auto* networkSession = this->networkSession(sessionID)) {
     565        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     566            resourceLoadStatistics->setPrevalentResource(resourceDomain, WTFMove(completionHandler));
     567    } else
     568        ASSERT_NOT_REACHED();
     569}
     570
     571void NetworkProcess::setPrevalentResourceForDebugMode(PAL::SessionID sessionID, String resourceDomain, CompletionHandler<void()>&& completionHandler)
     572{
     573    if (auto* networkSession = this->networkSession(sessionID)) {
     574        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     575            resourceLoadStatistics->setPrevalentResourceForDebugMode(resourceDomain, WTFMove(completionHandler));
     576    } else
     577        ASSERT_NOT_REACHED();
     578}
     579
     580void NetworkProcess::setVeryPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void()>&& completionHandler)
     581{
     582    if (auto* networkSession = this->networkSession(sessionID)) {
     583        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     584            resourceLoadStatistics->setVeryPrevalentResource(resourceDomain, WTFMove(completionHandler));
     585    } else
     586        ASSERT_NOT_REACHED();
     587}
     588
     589void NetworkProcess::clearPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void()>&& completionHandler)
     590{
     591    if (auto* networkSession = this->networkSession(sessionID)) {
     592        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     593            resourceLoadStatistics->clearPrevalentResource(resourceDomain, WTFMove(completionHandler));
     594    } else
     595        ASSERT_NOT_REACHED();
     596}
     597
     598void NetworkProcess::submitTelemetry(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler)
     599{
     600    if (auto* networkSession = this->networkSession(sessionID)) {
     601        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     602            resourceLoadStatistics->submitTelemetry(WTFMove(completionHandler));
     603    } else
     604        ASSERT_NOT_REACHED();
     605}
     606
     607void NetworkProcess::scheduleCookieBlockingUpdate(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler)
     608{
     609    if (auto* networkSession = this->networkSession(sessionID)) {
     610        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     611            resourceLoadStatistics->scheduleCookieBlockingUpdate(WTFMove(completionHandler));
     612    } else
     613        ASSERT_NOT_REACHED();
     614}
     615
     616void NetworkProcess::scheduleClearInMemoryAndPersistent(PAL::SessionID sessionID, Optional<WallTime> modifiedSince, bool shouldGrandfather, CompletionHandler<void()>&& completionHandler)
     617{
     618    if (auto* networkSession = this->networkSession(sessionID)) {
     619        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) {
     620            auto grandfather = shouldGrandfather ? ShouldGrandfather::Yes : ShouldGrandfather::No;
     621            if (modifiedSince)
     622                resourceLoadStatistics->scheduleClearInMemoryAndPersistent(modifiedSince.value(), grandfather, WTFMove(completionHandler));
     623            else
     624                resourceLoadStatistics->scheduleClearInMemoryAndPersistent(grandfather, WTFMove(completionHandler));
     625        }
     626    } else
     627        ASSERT_NOT_REACHED();
     628}
     629
     630void NetworkProcess::resetParametersToDefaultValues(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler)
     631{
     632    if (auto* networkSession = this->networkSession(sessionID)) {
     633        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     634            resourceLoadStatistics->resetParametersToDefaultValues(WTFMove(completionHandler));
     635    } else
     636        ASSERT_NOT_REACHED();
     637}
     638
     639void NetworkProcess::scheduleStatisticsAndDataRecordsProcessing(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler)
     640{
     641    if (auto* networkSession = this->networkSession(sessionID)) {
     642        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     643            resourceLoadStatistics->scheduleStatisticsAndDataRecordsProcessing(WTFMove(completionHandler));
     644    } else
     645        ASSERT_NOT_REACHED();
     646}
     647
     648void NetworkProcess::setNotifyPagesWhenDataRecordsWereScanned(PAL::SessionID sessionID, bool value, CompletionHandler<void()>&& completionHandler)
     649{
     650    if (auto* networkSession = this->networkSession(sessionID)) {
     651        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     652            resourceLoadStatistics->setNotifyPagesWhenDataRecordsWereScanned(value, WTFMove(completionHandler));
     653    } else
     654        ASSERT_NOT_REACHED();
     655}
     656
     657void NetworkProcess::setNotifyPagesWhenTelemetryWasCaptured(PAL::SessionID sessionID, bool value, CompletionHandler<void()>&& completionHandler)
     658{
     659    if (auto* networkSession = this->networkSession(sessionID)) {
     660        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     661            resourceLoadStatistics->setNotifyPagesWhenTelemetryWasCaptured(value, WTFMove(completionHandler));
     662    } else
     663        ASSERT_NOT_REACHED();
     664}
     665
     666void NetworkProcess::setSubframeUnderTopFrameOrigin(PAL::SessionID sessionID, String subframe, String topFrame, CompletionHandler<void()>&& completionHandler)
     667{
     668    if (auto* networkSession = this->networkSession(sessionID)) {
     669        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     670            resourceLoadStatistics->setSubframeUnderTopFrameOrigin(subframe, topFrame, WTFMove(completionHandler));
     671    } else
     672        ASSERT_NOT_REACHED();
     673}
     674
     675void NetworkProcess::isRegisteredAsRedirectingTo(PAL::SessionID sessionID, const String& redirectedFrom, const String& redirectedTo, CompletionHandler<void(bool)>&& completionHandler)
     676{
     677    if (auto* networkSession = this->networkSession(sessionID)) {
     678        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     679            resourceLoadStatistics->isRegisteredAsRedirectingTo(redirectedFrom, redirectedTo, WTFMove(completionHandler));
     680    } else
     681        ASSERT_NOT_REACHED();
     682}
     683
     684void NetworkProcess::isRegisteredAsSubFrameUnder(PAL::SessionID sessionID, const String& subframe, const String& topFrame, CompletionHandler<void(bool)>&& completionHandler)
     685{
     686    if (auto* networkSession = this->networkSession(sessionID)) {
     687        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     688            resourceLoadStatistics->isRegisteredAsSubFrameUnder(subframe, topFrame, WTFMove(completionHandler));
     689    } else
     690        ASSERT_NOT_REACHED();
     691}
     692
     693void NetworkProcess::setSubresourceUnderTopFrameOrigin(PAL::SessionID sessionID, String subresource, String topFrame, CompletionHandler<void()>&& completionHandler)
     694{
     695    if (auto* networkSession = this->networkSession(sessionID)) {
     696        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     697            resourceLoadStatistics->setSubresourceUnderTopFrameOrigin(subresource, topFrame, WTFMove(completionHandler));
     698    } else
     699        ASSERT_NOT_REACHED();
     700}
     701
     702void NetworkProcess::setSubresourceUniqueRedirectTo(PAL::SessionID sessionID, String subresource, String hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler)
     703{
     704    if (auto* networkSession = this->networkSession(sessionID)) {
     705        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     706            resourceLoadStatistics->setSubresourceUniqueRedirectTo(subresource, hostNameRedirectedTo, WTFMove(completionHandler));
     707    } else
     708        ASSERT_NOT_REACHED();
     709}
     710
     711void NetworkProcess::setSubresourceUniqueRedirectFrom(PAL::SessionID sessionID, String subresource, String hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler)
     712{
     713    if (auto* networkSession = this->networkSession(sessionID)) {
     714        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     715            resourceLoadStatistics->setSubresourceUniqueRedirectFrom(subresource, hostNameRedirectedFrom, WTFMove(completionHandler));
     716    } else
     717        ASSERT_NOT_REACHED();
     718}
     719
     720void NetworkProcess::isRegisteredAsSubresourceUnder(PAL::SessionID sessionID, const String& subresource, const String& topFrame, CompletionHandler<void(bool)>&& completionHandler)
     721{
     722    if (auto* networkSession = this->networkSession(sessionID)) {
     723        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     724            resourceLoadStatistics->isRegisteredAsSubresourceUnder(subresource, topFrame, WTFMove(completionHandler));
     725    } else
     726        ASSERT_NOT_REACHED();
     727}
     728
     729void NetworkProcess::setTopFrameUniqueRedirectTo(PAL::SessionID sessionID, String topFrameHostName, String hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler)
     730{
     731    if (auto* networkSession = this->networkSession(sessionID)) {
     732        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     733            resourceLoadStatistics->setTopFrameUniqueRedirectTo(topFrameHostName, hostNameRedirectedTo, WTFMove(completionHandler));
     734    } else
     735        ASSERT_NOT_REACHED();
     736}
     737
     738void NetworkProcess::setTopFrameUniqueRedirectFrom(PAL::SessionID sessionID, String topFrameHostName, String hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler)
     739{
     740    if (auto* networkSession = this->networkSession(sessionID)) {
     741        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     742            resourceLoadStatistics->setTopFrameUniqueRedirectFrom(topFrameHostName, hostNameRedirectedFrom, WTFMove(completionHandler));
     743    } else
     744        ASSERT_NOT_REACHED();
     745}
     746   
     747   
     748void NetworkProcess::setLastSeen(PAL::SessionID sessionID, const String& resourceDomain, Seconds seconds, CompletionHandler<void()>&& completionHandler)
     749{
     750    if (auto* networkSession = this->networkSession(sessionID)) {
     751        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     752            resourceLoadStatistics->setLastSeen(resourceDomain, seconds, WTFMove(completionHandler));
     753    } else
     754        ASSERT_NOT_REACHED();
     755}
     756
    514757void NetworkProcess::hasStorageAccessForFrame(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId)
    515758{
    516759    if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
    517         parentProcessConnection()->send(Messages::NetworkProcessProxy::StorageAccessRequestResult(networkStorageSession->hasStorageAccess(resourceDomain, firstPartyDomain, frameID, pageID), contextId), 0);
     760        parentProcessConnection()->send(Messages::NetworkProcessProxy::StorageAccessOperationResult(networkStorageSession->hasStorageAccess(resourceDomain, firstPartyDomain, frameID, pageID), contextId), 0);
    518761    else
    519762        ASSERT_NOT_REACHED();
     
    528771}
    529772
    530 void NetworkProcess::grantStorageAccess(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, uint64_t contextId)
     773void NetworkProcess::hasStorageAccess(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler)
     774{
     775    if (auto* networkSession = this->networkSession(sessionID)) {
     776        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     777            resourceLoadStatistics->hasStorageAccess(resourceDomain, firstPartyDomain, frameID, pageID, WTFMove(completionHandler));
     778    } else
     779        ASSERT_NOT_REACHED();
     780}
     781
     782void NetworkProcess::requestStorageAccess(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool promptEnabled, uint64_t contextId)
     783{
     784    if (auto* networkSession = this->networkSession(sessionID)) {
     785        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) {
     786            resourceLoadStatistics->requestStorageAccess(resourceDomain, firstPartyDomain, frameID, pageID, promptEnabled, [this, contextId](StorageAccessStatus promptAccepted) {
     787                parentProcessConnection()->send(Messages::NetworkProcessProxy::StorageAccessRequestResult(static_cast<unsigned>(promptAccepted), contextId), 0);
     788            });
     789        }
     790    } else
     791        ASSERT_NOT_REACHED();
     792}
     793
     794void NetworkProcess::grantStorageAccess(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool userWasPrompted, uint64_t contextId)
    531795{
    532796    bool isStorageGranted = false;
     
    538802        ASSERT_NOT_REACHED();
    539803
    540     parentProcessConnection()->send(Messages::NetworkProcessProxy::StorageAccessRequestResult(isStorageGranted, contextId), 0);
     804    parentProcessConnection()->send(Messages::NetworkProcessProxy::StorageAccessOperationResult(isStorageGranted, contextId), 0);
    541805}
    542806
     
    550814}
    551815
    552 void NetworkProcess::logUserInteraction(PAL::SessionID sessionID, const String& targetPrimaryDomain, uint64_t contextId)
     816void NetworkProcess::logUserInteraction(PAL::SessionID sessionID, const String& targetPrimaryDomain, CompletionHandler<void()>&& completionHandler)
     817{
     818    if (auto* networkSession = this->networkSession(sessionID)) {
     819        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     820            resourceLoadStatistics->logUserInteraction(targetPrimaryDomain, WTFMove(completionHandler));
     821    } else
     822        ASSERT_NOT_REACHED();
     823}
     824
     825void NetworkProcess::hadUserInteraction(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void(bool)>&& completionHandler)
    553826{
    554827    if (auto* networkSession = this->networkSession(sessionID)) {
    555828        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) {
    556             resourceLoadStatistics->logUserInteraction(targetPrimaryDomain, [this, contextId] {
    557                 parentProcessConnection()->send(Messages::NetworkProcessProxy::DidLogUserInteraction(contextId), 0);
    558             });       
     829            resourceLoadStatistics->hasHadUserInteraction(resourceDomain, WTFMove(completionHandler));
    559830        }
     831    } else
     832        ASSERT_NOT_REACHED();
     833}
     834
     835void NetworkProcess::clearUserInteraction(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void()>&& completionHandler)
     836{
     837    if (auto* networkSession = this->networkSession(sessionID)) {
     838        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     839            resourceLoadStatistics->clearUserInteraction(resourceDomain, WTFMove(completionHandler));
    560840    } else
    561841        ASSERT_NOT_REACHED();
     
    586866}
    587867
     868void NetworkProcess::setGrandfatheringTime(PAL::SessionID sessionID, Seconds seconds, CompletionHandler<void()>&& completionHandler)
     869{
     870    if (auto* networkSession = this->networkSession(sessionID)) {
     871        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     872            resourceLoadStatistics->setGrandfatheringTime(seconds, WTFMove(completionHandler));
     873    } else
     874        ASSERT_NOT_REACHED();
     875}
     876
     877void NetworkProcess::setMaxStatisticsEntries(PAL::SessionID sessionID, uint64_t maximumEntryCount, CompletionHandler<void()>&& completionHandler)
     878{
     879    if (auto* networkSession = this->networkSession(sessionID)) {
     880        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     881            resourceLoadStatistics->setMaxStatisticsEntries(maximumEntryCount, WTFMove(completionHandler));
     882    } else
     883        ASSERT_NOT_REACHED();
     884}
     885
     886void NetworkProcess::setMinimumTimeBetweenDataRecordsRemoval(PAL::SessionID sessionID, Seconds seconds, CompletionHandler<void()>&& completionHandler)
     887{
     888    if (auto* networkSession = this->networkSession(sessionID)) {
     889        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     890            resourceLoadStatistics->setMinimumTimeBetweenDataRecordsRemoval(seconds, WTFMove(completionHandler));
     891    } else
     892        ASSERT_NOT_REACHED();
     893}
     894
     895void NetworkProcess::setPruneEntriesDownTo(PAL::SessionID sessionID, uint64_t pruneTargetCount, CompletionHandler<void()>&& completionHandler)
     896{
     897    if (auto* networkSession = this->networkSession(sessionID)) {
     898        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     899            resourceLoadStatistics->setPruneEntriesDownTo(pruneTargetCount, WTFMove(completionHandler));
     900    } else
     901        ASSERT_NOT_REACHED();
     902}
     903
     904void NetworkProcess::setTimeToLiveUserInteraction(PAL::SessionID sessionID, Seconds seconds, CompletionHandler<void()>&& completionHandler)
     905{
     906    if (auto* networkSession = this->networkSession(sessionID)) {
     907        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     908            resourceLoadStatistics->setTimeToLiveUserInteraction(seconds, WTFMove(completionHandler));
     909    } else
     910        ASSERT_NOT_REACHED();
     911}
     912
     913void NetworkProcess::setShouldClassifyResourcesBeforeDataRecordsRemoval(PAL::SessionID sessionID, bool value, CompletionHandler<void()>&& completionHandler)
     914{
     915    if (auto* networkSession = this->networkSession(sessionID)) {
     916        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     917            resourceLoadStatistics->setShouldClassifyResourcesBeforeDataRecordsRemoval(value, WTFMove(completionHandler));
     918    } else
     919        ASSERT_NOT_REACHED();
     920}
     921
     922void NetworkProcess::setResourceLoadStatisticsEnabled(bool enabled)
     923{
     924    for (auto& networkSession : m_networkSessions.values())
     925        networkSession.get().setResourceLoadStatisticsEnabled(enabled);
     926}
     927
     928void NetworkProcess::setResourceLoadStatisticsDebugMode(PAL::SessionID sessionID, bool debugMode, CompletionHandler<void()>&& completionHandler)
     929{
     930    if (auto* networkSession = this->networkSession(sessionID)) {
     931        if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
     932            resourceLoadStatistics->setResourceLoadStatisticsDebugMode(debugMode, WTFMove(completionHandler));
     933    } else
     934        ASSERT_NOT_REACHED();
     935}
     936
    588937void NetworkProcess::resetCacheMaxAgeCapForPrevalentResources(PAL::SessionID sessionID, uint64_t contextId)
    589938{
     
    592941    else
    593942        ASSERT_NOT_REACHED();
    594     parentProcessConnection()->send(Messages::NetworkProcessProxy::DidResetCacheMaxAgeCapForPrevalentResources(contextId), 0);
     943    parentProcessConnection()->send(Messages::NetworkProcessProxy::DidUpdateRuntimeSettings(contextId), 0);
    595944}
    596945#endif // ENABLE(RESOURCE_LOAD_STATISTICS)
     
    6511000        ~CallbackAggregator()
    6521001        {
    653             ASSERT(RunLoop::isMain());
    654 
    6551002            RunLoop::main().dispatch([completionHandler = WTFMove(m_completionHandler), websiteData = WTFMove(m_websiteData)] () mutable {
    6561003                completionHandler(websiteData);
     
    7571104    if (websiteDataTypes.contains(WebsiteDataType::DiskCache) && !sessionID.isEphemeral())
    7581105        clearDiskCache(modifiedSince, [clearTasksHandler = WTFMove(clearTasksHandler)] { });
     1106
     1107#if ENABLE(RESOURCE_LOAD_STATISTICS)
     1108    if (websiteDataTypes.contains(WebsiteDataType::ResourceLoadStatistics)) {
     1109        if (auto* networkSession = this->networkSession(sessionID)) {
     1110            if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) {
     1111                auto deletedTypesRaw = websiteDataTypes.toRaw();
     1112                auto monitoredTypesRaw = WebResourceLoadStatisticsStore::monitoredDataTypes().toRaw();
     1113
     1114                // If we are deleting all of the data types that the resource load statistics store monitors
     1115                // we do not need to re-grandfather old data.
     1116                auto shouldGrandfather = ((monitoredTypesRaw & deletedTypesRaw) == monitoredTypesRaw) ? ShouldGrandfather::No : ShouldGrandfather::Yes;
     1117
     1118                resourceLoadStatistics->scheduleClearInMemoryAndPersistent(modifiedSince, shouldGrandfather, [clearTasksHandler = clearTasksHandler.copyRef()] { });
     1119            }
     1120        }
     1121    }
     1122#endif
    7591123}
    7601124
     
    8221186        clearDiskCacheEntries(cache(), originDatas, [clearTasksHandler = WTFMove(clearTasksHandler)] { });
    8231187}
     1188
     1189#if ENABLE(RESOURCE_LOAD_STATISTICS)
     1190static Vector<String> filterForTopLevelDomains(const Vector<String>& topLevelDomains, const HashSet<String>& foundValues)
     1191{
     1192    Vector<String> result;
     1193    for (const auto& hostname : topLevelDomains) {
     1194        if (foundValues.contains(hostname))
     1195            result.append(hostname);
     1196    }
     1197   
     1198    return result;
     1199}
     1200
     1201static Vector<WebsiteData::Entry> filterForTopLevelDomains(const Vector<String>& topLevelDomains, const Vector<WebsiteData::Entry>& foundValues)
     1202{
     1203    Vector<WebsiteData::Entry> result;
     1204    for (const auto& value : foundValues) {
     1205        if (topLevelDomains.contains(value.origin.host))
     1206            result.append(value);
     1207    }
     1208   
     1209    return result;
     1210}
     1211
     1212void NetworkProcess::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(PAL::SessionID sessionID, OptionSet<WebsiteDataType> websiteDataTypes, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&& completionHandler)
     1213{
     1214    OptionSet<WebsiteDataFetchOption> fetchOptions = WebsiteDataFetchOption::DoNotCreateProcesses;
     1215
     1216    struct CallbackAggregator final : public RefCounted<CallbackAggregator> {
     1217        explicit CallbackAggregator(CompletionHandler<void(const HashSet<String>&)>&& completionHandler)
     1218            : m_completionHandler(WTFMove(completionHandler))
     1219        {
     1220        }
     1221       
     1222        ~CallbackAggregator()
     1223        {
     1224            RunLoop::main().dispatch([completionHandler = WTFMove(m_completionHandler), websiteData = WTFMove(m_websiteData)] () mutable {
     1225                HashSet<String> origins;
     1226                for (const auto& hostnameWithCookies : websiteData.hostNamesWithCookies)
     1227                    origins.add(hostnameWithCookies);
     1228
     1229                for (const auto& hostnameWithHSTS : websiteData.hostNamesWithHSTSCache)
     1230                    origins.add(hostnameWithHSTS);
     1231
     1232                for (const auto& entry : websiteData.entries)
     1233                    origins.add(entry.origin.host);
     1234
     1235                completionHandler(origins);
     1236            });
     1237        }
     1238       
     1239        CompletionHandler<void(const HashSet<String>&)> m_completionHandler;
     1240        WebsiteData m_websiteData;
     1241    };
     1242   
     1243    auto callbackAggregator = adoptRef(*new CallbackAggregator([this, completionHandler = WTFMove(completionHandler), shouldNotifyPage] (const HashSet<String>& originsWithData) mutable {
     1244        if (shouldNotifyPage)
     1245            parentProcessConnection()->send(Messages::NetworkProcessProxy::NotifyWebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished(), 0);
     1246       
     1247        RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler), originsWithData = crossThreadCopy(originsWithData)] () mutable {
     1248            completionHandler(originsWithData);
     1249        });
     1250    }));
     1251
     1252    auto& websiteDataStore = callbackAggregator->m_websiteData;
     1253
     1254    Vector<String> hostnamesWithCookiesToDelete;
     1255    if (websiteDataTypes.contains(WebsiteDataType::Cookies)) {
     1256        if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID)) {
     1257            networkStorageSession->getHostnamesWithCookies(websiteDataStore.hostNamesWithCookies);
     1258            hostnamesWithCookiesToDelete = filterForTopLevelDomains(topPrivatelyControlledDomains, websiteDataStore.hostNamesWithCookies);
     1259            networkStorageSession->deleteCookiesForHostnames(hostnamesWithCookiesToDelete);
     1260        }
     1261    }
     1262
     1263    Vector<String> hostnamesWithHSTSToDelete;
     1264#if PLATFORM(COCOA)
     1265    if (websiteDataTypes.contains(WebsiteDataType::HSTSCache)) {
     1266        if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID)) {
     1267            getHostNamesWithHSTSCache(*networkStorageSession, websiteDataStore.hostNamesWithHSTSCache);
     1268            hostnamesWithHSTSToDelete = filterForTopLevelDomains(topPrivatelyControlledDomains, websiteDataStore.hostNamesWithHSTSCache);
     1269            deleteHSTSCacheForHostNames(*networkStorageSession, hostnamesWithHSTSToDelete);
     1270        }
     1271    }
     1272#endif
     1273
     1274    /*
     1275    // FIXME: No API to delete credentials by origin
     1276    if (websiteDataTypes.contains(WebsiteDataType::Credentials)) {
     1277        if (NetworkStorageSession::storageSession(sessionID))
     1278            websiteDataStore.originsWithCredentials = NetworkStorageSession::storageSession(sessionID)->credentialStorage().originsWithCredentials();
     1279    }
     1280    */
     1281   
     1282    if (websiteDataTypes.contains(WebsiteDataType::DOMCache)) {
     1283        CacheStorage::Engine::fetchEntries(*this, sessionID, fetchOptions.contains(WebsiteDataFetchOption::ComputeSizes), [this, topPrivatelyControlledDomains, sessionID, callbackAggregator = callbackAggregator.copyRef()](auto entries) mutable {
     1284           
     1285            auto entriesToDelete = filterForTopLevelDomains(topPrivatelyControlledDomains, entries);
     1286
     1287            callbackAggregator->m_websiteData.entries.appendVector(entriesToDelete);
     1288           
     1289            for (auto& entry : entriesToDelete)
     1290                CacheStorage::Engine::clearCachesForOrigin(*this, sessionID, SecurityOriginData { entry.origin }, [callbackAggregator = callbackAggregator.copyRef()] { });
     1291        });
     1292    }
     1293   
     1294#if ENABLE(INDEXED_DATABASE)
     1295    auto path = m_idbDatabasePaths.get(sessionID);
     1296    if (!path.isEmpty() && websiteDataTypes.contains(WebsiteDataType::IndexedDBDatabases)) {
     1297        // FIXME: Pick the right database store based on the session ID.
     1298        postStorageTask(CrossThreadTask([this, sessionID, callbackAggregator = callbackAggregator.copyRef(), path = WTFMove(path), topPrivatelyControlledDomains]() mutable {
     1299            RunLoop::main().dispatch([this, sessionID, topPrivatelyControlledDomains = crossThreadCopy(topPrivatelyControlledDomains), callbackAggregator = callbackAggregator.copyRef(), securityOrigins = indexedDatabaseOrigins(path)] {
     1300                Vector<SecurityOriginData> entriesToDelete;
     1301                for (const auto& securityOrigin : securityOrigins) {
     1302                    if (!topPrivatelyControlledDomains.contains(securityOrigin.host))
     1303                        continue;
     1304
     1305                    entriesToDelete.append(securityOrigin);
     1306                    callbackAggregator->m_websiteData.entries.append({ securityOrigin, WebsiteDataType::IndexedDBDatabases, 0 });
     1307                }
     1308
     1309                idbServer(sessionID).closeAndDeleteDatabasesForOrigins(entriesToDelete, [callbackAggregator = callbackAggregator.copyRef()] { });
     1310            });
     1311        }));
     1312    }
     1313#endif
     1314   
     1315#if ENABLE(SERVICE_WORKER)
     1316    path = m_swDatabasePaths.get(sessionID);
     1317    if (!path.isEmpty() && websiteDataTypes.contains(WebsiteDataType::ServiceWorkerRegistrations)) {
     1318        swServerForSession(sessionID).getOriginsWithRegistrations([this, sessionID, topPrivatelyControlledDomains, callbackAggregator = callbackAggregator.copyRef()](const HashSet<SecurityOriginData>& securityOrigins) mutable {
     1319            for (auto& securityOrigin : securityOrigins) {
     1320                if (!topPrivatelyControlledDomains.contains(securityOrigin.host))
     1321                    continue;
     1322                callbackAggregator->m_websiteData.entries.append({ securityOrigin, WebsiteDataType::ServiceWorkerRegistrations, 0 });
     1323                swServerForSession(sessionID).clear(securityOrigin, [callbackAggregator = callbackAggregator.copyRef()] { });
     1324            }
     1325        });
     1326    }
     1327#endif
     1328   
     1329    if (websiteDataTypes.contains(WebsiteDataType::DiskCache)) {
     1330        fetchDiskCacheEntries(cache(), sessionID, fetchOptions, [this, topPrivatelyControlledDomains, callbackAggregator = callbackAggregator.copyRef()](auto entries) mutable {
     1331
     1332            Vector<SecurityOriginData> entriesToDelete;
     1333            for (auto& entry : entries) {
     1334                if (!topPrivatelyControlledDomains.contains(entry.origin.host))
     1335                    continue;
     1336                entriesToDelete.append(entry.origin);
     1337                callbackAggregator->m_websiteData.entries.append(entry);
     1338            }
     1339            clearDiskCacheEntries(cache(), entriesToDelete, [callbackAggregator = callbackAggregator.copyRef()] { });
     1340        });
     1341    }
     1342}
     1343
     1344void NetworkProcess::topPrivatelyControlledDomainsWithWebsiteData(PAL::SessionID sessionID, OptionSet<WebsiteDataType> websiteDataTypes, bool shouldNotifyPage, CompletionHandler<void(HashSet<String>&&)>&& completionHandler)
     1345{
     1346    OptionSet<WebsiteDataFetchOption> fetchOptions = WebsiteDataFetchOption::DoNotCreateProcesses;
     1347   
     1348    struct CallbackAggregator final : public RefCounted<CallbackAggregator> {
     1349        explicit CallbackAggregator(CompletionHandler<void(HashSet<String>&&)>&& completionHandler)
     1350            : m_completionHandler(WTFMove(completionHandler))
     1351        {
     1352        }
     1353       
     1354        ~CallbackAggregator()
     1355        {
     1356            RunLoop::main().dispatch([completionHandler = WTFMove(m_completionHandler), websiteData = WTFMove(m_websiteData)] () mutable {
     1357                HashSet<String> origins;
     1358                for (const auto& hostnameWithCookies : websiteData.hostNamesWithCookies)
     1359                    origins.add(hostnameWithCookies);
     1360               
     1361                for (const auto& hostnameWithHSTS : websiteData.hostNamesWithHSTSCache)
     1362                    origins.add(hostnameWithHSTS);
     1363               
     1364                for (const auto& entry : websiteData.entries)
     1365                    origins.add(entry.origin.host);
     1366               
     1367                completionHandler(WTFMove(origins));
     1368            });
     1369        }
     1370       
     1371        CompletionHandler<void(HashSet<String>&&)> m_completionHandler;
     1372        WebsiteData m_websiteData;
     1373    };
     1374   
     1375    auto callbackAggregator = adoptRef(*new CallbackAggregator([this, completionHandler = WTFMove(completionHandler), shouldNotifyPage] (HashSet<String>&& originsWithData) mutable {
     1376        if (shouldNotifyPage)
     1377            parentProcessConnection()->send(Messages::NetworkProcessProxy::NotifyWebsiteDataScanForTopPrivatelyControlledDomainsFinished(), 0);
     1378
     1379        RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler), originsWithData = crossThreadCopy(originsWithData)] () mutable {
     1380            completionHandler(WTFMove(originsWithData));
     1381        });
     1382    }));
     1383   
     1384    auto& websiteDataStore = callbackAggregator->m_websiteData;
     1385   
     1386    Vector<String> hostnamesWithCookiesToDelete;
     1387    if (websiteDataTypes.contains(WebsiteDataType::Cookies)) {
     1388        if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
     1389            networkStorageSession->getHostnamesWithCookies(websiteDataStore.hostNamesWithCookies);
     1390    }
     1391   
     1392    Vector<String> hostnamesWithHSTSToDelete;
     1393#if PLATFORM(COCOA)
     1394    if (websiteDataTypes.contains(WebsiteDataType::HSTSCache)) {
     1395        if (auto* networkStorageSession = NetworkStorageSession::storageSession(sessionID))
     1396            getHostNamesWithHSTSCache(*networkStorageSession, websiteDataStore.hostNamesWithHSTSCache);
     1397    }
     1398#endif
     1399
     1400    if (websiteDataTypes.contains(WebsiteDataType::Credentials)) {
     1401        if (NetworkStorageSession::storageSession(sessionID))
     1402            websiteDataStore.originsWithCredentials = NetworkStorageSession::storageSession(sessionID)->credentialStorage().originsWithCredentials();
     1403    }
     1404   
     1405    if (websiteDataTypes.contains(WebsiteDataType::DOMCache)) {
     1406        CacheStorage::Engine::fetchEntries(*this, sessionID, fetchOptions.contains(WebsiteDataFetchOption::ComputeSizes), [callbackAggregator = callbackAggregator.copyRef()](auto entries) mutable {
     1407            callbackAggregator->m_websiteData.entries.appendVector(entries);
     1408        });
     1409    }
     1410   
     1411#if ENABLE(INDEXED_DATABASE)
     1412    auto path = m_idbDatabasePaths.get(sessionID);
     1413    if (!path.isEmpty() && websiteDataTypes.contains(WebsiteDataType::IndexedDBDatabases)) {
     1414        // FIXME: Pick the right database store based on the session ID.
     1415        postStorageTask(CrossThreadTask([this, callbackAggregator = callbackAggregator.copyRef(), path = WTFMove(path)]() mutable {
     1416            RunLoop::main().dispatch([callbackAggregator = callbackAggregator.copyRef(), securityOrigins = indexedDatabaseOrigins(path)] {
     1417                for (const auto& securityOrigin : securityOrigins)
     1418                    callbackAggregator->m_websiteData.entries.append({ securityOrigin, WebsiteDataType::IndexedDBDatabases, 0 });
     1419            });
     1420        }));
     1421    }
     1422#endif
     1423   
     1424#if ENABLE(SERVICE_WORKER)
     1425    path = m_swDatabasePaths.get(sessionID);
     1426    if (!path.isEmpty() && websiteDataTypes.contains(WebsiteDataType::ServiceWorkerRegistrations)) {
     1427        swServerForSession(sessionID).getOriginsWithRegistrations([callbackAggregator = callbackAggregator.copyRef()](const HashSet<SecurityOriginData>& securityOrigins) mutable {
     1428            for (auto& securityOrigin : securityOrigins)
     1429                callbackAggregator->m_websiteData.entries.append({ securityOrigin, WebsiteDataType::ServiceWorkerRegistrations, 0 });
     1430        });
     1431    }
     1432#endif
     1433   
     1434    if (websiteDataTypes.contains(WebsiteDataType::DiskCache)) {
     1435        fetchDiskCacheEntries(cache(), sessionID, fetchOptions, [callbackAggregator = callbackAggregator.copyRef()](auto entries) mutable {
     1436            callbackAggregator->m_websiteData.entries.appendVector(entries);
     1437        });
     1438    }
     1439}
     1440#endif // ENABLE(RESOURCE_LOAD_STATISTICS)
    8241441
    8251442CacheStorage::Engine* NetworkProcess::findCacheEngine(const PAL::SessionID& sessionID)
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.h

    r240099 r240243  
    160160
    161161#if ENABLE(RESOURCE_LOAD_STATISTICS)
     162    void clearPrevalentResource(PAL::SessionID, const String& resourceDomain, CompletionHandler<void()>&&);
     163    void clearUserInteraction(PAL::SessionID, const String& resourceDomain, CompletionHandler<void()>&&);
     164    void deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(PAL::SessionID, OptionSet<WebsiteDataType>, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&&);
     165    void dumpResourceLoadStatistics(PAL::SessionID, uint64_t contextId);
    162166    void updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID, const Vector<String>& domainsToBlock, uint64_t contextId);
     167    void isGrandfathered(PAL::SessionID, const String& targetPrimaryDomain, CompletionHandler<void(bool)>&&);
     168    void isPrevalentResource(PAL::SessionID, const String& resourceDomain, CompletionHandler<void(bool)>&&);
     169    void isVeryPrevalentResource(PAL::SessionID, const String& resourceDomain, CompletionHandler<void(bool)>&&);
    163170    void setAgeCapForClientSideCookies(PAL::SessionID, Optional<Seconds>, uint64_t contextId);
     171    void isRegisteredAsRedirectingTo(PAL::SessionID, const String& redirectedFrom, const String& redirectedTo, CompletionHandler<void(bool)>&&);
     172    void isRegisteredAsSubFrameUnder(PAL::SessionID, const String& subframe, const String& topFrame, CompletionHandler<void(bool)>&&);
     173    void isRegisteredAsSubresourceUnder(PAL::SessionID, const String& subresource, const String& topFrame, CompletionHandler<void(bool)>&&);
     174    void setGrandfathered(PAL::SessionID, const String& resourceDomain, bool isGrandfathered, CompletionHandler<void()>&&);
     175    void setMaxStatisticsEntries(PAL::SessionID, uint64_t maximumEntryCount, CompletionHandler<void()>&&);
     176    void setPrevalentResource(PAL::SessionID, const String& resourceDomain, CompletionHandler<void()>&&);
     177    void setPrevalentResourceForDebugMode(PAL::SessionID, String resourceDomain, CompletionHandler<void()>&&);
     178    void setVeryPrevalentResource(PAL::SessionID, const String& resourceDomain, CompletionHandler<void()>&&);
     179    void setPruneEntriesDownTo(PAL::SessionID, uint64_t pruneTargetCount, CompletionHandler<void()>&&);
     180    void hadUserInteraction(PAL::SessionID, const String& resourceDomain, CompletionHandler<void(bool)>&&);
    164181    void hasStorageAccessForFrame(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId);
    165182    void getAllStorageAccessEntries(PAL::SessionID, uint64_t contextId);
    166     void grantStorageAccess(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, uint64_t contextId);
     183    void grantStorageAccess(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool userWasPrompted, uint64_t contextId);
     184    void hasStorageAccess(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&&);
    167185    void logFrameNavigation(PAL::SessionID, const String& targetPrimaryDomain, const String& mainFramePrimaryDomain, const String& sourcePrimaryDomain, const String& targetHost, const String& mainFrameHost, bool isRedirect, bool isMainFrame);
    168     void logUserInteraction(PAL::SessionID, const String& targetPrimaryDomain, uint64_t contextId);
     186    void logUserInteraction(PAL::SessionID, const String& targetPrimaryDomain, CompletionHandler<void()>&&);
    169187    void removeAllStorageAccess(PAL::SessionID, uint64_t contextId);
    170188    void removePrevalentDomains(PAL::SessionID, const Vector<String>& domains);
     189    void requestStorageAccess(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool promptEnabled, uint64_t contextId);
     190    void resetCacheMaxAgeCapForPrevalentResources(PAL::SessionID, uint64_t contextId);
     191    void resetParametersToDefaultValues(PAL::SessionID, CompletionHandler<void()>&&);
     192    void scheduleClearInMemoryAndPersistent(PAL::SessionID, Optional<WallTime> modifiedSince, bool shouldGrandfather, CompletionHandler<void()>&&);
     193    void scheduleCookieBlockingUpdate(PAL::SessionID, CompletionHandler<void()>&&);
     194    void scheduleStatisticsAndDataRecordsProcessing(PAL::SessionID, CompletionHandler<void()>&&);
     195    void submitTelemetry(PAL::SessionID, CompletionHandler<void()>&&);
    171196    void setCacheMaxAgeCapForPrevalentResources(PAL::SessionID, Seconds, uint64_t contextId);
    172     void resetCacheMaxAgeCapForPrevalentResources(PAL::SessionID, uint64_t contextId);
     197    void setGrandfatheringTime(PAL::SessionID, Seconds, CompletionHandler<void()>&&);
     198    void setLastSeen(PAL::SessionID, const String& resourceDomain, Seconds, CompletionHandler<void()>&&);
     199    void setMinimumTimeBetweenDataRecordsRemoval(PAL::SessionID, Seconds, CompletionHandler<void()>&&);
     200    void setNotifyPagesWhenDataRecordsWereScanned(PAL::SessionID, bool value, CompletionHandler<void()>&&);
     201    void setNotifyPagesWhenTelemetryWasCaptured(PAL::SessionID, bool value, CompletionHandler<void()>&&);
     202    void setResourceLoadStatisticsEnabled(bool);
     203    void setResourceLoadStatisticsDebugMode(PAL::SessionID, bool debugMode, CompletionHandler<void()>&&d);
     204    void setShouldClassifyResourcesBeforeDataRecordsRemoval(PAL::SessionID, bool value, CompletionHandler<void()>&&);
     205    void setSubframeUnderTopFrameOrigin(PAL::SessionID, String subframe, String topFrame, CompletionHandler<void()>&&);
     206    void setSubresourceUnderTopFrameOrigin(PAL::SessionID, String subresource, String topFrame, CompletionHandler<void()>&&);
     207    void setSubresourceUniqueRedirectTo(PAL::SessionID, String subresource, String hostNameRedirectedTo, CompletionHandler<void()>&&);
     208    void setSubresourceUniqueRedirectFrom(PAL::SessionID, String subresource, String hostNameRedirectedFrom, CompletionHandler<void()>&&);
     209    void setTimeToLiveUserInteraction(PAL::SessionID, Seconds, CompletionHandler<void()>&&);
     210    void setTopFrameUniqueRedirectTo(PAL::SessionID, String topFrameHostName, String hostNameRedirectedTo, CompletionHandler<void()>&&);
     211    void setTopFrameUniqueRedirectFrom(PAL::SessionID, String topFrameHostName, String hostNameRedirectedFrom, CompletionHandler<void()>&&);
     212    void topPrivatelyControlledDomainsWithWebsiteData(PAL::SessionID, OptionSet<WebsiteDataType>, bool shouldNotifyPage, CompletionHandler<void(HashSet<String>&&)>&&);
    173213#endif
    174214
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in

    r239816 r240243  
    8686
    8787#if ENABLE(RESOURCE_LOAD_STATISTICS)
     88    ClearPrevalentResource(PAL::SessionID sessionID, String resourceDomain) -> () Async
     89    ClearUserInteraction(PAL::SessionID sessionID, String resourceDomain) -> () Async
     90    DumpResourceLoadStatistics(PAL::SessionID sessionID, uint64_t contextId)
     91    SetResourceLoadStatisticsEnabled(bool enabled)
    8892    UpdatePrevalentDomainsToBlockCookiesFor(PAL::SessionID sessionID, Vector<String> domainsToBlock, uint64_t contextId)
     93    IsGrandfathered(PAL::SessionID sessionID, String targetPrimaryDomain) -> (bool isGrandfathered) Async
     94    IsPrevalentResource(PAL::SessionID sessionID, String targetPrimaryDomain) -> (bool isPrevalent) Async
     95    IsVeryPrevalentResource(PAL::SessionID sessionID, String targetPrimaryDomain) -> (bool isVeryPrevalent) Async
    8996    SetAgeCapForClientSideCookies(PAL::SessionID sessionID, Optional<Seconds> seconds, uint64_t contextId)
     97    SetLastSeen(PAL::SessionID sessionID, String resourceDomain, Seconds seconds) -> () Async
     98    SetPrevalentResource(PAL::SessionID sessionID, String resourceDomain) -> () Async
     99    SetPrevalentResourceForDebugMode(PAL::SessionID sessionID, String resourceDomain) -> () Async
     100    HadUserInteraction(PAL::SessionID sessionID, String resourceDomain) -> (bool hadUserInteraction) Async
    90101    HasStorageAccessForFrame(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId)
     102    HasStorageAccess(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID) -> (bool hadUserInteraction) Async
    91103    GetAllStorageAccessEntries(PAL::SessionID sessionID, uint64_t contextId)
    92     GrantStorageAccess(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, uint64_t contextId)
     104    GrantStorageAccess(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool userWasPrompted, uint64_t contextId)
     105    IsRegisteredAsRedirectingTo(PAL::SessionID sessionID, String redirectedFrom, String redirectedTo) -> (bool isRedirectingTo) Async
     106    IsRegisteredAsSubFrameUnder(PAL::SessionID sessionID, String subframe, String topFrame) -> (bool isSubframeUnder) Async
     107    IsRegisteredAsSubresourceUnder(PAL::SessionID sessionID, String subresource, String topFrame) -> (bool isSubresourceUnder) Async
    93108    LogFrameNavigation(PAL::SessionID sessionID, String targetPrimaryDomain, String mainFramePrimaryDomain, String sourcePrimaryDomain, String targetHost, String mainFrameHost, bool isRedirect, bool isMainFrame)
    94     LogUserInteraction(PAL::SessionID sessionID, String targetPrimaryDomain, uint64_t contextId)
     109    LogUserInteraction(PAL::SessionID sessionID, String targetPrimaryDomain) -> () Async
    95110    RemoveAllStorageAccess(PAL::SessionID sessionID, uint64_t contextId)
    96111    RemovePrevalentDomains(PAL::SessionID sessionID, Vector<String> domainsWithInteraction)
     112    RequestStorageAccess(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool promptEnabled, uint64_t contextId)
     113    ResetParametersToDefaultValues(PAL::SessionID sessionID) -> () Async
     114    ScheduleClearInMemoryAndPersistent(PAL::SessionID sessionID, Optional<WallTime> modifiedSince, bool shouldGrandfather) -> () Async
     115    ScheduleCookieBlockingUpdate(PAL::SessionID sessionID) -> () Async
     116    ScheduleStatisticsAndDataRecordsProcessing(PAL::SessionID sessionID) -> () Async
     117    SubmitTelemetry(PAL::SessionID sessionID) -> () Async
    97118    SetCacheMaxAgeCapForPrevalentResources(PAL::SessionID sessionID, Seconds seconds, uint64_t contextId)
     119    SetGrandfathered(PAL::SessionID sessionID, String resourceDomain, bool isGrandfathered) -> () Async
     120    SetGrandfatheringTime(PAL::SessionID sessionID, Seconds seconds) -> () Async
     121    SetMaxStatisticsEntries(PAL::SessionID sessionID, uint64_t maximumEntryCount) -> () Async
     122    SetMinimumTimeBetweenDataRecordsRemoval(PAL::SessionID sessionID, Seconds seconds) -> () Async
     123    SetPruneEntriesDownTo(PAL::SessionID sessionID, uint64_t maximumEntryCount) -> () Async
     124    SetShouldClassifyResourcesBeforeDataRecordsRemoval(PAL::SessionID sessionID, bool value) -> () Async
     125    SetNotifyPagesWhenDataRecordsWereScanned(PAL::SessionID sessionID, bool value) -> () Async
     126    SetNotifyPagesWhenTelemetryWasCaptured(PAL::SessionID sessionID, bool value) -> () Async
     127    SetResourceLoadStatisticsDebugMode(PAL::SessionID sessionID, bool debugMode) -> () Async
     128    SetVeryPrevalentResource(PAL::SessionID sessionID, String resourceDomain) -> () Async
     129    SetSubframeUnderTopFrameOrigin(PAL::SessionID sessionID, String subframe, String topFrame) -> () Async
     130    SetSubresourceUnderTopFrameOrigin(PAL::SessionID sessionID, String subresource, String topFrame) -> () Async
     131    SetSubresourceUniqueRedirectTo(PAL::SessionID sessionID, String subresource, String hostNameRedirectedTo) -> () Async
     132    SetSubresourceUniqueRedirectFrom(PAL::SessionID sessionID, String subresource, String hostNameRedirectedFrom) -> () Async
     133    SetTimeToLiveUserInteraction(PAL::SessionID sessionID, Seconds seconds) -> () Async
     134    SetTopFrameUniqueRedirectTo(PAL::SessionID sessionID, String topFrameHostName, String hostNameRedirectedTo) -> () Async
     135    SetTopFrameUniqueRedirectFrom(PAL::SessionID sessionID, String topFrameHostName, String hostNameRedirectedFrom) -> () Async
    98136    ResetCacheMaxAgeCapForPrevalentResources(PAL::SessionID sessionID, uint64_t contextId)
    99137#endif
  • trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp

    r239816 r240243  
    2727#include "NetworkSession.h"
    2828
     29#include "NetworkProcess.h"
     30#include "NetworkProcessProxyMessages.h"
     31#include "WebProcessProxy.h"
    2932#include "WebResourceLoadStatisticsStore.h"
    3033#include <WebCore/NetworkStorageSession.h>
     
    7982}
    8083
    81 void NetworkSession::enableResourceLoadStatistics()
     84#if ENABLE(RESOURCE_LOAD_STATISTICS)
     85void NetworkSession::setResourceLoadStatisticsEnabled(bool enable)
    8286{
     87    if (!enable) {
     88        m_resourceLoadStatistics = nullptr;
     89        return;
     90    }
     91
    8392    if (m_resourceLoadStatistics)
    8493        return;
     
    8796}
    8897
     98void NetworkSession::notifyResourceLoadStatisticsProcessed()
     99{
     100    m_networkProcess->parentProcessConnection()->send(Messages::NetworkProcessProxy::NotifyResourceLoadStatisticsProcessed(), 0);
     101}
     102
     103void NetworkSession::logDiagnosticMessageWithValue(const String& message, const String& description, unsigned value, unsigned significantFigures, WebCore::ShouldSample shouldSample)
     104{
     105    m_networkProcess->parentProcessConnection()->send(Messages::WebPageProxy::LogDiagnosticMessageWithValue(message, description, value, significantFigures, shouldSample), 0);
     106}
     107
     108void NetworkSession::notifyPageStatisticsTelemetryFinished(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins)
     109{
     110    m_networkProcess->parentProcessConnection()->send(Messages::NetworkProcessProxy::NotifyResourceLoadStatisticsTelemetryFinished(totalPrevalentResources, totalPrevalentResourcesWithUserInteraction, top3SubframeUnderTopFrameOrigins), 0);
     111}
     112
     113void NetworkSession::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType> dataTypes, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&& completionHandler)
     114{
     115    m_networkProcess->deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(m_sessionID, dataTypes, WTFMove(topPrivatelyControlledDomains), shouldNotifyPage, WTFMove(completionHandler));
     116}
     117
     118void NetworkSession::topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType> dataTypes, bool shouldNotifyPage, CompletionHandler<void(HashSet<String>&&)>&& completionHandler)
     119{
     120    m_networkProcess->topPrivatelyControlledDomainsWithWebsiteData(m_sessionID, dataTypes, shouldNotifyPage, WTFMove(completionHandler));
     121}
     122#endif
     123
    89124} // namespace WebKit
  • trunk/Source/WebKit/NetworkProcess/NetworkSession.h

    r239816 r240243  
    11/*
    2  * Copyright (C) 2015 Apple Inc. All rights reserved.
     2 * Copyright (C) 2015-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3636namespace WebCore {
    3737class NetworkStorageSession;
     38enum class ShouldSample : bool;
    3839}
    3940
     
    4546struct NetworkSessionCreationParameters;
    4647
     48enum class WebsiteDataType;
     49   
    4750class NetworkSession : public RefCounted<NetworkSession>, public CanMakeWeakPtr<NetworkSession> {
    4851public:
     
    6265    void unregisterNetworkDataTask(NetworkDataTask& task) { m_dataTaskSet.remove(&task); }
    6366
     67#if ENABLE(RESOURCE_LOAD_STATISTICS)
    6468    WebResourceLoadStatisticsStore* resourceLoadStatistics() const { return m_resourceLoadStatistics.get(); }
    65     void enableResourceLoadStatistics();
    66    
     69    void setResourceLoadStatisticsEnabled(bool);
     70    void notifyResourceLoadStatisticsProcessed();
     71    void deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType>, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&&);
     72    void topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType>, bool shouldNotifyPage, CompletionHandler<void(HashSet<String>&&)>&&);
     73    void logDiagnosticMessageWithValue(const String& message, const String& description, unsigned value, unsigned significantFigures, WebCore::ShouldSample);
     74    void notifyPageStatisticsTelemetryFinished(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins);
     75#endif
     76
    6777protected:
    6878    NetworkSession(NetworkProcess&, PAL::SessionID);
     
    7282    HashSet<NetworkDataTask*> m_dataTaskSet;
    7383    String m_resourceLoadStatisticsDirectory;
     84#if ENABLE(RESOURCE_LOAD_STATISTICS)
    7485    RefPtr<WebResourceLoadStatisticsStore> m_resourceLoadStatistics;
     86#endif
    7587};
    7688
  • trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm

    r239815 r240243  
    349349        request.setFirstPartyForCookies(request.url());
    350350
    351     bool shouldBlockCookies = false;
    352351#if ENABLE(RESOURCE_LOAD_STATISTICS)
    353     shouldBlockCookies = m_session->networkStorageSession().shouldBlockCookies(request, m_frameID, m_pageID);
     352    bool shouldBlockCookies = m_session->networkStorageSession().shouldBlockCookies(request, m_frameID, m_pageID);
    354353#if !RELEASE_LOG_DISABLED
    355354    if (m_session->shouldLogCookieInformation())
     
    379378        m_client->willPerformHTTPRedirection(WTFMove(redirectResponse), WTFMove(request), [completionHandler = WTFMove(completionHandler), this, protectedThis = makeRef(*this)] (auto&& request) mutable {
    380379            if (!request.isNull()) {
     380#if ENABLE(RESOURCE_LOAD_STATISTICS)
    381381                bool shouldBlockCookies = m_session->networkStorageSession().shouldBlockCookies(request, m_frameID, m_pageID);
     382#else
     383                bool shouldBlockCookies = false;
     384#endif
    382385                restrictRequestReferrerToOriginIfNeeded(request, shouldBlockCookies);
    383386            }
  • trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm

    r239884 r240243  
    378378}
    379379
    380 #if HAVE(CFNETWORK_WITH_IGNORE_HSTS)
     380#if HAVE(CFNETWORK_WITH_IGNORE_HSTS) && ENABLE(RESOURCE_LOAD_STATISTICS)
    381381static NSURLRequest* downgradeRequest(NSURLRequest *request)
    382382{
     
    399399        && [request _schemeWasUpgradedDueToDynamicHSTS];
    400400}
    401 
     401#endif
     402
     403#if HAVE(CFNETWORK_WITH_IGNORE_HSTS)
    402404static void setIgnoreHSTS(NSMutableURLRequest *request, bool ignoreHSTS)
    403405{
     
    445447
    446448        bool shouldIgnoreHSTS = false;
    447 #if HAVE(CFNETWORK_WITH_IGNORE_HSTS)
     449#if HAVE(CFNETWORK_WITH_IGNORE_HSTS) && ENABLE(RESOURCE_LOAD_STATISTICS)       
    448450        shouldIgnoreHSTS = schemeWasUpgradedDueToDynamicHSTS(request) && WebCore::NetworkStorageSession::storageSession(_session->sessionID())->shouldBlockCookies(request, networkDataTask->frameID(), networkDataTask->pageID());
    449451        if (shouldIgnoreHSTS) {
     
    478480    if (auto* networkDataTask = [self existingTask:task]) {
    479481        bool shouldIgnoreHSTS = false;
    480 #if HAVE(CFNETWORK_WITH_IGNORE_HSTS)
     482#if HAVE(CFNETWORK_WITH_IGNORE_HSTS) && ENABLE(RESOURCE_LOAD_STATISTICS)
    481483        shouldIgnoreHSTS = schemeWasUpgradedDueToDynamicHSTS(request) && WebCore::NetworkStorageSession::storageSession(_session->sessionID())->shouldBlockCookies(request, networkDataTask->frameID(), networkDataTask->pageID());
    482484        if (shouldIgnoreHSTS) {
     
    945947    m_statelessSession = [NSURLSession sessionWithConfiguration:configuration delegate:static_cast<id>(m_statelessSessionDelegate.get()) delegateQueue:[NSOperationQueue mainQueue]];
    946948
     949#if ENABLE(RESOURCE_LOAD_STATISTICS)
    947950    m_resourceLoadStatisticsDirectory = parameters.resourceLoadStatisticsDirectory;
    948     if (parameters.enableResourceLoadStatistics)
    949         enableResourceLoadStatistics();
     951    setResourceLoadStatisticsEnabled(parameters.enableResourceLoadStatistics);
     952#endif
    950953}
    951954
  • trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp

    r239752 r240243  
    3737#include "WKString.h"
    3838#include "WebResourceLoadStatisticsStore.h"
    39 #include "WebResourceLoadStatisticsTelemetry.h"
    4039#include "WebsiteData.h"
    4140#include "WebsiteDataFetchOption.h"
     
    7776void WKWebsiteDataStoreSetResourceLoadStatisticsDebugModeWithCompletionHandler(WKWebsiteDataStoreRef dataStoreRef, bool enable, void* context, WKWebsiteDataStoreStatisticsDebugModeFunction completionHandler)
    7877{
    79     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    80     if (!store) {
     78#if ENABLE(RESOURCE_LOAD_STATISTICS)
     79    WebKit::toImpl(dataStoreRef)->websiteDataStore().setResourceLoadStatisticsDebugMode(enable, [context, completionHandler] {
    8180        completionHandler(context);
    82         return;
    83     }
    84    
    85     store->setResourceLoadStatisticsDebugMode(enable, [context, completionHandler] {
     81    });
     82#else
     83    completionHandler(context);
     84#endif
     85}
     86
     87void WKWebsiteDataStoreSetResourceLoadStatisticsPrevalentResourceForDebugMode(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreStatisticsDebugModeFunction completionHandler)
     88{
     89#if ENABLE(RESOURCE_LOAD_STATISTICS)
     90    WebKit::toImpl(dataStoreRef)->websiteDataStore().setPrevalentResourceForDebugMode(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {
    8691        completionHandler(context);
    8792    });
    88 }
    89 
    90 void WKWebsiteDataStoreSetResourceLoadStatisticsPrevalentResourceForDebugMode(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreStatisticsDebugModeFunction completionHandler)
    91 {
    92     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    93     if (!store) {
     93#else
     94    completionHandler(context);
     95#endif
     96}
     97void WKWebsiteDataStoreSetStatisticsLastSeen(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, double seconds, void* context, WKWebsiteDataStoreStatisticsLastSeenFunction completionHandler)
     98{
     99#if ENABLE(RESOURCE_LOAD_STATISTICS)
     100    WebKit::toImpl(dataStoreRef)->websiteDataStore().setLastSeen(URL(URL(), WebKit::toImpl(host)->string()), Seconds { seconds }, [context, completionHandler] {
    94101        completionHandler(context);
    95         return;
    96     }
    97    
    98     store->setPrevalentResourceForDebugMode(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {
    99         completionHandler(context);
    100     });
    101 }
    102 void WKWebsiteDataStoreSetStatisticsLastSeen(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, double seconds, void* context, WKWebsiteDataStoreStatisticsLastSeenFunction completionHandler)
    103 {
    104     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    105     if (!store) {
    106         completionHandler(context);
    107         return;
    108     }
    109 
    110     store->setLastSeen(URL(URL(), WebKit::toImpl(host)->string()), Seconds { seconds }, [context, completionHandler] {
    111         completionHandler(context);
    112     });
     102    });
     103#else
     104    completionHandler(context);
     105#endif
    113106}
    114107
    115108void WKWebsiteDataStoreSetStatisticsPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value, void* context, WKWebsiteDataStoreStatisticsPrevalentResourceFunction completionHandler)
    116109{
    117     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    118     if (!store) {
    119         completionHandler(context);
    120         return;
    121     }
     110#if ENABLE(RESOURCE_LOAD_STATISTICS)
     111    auto& websiteDataStore = WebKit::toImpl(dataStoreRef)->websiteDataStore();
    122112
    123113    if (value)
    124         store->setPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {
     114        websiteDataStore.setPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {
    125115            completionHandler(context);
    126116        });
    127117    else
    128         store->clearPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {
     118        websiteDataStore.clearPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {
    129119            completionHandler(context);
    130120        });
     121#else
     122    completionHandler(context);
     123#endif
    131124}
    132125
    133126void WKWebsiteDataStoreSetStatisticsVeryPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value, void* context, WKWebsiteDataStoreStatisticsVeryPrevalentResourceFunction completionHandler)
    134127{
    135     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    136     if (!store) {
    137         completionHandler(context);
    138         return;
    139     }
     128#if ENABLE(RESOURCE_LOAD_STATISTICS)
     129    auto& websiteDataStore = WebKit::toImpl(dataStoreRef)->websiteDataStore();
    140130
    141131    if (value)
    142         store->setVeryPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {
     132        websiteDataStore.setVeryPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {
    143133            completionHandler(context);
    144134        });
    145135    else
    146         store->clearPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {
     136        websiteDataStore.clearPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {
    147137            completionHandler(context);
    148138        });
     139#else
     140    completionHandler(context);
     141#endif
    149142}
    150143
    151144void WKWebsiteDataStoreDumpResourceLoadStatistics(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreDumpResourceLoadStatisticsFunction callback)
    152145{
    153     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    154     if (!store) {
    155         callback(WebKit::toAPI(emptyString().impl()), context);
    156         return;
    157     }
    158 
    159     store->dumpResourceLoadStatistics([context, callback] (const String& resourceLoadStatistics) {
     146#if ENABLE(RESOURCE_LOAD_STATISTICS)
     147    WebKit::toImpl(dataStoreRef)->websiteDataStore().dumpResourceLoadStatistics([context, callback] (const String& resourceLoadStatistics) {
    160148        callback(WebKit::toAPI(resourceLoadStatistics.impl()), context);
    161149    });
     150#else
     151    callback(WebKit::toAPI(emptyString().impl()), context);
     152#endif
    162153}
    163154
    164155void WKWebsiteDataStoreIsStatisticsPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsPrevalentResourceFunction callback)
    165156{
    166     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    167     if (!store) {
    168         callback(false, context);
    169         return;
    170     }
    171 
    172     store->isPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, callback](bool isPrevalentResource) {
     157#if ENABLE(RESOURCE_LOAD_STATISTICS)
     158    WebKit::toImpl(dataStoreRef)->websiteDataStore().isPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, callback](bool isPrevalentResource) {
    173159        callback(isPrevalentResource, context);
    174160    });
     161#else
     162    callback(false, context);
     163#endif
    175164}
    176165
    177166void WKWebsiteDataStoreIsStatisticsVeryPrevalentResource(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsPrevalentResourceFunction callback)
    178167{
    179     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    180     if (!store) {
    181         callback(false, context);
    182         return;
    183     }
    184    
    185     store->isVeryPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, callback](bool isVeryPrevalentResource) {
     168#if ENABLE(RESOURCE_LOAD_STATISTICS)
     169    WebKit::toImpl(dataStoreRef)->websiteDataStore().isVeryPrevalentResource(URL(URL(), WebKit::toImpl(host)->string()), [context, callback](bool isVeryPrevalentResource) {
    186170        callback(isVeryPrevalentResource, context);
    187171    });
     172#else
     173    callback(false, context);
     174#endif
    188175}
    189176
    190177void WKWebsiteDataStoreIsStatisticsRegisteredAsSubresourceUnder(WKWebsiteDataStoreRef dataStoreRef, WKStringRef subresourceHost, WKStringRef topFrameHost, void* context, WKWebsiteDataStoreIsStatisticsRegisteredAsSubresourceUnderFunction callback)
    191178{
    192     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    193     if (!store) {
    194         callback(false, context);
    195         return;
    196     }
    197    
    198     store->isRegisteredAsSubresourceUnder(URL(URL(), WebKit::toImpl(subresourceHost)->string()), URL(URL(), WebKit::toImpl(topFrameHost)->string()), [context, callback](bool isRegisteredAsSubresourceUnder) {
     179#if ENABLE(RESOURCE_LOAD_STATISTICS)
     180    WebKit::toImpl(dataStoreRef)->websiteDataStore().isRegisteredAsSubresourceUnder(URL(URL(), WebKit::toImpl(subresourceHost)->string()), URL(URL(), WebKit::toImpl(topFrameHost)->string()), [context, callback](bool isRegisteredAsSubresourceUnder) {
    199181        callback(isRegisteredAsSubresourceUnder, context);
    200182    });
     183#else
     184    callback(false, context);
     185#endif
    201186}
    202187
    203188void WKWebsiteDataStoreIsStatisticsRegisteredAsSubFrameUnder(WKWebsiteDataStoreRef dataStoreRef, WKStringRef subFrameHost, WKStringRef topFrameHost, void* context, WKWebsiteDataStoreIsStatisticsRegisteredAsSubFrameUnderFunction callback)
    204189{
    205     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    206     if (!store) {
    207         callback(false, context);
    208         return;
    209     }
    210 
    211     store->isRegisteredAsSubFrameUnder(URL(URL(), WebKit::toImpl(subFrameHost)->string()), URL(URL(), WebKit::toImpl(topFrameHost)->string()), [context, callback](bool isRegisteredAsSubFrameUnder) {
     190#if ENABLE(RESOURCE_LOAD_STATISTICS)
     191    WebKit::toImpl(dataStoreRef)->websiteDataStore().isRegisteredAsSubFrameUnder(URL(URL(), WebKit::toImpl(subFrameHost)->string()), URL(URL(), WebKit::toImpl(topFrameHost)->string()), [context, callback](bool isRegisteredAsSubFrameUnder) {
    212192        callback(isRegisteredAsSubFrameUnder, context);
    213193    });
     194#else
     195    callback(false, context);
     196#endif
    214197}
    215198
    216199void WKWebsiteDataStoreIsStatisticsRegisteredAsRedirectingTo(WKWebsiteDataStoreRef dataStoreRef, WKStringRef hostRedirectedFrom, WKStringRef hostRedirectedTo, void* context, WKWebsiteDataStoreIsStatisticsRegisteredAsRedirectingToFunction callback)
    217200{
    218     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    219     if (!store) {
    220         callback(false, context);
    221         return;
    222     }
    223 
    224     store->isRegisteredAsRedirectingTo(URL(URL(), WebKit::toImpl(hostRedirectedFrom)->string()), URL(URL(), WebKit::toImpl(hostRedirectedTo)->string()), [context, callback](bool isRegisteredAsRedirectingTo) {
     201#if ENABLE(RESOURCE_LOAD_STATISTICS)
     202    WebKit::toImpl(dataStoreRef)->websiteDataStore().isRegisteredAsRedirectingTo(URL(URL(), WebKit::toImpl(hostRedirectedFrom)->string()), URL(URL(), WebKit::toImpl(hostRedirectedTo)->string()), [context, callback](bool isRegisteredAsRedirectingTo) {
    225203        callback(isRegisteredAsRedirectingTo, context);
    226204    });
     205#else
     206    callback(false, context);
     207#endif
    227208}
    228209
    229210void WKWebsiteDataStoreSetStatisticsHasHadUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value, void* context, WKWebsiteDataStoreStatisticsHasHadUserInteractionFunction completionHandler)
    230211{
    231     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    232     if (!store) {
    233         completionHandler(context);
    234         return;
    235     }
     212#if ENABLE(RESOURCE_LOAD_STATISTICS)
     213    auto& dataStore = WebKit::toImpl(dataStoreRef)->websiteDataStore();
    236214
    237215    if (value)
    238         store->logUserInteraction(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {
     216        dataStore.logUserInteraction(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {
    239217            completionHandler(context);
    240218        });
    241219    else
    242         store->clearUserInteraction(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {
     220        dataStore.clearUserInteraction(URL(URL(), WebKit::toImpl(host)->string()), [context, completionHandler] {
    243221            completionHandler(context);
    244222        });
     223#else
     224    completionHandler(context);
     225#endif
    245226}
    246227
    247228void WKWebsiteDataStoreIsStatisticsHasHadUserInteraction(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsHasHadUserInteractionFunction callback)
    248229{
    249     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    250     if (!store) {
    251         callback(false, context);
    252         return;
    253     }
    254 
    255     store->hasHadUserInteraction(URL(URL(), WebKit::toImpl(host)->string()), [context, callback](bool hasHadUserInteraction) {
     230#if ENABLE(RESOURCE_LOAD_STATISTICS)
     231    WebKit::toImpl(dataStoreRef)->websiteDataStore().hasHadUserInteraction(URL(URL(), WebKit::toImpl(host)->string()), [context, callback](bool hasHadUserInteraction) {
    256232        callback(hasHadUserInteraction, context);
    257233    });
     234#else
     235    callback(false, context);
     236#endif
    258237}
    259238
    260239void WKWebsiteDataStoreSetStatisticsGrandfathered(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, bool value)
    261240{
    262     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    263     if (!store)
    264         return;
    265 
    266     store->setGrandfathered(URL(URL(), WebKit::toImpl(host)->string()), value);
     241#if ENABLE(RESOURCE_LOAD_STATISTICS)
     242    WebKit::toImpl(dataStoreRef)->websiteDataStore().setGrandfathered(URL(URL(), WebKit::toImpl(host)->string()), value, [] { });
     243#endif
    267244}
    268245
    269246void WKWebsiteDataStoreIsStatisticsGrandfathered(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, void* context, WKWebsiteDataStoreIsStatisticsGrandfatheredFunction callback)
    270247{
    271     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    272     if (!store) {
    273         callback(false, context);
    274         return;
    275     }
    276 
    277     store->hasHadUserInteraction(URL(URL(), WebKit::toImpl(host)->string()), [context, callback](bool isGrandfathered) {
     248#if ENABLE(RESOURCE_LOAD_STATISTICS)
     249    WebKit::toImpl(dataStoreRef)->websiteDataStore().hasHadUserInteraction(URL(URL(), WebKit::toImpl(host)->string()), [context, callback](bool isGrandfathered) {
    278250        callback(isGrandfathered, context);
    279251    });
     252#else
     253    callback(false, context);
     254#endif
    280255}
    281256
    282257void WKWebsiteDataStoreSetStatisticsSubframeUnderTopFrameOrigin(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef topFrameHost)
    283258{
    284     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    285     if (!store)
    286         return;
    287 
    288     store->setSubframeUnderTopFrameOrigin(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(topFrameHost)->string()));
     259#if ENABLE(RESOURCE_LOAD_STATISTICS)
     260    WebKit::toImpl(dataStoreRef)->websiteDataStore().setSubframeUnderTopFrameOrigin(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(topFrameHost)->string()), [] { });
     261#endif
    289262}
    290263
    291264void WKWebsiteDataStoreSetStatisticsSubresourceUnderTopFrameOrigin(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef topFrameHost)
    292265{
    293     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    294     if (!store)
    295         return;
    296 
    297     store->setSubresourceUnderTopFrameOrigin(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(topFrameHost)->string()));
     266#if ENABLE(RESOURCE_LOAD_STATISTICS)
     267    WebKit::toImpl(dataStoreRef)->websiteDataStore().setSubresourceUnderTopFrameOrigin(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(topFrameHost)->string()), [] { });
     268#endif
    298269}
    299270
    300271void WKWebsiteDataStoreSetStatisticsSubresourceUniqueRedirectTo(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef hostRedirectedTo)
    301272{
    302     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    303     if (!store)
    304         return;
    305 
    306     store->setSubresourceUniqueRedirectTo(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(hostRedirectedTo)->string()));
     273#if ENABLE(RESOURCE_LOAD_STATISTICS)
     274    WebKit::toImpl(dataStoreRef)->websiteDataStore().setSubresourceUniqueRedirectTo(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(hostRedirectedTo)->string()), [] { });
     275#endif
    307276}
    308277
    309278void WKWebsiteDataStoreSetStatisticsSubresourceUniqueRedirectFrom(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef hostRedirectedFrom)
    310279{
    311     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    312     if (!store)
    313         return;
    314    
    315     store->setSubresourceUniqueRedirectFrom(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(hostRedirectedFrom)->string()));
     280#if ENABLE(RESOURCE_LOAD_STATISTICS)
     281    WebKit::toImpl(dataStoreRef)->websiteDataStore().setSubresourceUniqueRedirectFrom(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(hostRedirectedFrom)->string()), [] { });
     282#endif
    316283}
    317284
    318285void WKWebsiteDataStoreSetStatisticsTopFrameUniqueRedirectTo(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef hostRedirectedTo)
    319286{
    320     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    321     if (!store)
    322         return;
    323    
    324     store->setTopFrameUniqueRedirectTo(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(hostRedirectedTo)->string()));
     287#if ENABLE(RESOURCE_LOAD_STATISTICS)
     288    WebKit::toImpl(dataStoreRef)->websiteDataStore().setTopFrameUniqueRedirectTo(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(hostRedirectedTo)->string()), [] { });
     289#endif
    325290}
    326291
    327292void WKWebsiteDataStoreSetStatisticsTopFrameUniqueRedirectFrom(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef hostRedirectedFrom)
    328293{
    329     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    330     if (!store)
    331         return;
    332    
    333     store->setTopFrameUniqueRedirectFrom(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(hostRedirectedFrom)->string()));
     294#if ENABLE(RESOURCE_LOAD_STATISTICS)
     295    WebKit::toImpl(dataStoreRef)->websiteDataStore().setTopFrameUniqueRedirectFrom(URL(URL(), WebKit::toImpl(host)->string()), URL(URL(), WebKit::toImpl(hostRedirectedFrom)->string()), [] { });
     296#endif
    334297}
    335298
    336299void WKWebsiteDataStoreSetStatisticsTimeToLiveUserInteraction(WKWebsiteDataStoreRef dataStoreRef, double seconds)
    337300{
    338     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    339     if (!store)
    340         return;
    341 
    342     store->setTimeToLiveUserInteraction(Seconds { seconds });
     301#if ENABLE(RESOURCE_LOAD_STATISTICS)
     302    WebKit::toImpl(dataStoreRef)->websiteDataStore().setTimeToLiveUserInteraction(Seconds { seconds }, [] { });
     303#endif
    343304}
    344305
    345306void WKWebsiteDataStoreStatisticsProcessStatisticsAndDataRecords(WKWebsiteDataStoreRef dataStoreRef)
    346307{
    347     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    348     if (!store)
    349         return;
    350 
    351     store->scheduleStatisticsAndDataRecordsProcessing();
     308#if ENABLE(RESOURCE_LOAD_STATISTICS)
     309    WebKit::toImpl(dataStoreRef)->websiteDataStore().scheduleStatisticsAndDataRecordsProcessing([] { });
     310#endif
    352311}
    353312
    354313void WKWebsiteDataStoreStatisticsUpdateCookieBlocking(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreStatisticsUpdateCookieBlockingFunction completionHandler)
    355314{
    356     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    357     if (!store) {
     315#if ENABLE(RESOURCE_LOAD_STATISTICS)
     316    WebKit::toImpl(dataStoreRef)->websiteDataStore().scheduleCookieBlockingUpdate([context, completionHandler]() {
    358317        completionHandler(context);
    359         return;
    360     }
    361 
    362     store->scheduleCookieBlockingUpdate([context, completionHandler]() {
    363         completionHandler(context);
    364     });
     318    });
     319#endif
    365320}
    366321
    367322void WKWebsiteDataStoreStatisticsSubmitTelemetry(WKWebsiteDataStoreRef dataStoreRef)
    368323{
    369     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    370     if (!store)
    371         return;
    372 
    373     store->submitTelemetry();
     324#if ENABLE(RESOURCE_LOAD_STATISTICS)
     325    WebKit::toImpl(dataStoreRef)->websiteDataStore().submitTelemetry();
     326#endif
    374327}
    375328
    376329void WKWebsiteDataStoreSetStatisticsNotifyPagesWhenDataRecordsWereScanned(WKWebsiteDataStoreRef dataStoreRef, bool value)
    377330{
    378     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    379     if (!store)
    380         return;
    381 
    382     store->setNotifyPagesWhenDataRecordsWereScanned(value);
     331#if ENABLE(RESOURCE_LOAD_STATISTICS)
     332    WebKit::toImpl(dataStoreRef)->websiteDataStore().setNotifyPagesWhenDataRecordsWereScanned(value, [] { });
     333#endif
    383334}
    384335
    385336void WKWebsiteDataStoreSetStatisticsShouldClassifyResourcesBeforeDataRecordsRemoval(WKWebsiteDataStoreRef dataStoreRef, bool value)
    386337{
    387     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    388     if (!store)
    389         return;
    390 
    391     store->setShouldClassifyResourcesBeforeDataRecordsRemoval(value);
    392 }
    393 
    394 void WKWebsiteDataStoreSetStatisticsNotifyPagesWhenTelemetryWasCaptured(WKWebsiteDataStoreRef, bool value)
    395 {
    396     WebKit::WebResourceLoadStatisticsTelemetry::setNotifyPagesWhenTelemetryWasCaptured(value);
     338#if ENABLE(RESOURCE_LOAD_STATISTICS)
     339    WebKit::toImpl(dataStoreRef)->websiteDataStore().setShouldClassifyResourcesBeforeDataRecordsRemoval(value, []() { });
     340#endif
     341}
     342
     343void WKWebsiteDataStoreSetStatisticsNotifyPagesWhenTelemetryWasCaptured(WKWebsiteDataStoreRef dataStoreRef, bool value)
     344{
     345#if ENABLE(RESOURCE_LOAD_STATISTICS)
     346    WebKit::toImpl(dataStoreRef)->websiteDataStore().setNotifyPagesWhenTelemetryWasCaptured(value, []() { });
     347#endif
    397348}
    398349
    399350void WKWebsiteDataStoreSetStatisticsMinimumTimeBetweenDataRecordsRemoval(WKWebsiteDataStoreRef dataStoreRef, double seconds)
    400351{
    401     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    402     if (!store)
    403         return;
    404 
    405     store->setMinimumTimeBetweenDataRecordsRemoval(Seconds { seconds });
     352#if ENABLE(RESOURCE_LOAD_STATISTICS)
     353    WebKit::toImpl(dataStoreRef)->websiteDataStore().setMinimumTimeBetweenDataRecordsRemoval(Seconds { seconds }, []() { });
     354#endif
    406355}
    407356
    408357void WKWebsiteDataStoreSetStatisticsGrandfatheringTime(WKWebsiteDataStoreRef dataStoreRef, double seconds)
    409358{
    410     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    411     if (!store)
    412         return;
    413 
    414     store->setGrandfatheringTime(Seconds {seconds });
     359#if ENABLE(RESOURCE_LOAD_STATISTICS)
     360    WebKit::toImpl(dataStoreRef)->websiteDataStore().setGrandfatheringTime(Seconds { seconds }, []() { });
     361#endif
    415362}
    416363
    417364void WKWebsiteDataStoreSetStatisticsMaxStatisticsEntries(WKWebsiteDataStoreRef dataStoreRef, unsigned entries)
    418365{
    419     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    420     if (!store)
    421         return;
    422 
    423     store->setMaxStatisticsEntries(entries);
     366#if ENABLE(RESOURCE_LOAD_STATISTICS)
     367    WebKit::toImpl(dataStoreRef)->websiteDataStore().setMaxStatisticsEntries(entries, []() { });
     368#endif
    424369}
    425370
    426371void WKWebsiteDataStoreSetStatisticsPruneEntriesDownTo(WKWebsiteDataStoreRef dataStoreRef, unsigned entries)
    427372{
    428     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    429     if (!store)
    430         return;
    431 
    432     store->setPruneEntriesDownTo(entries);
     373#if ENABLE(RESOURCE_LOAD_STATISTICS)
     374    WebKit::toImpl(dataStoreRef)->websiteDataStore().setPruneEntriesDownTo(entries, []() { });
     375#endif
    433376}
    434377
    435378void WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStore(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStoreFunction callback)
    436379{
    437     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    438     if (!store) {
    439         callback(context);
    440         return;
    441     }
    442 
    443     store->scheduleClearInMemoryAndPersistent(WebKit::WebResourceLoadStatisticsStore::ShouldGrandfather::Yes, [context, callback]() {
    444         callback(context);
    445     });
     380#if ENABLE(RESOURCE_LOAD_STATISTICS)
     381    WebKit::toImpl(dataStoreRef)->websiteDataStore().scheduleClearInMemoryAndPersistent(ShouldGrandfather::Yes, [context, callback]() {
     382        callback(context);
     383    });
     384#else
     385    callback(context);
     386#endif
    446387}
    447388
    448389void WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStoreModifiedSinceHours(WKWebsiteDataStoreRef dataStoreRef, unsigned hours, void* context, WKWebsiteDataStoreStatisticsClearInMemoryAndPersistentStoreModifiedSinceHoursFunction callback)
    449390{
    450     auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics();
    451     if (!store) {
    452         callback(context);
    453         return;
    454     }
    455 
    456     store->scheduleClearInMemoryAndPersistent(WallTime::now() - Seconds::fromHours(hours), WebKit::WebResourceLoadStatisticsStore::ShouldGrandfather::Yes, [context, callback]() {
    457         callback(context);
    458     });
     391#if ENABLE(RESOURCE_LOAD_STATISTICS)
     392    WebKit::toImpl(dataStoreRef)->websiteDataStore().scheduleClearInMemoryAndPersistent(WallTime::now() - Seconds::fromHours(hours), ShouldGrandfather::Yes, [context, callback]() {
     393        callback(context);
     394    });
     395#endif
    459396}
    460397
     
    476413void WKWebsiteDataStoreStatisticsResetToConsistentState(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreStatisticsResetToConsistentStateFunction completionHandler)
    477414{
     415#if ENABLE(RESOURCE_LOAD_STATISTICS)
    478416    auto callbackAggregator = CallbackAggregator::create([context, completionHandler]() {
    479417        completionHandler(context);
     
    483421    store.clearResourceLoadStatisticsInWebProcesses([callbackAggregator = callbackAggregator.copyRef()] { });
    484422    store.resetCacheMaxAgeCapForPrevalentResources([callbackAggregator = callbackAggregator.copyRef()] { });
    485 
    486     auto* statisticsStore = store.resourceLoadStatistics();
    487     if (!statisticsStore)
    488         return;
    489 
    490     statisticsStore->resetParametersToDefaultValues([callbackAggregator = callbackAggregator.copyRef()] { });
    491     statisticsStore->scheduleClearInMemoryAndPersistent(WebKit::WebResourceLoadStatisticsStore::ShouldGrandfather::No, [callbackAggregator = callbackAggregator.copyRef()] { });
     423    store.resetParametersToDefaultValues([callbackAggregator = callbackAggregator.copyRef()] { });
     424    store.scheduleClearInMemoryAndPersistent(ShouldGrandfather::No, [callbackAggregator = callbackAggregator.copyRef()] { });
     425#else
     426    UNUSED_PARAM(dataStoreRef);
     427    completionHandler(context);
     428#endif
    492429}
    493430
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm

    r240156 r240243  
    293293- (BOOL)_resourceLoadStatisticsDebugMode
    294294{
     295#if ENABLE(RESOURCE_LOAD_STATISTICS)
    295296    return _websiteDataStore->websiteDataStore().resourceLoadStatisticsDebugMode();
     297#else
     298    return NO;
     299#endif
    296300}
    297301
    298302- (void)_setResourceLoadStatisticsDebugMode:(BOOL)enabled
    299303{
     304#if ENABLE(RESOURCE_LOAD_STATISTICS)
    300305    _websiteDataStore->websiteDataStore().setResourceLoadStatisticsDebugMode(enabled);
     306#else
     307    UNUSED_PARAM(enabled);
     308#endif
    301309}
    302310
     
    363371- (void)_resourceLoadStatisticsSetShouldSubmitTelemetry:(BOOL)value
    364372{
     373#if ENABLE(RESOURCE_LOAD_STATISTICS)
    365374    auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    366375    if (!store)
     
    368377
    369378    store->setShouldSubmitTelemetry(value);
     379#endif
    370380}
    371381
    372382- (void)_setResourceLoadStatisticsTestingCallback:(void (^)(WKWebsiteDataStore *, NSString *))callback
    373383{
     384#if ENABLE(RESOURCE_LOAD_STATISTICS)
    374385    if (!_websiteDataStore->isPersistent())
    375386        return;
     
    382393    }
    383394
    384     auto* store = _websiteDataStore->websiteDataStore().resourceLoadStatistics();
    385     if (!store)
    386         return;
    387 
    388     store->setStatisticsTestingCallback(nullptr);
     395    _websiteDataStore->websiteDataStore().setStatisticsTestingCallback(nullptr);
     396#endif
    389397}
    390398
     
    407415    }
    408416
     417#if ENABLE(RESOURCE_LOAD_STATISTICS)
    409418    _websiteDataStore->websiteDataStore().getAllStorageAccessEntries(webPageProxy->pageID(), [completionHandler = makeBlockPtr(completionHandler)](auto domains) {
    410419        Vector<RefPtr<API::Object>> apiDomains;
     
    414423        completionHandler(wrapper(API::Array::create(WTFMove(apiDomains))));
    415424    });
     425#endif
    416426}
    417427
  • trunk/Source/WebKit/UIProcess/Cocoa/ResourceLoadStatisticsMemoryStoreCocoa.mm

    r240129 r240243  
    2626#import "config.h"
    2727#import "ResourceLoadStatisticsMemoryStore.h"
     28
     29#if ENABLE(RESOURCE_LOAD_STATISTICS)
     30
    2831#import <wtf/text/WTFString.h>
    2932
     
    6366
    6467}
     68
     69#endif
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp

    r240156 r240243  
    11/*
    2  * Copyright (C) 2012-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4242#include "WebProcessMessages.h"
    4343#include "WebProcessPool.h"
     44#include "WebProcessProxy.h"
     45#include "WebResourceLoadStatisticsStore.h"
    4446#include "WebUserContentControllerProxy.h"
    4547#include "WebsiteData.h"
     
    234236        m_pendingDeleteWebsiteDataForOriginsCallbacks.take(m_pendingDeleteWebsiteDataForOriginsCallbacks.begin()->key)();
    235237
    236     while (!m_updateBlockCookiesCallbackMap.isEmpty())
    237         m_updateBlockCookiesCallbackMap.take(m_updateBlockCookiesCallbackMap.begin()->key)();
    238    
     238#if ENABLE(RESOURCE_LOAD_STATISTICS)
     239    while (!m_scheduleStatisticsProcessingCallbackMap.isEmpty())
     240        m_scheduleStatisticsProcessingCallbackMap.take(m_scheduleStatisticsProcessingCallbackMap.begin()->key)();
     241
    239242    while (!m_storageAccessResponseCallbackMap.isEmpty())
    240243        m_storageAccessResponseCallbackMap.take(m_storageAccessResponseCallbackMap.begin()->key)(false);
     244   
     245    while (!m_storageAccessRequestResponseCallbackMap.isEmpty())
     246        m_storageAccessRequestResponseCallbackMap.take(m_storageAccessRequestResponseCallbackMap.begin()->key)(StorageAccessStatus::CannotRequestAccess);
     247
     248    while (!m_removeAllStorageAccessCallbackMap.isEmpty())
     249        m_removeAllStorageAccessCallbackMap.take(m_removeAllStorageAccessCallbackMap.begin()->key)();
     250
     251    while (!m_allStorageAccessEntriesCallbackMap.isEmpty())
     252        m_allStorageAccessEntriesCallbackMap.take(m_allStorageAccessEntriesCallbackMap.begin()->key)({ });
     253
     254    while (!m_dumpStatisticsCallbackMap.isEmpty())
     255        m_dumpStatisticsCallbackMap.take(m_dumpStatisticsCallbackMap.begin()->key)({ });
     256#endif
    241257}
    242258
     
    275291    m_syncAllCookiesCounter = 0;
    276292
     293#if ENABLE(RESOURCE_LOAD_STATISTICS)
    277294    for (auto& callback : m_removeAllStorageAccessCallbackMap.values())
    278295        callback();
    279296    m_removeAllStorageAccessCallbackMap.clear();
    280297
    281     for (auto& callback : m_updateBlockCookiesCallbackMap.values())
     298    for (auto& callback : m_scheduleStatisticsProcessingCallbackMap.values())
    282299        callback();
    283     m_updateBlockCookiesCallbackMap.clear();
    284    
     300    m_scheduleStatisticsProcessingCallbackMap.clear();
     301#endif
     302
    285303    // This will cause us to be deleted.
    286304    networkProcessCrashed();
     
    401419}
    402420
     421void NetworkProcessProxy::logGlobalDiagnosticMessageWithValue(const String& message, const String& description, double value, unsigned significantFigures, WebCore::ShouldSample shouldSample)
     422{
     423    if (auto* page = WebPageProxy::nonEphemeralWebPageProxy())
     424        page->logDiagnosticMessageWithValue(message, description, value, significantFigures, shouldSample);
     425}
     426
    403427#if ENABLE(RESOURCE_LOAD_STATISTICS)
     428void NetworkProcessProxy::dumpResourceLoadStatistics(PAL::SessionID sessionID, CompletionHandler<void(const String&)>&& completionHandler)
     429{
     430    if (!canSendMessage()) {
     431        completionHandler({ });
     432        return;
     433    }
     434   
     435    auto callbackId = generateCallbackID();
     436    auto addResult = m_dumpStatisticsCallbackMap.add(callbackId, [protectedProcessPool = makeRef(m_processPool), token = throttler().backgroundActivityToken(), completionHandler = WTFMove(completionHandler)](const String& dumpedStatistics) mutable {
     437        completionHandler(dumpedStatistics);
     438    });
     439    ASSERT_UNUSED(addResult, addResult.isNewEntry);
     440    send(Messages::NetworkProcess::DumpResourceLoadStatistics(sessionID, callbackId), 0);
     441}
     442
     443void NetworkProcessProxy::didDumpResourceLoadStatistics(String dumpedStatistics, uint64_t callbackId)
     444{
     445    m_dumpStatisticsCallbackMap.take(callbackId)(dumpedStatistics);
     446}
     447
    404448void NetworkProcessProxy::updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID sessionID, const Vector<String>& domainsToBlock, CompletionHandler<void()>&& completionHandler)
    405449{
     
    410454   
    411455    auto callbackId = generateCallbackID();
    412     auto addResult = m_updateBlockCookiesCallbackMap.add(callbackId, [protectedProcessPool = makeRef(m_processPool), token = throttler().backgroundActivityToken(), completionHandler = WTFMove(completionHandler)]() mutable {
     456    auto addResult = m_scheduleStatisticsProcessingCallbackMap.add(callbackId, [protectedProcessPool = makeRef(m_processPool), token = throttler().backgroundActivityToken(), completionHandler = WTFMove(completionHandler)]() mutable {
    413457        completionHandler();
    414458    });
     
    419463void NetworkProcessProxy::didUpdateBlockCookies(uint64_t callbackId)
    420464{
    421     m_updateBlockCookiesCallbackMap.take(callbackId)();
    422 }
    423 
    424 void NetworkProcessProxy::didLogUserInteraction(uint64_t contextId)
    425 {
    426     // FIXME(193297): Implement when activating automated test cases.
    427     UNUSED_PARAM(contextId);
     465    m_scheduleStatisticsProcessingCallbackMap.take(callbackId)();
     466}
     467
     468void NetworkProcessProxy::isPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void(bool)>&& completionHandler)
     469{
     470    if (!canSendMessage()) {
     471        completionHandler(false);
     472        return;
     473    }
     474
     475    sendWithAsyncReply(Messages::NetworkProcess::IsPrevalentResource(sessionID, resourceDomain), WTFMove(completionHandler));
     476}
     477
     478void NetworkProcessProxy::isVeryPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void(bool)>&& completionHandler)
     479{
     480    if (!canSendMessage()) {
     481        completionHandler(false);
     482        return;
     483    }
     484
     485    sendWithAsyncReply(Messages::NetworkProcess::IsVeryPrevalentResource(sessionID, resourceDomain), WTFMove(completionHandler));
     486}
     487
     488void NetworkProcessProxy::setPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void()>&& completionHandler)
     489{
     490    if (!canSendMessage()) {
     491        completionHandler();
     492        return;
     493    }
     494
     495    sendWithAsyncReply(Messages::NetworkProcess::SetPrevalentResource(sessionID, resourceDomain), WTFMove(completionHandler));
     496}
     497
     498void NetworkProcessProxy::setPrevalentResourceForDebugMode(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void()>&& completionHandler)
     499{
     500    if (!canSendMessage()) {
     501        completionHandler();
     502        return;
     503    }
     504
     505    sendWithAsyncReply(Messages::NetworkProcess::SetPrevalentResourceForDebugMode(sessionID, resourceDomain), WTFMove(completionHandler));
     506}
     507
     508void NetworkProcessProxy::setVeryPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void()>&& completionHandler)
     509{
     510    if (!canSendMessage()) {
     511        completionHandler();
     512        return;
     513    }
     514
     515    sendWithAsyncReply(Messages::NetworkProcess::SetVeryPrevalentResource(sessionID, resourceDomain), WTFMove(completionHandler));
     516}
     517
     518void NetworkProcessProxy::setLastSeen(PAL::SessionID sessionID, const String& resourceDomain, Seconds lastSeen, CompletionHandler<void()>&& completionHandler)
     519{
     520    if (!canSendMessage()) {
     521        completionHandler();
     522        return;
     523    }
     524   
     525    sendWithAsyncReply(Messages::NetworkProcess::SetLastSeen(sessionID, resourceDomain, lastSeen), WTFMove(completionHandler));
     526}
     527
     528void NetworkProcessProxy::clearPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void()>&& completionHandler)
     529{
     530    if (!canSendMessage()) {
     531        completionHandler();
     532        return;
     533    }
     534   
     535    sendWithAsyncReply(Messages::NetworkProcess::ClearPrevalentResource(sessionID, resourceDomain), WTFMove(completionHandler));
     536}
     537   
     538void NetworkProcessProxy::scheduleCookieBlockingUpdate(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler)
     539{
     540    if (!canSendMessage()) {
     541        completionHandler();
     542        return;
     543    }
     544   
     545    sendWithAsyncReply(Messages::NetworkProcess::ScheduleCookieBlockingUpdate(sessionID), WTFMove(completionHandler));
     546}
     547
     548void NetworkProcessProxy::scheduleClearInMemoryAndPersistent(PAL::SessionID sessionID, Optional<WallTime> modifiedSince, ShouldGrandfather shouldGrandfather, CompletionHandler<void()>&& completionHandler)
     549{
     550    if (!canSendMessage()) {
     551        completionHandler();
     552        return;
     553    }
     554
     555    bool shouldGrandfatherBool = shouldGrandfather == ShouldGrandfather::Yes;
     556    sendWithAsyncReply(Messages::NetworkProcess::ScheduleClearInMemoryAndPersistent(sessionID, modifiedSince, shouldGrandfatherBool), WTFMove(completionHandler));
     557}
     558
     559void NetworkProcessProxy::scheduleStatisticsAndDataRecordsProcessing(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler)
     560{
     561    if (!canSendMessage()) {
     562        completionHandler();
     563        return;
     564    }
     565   
     566    sendWithAsyncReply(Messages::NetworkProcess::ScheduleStatisticsAndDataRecordsProcessing(sessionID), WTFMove(completionHandler));
     567}
     568
     569void NetworkProcessProxy::logUserInteraction(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void()>&& completionHandler)
     570{
     571    if (!canSendMessage()) {
     572        completionHandler();
     573        return;
     574    }
     575
     576    sendWithAsyncReply(Messages::NetworkProcess::LogUserInteraction(sessionID, resourceDomain), WTFMove(completionHandler));
     577}
     578
     579void NetworkProcessProxy::hasHadUserInteraction(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void(bool)>&& completionHandler)
     580{
     581    if (!canSendMessage()) {
     582        completionHandler(false);
     583        return;
     584    }
     585   
     586    sendWithAsyncReply(Messages::NetworkProcess::HadUserInteraction(sessionID, resourceDomain), WTFMove(completionHandler));
     587}
     588
     589void NetworkProcessProxy::clearUserInteraction(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void()>&& completionHandler)
     590{
     591    if (!canSendMessage()) {
     592        completionHandler();
     593        return;
     594    }
     595   
     596    sendWithAsyncReply(Messages::NetworkProcess::ClearUserInteraction(sessionID, resourceDomain), WTFMove(completionHandler));
    428597}
    429598
     
    436605   
    437606    auto callbackId = generateCallbackID();
    438     auto addResult = m_updateBlockCookiesCallbackMap.add(callbackId, [protectedProcessPool = makeRef(m_processPool), token = throttler().backgroundActivityToken(), completionHandler = WTFMove(completionHandler)]() mutable {
     607    auto addResult = m_scheduleStatisticsProcessingCallbackMap.add(callbackId, [protectedProcessPool = makeRef(m_processPool), token = throttler().backgroundActivityToken(), completionHandler = WTFMove(completionHandler)]() mutable {
    439608        completionHandler();
    440609    });
     
    445614void NetworkProcessProxy::didSetAgeCapForClientSideCookies(uint64_t callbackId)
    446615{
    447     m_updateBlockCookiesCallbackMap.take(callbackId)();
     616    m_scheduleStatisticsProcessingCallbackMap.take(callbackId)();
     617}
     618
     619void NetworkProcessProxy::setTimeToLiveUserInteraction(PAL::SessionID sessionID, Seconds seconds, CompletionHandler<void()>&& completionHandler)
     620{
     621    if (!canSendMessage()) {
     622        completionHandler();
     623        return;
     624    }
     625   
     626    sendWithAsyncReply(Messages::NetworkProcess::SetTimeToLiveUserInteraction(sessionID, seconds), WTFMove(completionHandler));
     627}
     628
     629void NetworkProcessProxy::didUpdateRuntimeSettings(uint64_t callbackId)
     630{
     631    m_updateRuntimeSettingsCallbackMap.take(callbackId)();
     632}
     633
     634void NetworkProcessProxy::setNotifyPagesWhenTelemetryWasCaptured(PAL::SessionID sessionID, bool value, CompletionHandler<void()>&& completionHandler)
     635{
     636    if (!canSendMessage()) {
     637        completionHandler();
     638        return;
     639    }
     640   
     641    sendWithAsyncReply(Messages::NetworkProcess::SetNotifyPagesWhenTelemetryWasCaptured(sessionID, value), WTFMove(completionHandler));
     642}
     643
     644void NetworkProcessProxy::setNotifyPagesWhenDataRecordsWereScanned(PAL::SessionID sessionID, bool value, CompletionHandler<void()>&& completionHandler)
     645{
     646    if (!canSendMessage()) {
     647        completionHandler();
     648        return;
     649    }
     650   
     651    sendWithAsyncReply(Messages::NetworkProcess::SetNotifyPagesWhenDataRecordsWereScanned(sessionID, value), WTFMove(completionHandler));
     652}
     653
     654void NetworkProcessProxy::setSubframeUnderTopFrameOrigin(PAL::SessionID sessionID, const String& subframe, const String& topFrame, CompletionHandler<void()>&& completionHandler)
     655{
     656    if (!canSendMessage()) {
     657        completionHandler();
     658        return;
     659    }
     660   
     661    sendWithAsyncReply(Messages::NetworkProcess::SetSubframeUnderTopFrameOrigin(sessionID, subframe, topFrame), WTFMove(completionHandler));
     662}
     663
     664void NetworkProcessProxy::isRegisteredAsRedirectingTo(PAL::SessionID sessionID, const String& redirectedFrom, const String& redirectedTo, CompletionHandler<void(bool)>&& completionHandler)
     665{
     666    if (!canSendMessage()) {
     667        completionHandler(false);
     668        return;
     669    }
     670   
     671    sendWithAsyncReply(Messages::NetworkProcess::IsRegisteredAsRedirectingTo(sessionID, redirectedFrom, redirectedTo), WTFMove(completionHandler));
     672}
     673
     674void NetworkProcessProxy::isRegisteredAsSubFrameUnder(PAL::SessionID sessionID, const String& subFrame, const String& topFrame, CompletionHandler<void(bool)>&& completionHandler)
     675{
     676    if (!canSendMessage()) {
     677        completionHandler(false);
     678        return;
     679    }
     680   
     681    sendWithAsyncReply(Messages::NetworkProcess::IsRegisteredAsSubFrameUnder(sessionID, subFrame, topFrame), WTFMove(completionHandler));
     682}
     683
     684void NetworkProcessProxy::setSubresourceUnderTopFrameOrigin(PAL::SessionID sessionID, const String& subresource, const String& topFrame, CompletionHandler<void()>&& completionHandler)
     685{
     686    if (!canSendMessage()) {
     687        completionHandler();
     688        return;
     689    }
     690   
     691    sendWithAsyncReply(Messages::NetworkProcess::SetSubresourceUnderTopFrameOrigin(sessionID, subresource, topFrame), WTFMove(completionHandler));
     692}
     693
     694void NetworkProcessProxy::isRegisteredAsSubresourceUnder(PAL::SessionID sessionID, const String& subresource, const String& topFrame, CompletionHandler<void(bool)>&& completionHandler)
     695{
     696    if (!canSendMessage()) {
     697        completionHandler(false);
     698        return;
     699    }
     700   
     701    sendWithAsyncReply(Messages::NetworkProcess::IsRegisteredAsSubresourceUnder(sessionID, subresource, topFrame), WTFMove(completionHandler));
     702}
     703
     704void NetworkProcessProxy::setSubresourceUniqueRedirectTo(PAL::SessionID sessionID, const String& subresource, const String& hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler)
     705{
     706    if (!canSendMessage()) {
     707        completionHandler();
     708        return;
     709    }
     710   
     711    sendWithAsyncReply(Messages::NetworkProcess::SetSubresourceUniqueRedirectTo(sessionID, subresource, hostNameRedirectedTo), WTFMove(completionHandler));
     712}
     713
     714void NetworkProcessProxy::setSubresourceUniqueRedirectFrom(PAL::SessionID sessionID, const String& subresource, const String& hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler)
     715{
     716    if (!canSendMessage()) {
     717        completionHandler();
     718        return;
     719    }
     720   
     721    sendWithAsyncReply(Messages::NetworkProcess::SetSubresourceUniqueRedirectFrom(sessionID, subresource, hostNameRedirectedFrom), WTFMove(completionHandler));
     722}
     723
     724void NetworkProcessProxy::setTopFrameUniqueRedirectTo(PAL::SessionID sessionID, const String& topFrameHostName, const String& hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler)
     725{
     726    if (!canSendMessage()) {
     727        completionHandler();
     728        return;
     729    }
     730   
     731    sendWithAsyncReply(Messages::NetworkProcess::SetTopFrameUniqueRedirectTo(sessionID, topFrameHostName, hostNameRedirectedTo), WTFMove(completionHandler));
     732}
     733
     734void NetworkProcessProxy::setTopFrameUniqueRedirectFrom(PAL::SessionID sessionID, const String& topFrameHostName, const String& hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler)
     735{
     736    if (!canSendMessage()) {
     737        completionHandler();
     738        return;
     739    }
     740   
     741    sendWithAsyncReply(Messages::NetworkProcess::SetTopFrameUniqueRedirectFrom(sessionID, topFrameHostName, hostNameRedirectedFrom), WTFMove(completionHandler));
     742}
     743
     744void NetworkProcessProxy::isGrandfathered(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void(bool)>&& completionHandler)
     745{
     746    if (!canSendMessage()) {
     747        completionHandler(false);
     748        return;
     749    }
     750   
     751    sendWithAsyncReply(Messages::NetworkProcess::IsGrandfathered(sessionID, resourceDomain), WTFMove(completionHandler));
     752}
     753
     754void NetworkProcessProxy::setGrandfathered(PAL::SessionID sessionID, const String& resourceDomain, bool isGrandfathered, CompletionHandler<void()>&& completionHandler)
     755{
     756    if (!canSendMessage()) {
     757        completionHandler();
     758        return;
     759    }
     760   
     761    sendWithAsyncReply(Messages::NetworkProcess::SetGrandfathered(sessionID, resourceDomain, isGrandfathered), WTFMove(completionHandler));
    448762}
    449763
    450764void NetworkProcessProxy::hasStorageAccessForFrame(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, WTF::CompletionHandler<void(bool)>&& callback)
    451765{
     766    if (!canSendMessage()) {
     767        callback(false);
     768        return;
     769    }
     770
    452771    auto contextId = generateCallbackID();
    453772    auto addResult = m_storageAccessResponseCallbackMap.add(contextId, WTFMove(callback));
     
    456775}
    457776
    458 void NetworkProcessProxy::grantStorageAccess(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, WTF::CompletionHandler<void(bool)>&& callback)
    459 {
     777void NetworkProcessProxy::hasStorageAccess(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler)
     778{
     779    if (!canSendMessage()) {
     780        completionHandler(false);
     781        return;
     782    }
     783   
     784    sendWithAsyncReply(Messages::NetworkProcess::HasStorageAccess(sessionID, resourceDomain, firstPartyDomain, frameID, pageID), WTFMove(completionHandler));
     785}
     786
     787void NetworkProcessProxy::requestStorageAccess(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&& completionHandler)
     788{
     789    if (!canSendMessage()) {
     790        completionHandler(StorageAccessStatus::CannotRequestAccess);
     791        return;
     792    }
     793
    460794    auto contextId = generateCallbackID();
    461     auto addResult = m_storageAccessResponseCallbackMap.add(contextId, WTFMove(callback));
     795    auto addResult = m_storageAccessRequestResponseCallbackMap.add(contextId, WTFMove(completionHandler));
    462796    ASSERT_UNUSED(addResult, addResult.isNewEntry);
    463     send(Messages::NetworkProcess::GrantStorageAccess(sessionID, resourceDomain, firstPartyDomain, frameID, pageID, contextId), 0);
    464 }
    465 
    466 void NetworkProcessProxy::storageAccessRequestResult(bool wasGranted, uint64_t contextId)
    467 {
    468     auto callback = m_storageAccessResponseCallbackMap.take(contextId);
    469     callback(wasGranted);
     797    send(Messages::NetworkProcess::RequestStorageAccess(sessionID, resourceDomain, firstPartyDomain, frameID, pageID, promptEnabled, contextId), 0);
     798}
     799
     800void 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)
     801{
     802    if (!canSendMessage()) {
     803        completionHandler(false);
     804        return;
     805    }
     806
     807    auto contextId = generateCallbackID();
     808    auto addResult = m_storageAccessResponseCallbackMap.add(contextId, WTFMove(completionHandler));
     809    ASSERT_UNUSED(addResult, addResult.isNewEntry);
     810    send(Messages::NetworkProcess::GrantStorageAccess(sessionID, resourceDomain, firstPartyDomain, frameID.value(), pageID, userWasPrompted, contextId), 0);
     811}
     812
     813void NetworkProcessProxy::storageAccessRequestResult(unsigned status, uint64_t contextId)
     814{
     815    m_storageAccessRequestResponseCallbackMap.take(contextId)(static_cast<StorageAccessStatus>(status));
     816}
     817
     818void NetworkProcessProxy::storageAccessOperationResult(bool wasGranted, uint64_t contextId)
     819{
     820    m_storageAccessResponseCallbackMap.take(contextId)(wasGranted);
    470821}
    471822
     
    485836void NetworkProcessProxy::didRemoveAllStorageAccess(uint64_t contextId)
    486837{
    487     auto completionHandler = m_removeAllStorageAccessCallbackMap.take(contextId);
    488     completionHandler();
     838    m_removeAllStorageAccessCallbackMap.take(contextId)();
    489839}
    490840
    491841void NetworkProcessProxy::getAllStorageAccessEntries(PAL::SessionID sessionID, CompletionHandler<void(Vector<String>&& domains)>&& callback)
    492842{
     843    if (!canSendMessage()) {
     844        callback({ });
     845        return;
     846    }
     847
    493848    auto contextId = generateCallbackID();
    494849    auto addResult = m_allStorageAccessEntriesCallbackMap.add(contextId, WTFMove(callback));
     
    518873void NetworkProcessProxy::didSetCacheMaxAgeCapForPrevalentResources(uint64_t contextId)
    519874{
    520     auto completionHandler = m_updateRuntimeSettingsCallbackMap.take(contextId);
    521     completionHandler();
     875    m_updateRuntimeSettingsCallbackMap.take(contextId)();
     876}
     877
     878void NetworkProcessProxy::setCacheMaxAgeCap(PAL::SessionID sessionID, Seconds seconds, CompletionHandler<void()>&& completionHandler)
     879{
     880    if (!canSendMessage()) {
     881        completionHandler();
     882        return;
     883    }
     884   
     885    auto contextId = generateCallbackID();
     886    auto addResult = m_updateRuntimeSettingsCallbackMap.add(contextId, WTFMove(completionHandler));
     887    ASSERT_UNUSED(addResult, addResult.isNewEntry);
     888    send(Messages::NetworkProcess::SetCacheMaxAgeCapForPrevalentResources(sessionID, seconds, contextId), 0);
     889}
     890
     891void NetworkProcessProxy::setGrandfatheringTime(PAL::SessionID sessionID, Seconds seconds, CompletionHandler<void()>&& completionHandler)
     892{
     893    if (!canSendMessage()) {
     894        completionHandler();
     895        return;
     896    }
     897   
     898    sendWithAsyncReply(Messages::NetworkProcess::SetGrandfatheringTime(sessionID, seconds), WTFMove(completionHandler));
     899}
     900
     901void NetworkProcessProxy::setMaxStatisticsEntries(PAL::SessionID sessionID, size_t maximumEntryCount, CompletionHandler<void()>&& completionHandler)
     902{
     903    if (!canSendMessage()) {
     904        completionHandler();
     905        return;
     906    }
     907
     908    sendWithAsyncReply(Messages::NetworkProcess::SetMaxStatisticsEntries(sessionID, maximumEntryCount), WTFMove(completionHandler));
     909}
     910
     911void NetworkProcessProxy::setMinimumTimeBetweenDataRecordsRemoval(PAL::SessionID sessionID, Seconds seconds, CompletionHandler<void()>&& completionHandler)
     912{
     913    if (!canSendMessage()) {
     914        completionHandler();
     915        return;
     916    }
     917   
     918    sendWithAsyncReply(Messages::NetworkProcess::SetMinimumTimeBetweenDataRecordsRemoval(sessionID, seconds), WTFMove(completionHandler));
     919}
     920
     921void NetworkProcessProxy::setPruneEntriesDownTo(PAL::SessionID sessionID, size_t pruneTargetCount, CompletionHandler<void()>&& completionHandler)
     922{
     923    if (!canSendMessage()) {
     924        completionHandler();
     925        return;
     926    }
     927
     928    sendWithAsyncReply(Messages::NetworkProcess::SetPruneEntriesDownTo(sessionID, pruneTargetCount), WTFMove(completionHandler));
     929}
     930
     931void NetworkProcessProxy::setShouldClassifyResourcesBeforeDataRecordsRemoval(PAL::SessionID sessionID, bool value, CompletionHandler<void()>&& completionHandler)
     932{
     933    if (!canSendMessage()) {
     934        completionHandler();
     935        return;
     936    }
     937   
     938    sendWithAsyncReply(Messages::NetworkProcess::SetShouldClassifyResourcesBeforeDataRecordsRemoval(sessionID, value), WTFMove(completionHandler));
     939}
     940
     941void NetworkProcessProxy::setResourceLoadStatisticsDebugMode(PAL::SessionID sessionID, bool debugMode, CompletionHandler<void()>&& completionHandler)
     942{
     943    if (!canSendMessage()) {
     944        completionHandler();
     945        return;
     946    }
     947   
     948    sendWithAsyncReply(Messages::NetworkProcess::SetResourceLoadStatisticsDebugMode(sessionID, debugMode), WTFMove(completionHandler));
    522949}
    523950
     
    535962}
    536963
    537 void NetworkProcessProxy::didResetCacheMaxAgeCapForPrevalentResources(uint64_t contextId)
    538 {
    539     auto completionHandler = m_updateRuntimeSettingsCallbackMap.take(contextId);
    540     completionHandler();
     964void NetworkProcessProxy::resetParametersToDefaultValues(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler)
     965{
     966    if (!canSendMessage()) {
     967        completionHandler();
     968        return;
     969    }
     970   
     971    sendWithAsyncReply(Messages::NetworkProcess::ResetParametersToDefaultValues(sessionID), WTFMove(completionHandler));
     972}
     973
     974void NetworkProcessProxy::submitTelemetry(PAL::SessionID sessionID, CompletionHandler<void()>&& completionHandler)
     975{
     976    if (!canSendMessage()) {
     977        completionHandler();
     978        return;
     979    }
     980   
     981    sendWithAsyncReply(Messages::NetworkProcess::SubmitTelemetry(sessionID), WTFMove(completionHandler));
     982}
     983
     984void NetworkProcessProxy::scheduleClearInMemoryAndPersistent(PAL::SessionID sessionID, bool shouldGrandfather, CompletionHandler<void()>&& completionHandler)
     985{
     986    if (!canSendMessage()) {
     987        completionHandler();
     988        return;
     989    }
     990   
     991
     992    sendWithAsyncReply(Messages::NetworkProcess::ScheduleClearInMemoryAndPersistent(sessionID, { }, shouldGrandfather), WTFMove(completionHandler));
     993}
     994
     995void NetworkProcessProxy::notifyResourceLoadStatisticsProcessed()
     996{
     997    WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed();
     998}
     999
     1000void NetworkProcessProxy::notifyWebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished()
     1001{
     1002    WebProcessProxy::notifyWebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished();
     1003}
     1004
     1005void NetworkProcessProxy::notifyWebsiteDataScanForTopPrivatelyControlledDomainsFinished()
     1006{
     1007    WebProcessProxy::notifyWebsiteDataScanForTopPrivatelyControlledDomainsFinished();
     1008}
     1009
     1010void NetworkProcessProxy::notifyResourceLoadStatisticsTelemetryFinished(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins)
     1011{
     1012    API::Dictionary::MapType messageBody;
     1013    messageBody.set("TotalPrevalentResources"_s, API::UInt64::create(totalPrevalentResources));
     1014    messageBody.set("TotalPrevalentResourcesWithUserInteraction"_s, API::UInt64::create(totalPrevalentResourcesWithUserInteraction));
     1015    messageBody.set("Top3SubframeUnderTopFrameOrigins"_s, API::UInt64::create(top3SubframeUnderTopFrameOrigins));
     1016
     1017    WebProcessProxy::notifyPageStatisticsTelemetryFinished(API::Dictionary::create(messageBody).ptr());
    5411018}
    5421019#endif // ENABLE(RESOURCE_LOAD_STATISTICS)
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h

    r240099 r240243  
    5858class DownloadProxyMap;
    5959class WebProcessPool;
     60enum class StorageAccessStatus : unsigned;
    6061enum class WebsiteDataFetchOption;
    6162enum class WebsiteDataType;
     
    7879
    7980#if ENABLE(RESOURCE_LOAD_STATISTICS)
     81    void clearPrevalentResource(PAL::SessionID, const String& resourceDomain, CompletionHandler<void()>&&);
     82    void clearUserInteraction(PAL::SessionID, const String& resourceDomain, CompletionHandler<void()>&&);
     83    void dumpResourceLoadStatistics(PAL::SessionID, CompletionHandler<void(const String&)>&&);
    8084    void updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID, const Vector<String>& domainsToBlock, CompletionHandler<void()>&&);
     85    void hasHadUserInteraction(PAL::SessionID, const String& resourceDomain, CompletionHandler<void(bool)>&&);
     86    void isGrandfathered(PAL::SessionID, const String& resourceDomain, CompletionHandler<void(bool)>&&);
     87    void isPrevalentResource(PAL::SessionID, const String& resourceDomain, CompletionHandler<void(bool)>&&);
     88    void isRegisteredAsRedirectingTo(PAL::SessionID, const String& redirectedFrom, const String& redirectedTo, CompletionHandler<void(bool)>&&);
     89    void isRegisteredAsSubFrameUnder(PAL::SessionID, const String& subFrame, const String& topFrame, CompletionHandler<void(bool)>&&);
     90    void isRegisteredAsSubresourceUnder(PAL::SessionID, const String& subresource, const String& topFrame, CompletionHandler<void(bool)>&&);
     91    void isVeryPrevalentResource(PAL::SessionID, const String& resourceDomain, CompletionHandler<void(bool)>&&);
     92    void logUserInteraction(PAL::SessionID, const String& resourceDomain, CompletionHandler<void()>&&);
     93    void scheduleStatisticsAndDataRecordsProcessing(PAL::SessionID, CompletionHandler<void()>&&);
     94    void setLastSeen(PAL::SessionID, const String& resourceDomain, Seconds, CompletionHandler<void()>&&);
    8195    void setAgeCapForClientSideCookies(PAL::SessionID, Optional<Seconds>, CompletionHandler<void()>&&);
     96    void setCacheMaxAgeCap(PAL::SessionID, Seconds, CompletionHandler<void()>&&);
     97    void setGrandfathered(PAL::SessionID, const String& resourceDomain, bool isGrandfathered, CompletionHandler<void()>&&);
     98    void setNotifyPagesWhenDataRecordsWereScanned(PAL::SessionID, bool, CompletionHandler<void()>&&);
     99    void setNotifyPagesWhenTelemetryWasCaptured(PAL::SessionID, bool, CompletionHandler<void()>&&);
     100    void setSubframeUnderTopFrameOrigin(PAL::SessionID, const String& subframe, const String& topFrame, CompletionHandler<void()>&&);
     101    void setSubresourceUnderTopFrameOrigin(PAL::SessionID, const String& subresource, const String& topFrame, CompletionHandler<void()>&&);
     102    void setSubresourceUniqueRedirectTo(PAL::SessionID, const String& subresource, const String& hostNameRedirectedTo, CompletionHandler<void()>&&);
     103    void setSubresourceUniqueRedirectFrom(PAL::SessionID, const String& subresource, const String& hostNameRedirectedFrom, CompletionHandler<void()>&&);
     104    void setTimeToLiveUserInteraction(PAL::SessionID, Seconds, CompletionHandler<void()>&&);
     105    void setTopFrameUniqueRedirectTo(PAL::SessionID, const String& topFrameHostName, const String& hostNameRedirectedTo, CompletionHandler<void()>&&);
     106    void setTopFrameUniqueRedirectFrom(PAL::SessionID, const String& topFrameHostName, const String& hostNameRedirectedFrom, CompletionHandler<void()>&&);
     107    void setPrevalentResource(PAL::SessionID, const String& resourceDomain, CompletionHandler<void()>&&);
     108    void setPrevalentResourceForDebugMode(PAL::SessionID, const String& resourceDomain, CompletionHandler<void()>&&);
     109    void setVeryPrevalentResource(PAL::SessionID, const String& resourceDomain, CompletionHandler<void()>&&);
    82110    void hasStorageAccessForFrame(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback);
    83111    void getAllStorageAccessEntries(PAL::SessionID, CompletionHandler<void(Vector<String>&& domains)>&&);
    84     void grantStorageAccess(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback);
     112    void grantStorageAccess(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool userWasPrompted, WTF::CompletionHandler<void(bool)>&&);
     113    void hasStorageAccess(PAL::SessionID, const String& subFrameHost, const String& topFrameHost, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&&);
     114    void requestStorageAccess(PAL::SessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&&);
     115    void resetParametersToDefaultValues(PAL::SessionID, CompletionHandler<void()>&&);
    85116    void removeAllStorageAccess(PAL::SessionID, CompletionHandler<void()>&&);
     117    void scheduleClearInMemoryAndPersistent(PAL::SessionID, bool shouldGrandfather, CompletionHandler<void()>&&);
     118    void scheduleClearInMemoryAndPersistent(PAL::SessionID, Optional<WallTime> modifiedSince, ShouldGrandfather, CompletionHandler<void()>&&);
     119    void scheduleCookieBlockingUpdate(PAL::SessionID, CompletionHandler<void()>&&);
     120    void submitTelemetry(PAL::SessionID, CompletionHandler<void()>&&);
    86121    void setCacheMaxAgeCapForPrevalentResources(PAL::SessionID, Seconds, CompletionHandler<void()>&&);
     122    void setGrandfatheringTime(PAL::SessionID, Seconds, CompletionHandler<void()>&&);
     123    void setMaxStatisticsEntries(PAL::SessionID, size_t maximumEntryCount, CompletionHandler<void()>&&);
     124    void setMinimumTimeBetweenDataRecordsRemoval(PAL::SessionID, Seconds, CompletionHandler<void()>&&);
     125    void setPruneEntriesDownTo(PAL::SessionID, size_t pruneTargetCount, CompletionHandler<void()>&&);
     126    void setResourceLoadStatisticsDebugMode(PAL::SessionID, bool debugMode, CompletionHandler<void()>&&);
     127    void setShouldClassifyResourcesBeforeDataRecordsRemoval(PAL::SessionID, bool, CompletionHandler<void()>&&);
    87128    void resetCacheMaxAgeCapForPrevalentResources(PAL::SessionID, CompletionHandler<void()>&&);
    88129#endif
     
    142183    void logDiagnosticMessageWithResult(uint64_t pageID, const String& message, const String& description, uint32_t result, WebCore::ShouldSample);
    143184    void logDiagnosticMessageWithValue(uint64_t pageID, const String& message, const String& description, double value, unsigned significantFigures, WebCore::ShouldSample);
     185    void logGlobalDiagnosticMessageWithValue(const String& message, const String& description, double value, unsigned significantFigures, WebCore::ShouldSample);
    144186#if ENABLE(RESOURCE_LOAD_STATISTICS)
    145     void didLogUserInteraction(uint64_t contextId);
     187    void didDumpResourceLoadStatistics(String dumpedStatistics, uint64_t callbackId);
    146188    void didUpdateBlockCookies(uint64_t contextId);
    147189    void didSetAgeCapForClientSideCookies(uint64_t contextId);
    148     void storageAccessRequestResult(bool wasGranted, uint64_t contextId);
     190    void storageAccessOperationResult(bool wasGranted, uint64_t contextId);
     191    void storageAccessRequestResult(unsigned wasGranted, uint64_t contextId);
    149192    void allStorageAccessEntriesResult(Vector<String>&& domains, uint64_t contextId);
    150193    void didRemoveAllStorageAccess(uint64_t contextId);
    151194    void didSetCacheMaxAgeCapForPrevalentResources(uint64_t contextId);
    152     void didResetCacheMaxAgeCapForPrevalentResources(uint64_t contextId);
     195    void didUpdateRuntimeSettings(uint64_t contextId);
     196    void notifyResourceLoadStatisticsProcessed();
     197    void notifyWebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished();
     198    void notifyWebsiteDataScanForTopPrivatelyControlledDomainsFinished();
     199    void notifyResourceLoadStatisticsTelemetryFinished(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins);
    153200#endif
    154201    void retrieveCacheStorageParameters(PAL::SessionID);
     
    193240    unsigned m_syncAllCookiesCounter { 0 };
    194241
    195     HashMap<uint64_t, CompletionHandler<void()>> m_updateBlockCookiesCallbackMap;
     242#if ENABLE(RESOURCE_LOAD_STATISTICS)
     243    HashMap<uint64_t, CompletionHandler<void()>> m_scheduleStatisticsProcessingCallbackMap;
    196244    HashMap<uint64_t, CompletionHandler<void(bool wasGranted)>> m_storageAccessResponseCallbackMap;
     245    HashMap<uint64_t, CompletionHandler<void(StorageAccessStatus wasGranted)>> m_storageAccessRequestResponseCallbackMap;
    197246    HashMap<uint64_t, CompletionHandler<void()>> m_removeAllStorageAccessCallbackMap;
    198247    HashMap<uint64_t, CompletionHandler<void(Vector<String>&& domains)>> m_allStorageAccessEntriesCallbackMap;
     248    HashMap<uint64_t, CompletionHandler<void(const String&)>> m_dumpStatisticsCallbackMap;
     249#endif
    199250
    200251    HashMap<uint64_t, CompletionHandler<void()>> m_updateRuntimeSettingsCallbackMap;
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in

    r240099 r240243  
    3939    LogDiagnosticMessageWithResult(uint64_t pageID, String message, String description, uint32_t result, enum:bool WebCore::ShouldSample shouldSample)
    4040    LogDiagnosticMessageWithValue(uint64_t pageID, String message, String description, double value, unsigned significantFigures, enum:bool WebCore::ShouldSample shouldSample)
     41    LogGlobalDiagnosticMessageWithValue(String message, String description, double value, unsigned significantFigures, enum:bool WebCore::ShouldSample shouldSample)
    4142
    4243#if ENABLE(RESOURCE_LOAD_STATISTICS)
    43     DidLogUserInteraction(uint64_t callbackId)
     44    DidDumpResourceLoadStatistics(String dumpedStatistics, uint64_t callbackId)
    4445    DidUpdateBlockCookies(uint64_t callbackId)
    4546    DidSetAgeCapForClientSideCookies(uint64_t callbackId)
    46     StorageAccessRequestResult(bool wasGranted, uint64_t contextId)
     47    StorageAccessOperationResult(bool wasGranted, uint64_t contextId)
     48    StorageAccessRequestResult(unsigned wasGranted, uint64_t contextId)
    4749    AllStorageAccessEntriesResult(Vector<String> domains, uint64_t contextId)
    4850    DidRemoveAllStorageAccess(uint64_t contextId)
    4951    DidSetCacheMaxAgeCapForPrevalentResources(uint64_t contextId)
    50     DidResetCacheMaxAgeCapForPrevalentResources(uint64_t contextId)
     52    DidUpdateRuntimeSettings(uint64_t contextId)
     53    NotifyResourceLoadStatisticsProcessed()
     54    NotifyWebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished()
     55    NotifyWebsiteDataScanForTopPrivatelyControlledDomainsFinished()
     56    NotifyResourceLoadStatisticsTelemetryFinished(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins)
    5157#endif
    5258#if ENABLE(CONTENT_EXTENSIONS)
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r240055 r240243  
    44814481}
    44824482
     4483WebPageProxy* WebPageProxy::nonEphemeralWebPageProxy()
     4484{
     4485    auto processPools = WebProcessPool::allProcessPools();
     4486    if (processPools.isEmpty())
     4487        return nullptr;
     4488   
     4489    auto processPool = processPools[0];
     4490    if (!processPool)
     4491        return nullptr;
     4492   
     4493    for (auto& webProcess : processPool->processes()) {
     4494        for (auto& page : webProcess->pages()) {
     4495            if (page->sessionID().isEphemeral())
     4496                continue;
     4497            return page;
     4498        }
     4499    }
     4500    return nullptr;
     4501}
     4502
    44834503#if ENABLE(RESOURCE_LOAD_STATISTICS)
    44844504void WebPageProxy::logFrameNavigation(const WebFrameProxy& frame, const URL& pageURL, const WebCore::ResourceRequest& request, const URL& redirectURL)
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r240199 r240243  
    11/*
    2  * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    13841384#endif
    13851385
     1386    static WebPageProxy* nonEphemeralWebPageProxy();
     1387
    13861388#if ENABLE(ATTACHMENT_ELEMENT)
    13871389    RefPtr<API::Attachment> attachmentForIdentifier(const String& identifier) const;
  • trunk/Source/WebKit/UIProcess/WebProcessPool.cpp

    r239880 r240243  
    561561    SandboxExtension::createHandleForReadWriteDirectory(parameters.defaultDataStoreParameters.networkSessionParameters.resourceLoadStatisticsDirectory, parameters.defaultDataStoreParameters.networkSessionParameters.resourceLoadStatisticsDirectoryExtensionHandle);
    562562
    563     parameters.defaultDataStoreParameters.networkSessionParameters.enableResourceLoadStatistics = false; // FIXME(193297): Turn on when the feature is on.
     563    parameters.defaultDataStoreParameters.networkSessionParameters.enableResourceLoadStatistics = false; // FIXME(193297): Turn on when the feature is on. (m_configuration->resourceLoadStatisticsEnabled()?)
    564564
    565565    // Add any platform specific parameters
  • trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp

    r240161 r240243  
    285285}
    286286
     287#if ENABLE(RESOURCE_LOAD_STATISTICS)
    287288void WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType> dataTypes, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, CompletionHandler<void (const HashSet<String>&)>&& completionHandler)
    288289{
     
    418419        page.value->postMessageToInjectedBundle("WebsiteDataScanForTopPrivatelyControlledDomainsFinished", nullptr);
    419420}
    420    
     421
     422void WebProcessProxy::notifyWebsiteDataScanForTopPrivatelyControlledDomainsFinished()
     423{
     424    for (auto& page : globalPageMap())
     425        page.value->postMessageToInjectedBundle("WebsiteDataScanForTopPrivatelyControlledDomainsFinished", nullptr);
     426}
     427
     428void WebProcessProxy::notifyWebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished()
     429{
     430    for (auto& page : globalPageMap())
     431        page.value->postMessageToInjectedBundle("WebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished", nullptr);
     432}
     433
    421434void WebProcessProxy::notifyPageStatisticsTelemetryFinished(API::Object* messageBody)
    422435{
     
    424437        page.value->postMessageToInjectedBundle("ResourceLoadStatisticsTelemetryFinished", messageBody);
    425438}
    426    
     439#endif
     440
    427441Ref<WebPageProxy> WebProcessProxy::createWebPage(PageClient& pageClient, Ref<API::PageConfiguration>&& pageConfiguration)
    428442{
  • trunk/Source/WebKit/UIProcess/WebProcessProxy.h

    r240161 r240243  
    172172    void deleteWebsiteData(PAL::SessionID, OptionSet<WebsiteDataType>, WallTime modifiedSince, CompletionHandler<void()>&&);
    173173    void deleteWebsiteDataForOrigins(PAL::SessionID, OptionSet<WebsiteDataType>, const Vector<WebCore::SecurityOriginData>&, CompletionHandler<void()>&&);
     174
     175#if ENABLE(RESOURCE_LOAD_STATISTICS)
    174176    static void deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType>, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPages, CompletionHandler<void (const HashSet<String>&)>&&);
    175177    static void topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType> dataTypes, bool shouldNotifyPage, CompletionHandler<void(HashSet<String>&&)>&&);
     178
    176179    static void notifyPageStatisticsAndDataRecordsProcessed();
    177180    static void notifyPageStatisticsTelemetryFinished(API::Object* messageBody);
     181
     182    static void notifyWebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished();
     183    static void notifyWebsiteDataScanForTopPrivatelyControlledDomainsFinished();
     184#endif
    178185
    179186    void enableSuddenTermination();
     
    267274
    268275    bool isJITEnabled() const final;
    269    
     276
    270277private:
    271278    // IPC message handlers.
  • trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.messages.in

    r236563 r240243  
    2121# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2222
     23#if ENABLE(RESOURCE_LOAD_STATISTICS)
     24
    2325messages -> WebResourceLoadStatisticsStore {
    2426    RequestStorageAccessUnderOpener(String domainReceivingUserInteraction, uint64_t openerPageID, String openerDomain)
    2527    ResourceLoadStatisticsUpdated(Vector<WebCore::ResourceLoadStatistics> origins)
    2628}
     29
     30#endif
  • trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm

    r239816 r240243  
    155155            for (auto& dataStore : dataStoresWithStorageManagers()) {
    156156                dataStore->m_storageManager->applicationWillTerminate();
     157#if ENABLE(RESOURCE_LOAD_STATISTICS)
    157158                if (dataStore->m_resourceLoadStatistics)
    158159                    dataStore->m_resourceLoadStatistics->applicationWillTerminate();
     160#endif
    159161            }
    160162        }];
     
    167169void WebsiteDataStore::platformDestroy()
    168170{
     171#if ENABLE(RESOURCE_LOAD_STATISTICS)
    169172    if (m_resourceLoadStatistics)
    170173        m_resourceLoadStatistics->applicationWillTerminate();
     174#endif
    171175
    172176    if (!m_storageManager)
  • trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp

    r240156 r240243  
    11/*
    2  * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    131131    platformDestroy();
    132132
     133#if ENABLE(RESOURCE_LOAD_STATISTICS)
    133134    unregisterWebResourceLoadStatisticsStoreAsMessageReceiver();
     135#endif
    134136
    135137    if (m_sessionID.isValid() && m_sessionID != PAL::SessionID::defaultSessionID()) {
     
    614616}
    615617
     618#if ENABLE(RESOURCE_LOAD_STATISTICS)
    616619void WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType> dataTypes, OptionSet<WebsiteDataFetchOption> fetchOptions, const Vector<String>& topPrivatelyControlledDomains, Function<void(Vector<WebsiteDataRecord>&&, HashSet<String>&&)>&& completionHandler)
    617620{
     
    649652    });
    650653}
     654#endif
    651655
    652656static ProcessAccessType computeNetworkProcessAccessTypeForDataRemoval(OptionSet<WebsiteDataType> dataTypes, bool isNonPersistentStore)
     
    926930#endif
    927931
    928     if (dataTypes.contains(WebsiteDataType::ResourceLoadStatistics) && m_resourceLoadStatistics) {
     932#if ENABLE(RESOURCE_LOAD_STATISTICS)
     933    if (dataTypes.contains(WebsiteDataType::ResourceLoadStatistics)) {
    929934        auto deletedTypesRaw = dataTypes.toRaw();
    930935        auto monitoredTypesRaw = WebResourceLoadStatisticsStore::monitoredDataTypes().toRaw();
     
    932937        // If we are deleting all of the data types that the resource load statistics store monitors
    933938        // we do not need to re-grandfather old data.
     939        auto shouldGrandfather = ((monitoredTypesRaw & deletedTypesRaw) == monitoredTypesRaw) ? ShouldGrandfather::No : ShouldGrandfather::Yes;
     940       
    934941        callbackAggregator->addPendingCallback();
    935         if ((monitoredTypesRaw & deletedTypesRaw) == monitoredTypesRaw)
    936             m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(modifiedSince, WebResourceLoadStatisticsStore::ShouldGrandfather::No, [callbackAggregator] {
     942
     943        if (m_resourceLoadStatistics) {
     944            m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(modifiedSince, shouldGrandfather, [callbackAggregator] {
    937945                callbackAggregator->removePendingCallback();
    938946            });
    939         else
    940             m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(modifiedSince, WebResourceLoadStatisticsStore::ShouldGrandfather::Yes, [callbackAggregator] {
    941                 callbackAggregator->removePendingCallback();
    942             });
     947        } else {
     948            for (auto& processPool : processPools()) {
     949                if (auto* process = processPool->networkProcess()) {
     950                    process->deleteWebsiteData(m_sessionID, dataTypes, modifiedSince, [callbackAggregator] {
     951                        callbackAggregator->removePendingCallback();
     952                    });
     953                }
     954            }
     955        }
    943956
    944957        callbackAggregator->addPendingCallback();
     
    947960        });
    948961    }
     962#endif
    949963
    950964    // There's a chance that we don't have any pending callbacks. If so, we want to dispatch the completion handler right away.
     
    12221236#endif
    12231237
     1238#if ENABLE(RESOURCE_LOAD_STATISTICS)
    12241239    // FIXME <rdar://problem/33491222>; scheduleClearInMemoryAndPersistent does not have a completion handler,
    12251240    // so the completion handler for this removeData() call can be called prematurely.
     
    12321247        callbackAggregator->addPendingCallback();
    12331248        if ((monitoredTypesRaw & deletedTypesRaw) == monitoredTypesRaw)
    1234             m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(WebResourceLoadStatisticsStore::ShouldGrandfather::No, [callbackAggregator] {
     1249            m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(ShouldGrandfather::No, [callbackAggregator] {
    12351250                callbackAggregator->removePendingCallback();
    12361251            });
    12371252        else
    1238             m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(WebResourceLoadStatisticsStore::ShouldGrandfather::Yes, [callbackAggregator] {
     1253            m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(ShouldGrandfather::Yes, [callbackAggregator] {
    12391254                callbackAggregator->removePendingCallback();
    12401255            });
     
    12451260        });
    12461261    }
     1262#endif
    12471263
    12481264    // There's a chance that we don't have any pending callbacks. If so, we want to dispatch the completion handler right away.
     
    12501266}
    12511267
     1268#if ENABLE(RESOURCE_LOAD_STATISTICS)
    12521269void WebsiteDataStore::removeDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType> dataTypes, OptionSet<WebsiteDataFetchOption> fetchOptions, const Vector<String>& topPrivatelyControlledDomains, Function<void(HashSet<String>&&)>&& completionHandler)
    12531270{
     
    12591276}
    12601277
     1278void WebsiteDataStore::setMaxStatisticsEntries(size_t maximumEntryCount, CompletionHandler<void()>&& completionHandler)
     1279{
     1280    ASSERT(RunLoop::isMain());
     1281
     1282    if (m_resourceLoadStatistics) {
     1283        m_resourceLoadStatistics->setMaxStatisticsEntries(maximumEntryCount, WTFMove(completionHandler));
     1284        return;
     1285    }
     1286   
     1287    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     1288
     1289    for (auto& processPool : processPools()) {
     1290        if (auto* process = processPool->networkProcess())
     1291            process->setMaxStatisticsEntries(m_sessionID, maximumEntryCount, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
     1292    }
     1293}
     1294
     1295void WebsiteDataStore::setPruneEntriesDownTo(size_t pruneTargetCount, CompletionHandler<void()>&& completionHandler)
     1296{
     1297    ASSERT(RunLoop::isMain());
     1298   
     1299    if (m_resourceLoadStatistics) {
     1300        m_resourceLoadStatistics->setPruneEntriesDownTo(pruneTargetCount, WTFMove(completionHandler));
     1301        return;
     1302    }
     1303
     1304    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     1305
     1306    for (auto& processPool : processPools()) {
     1307        if (auto* process = processPool->networkProcess())
     1308            process->setPruneEntriesDownTo(m_sessionID, pruneTargetCount, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
     1309    }
     1310}
     1311
     1312void WebsiteDataStore::setGrandfatheringTime(Seconds seconds, CompletionHandler<void()>&& completionHandler)
     1313{
     1314    ASSERT(RunLoop::isMain());
     1315
     1316    if (m_resourceLoadStatistics) {
     1317        m_resourceLoadStatistics->setGrandfatheringTime(seconds, WTFMove(completionHandler));
     1318        return;
     1319    }
     1320   
     1321    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     1322
     1323    for (auto& processPool : processPools()) {
     1324        if (auto* process = processPool->networkProcess())
     1325            process->setGrandfatheringTime(m_sessionID, seconds, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
     1326    }
     1327}
     1328
     1329void WebsiteDataStore::setCacheMaxAgeCap(Seconds seconds, CompletionHandler<void()>&& completionHandler)
     1330{
     1331    ASSERT(RunLoop::isMain());
     1332    ASSERT(seconds >= 0_s);
     1333   
     1334    if (m_resourceLoadStatistics) {
     1335        setCacheMaxAgeCap(seconds, WTFMove(completionHandler));
     1336        return;
     1337    }
     1338
     1339    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     1340
     1341    for (auto& processPool : processPools()) {
     1342        if (auto* process = processPool->networkProcess())
     1343            process->setCacheMaxAgeCap(m_sessionID, seconds, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
     1344    }
     1345}
     1346
     1347void WebsiteDataStore::setMinimumTimeBetweenDataRecordsRemoval(Seconds seconds, CompletionHandler<void()>&& completionHandler)
     1348{
     1349    ASSERT(RunLoop::isMain());
     1350
     1351    if (m_resourceLoadStatistics) {
     1352        m_resourceLoadStatistics->setMinimumTimeBetweenDataRecordsRemoval(seconds, WTFMove(completionHandler));
     1353        return;
     1354    }
     1355   
     1356    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     1357
     1358    for (auto& processPool : processPools()) {
     1359        if (auto* process = processPool->networkProcess())
     1360            process->setMinimumTimeBetweenDataRecordsRemoval(m_sessionID, seconds, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
     1361    }
     1362}
     1363   
     1364void WebsiteDataStore::dumpResourceLoadStatistics(CompletionHandler<void(const String&)>&& completionHandler)
     1365{
     1366    ASSERT(RunLoop::isMain());
     1367
     1368    if (m_resourceLoadStatistics) {
     1369        m_resourceLoadStatistics->dumpResourceLoadStatistics(WTFMove(completionHandler));
     1370        return;
     1371    }
     1372   
     1373    for (auto& processPool : processPools()) {
     1374        if (auto* process = processPool->networkProcess()) {
     1375            process->dumpResourceLoadStatistics(m_sessionID, WTFMove(completionHandler));
     1376            RELEASE_ASSERT(processPools().size() == 1);
     1377            break;
     1378        }
     1379    }
     1380}
     1381
     1382void WebsiteDataStore::isPrevalentResource(const URL& url, CompletionHandler<void(bool isPrevalent)>&& completionHandler)
     1383{
     1384    ASSERT(RunLoop::isMain());
     1385   
     1386    if (url.protocolIsAbout() || url.isEmpty()) {
     1387        completionHandler(false);
     1388        return;
     1389    }
     1390
     1391    if (m_resourceLoadStatistics) {
     1392        m_resourceLoadStatistics->isPrevalentResource(url, WTFMove(completionHandler));
     1393        return;
     1394    }
     1395
     1396    for (auto& processPool : processPools()) {
     1397        if (auto* process = processPool->networkProcess()) {
     1398            process->isPrevalentResource(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler));
     1399            RELEASE_ASSERT(processPools().size() == 1);
     1400            break;
     1401        }
     1402    }
     1403}
     1404
     1405void WebsiteDataStore::setPrevalentResource(const URL& url, CompletionHandler<void()>&& completionHandler)
     1406{
     1407    ASSERT(RunLoop::isMain());
     1408   
     1409    if (url.protocolIsAbout() || url.isEmpty()) {
     1410        completionHandler();
     1411        return;
     1412    }
     1413   
     1414    if (m_resourceLoadStatistics) {
     1415        m_resourceLoadStatistics->setPrevalentResource(url, WTFMove(completionHandler));
     1416        return;
     1417    }
     1418
     1419    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     1420
     1421    for (auto& processPool : processPools()) {
     1422        if (auto* process = processPool->networkProcess())
     1423            process->setPrevalentResource(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
     1424    }
     1425}
     1426
     1427void WebsiteDataStore::setPrevalentResourceForDebugMode(const URL& url, CompletionHandler<void()>&& completionHandler)
     1428{
     1429    ASSERT(RunLoop::isMain());
     1430   
     1431    if (url.protocolIsAbout() || url.isEmpty()) {
     1432        completionHandler();
     1433        return;
     1434    }
     1435   
     1436    if (m_resourceLoadStatistics) {
     1437        m_resourceLoadStatistics->setPrevalentResourceForDebugMode(url, WTFMove(completionHandler));
     1438        return;
     1439    }
     1440   
     1441    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     1442   
     1443    for (auto& processPool : processPools()) {
     1444        if (auto* process = processPool->networkProcess())
     1445            process->setPrevalentResourceForDebugMode(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
     1446    }
     1447}
     1448
     1449void WebsiteDataStore::isVeryPrevalentResource(const URL& url, CompletionHandler<void(bool isVeryPrevalent)>&& completionHandler)
     1450{
     1451    ASSERT(RunLoop::isMain());
     1452   
     1453    if (url.protocolIsAbout() || url.isEmpty()) {
     1454        completionHandler(false);
     1455        return;
     1456    }
     1457   
     1458    if (m_resourceLoadStatistics) {
     1459        m_resourceLoadStatistics->isVeryPrevalentResource(url, WTFMove(completionHandler));
     1460        return;
     1461    }
     1462   
     1463    for (auto& processPool : processPools()) {
     1464        if (auto* process = processPool->networkProcess()) {
     1465            process->isVeryPrevalentResource(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler));
     1466            ASSERT(processPools().size() == 1);
     1467            break;
     1468        }
     1469    }
     1470}
     1471
     1472void WebsiteDataStore::setVeryPrevalentResource(const URL& url, CompletionHandler<void()>&& completionHandler)
     1473{
     1474    ASSERT(RunLoop::isMain());
     1475   
     1476    if (url.protocolIsAbout() || url.isEmpty()) {
     1477        completionHandler();
     1478        return;
     1479    }
     1480   
     1481    if (m_resourceLoadStatistics) {
     1482        m_resourceLoadStatistics->setVeryPrevalentResource(url, WTFMove(completionHandler));
     1483        return;
     1484    }
     1485   
     1486    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     1487   
     1488    for (auto& processPool : processPools()) {
     1489        if (auto* process = processPool->networkProcess())
     1490            process->setVeryPrevalentResource(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
     1491    }
     1492}
     1493
     1494void WebsiteDataStore::setShouldClassifyResourcesBeforeDataRecordsRemoval(bool value, CompletionHandler<void()>&& completionHandler)
     1495{
     1496    ASSERT(RunLoop::isMain());
     1497   
     1498    if (m_resourceLoadStatistics) {
     1499        m_resourceLoadStatistics->setShouldClassifyResourcesBeforeDataRecordsRemoval(value, WTFMove(completionHandler));
     1500        return;
     1501    }
     1502   
     1503    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     1504
     1505    for (auto& processPool : processPools()) {
     1506        if (auto* process = processPool->networkProcess())
     1507            process->setShouldClassifyResourcesBeforeDataRecordsRemoval(m_sessionID, value, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
     1508    }
     1509}
     1510
     1511void WebsiteDataStore::setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame, CompletionHandler<void()>&& completionHandler)
     1512{
     1513    ASSERT(RunLoop::isMain());
     1514   
     1515    if (subframe.protocolIsAbout() || subframe.isEmpty() || topFrame.protocolIsAbout() || topFrame.isEmpty()) {
     1516        completionHandler();
     1517        return;
     1518    }
     1519
     1520    if (m_resourceLoadStatistics) {
     1521        m_resourceLoadStatistics->setSubframeUnderTopFrameOrigin(subframe, topFrame, WTFMove(completionHandler));
     1522        return;
     1523    }
     1524   
     1525    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     1526   
     1527    for (auto& processPool : processPools()) {
     1528        if (auto* process = processPool->networkProcess())
     1529            process->setSubframeUnderTopFrameOrigin(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(subframe), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
     1530    }
     1531}
     1532
     1533void WebsiteDataStore::isRegisteredAsSubFrameUnder(const URL& subFrame, const URL& topFrame, CompletionHandler<void(bool)>&& completionHandler)
     1534{
     1535    ASSERT(RunLoop::isMain());
     1536
     1537    if (m_resourceLoadStatistics) {
     1538        m_resourceLoadStatistics->isRegisteredAsSubFrameUnder(subFrame, topFrame, WTFMove(completionHandler));
     1539        return;
     1540    }
     1541   
     1542    for (auto& processPool : processPools()) {
     1543        if (auto* process = processPool->networkProcess()) {
     1544            process->isRegisteredAsSubFrameUnder(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(subFrame), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), WTFMove(completionHandler));
     1545            ASSERT(processPools().size() == 1);
     1546            break;
     1547        }
     1548    }
     1549}
     1550
     1551void WebsiteDataStore::setSubresourceUnderTopFrameOrigin(const URL& subresource, const URL& topFrame, CompletionHandler<void()>&& completionHandler)
     1552{
     1553    ASSERT(RunLoop::isMain());
     1554   
     1555    if (subresource.protocolIsAbout() || subresource.isEmpty() || topFrame.protocolIsAbout() || topFrame.isEmpty()) {
     1556        completionHandler();
     1557        return;
     1558    }
     1559
     1560    if (m_resourceLoadStatistics) {
     1561        m_resourceLoadStatistics->setSubresourceUnderTopFrameOrigin(subresource, topFrame, WTFMove(completionHandler));
     1562        return;
     1563    }
     1564
     1565    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     1566   
     1567    for (auto& processPool : processPools()) {
     1568        if (auto* process = processPool->networkProcess())
     1569            process->setSubresourceUnderTopFrameOrigin(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
     1570    }
     1571}
     1572
     1573void WebsiteDataStore::isRegisteredAsSubresourceUnder(const URL& subresource, const URL& topFrame, CompletionHandler<void(bool)>&& completionHandler)
     1574{
     1575    ASSERT(RunLoop::isMain());
     1576   
     1577    if (m_resourceLoadStatistics) {
     1578        m_resourceLoadStatistics->isRegisteredAsSubresourceUnder(subresource, topFrame, WTFMove(completionHandler));
     1579        return;
     1580    }
     1581
     1582    for (auto& processPool : processPools()) {
     1583        if (auto* process = processPool->networkProcess()) {
     1584            process->isRegisteredAsSubresourceUnder(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), WTFMove(completionHandler));
     1585            ASSERT(processPools().size() == 1);
     1586            break;
     1587        }
     1588    }
     1589}
     1590
     1591void WebsiteDataStore::setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler)
     1592{
     1593    ASSERT(RunLoop::isMain());
     1594   
     1595    if (subresource.protocolIsAbout() || subresource.isEmpty() || hostNameRedirectedTo.protocolIsAbout() || hostNameRedirectedTo.isEmpty()) {
     1596        completionHandler();
     1597        return;
     1598    }
     1599
     1600    if (m_resourceLoadStatistics) {
     1601        m_resourceLoadStatistics->setSubresourceUniqueRedirectTo(subresource, hostNameRedirectedTo, WTFMove(completionHandler));
     1602        return;
     1603    }
     1604   
     1605    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     1606   
     1607    for (auto& processPool : processPools()) {
     1608        if (auto* process = processPool->networkProcess())
     1609            process->setSubresourceUniqueRedirectTo(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedTo), [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
     1610    }
     1611}
     1612
     1613void WebsiteDataStore::setSubresourceUniqueRedirectFrom(const URL& subresource, const URL& hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler)
     1614{
     1615    ASSERT(RunLoop::isMain());
     1616   
     1617    if (subresource.protocolIsAbout() || subresource.isEmpty() || hostNameRedirectedFrom.protocolIsAbout() || hostNameRedirectedFrom.isEmpty()) {
     1618        completionHandler();
     1619        return;
     1620    }
     1621
     1622    if (m_resourceLoadStatistics) {
     1623        m_resourceLoadStatistics->setSubresourceUniqueRedirectFrom(subresource, hostNameRedirectedFrom, WTFMove(completionHandler));
     1624        return;
     1625    }
     1626   
     1627    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     1628   
     1629    for (auto& processPool : processPools()) {
     1630        if (auto* process = processPool->networkProcess())
     1631            process->setSubresourceUniqueRedirectFrom(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedFrom), [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
     1632    }
     1633}
     1634
     1635void WebsiteDataStore::setTopFrameUniqueRedirectTo(const URL& topFrameHostName, const URL& hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler)
     1636{
     1637    ASSERT(RunLoop::isMain());
     1638   
     1639    if (topFrameHostName.protocolIsAbout() || topFrameHostName.isEmpty() || hostNameRedirectedTo.protocolIsAbout() || hostNameRedirectedTo.isEmpty()) {
     1640        completionHandler();
     1641        return;
     1642    }
     1643
     1644    if (m_resourceLoadStatistics) {
     1645        m_resourceLoadStatistics->setTopFrameUniqueRedirectTo(topFrameHostName, hostNameRedirectedTo, WTFMove(completionHandler));
     1646        return;
     1647    }
     1648   
     1649    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     1650   
     1651    for (auto& processPool : processPools()) {
     1652        if (auto* process = processPool->networkProcess())
     1653            process->setTopFrameUniqueRedirectTo(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(topFrameHostName), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedTo), [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
     1654    }
     1655}
     1656
     1657void WebsiteDataStore::setTopFrameUniqueRedirectFrom(const URL& topFrameHostName, const URL& hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler)
     1658{
     1659    ASSERT(RunLoop::isMain());
     1660   
     1661    if (topFrameHostName.protocolIsAbout() || topFrameHostName.isEmpty() || hostNameRedirectedFrom.protocolIsAbout() || hostNameRedirectedFrom.isEmpty()) {
     1662        completionHandler();
     1663        return;
     1664    }
     1665
     1666    if (m_resourceLoadStatistics) {
     1667        m_resourceLoadStatistics->setTopFrameUniqueRedirectFrom(topFrameHostName, hostNameRedirectedFrom, WTFMove(completionHandler));
     1668        return;
     1669    }
     1670   
     1671    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     1672   
     1673    for (auto& processPool : processPools()) {
     1674        if (auto* process = processPool->networkProcess())
     1675            process->setTopFrameUniqueRedirectFrom(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(topFrameHostName), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedFrom), [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
     1676    }
     1677}
     1678
     1679void WebsiteDataStore::isRegisteredAsRedirectingTo(const URL& hostRedirectedFrom, const URL& hostRedirectedTo, CompletionHandler<void(bool)>&& completionHandler)
     1680{
     1681    ASSERT(RunLoop::isMain());
     1682   
     1683    if (m_resourceLoadStatistics) {
     1684        m_resourceLoadStatistics->isRegisteredAsRedirectingTo(hostRedirectedFrom, hostRedirectedTo, WTFMove(completionHandler));
     1685        return;
     1686    }
     1687
     1688    for (auto& processPool : processPools()) {
     1689        if (auto* process = processPool->networkProcess()) {
     1690            process->isRegisteredAsRedirectingTo(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(hostRedirectedFrom), WebCore::ResourceLoadStatistics::primaryDomain(hostRedirectedTo), WTFMove(completionHandler));
     1691            ASSERT(processPools().size() == 1);
     1692            break;
     1693        }
     1694    }
     1695}
     1696
     1697void WebsiteDataStore::clearPrevalentResource(const URL& url, CompletionHandler<void()>&& completionHandler)
     1698{
     1699    ASSERT(RunLoop::isMain());
     1700       
     1701    if (url.protocolIsAbout() || url.isEmpty()) {
     1702        completionHandler();
     1703        return;
     1704    }
     1705
     1706    if (m_resourceLoadStatistics) {
     1707        m_resourceLoadStatistics->clearPrevalentResource(url, WTFMove(completionHandler));
     1708        return;
     1709    }
     1710
     1711    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     1712
     1713    const auto& primaryDomain = WebCore::ResourceLoadStatistics::primaryDomain(url);
     1714    for (auto& processPool : processPools()) {
     1715        if (auto* process = processPool->networkProcess())
     1716            process->clearPrevalentResource(m_sessionID, primaryDomain, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
     1717    }
     1718}
     1719
     1720void WebsiteDataStore::resetParametersToDefaultValues(CompletionHandler<void()>&& completionHandler)
     1721{
     1722    ASSERT(RunLoop::isMain());
     1723
     1724    if (m_resourceLoadStatistics) {
     1725        m_resourceLoadStatistics->resetParametersToDefaultValues(WTFMove(completionHandler));
     1726        return;
     1727    }
     1728
     1729    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     1730   
     1731    for (auto& processPool : processPools()) {
     1732        if (auto* process = processPool->networkProcess())
     1733            process->resetParametersToDefaultValues(m_sessionID, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
     1734    }
     1735}
     1736
     1737void WebsiteDataStore::submitTelemetry()
     1738{
     1739    ASSERT(RunLoop::isMain());
     1740   
     1741    if (m_resourceLoadStatistics) {
     1742        m_resourceLoadStatistics->submitTelemetry([] { });
     1743        return;
     1744    }
     1745   
     1746    for (auto& processPool : processPools()) {
     1747        if (auto* process = processPool->networkProcess())
     1748            process->submitTelemetry(m_sessionID, [] { });
     1749    }
     1750}
     1751
     1752void WebsiteDataStore::scheduleClearInMemoryAndPersistent(WallTime modifiedSince, ShouldGrandfather shouldGrandfather, CompletionHandler<void()>&& completionHandler)
     1753{
     1754    ASSERT(RunLoop::isMain());
     1755   
     1756    if (m_resourceLoadStatistics) {
     1757        m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(modifiedSince, shouldGrandfather, WTFMove(completionHandler));
     1758        return;
     1759    }
     1760   
     1761    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     1762
     1763    for (auto& processPool : processPools()) {
     1764        if (auto* process = processPool->networkProcess())
     1765            process->scheduleClearInMemoryAndPersistent(m_sessionID, modifiedSince, shouldGrandfather, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
     1766    }
     1767}
     1768
     1769void WebsiteDataStore::scheduleClearInMemoryAndPersistent(ShouldGrandfather shouldGrandfather, CompletionHandler<void()>&& completionHandler)
     1770{
     1771    ASSERT(RunLoop::isMain());
     1772   
     1773    if (m_resourceLoadStatistics) {
     1774        m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(shouldGrandfather, WTFMove(completionHandler));
     1775        return;
     1776    }
     1777
     1778    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     1779
     1780    for (auto& processPool : processPools()) {
     1781        if (auto* process = processPool->networkProcess())
     1782            process->scheduleClearInMemoryAndPersistent(m_sessionID, { }, shouldGrandfather, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
     1783    }
     1784}
     1785
     1786void WebsiteDataStore::scheduleCookieBlockingUpdate(CompletionHandler<void()>&& completionHandler)
     1787{
     1788    if (m_resourceLoadStatistics) {
     1789        m_resourceLoadStatistics->scheduleCookieBlockingUpdate(WTFMove(completionHandler));
     1790        return;
     1791    }
     1792
     1793    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     1794
     1795    for (auto& processPool : processPools()) {
     1796        if (auto* process = processPool->networkProcess())
     1797            process->scheduleCookieBlockingUpdate(m_sessionID, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
     1798    }
     1799}
     1800
     1801void WebsiteDataStore::scheduleStatisticsAndDataRecordsProcessing(CompletionHandler<void()>&& completionHandler)
     1802{
     1803    ASSERT(RunLoop::isMain());
     1804   
     1805    if (m_resourceLoadStatistics) {
     1806        m_resourceLoadStatistics->scheduleStatisticsAndDataRecordsProcessing(WTFMove(completionHandler));
     1807        return;
     1808    }
     1809   
     1810    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     1811   
     1812    for (auto& processPool : processPools()) {
     1813        if (auto* process = processPool->networkProcess())
     1814            process->scheduleStatisticsAndDataRecordsProcessing(m_sessionID, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
     1815    }
     1816}
     1817
    12611818#if ENABLE(RESOURCE_LOAD_STATISTICS)
    12621819void WebsiteDataStore::updatePrevalentDomainsToBlockCookiesFor(const Vector<String>& domainsToBlock, CompletionHandler<void()>&& completionHandler)
     
    12691826    }
    12701827}
     1828#endif
    12711829
    12721830void WebsiteDataStore::setAgeCapForClientSideCookies(Optional<Seconds> seconds, CompletionHandler<void()>&& completionHandler)
     
    12771835        if (auto* process = processPool->networkProcess())
    12781836            process->setAgeCapForClientSideCookies(m_sessionID, seconds, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
     1837    }
     1838}
     1839
     1840void WebsiteDataStore::setLastSeen(const URL& url, Seconds seconds, CompletionHandler<void()>&& completionHandler)
     1841{
     1842    if (url.protocolIsAbout() || url.isEmpty()) {
     1843        completionHandler();
     1844        return;
     1845    }
     1846
     1847    if (m_resourceLoadStatistics) {
     1848        m_resourceLoadStatistics->setLastSeen(url, seconds, WTFMove(completionHandler));
     1849        return;
     1850    }
     1851
     1852    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     1853
     1854    const auto& primaryDomain = WebCore::ResourceLoadStatistics::primaryDomain(url);
     1855    for (auto& processPool : processPools()) {
     1856        if (auto* process = processPool->networkProcess())
     1857            process->setLastSeen(m_sessionID, primaryDomain, seconds, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
     1858    }
     1859}
     1860
     1861void WebsiteDataStore::setNotifyPagesWhenDataRecordsWereScanned(bool value, CompletionHandler<void()>&& completionHandler)
     1862{
     1863    if (m_resourceLoadStatistics) {
     1864        m_resourceLoadStatistics->setNotifyPagesWhenDataRecordsWereScanned(value, WTFMove(completionHandler));
     1865        return;
     1866    }
     1867
     1868    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     1869
     1870    for (auto& processPool : processPools()) {
     1871        if (auto* process = processPool->networkProcess())
     1872            process->setNotifyPagesWhenDataRecordsWereScanned(m_sessionID, value, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
     1873    }
     1874}
     1875
     1876void WebsiteDataStore::setNotifyPagesWhenTelemetryWasCaptured(bool value, CompletionHandler<void()>&& completionHandler)
     1877{
     1878    if (m_resourceLoadStatistics) {
     1879        m_resourceLoadStatistics->setNotifyPagesWhenTelemetryWasCaptured(value, WTFMove(completionHandler));
     1880        return;
     1881    }
     1882   
     1883    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     1884   
     1885    for (auto& processPool : processPools()) {
     1886        if (auto* process = processPool->networkProcess())
     1887            process->setNotifyPagesWhenTelemetryWasCaptured(m_sessionID, value, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
    12791888    }
    12801889}
     
    13131922
    13141923    auto& networkProcess = webPage->process().processPool().ensureNetworkProcess();
    1315     networkProcess.grantStorageAccess(m_sessionID, resourceDomain, firstPartyDomain, frameID, pageID, WTFMove(completionHandler));
     1924    networkProcess.grantStorageAccess(m_sessionID, resourceDomain, firstPartyDomain, frameID, pageID, false, WTFMove(completionHandler));
    13161925}
    13171926
     
    13381947        return;
    13391948    }
    1340    
    1341     m_resourceLoadStatistics->hasStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, WTFMove(completionHandler));
     1949
     1950    if (m_resourceLoadStatistics) {
     1951        m_resourceLoadStatistics->hasStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, WTFMove(completionHandler));
     1952        return;
     1953    }
     1954
     1955    auto* webPage = WebProcessProxy::webPage(pageID);
     1956    if (!webPage) {
     1957        completionHandler(false);
     1958        return;
     1959    }
     1960
     1961    if (auto networkProcess = webPage->process().processPool().networkProcess())
     1962        networkProcess->hasStorageAccess(m_sessionID, WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, WTFMove(completionHandler));
    13421963}
    13431964
     
    13491970    }
    13501971   
    1351     m_resourceLoadStatistics->requestStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, promptEnabled, WTFMove(completionHandler));
     1972    if (m_resourceLoadStatistics) {
     1973        m_resourceLoadStatistics->requestStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, promptEnabled, WTFMove(completionHandler));
     1974        return;
     1975    }
     1976
     1977    auto* webPage = WebProcessProxy::webPage(pageID);
     1978    if (!webPage) {
     1979        completionHandler(StorageAccessStatus::CannotRequestAccess);
     1980        return;
     1981    }
     1982
     1983    if (auto networkProcess = webPage->process().processPool().networkProcess())
     1984        networkProcess->requestStorageAccess(m_sessionID, WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, promptEnabled, WTFMove(completionHandler));
    13521985}
    13531986
     
    13591992    }
    13601993   
    1361     m_resourceLoadStatistics->grantStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, userWasPrompted, WTFMove(completionHandler));
     1994    if (m_resourceLoadStatistics) {
     1995        m_resourceLoadStatistics->grantStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, userWasPrompted, WTFMove(completionHandler));
     1996        return;
     1997    }
     1998
     1999    auto* webPage = WebProcessProxy::webPage(pageID);
     2000    if (!webPage) {
     2001        completionHandler(false);
     2002        return;
     2003    }
     2004
     2005    if (auto networkProcess = webPage->process().processPool().networkProcess())
     2006        networkProcess->grantStorageAccess(m_sessionID, WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, userWasPrompted, WTFMove(completionHandler));
     2007}
     2008
     2009void WebsiteDataStore::setTimeToLiveUserInteraction(Seconds seconds, CompletionHandler<void()>&& completionHandler)
     2010{
     2011    if (m_resourceLoadStatistics) {
     2012        m_resourceLoadStatistics->setTimeToLiveUserInteraction(seconds, WTFMove(completionHandler));
     2013        return;
     2014    }
     2015
     2016    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     2017   
     2018    for (auto& processPool : processPools()) {
     2019        if (auto* networkProcess = processPool->networkProcess())
     2020            networkProcess->setTimeToLiveUserInteraction(m_sessionID, seconds, [callbackAggregator = callbackAggregator.copyRef()] { });
     2021    }
     2022}
     2023
     2024void WebsiteDataStore::logUserInteraction(const URL& url, CompletionHandler<void()>&& completionHandler)
     2025{
     2026    ASSERT(RunLoop::isMain());
     2027   
     2028    if (url.protocolIsAbout() || url.isEmpty()) {
     2029        completionHandler();
     2030        return;
     2031    }
     2032   
     2033    if (m_resourceLoadStatistics) {
     2034        m_resourceLoadStatistics->logUserInteraction(url, WTFMove(completionHandler));
     2035        return;
     2036    }
     2037
     2038    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     2039
     2040    for (auto& processPool : processPools()) {
     2041        if (auto* process = processPool->networkProcess())
     2042            process->logUserInteraction(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), [callbackAggregator = callbackAggregator.copyRef()] { });
     2043    }
     2044}
     2045
     2046void WebsiteDataStore::hasHadUserInteraction(const URL& url, CompletionHandler<void(bool)>&& completionHandler)
     2047{
     2048    ASSERT(RunLoop::isMain());
     2049   
     2050    if (url.protocolIsAbout() || url.isEmpty()) {
     2051        completionHandler(false);
     2052        return;
     2053    }
     2054   
     2055    if (m_resourceLoadStatistics) {
     2056        m_resourceLoadStatistics->hasHadUserInteraction(url, WTFMove(completionHandler));
     2057        return;
     2058    }
     2059   
     2060    for (auto& processPool : processPools()) {
     2061        if (auto* process = processPool->networkProcess()) {
     2062            process->hasHadUserInteraction(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler));
     2063            ASSERT(processPools().size() == 1);
     2064            break;
     2065        }
     2066    }
     2067}
     2068
     2069void WebsiteDataStore::clearUserInteraction(const URL& url, CompletionHandler<void()>&& completionHandler)
     2070{
     2071    ASSERT(RunLoop::isMain());
     2072   
     2073    if (url.protocolIsAbout() || url.isEmpty()) {
     2074        completionHandler();
     2075        return;
     2076    }
     2077   
     2078    if (m_resourceLoadStatistics) {
     2079        m_resourceLoadStatistics->clearUserInteraction(url, WTFMove(completionHandler));
     2080        return;
     2081    }
     2082   
     2083    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     2084
     2085    for (auto& processPool : processPools()) {
     2086        if (auto* process = processPool->networkProcess())
     2087            process->clearUserInteraction(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), [callbackAggregator = callbackAggregator.copyRef()] { });
     2088    }
     2089}
     2090
     2091void WebsiteDataStore::isGrandfathered(const URL& url, CompletionHandler<void(bool)>&& completionHandler)
     2092{
     2093    ASSERT(RunLoop::isMain());
     2094   
     2095    if (url.protocolIsAbout() || url.isEmpty()) {
     2096        completionHandler(false);
     2097        return;
     2098    }
     2099   
     2100    if (m_resourceLoadStatistics) {
     2101        m_resourceLoadStatistics->isGrandfathered(url, WTFMove(completionHandler));
     2102        return;
     2103    }
     2104   
     2105    for (auto& processPool : processPools()) {
     2106        if (auto* process = processPool->networkProcess()) {
     2107            process->isGrandfathered(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler));
     2108            ASSERT(processPools().size() == 1);
     2109            break;
     2110        }
     2111    }
     2112}
     2113
     2114void WebsiteDataStore::setGrandfathered(const URL& url, bool isGrandfathered, CompletionHandler<void()>&& completionHandler)
     2115{
     2116    ASSERT(RunLoop::isMain());
     2117   
     2118    if (url.protocolIsAbout() || url.isEmpty()) {
     2119        completionHandler();
     2120        return;
     2121    }
     2122   
     2123    if (m_resourceLoadStatistics) {
     2124        m_resourceLoadStatistics->setGrandfathered(url, isGrandfathered, WTFMove(completionHandler));
     2125        return;
     2126    }
     2127   
     2128    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     2129   
     2130    for (auto& processPool : processPools()) {
     2131        if (auto* process = processPool->networkProcess())
     2132            process->setGrandfathered(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), isGrandfathered, [callbackAggregator = callbackAggregator.copyRef()] { });
     2133    }
    13622134}
    13632135#endif // ENABLE(RESOURCE_LOAD_STATISTICS)
     
    14092181        m_storageManager->processWillOpenConnection(webProcessProxy, connection);
    14102182
     2183#if ENABLE(RESOURCE_LOAD_STATISTICS)
    14112184    if (m_resourceLoadStatistics)
    14122185        webProcessProxy.addMessageReceiver(Messages::WebResourceLoadStatisticsStore::messageReceiverName(), *m_resourceLoadStatistics);
     2186#endif
    14132187}
    14142188
     
    14272201void WebsiteDataStore::webProcessDidCloseConnection(WebProcessProxy& webProcessProxy, IPC::Connection& connection)
    14282202{
     2203#if ENABLE(RESOURCE_LOAD_STATISTICS)
    14292204    if (m_resourceLoadStatistics)
    14302205        webProcessProxy.removeMessageReceiver(Messages::WebResourceLoadStatisticsStore::messageReceiverName());
     2206#endif
    14312207
    14322208    if (m_storageManager)
     
    15412317bool WebsiteDataStore::resourceLoadStatisticsEnabled() const
    15422318{
    1543     return !!m_resourceLoadStatistics;
     2319#if ENABLE(RESOURCE_LOAD_STATISTICS)
     2320    return m_resourceLoadStatisticsEnabled;
     2321#else
     2322    return false;
     2323#endif
     2324}
     2325
     2326bool WebsiteDataStore::resourceLoadStatisticsDebugMode() const
     2327{
     2328#if ENABLE(RESOURCE_LOAD_STATISTICS)
     2329    return m_resourceLoadStatisticsDebugMode;
     2330#else
     2331    return false;
     2332#endif
    15442333}
    15452334
    15462335void WebsiteDataStore::setResourceLoadStatisticsEnabled(bool enabled)
    15472336{
     2337#if ENABLE(RESOURCE_LOAD_STATISTICS)
    15482338    if (m_sessionID.isEphemeral() || enabled == resourceLoadStatisticsEnabled())
    15492339        return;
    15502340
    15512341    if (enabled) {
     2342        // FIXME(193297): Remove this assert
    15522343        ASSERT(!m_resourceLoadStatistics);
    15532344        enableResourceLoadStatisticsAndSetTestingCallback(nullptr);
     
    15552346    }
    15562347
    1557 
     2348    // FIXME(193297): Remove these two lines
    15582349    unregisterWebResourceLoadStatisticsStoreAsMessageReceiver();
    15592350    m_resourceLoadStatistics = nullptr;
    15602351
    1561     auto existingProcessPools = processPools(std::numeric_limits<size_t>::max(), false);
    1562     for (auto& processPool : existingProcessPools)
     2352    for (auto& processPool : processPools(std::numeric_limits<size_t>::max(), false)) {
    15632353        processPool->setResourceLoadStatisticsEnabled(false);
    1564 }
    1565 
     2354        processPool->sendToNetworkingProcess(Messages::NetworkProcess::SetResourceLoadStatisticsEnabled(false));
     2355    }
     2356#else
     2357    UNUSED_PARAM(enabled);
     2358#endif
     2359}
     2360
     2361void WebsiteDataStore::setResourceLoadStatisticsDebugMode(bool enabled)
     2362{
     2363    setResourceLoadStatisticsDebugMode(enabled, []() { });
     2364}
     2365
     2366void WebsiteDataStore::setResourceLoadStatisticsDebugMode(bool enabled, CompletionHandler<void()>&& completionHandler)
     2367{
     2368#if ENABLE(RESOURCE_LOAD_STATISTICS)
     2369    m_resourceLoadStatisticsDebugMode = enabled;
     2370    if (m_resourceLoadStatistics) {
     2371        m_resourceLoadStatistics->setResourceLoadStatisticsDebugMode(enabled, WTFMove(completionHandler));
     2372        return;
     2373    }
     2374   
     2375    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
     2376   
     2377    for (auto& processPool : processPools()) {
     2378        if (auto* process = processPool->networkProcess())
     2379            process->setResourceLoadStatisticsDebugMode(m_sessionID, enabled, [callbackAggregator = callbackAggregator.copyRef()] { });
     2380    }
     2381#else
     2382    UNUSED_PARAM(enabled);
     2383    UNUSED_PARAM(completionHandler);
     2384#endif
     2385}
     2386
     2387#if ENABLE(RESOURCE_LOAD_STATISTICS)
    15662388void WebsiteDataStore::unregisterWebResourceLoadStatisticsStoreAsMessageReceiver()
    15672389{
     
    15832405}
    15842406
    1585 bool WebsiteDataStore::resourceLoadStatisticsDebugMode() const
    1586 {
    1587     return m_resourceLoadStatisticsDebugMode;
    1588 }
    1589 
    1590 void WebsiteDataStore::setResourceLoadStatisticsDebugMode(bool enabled)
    1591 {
    1592     setResourceLoadStatisticsDebugMode(enabled, []() { });
    1593 }
    1594 
    1595 void WebsiteDataStore::setResourceLoadStatisticsDebugMode(bool enabled, CompletionHandler<void()>&& completionHandler)
    1596 {
    1597     m_resourceLoadStatisticsDebugMode = enabled;
     2407void WebsiteDataStore::enableResourceLoadStatisticsAndSetTestingCallback(Function<void (const String&)>&& callback)
     2408{
     2409    ASSERT(!m_sessionID.isEphemeral());
     2410
     2411    m_resourceLoadStatisticsEnabled = true;
     2412    setStatisticsTestingCallback(WTFMove(callback));
     2413
     2414    // FIXME(193297): Remove this check
    15982415    if (m_resourceLoadStatistics)
    1599         m_resourceLoadStatistics->setResourceLoadStatisticsDebugMode(enabled, WTFMove(completionHandler));
    1600     else
    1601         completionHandler();
    1602 }
    1603 
    1604 void WebsiteDataStore::enableResourceLoadStatisticsAndSetTestingCallback(Function<void (const String&)>&& callback)
    1605 {
    1606     ASSERT(!m_sessionID.isEphemeral());
    1607 
    1608     if (m_resourceLoadStatistics) {
    1609         m_resourceLoadStatistics->setStatisticsTestingCallback(WTFMove(callback));
    1610         return;
    1611     }
     2416        return;
    16122417
    16132418    resolveDirectoriesIfNecessary();
     2419
     2420    // FIXME(193297): Remove these two lines
    16142421    m_resourceLoadStatistics = WebResourceLoadStatisticsStore::create(*this);
    1615     m_resourceLoadStatistics->setStatisticsTestingCallback(WTFMove(callback));
    1616 
    16172422    registerWebResourceLoadStatisticsStoreAsMessageReceiver();
    16182423
    1619     for (auto& processPool : processPools(std::numeric_limits<size_t>::max(), false))
     2424    for (auto& processPool : processPools(std::numeric_limits<size_t>::max(), false)) {
    16202425        processPool->setResourceLoadStatisticsEnabled(true);
     2426        processPool->sendToNetworkingProcess(Messages::NetworkProcess::SetResourceLoadStatisticsEnabled(true));
     2427    }
     2428}
     2429
     2430void WebsiteDataStore::logTestingEvent(const String& event)
     2431{
     2432    ASSERT(RunLoop::isMain());
     2433   
     2434    if (m_statisticsTestingCallback)
     2435        m_statisticsTestingCallback(event);
    16212436}
    16222437
     
    16292444    callback();
    16302445}
     2446#endif
    16312447
    16322448Vector<WebCore::Cookie> WebsiteDataStore::pendingCookies() const
     
    16992515void WebsiteDataStore::didCreateNetworkProcess()
    17002516{
     2517#if ENABLE(RESOURCE_LOAD_STATISTICS)
    17012518    if (m_resourceLoadStatistics)
    17022519        m_resourceLoadStatistics->didCreateNetworkProcess();
    1703 }
    1704 
    1705 }
     2520#endif
     2521}
     2522
     2523}
  • trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h

    r240156 r240243  
    11/*
    2  * Copyright (C) 2014-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    7373
    7474#if ENABLE(RESOURCE_LOAD_STATISTICS)
    75 enum class StorageAccessStatus;
     75enum class ShouldGrandfather;
     76enum class StorageAccessStatus : unsigned;
    7677enum class StorageAccessPromptStatus;
    7778#endif
     
    105106    void setServiceWorkerRegistrationDirectory(String&& directory) { m_resolvedConfiguration->setServiceWorkerRegistrationDirectory(WTFMove(directory)); }
    106107
     108#if ENABLE(RESOURCE_LOAD_STATISTICS)
    107109    WebResourceLoadStatisticsStore* resourceLoadStatistics() const { return m_resourceLoadStatistics.get(); }
    108110    void clearResourceLoadStatisticsInWebProcesses(CompletionHandler<void()>&&);
     111#endif
    109112
    110113    static void cloneSessionData(WebPageProxy& sourcePage, WebPageProxy& newPage);
    111114
    112115    void fetchData(OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, Function<void(Vector<WebsiteDataRecord>)>&& completionHandler);
     116    void removeData(OptionSet<WebsiteDataType>, WallTime modifiedSince, Function<void()>&& completionHandler);
     117    void removeData(OptionSet<WebsiteDataType>, const Vector<WebsiteDataRecord>&, Function<void()>&& completionHandler);
     118
     119#if ENABLE(RESOURCE_LOAD_STATISTICS)
    113120    void fetchDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, const Vector<String>& topPrivatelyControlledDomains, Function<void(Vector<WebsiteDataRecord>&&, HashSet<String>&&)>&& completionHandler);
    114121    void topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType> dataTypes, OptionSet<WebsiteDataFetchOption> fetchOptions, Function<void(HashSet<String>&&)>&& completionHandler);
    115     void removeData(OptionSet<WebsiteDataType>, WallTime modifiedSince, Function<void()>&& completionHandler);
    116     void removeData(OptionSet<WebsiteDataType>, const Vector<WebsiteDataRecord>&, Function<void()>&& completionHandler);
    117122    void removeDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, const Vector<String>& topPrivatelyControlledDomains, Function<void(HashSet<String>&&)>&& completionHandler);
    118123
    119 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     124    void clearPrevalentResource(const URL&, CompletionHandler<void()>&&);
     125    void clearUserInteraction(const URL&, CompletionHandler<void()>&&);
     126    void deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType>, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPages, CompletionHandler<void(const HashSet<String>&)>&&);
     127    void dumpResourceLoadStatistics(CompletionHandler<void(const String&)>&&);
     128    void logTestingEvent(const String&);
     129    void logUserInteraction(const URL&, CompletionHandler<void()>&&);
    120130    void updatePrevalentDomainsToBlockCookiesFor(const Vector<String>& domainsToBlock, CompletionHandler<void()>&&);
    121131    void setAgeCapForClientSideCookies(Optional<Seconds>, CompletionHandler<void()>&&);
     
    123133    void getAllStorageAccessEntries(uint64_t pageID, CompletionHandler<void(Vector<String>&& domains)>&&);
    124134    void grantStorageAccessHandler(const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool wasGranted)>&&);
     135    void hasHadUserInteraction(const URL&, CompletionHandler<void(bool)>&&);
     136    void isGrandfathered(const URL&, CompletionHandler<void(bool)>&&);
     137    void isPrevalentResource(const URL&, CompletionHandler<void(bool)>&&);
     138    void isRegisteredAsRedirectingTo(const URL& hostRedirectedFrom, const URL& hostRedirectedTo, CompletionHandler<void(bool)>&&);
     139    void isRegisteredAsSubresourceUnder(const URL& subresource, const URL& topFrame, CompletionHandler<void(bool)>&&);
     140    void isRegisteredAsSubFrameUnder(const URL& subFrame, const URL& topFrame, CompletionHandler<void(bool)>&&);
     141    void isVeryPrevalentResource(const URL&, CompletionHandler<void(bool)>&&);
    125142    void removeAllStorageAccessHandler(CompletionHandler<void()>&&);
    126143    void removePrevalentDomains(const Vector<String>& domains);
     144    void resetParametersToDefaultValues(CompletionHandler<void()>&&);
     145    void scheduleCookieBlockingUpdate(CompletionHandler<void()>&&);
     146    void scheduleClearInMemoryAndPersistent(WallTime modifiedSince, ShouldGrandfather, CompletionHandler<void()>&&);
     147    void scheduleClearInMemoryAndPersistent(ShouldGrandfather, CompletionHandler<void()>&&);
     148    void scheduleStatisticsAndDataRecordsProcessing(CompletionHandler<void()>&&);
     149    void submitTelemetry();
     150    void setCacheMaxAgeCap(Seconds, CompletionHandler<void()>&&);
     151    void setGrandfathered(const URL&, bool, CompletionHandler<void()>&&);
     152    void setGrandfatheringTime(Seconds, CompletionHandler<void()>&&);
     153    void setLastSeen(const URL&, Seconds, CompletionHandler<void()>&&);
     154    void setNotifyPagesWhenDataRecordsWereScanned(bool, CompletionHandler<void()>&&);
     155    void setPruneEntriesDownTo(size_t, CompletionHandler<void()>&&);
     156    void setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame, CompletionHandler<void()>&&);
     157    void setSubresourceUnderTopFrameOrigin(const URL& subresource, const URL& topFrame, CompletionHandler<void()>&&);
     158    void setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo, CompletionHandler<void()>&&);
     159    void setSubresourceUniqueRedirectFrom(const URL& subresource, const URL& hostNameRedirectedFrom, CompletionHandler<void()>&&);
     160    void setTimeToLiveUserInteraction(Seconds, CompletionHandler<void()>&&);
     161    void setTopFrameUniqueRedirectTo(const URL& topFrameHostName, const URL& hostNameRedirectedTo, CompletionHandler<void()>&&);
     162    void setTopFrameUniqueRedirectFrom(const URL& topFrameHostName, const URL& hostNameRedirectedFrom, CompletionHandler<void()>&&);
     163    void setMaxStatisticsEntries(size_t, CompletionHandler<void()>&&);
     164    void setMinimumTimeBetweenDataRecordsRemoval(Seconds, CompletionHandler<void()>&&);
     165    void setNotifyPagesWhenTelemetryWasCaptured(bool, CompletionHandler<void()>&&);
     166    void setPrevalentResource(const URL&, CompletionHandler<void()>&&);
     167    void setPrevalentResourceForDebugMode(const URL&, CompletionHandler<void()>&&);
     168    void setShouldClassifyResourcesBeforeDataRecordsRemoval(bool, CompletionHandler<void()>&&);
     169    void setStatisticsTestingCallback(WTF::Function<void(const String&)>&& callback) { m_statisticsTestingCallback = WTFMove(callback); }
     170    void setVeryPrevalentResource(const URL&, CompletionHandler<void()>&&);
    127171    void hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&&);
    128172    void requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&&);
    129173    void grantStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPrompted, CompletionHandler<void(bool)>&&);
     174    void setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame);
    130175#endif
    131176    void setCacheMaxAgeCapForPrevalentResources(Seconds, CompletionHandler<void()>&&);
     
    211256    static void platformRemoveRecentSearches(WallTime);
    212257
     258#if ENABLE(RESOURCE_LOAD_STATISTICS)
    213259    void registerWebResourceLoadStatisticsStoreAsMessageReceiver();
    214260    void unregisterWebResourceLoadStatisticsStoreAsMessageReceiver();
     261#endif
    215262
    216263    HashSet<RefPtr<WebProcessPool>> processPools(size_t count = std::numeric_limits<size_t>::max(), bool ensureAPoolExists = true) const;
     
    234281    const RefPtr<StorageManager> m_storageManager;
    235282    const Ref<DeviceIdHashSaltStorage> m_deviceIdHashSaltStorage;
     283
     284#if ENABLE(RESOURCE_LOAD_STATISTICS)
    236285    RefPtr<WebResourceLoadStatisticsStore> m_resourceLoadStatistics;
    237286    bool m_resourceLoadStatisticsDebugMode { false };
     287    bool m_resourceLoadStatisticsEnabled { false };
     288    WTF::Function<void(const String&)> m_statisticsTestingCallback;
     289#endif
    238290
    239291    Ref<WorkQueue> m_queue;
  • trunk/Source/WebKit/WebProcess/WebProcess.cpp

    r239835 r240243  
    205205    m_plugInAutoStartOriginHashes.add(PAL::SessionID::defaultSessionID(), HashMap<unsigned, WallTime>());
    206206
     207#if ENABLE(RESOURCE_LOAD_STATISTICS)
    207208    ResourceLoadObserver::shared().setNotificationCallback([this] (Vector<ResourceLoadStatistics>&& statistics) {
    208209        parentProcessConnection()->send(Messages::WebResourceLoadStatisticsStore::ResourceLoadStatisticsUpdated(WTFMove(statistics)), 0);
     
    212213        parentProcessConnection()->send(Messages::WebResourceLoadStatisticsStore::RequestStorageAccessUnderOpener(domainInNeedOfStorageAccess, openerPageID, openerDomain), 0);
    213214    });
     215#endif
    214216   
    215217    Gigacage::disableDisablingPrimitiveGigacageIfShouldBeEnabled();
     
    383385    ensureNetworkProcessConnection();
    384386
     387#if ENABLE(RESOURCE_LOAD_STATISTICS)
     388    ResourceLoadObserver::shared().setLogUserInteractionNotificationCallback([this] (PAL::SessionID sessionID, const String& topLevelOrigin) {
     389        m_networkProcessConnection->connection().send(Messages::NetworkConnectionToWebProcess::LogUserInteraction(sessionID, topLevelOrigin), 0);
     390    });
     391#endif
     392
    385393    setTerminationTimeout(parameters.terminationTimeout);
    386394
Note: See TracChangeset for help on using the changeset viewer.