Changeset 240586 in webkit


Ignore:
Timestamp:
Jan 28, 2019 9:29:44 AM (5 years ago)
Author:
Brent Fulgham
Message:

Remove the UIProcess components of the ResourceLoadStatistics code
https://bugs.webkit.org/show_bug.cgi?id=193303
<rdar://problem/47160073>

Reviewed by Chris Dumez.

Now that the ResourceLoadStatistics code is running in the NetworkProcess, we can get rid
of the UIProcess copies of these routines.

Tested by existing ResourceLoadStatistics and StorageAccess tests.

  • NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:

(WebKit::ResourceLoadStatisticsMemoryStore::updateClientSideCookiesAgeCap):

  • NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:

(WebKit::WebResourceLoadStatisticsStore::callHasStorageAccessForFrameHandler):
(WebKit::WebResourceLoadStatisticsStore::callGrantStorageAccessHandler):
(WebKit::WebResourceLoadStatisticsStore::removeAllStorageAccess):
(WebKit::WebResourceLoadStatisticsStore::setCacheMaxAgeCap):
(WebKit::WebResourceLoadStatisticsStore::callUpdatePrevalentDomainsToBlockCookiesForHandler):
(WebKit::WebResourceLoadStatisticsStore::callRemoveDomainsHandler):
(WebKit::WebResourceLoadStatisticsStore::logTestingEvent):
(WebKit::WebResourceLoadStatisticsStore::notifyResourceLoadStatisticsProcessed):
(WebKit::WebResourceLoadStatisticsStore::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores):
(WebKit::WebResourceLoadStatisticsStore::topPrivatelyControlledDomainsWithWebsiteData):
(WebKit::WebResourceLoadStatisticsStore::sendDiagnosticMessageWithValue const):
(WebKit::WebResourceLoadStatisticsStore::notifyPageStatisticsTelemetryFinished const):

  • NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
  • UIProcess/WebProcessProxy.cpp:

(WebKit::WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores): Deleted.
(WebKit::WebProcessProxy::topPrivatelyControlledDomainsWithWebsiteData): Deleted.

  • UIProcess/WebProcessProxy.h:
  • UIProcess/WebsiteData/WebsiteDataStore.cpp:

(WebKit::WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains):
(WebKit::WebsiteDataStore::removeData):
(WebKit::WebsiteDataStore::setMaxStatisticsEntries):
(WebKit::WebsiteDataStore::setPruneEntriesDownTo):
(WebKit::WebsiteDataStore::setGrandfatheringTime):
(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::setLastSeen):
(WebKit::WebsiteDataStore::setNotifyPagesWhenDataRecordsWereScanned):
(WebKit::WebsiteDataStore::setNotifyPagesWhenTelemetryWasCaptured):
(WebKit::WebsiteDataStore::hasStorageAccess):
(WebKit::WebsiteDataStore::requestStorageAccess):
(WebKit::WebsiteDataStore::grantStorageAccess):
(WebKit::WebsiteDataStore::setTimeToLiveUserInteraction):
(WebKit::WebsiteDataStore::logUserInteraction):
(WebKit::WebsiteDataStore::hasHadUserInteraction):
(WebKit::WebsiteDataStore::clearUserInteraction):
(WebKit::WebsiteDataStore::setGrandfathered):
(WebKit::WebsiteDataStore::webProcessWillOpenConnection):
(WebKit::WebsiteDataStore::webProcessDidCloseConnection):
(WebKit::WebsiteDataStore::setResourceLoadStatisticsDebugMode):
(WebKit::WebsiteDataStore::didCreateNetworkProcess):
(WebKit::WebsiteDataStore::topPrivatelyControlledDomainsWithWebsiteData): Deleted.
(WebKit::WebsiteDataStore::removeDataForTopPrivatelyControlledDomains): Deleted.
(WebKit::WebsiteDataStore::setCacheMaxAgeCap): Deleted.
(WebKit::WebsiteDataStore::updatePrevalentDomainsToBlockCookiesFor): Deleted.
(WebKit::WebsiteDataStore::setAgeCapForClientSideCookies): Deleted.
(WebKit::WebsiteDataStore::hasStorageAccessForFrameHandler): Deleted.
(WebKit::WebsiteDataStore::grantStorageAccessHandler): Deleted.
(WebKit::WebsiteDataStore::removeAllStorageAccessHandler): Deleted.
(WebKit::WebsiteDataStore::removePrevalentDomains): Deleted.
(WebKit::WebsiteDataStore::isGrandfathered): Deleted.

  • UIProcess/WebsiteData/WebsiteDataStore.h:
Location:
trunk/Source/WebKit
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r240579 r240586  
     12019-01-28  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Remove the UIProcess components of the ResourceLoadStatistics code
     4        https://bugs.webkit.org/show_bug.cgi?id=193303
     5        <rdar://problem/47160073>
     6
     7        Reviewed by Chris Dumez.
     8
     9        Now that the ResourceLoadStatistics code is running in the NetworkProcess, we can get rid
     10        of the UIProcess copies of these routines.
     11
     12        Tested by existing ResourceLoadStatistics and StorageAccess tests.
     13
     14        * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
     15        (WebKit::ResourceLoadStatisticsMemoryStore::updateClientSideCookiesAgeCap):
     16        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp:
     17        (WebKit::WebResourceLoadStatisticsStore::callHasStorageAccessForFrameHandler):
     18        (WebKit::WebResourceLoadStatisticsStore::callGrantStorageAccessHandler):
     19        (WebKit::WebResourceLoadStatisticsStore::removeAllStorageAccess):
     20        (WebKit::WebResourceLoadStatisticsStore::setCacheMaxAgeCap):
     21        (WebKit::WebResourceLoadStatisticsStore::callUpdatePrevalentDomainsToBlockCookiesForHandler):
     22        (WebKit::WebResourceLoadStatisticsStore::callRemoveDomainsHandler):
     23        (WebKit::WebResourceLoadStatisticsStore::logTestingEvent):
     24        (WebKit::WebResourceLoadStatisticsStore::notifyResourceLoadStatisticsProcessed):
     25        (WebKit::WebResourceLoadStatisticsStore::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores):
     26        (WebKit::WebResourceLoadStatisticsStore::topPrivatelyControlledDomainsWithWebsiteData):
     27        (WebKit::WebResourceLoadStatisticsStore::sendDiagnosticMessageWithValue const):
     28        (WebKit::WebResourceLoadStatisticsStore::notifyPageStatisticsTelemetryFinished const):
     29        * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h:
     30        * UIProcess/WebProcessProxy.cpp:
     31        (WebKit::WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores): Deleted.
     32        (WebKit::WebProcessProxy::topPrivatelyControlledDomainsWithWebsiteData): Deleted.
     33        * UIProcess/WebProcessProxy.h:
     34        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
     35        (WebKit::WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains):
     36        (WebKit::WebsiteDataStore::removeData):
     37        (WebKit::WebsiteDataStore::setMaxStatisticsEntries):
     38        (WebKit::WebsiteDataStore::setPruneEntriesDownTo):
     39        (WebKit::WebsiteDataStore::setGrandfatheringTime):
     40        (WebKit::WebsiteDataStore::setMinimumTimeBetweenDataRecordsRemoval):
     41        (WebKit::WebsiteDataStore::dumpResourceLoadStatistics):
     42        (WebKit::WebsiteDataStore::isPrevalentResource):
     43        (WebKit::WebsiteDataStore::setPrevalentResource):
     44        (WebKit::WebsiteDataStore::setPrevalentResourceForDebugMode):
     45        (WebKit::WebsiteDataStore::isVeryPrevalentResource):
     46        (WebKit::WebsiteDataStore::setVeryPrevalentResource):
     47        (WebKit::WebsiteDataStore::setShouldClassifyResourcesBeforeDataRecordsRemoval):
     48        (WebKit::WebsiteDataStore::setSubframeUnderTopFrameOrigin):
     49        (WebKit::WebsiteDataStore::isRegisteredAsSubFrameUnder):
     50        (WebKit::WebsiteDataStore::setSubresourceUnderTopFrameOrigin):
     51        (WebKit::WebsiteDataStore::isRegisteredAsSubresourceUnder):
     52        (WebKit::WebsiteDataStore::setSubresourceUniqueRedirectTo):
     53        (WebKit::WebsiteDataStore::setSubresourceUniqueRedirectFrom):
     54        (WebKit::WebsiteDataStore::setTopFrameUniqueRedirectTo):
     55        (WebKit::WebsiteDataStore::setTopFrameUniqueRedirectFrom):
     56        (WebKit::WebsiteDataStore::isRegisteredAsRedirectingTo):
     57        (WebKit::WebsiteDataStore::clearPrevalentResource):
     58        (WebKit::WebsiteDataStore::resetParametersToDefaultValues):
     59        (WebKit::WebsiteDataStore::submitTelemetry):
     60        (WebKit::WebsiteDataStore::scheduleClearInMemoryAndPersistent):
     61        (WebKit::WebsiteDataStore::scheduleCookieBlockingUpdate):
     62        (WebKit::WebsiteDataStore::scheduleStatisticsAndDataRecordsProcessing):
     63        (WebKit::WebsiteDataStore::setLastSeen):
     64        (WebKit::WebsiteDataStore::setNotifyPagesWhenDataRecordsWereScanned):
     65        (WebKit::WebsiteDataStore::setNotifyPagesWhenTelemetryWasCaptured):
     66        (WebKit::WebsiteDataStore::hasStorageAccess):
     67        (WebKit::WebsiteDataStore::requestStorageAccess):
     68        (WebKit::WebsiteDataStore::grantStorageAccess):
     69        (WebKit::WebsiteDataStore::setTimeToLiveUserInteraction):
     70        (WebKit::WebsiteDataStore::logUserInteraction):
     71        (WebKit::WebsiteDataStore::hasHadUserInteraction):
     72        (WebKit::WebsiteDataStore::clearUserInteraction):
     73        (WebKit::WebsiteDataStore::setGrandfathered):
     74        (WebKit::WebsiteDataStore::webProcessWillOpenConnection):
     75        (WebKit::WebsiteDataStore::webProcessDidCloseConnection):
     76        (WebKit::WebsiteDataStore::setResourceLoadStatisticsDebugMode):
     77        (WebKit::WebsiteDataStore::didCreateNetworkProcess):
     78        (WebKit::WebsiteDataStore::topPrivatelyControlledDomainsWithWebsiteData): Deleted.
     79        (WebKit::WebsiteDataStore::removeDataForTopPrivatelyControlledDomains): Deleted.
     80        (WebKit::WebsiteDataStore::setCacheMaxAgeCap): Deleted.
     81        (WebKit::WebsiteDataStore::updatePrevalentDomainsToBlockCookiesFor): Deleted.
     82        (WebKit::WebsiteDataStore::setAgeCapForClientSideCookies): Deleted.
     83        (WebKit::WebsiteDataStore::hasStorageAccessForFrameHandler): Deleted.
     84        (WebKit::WebsiteDataStore::grantStorageAccessHandler): Deleted.
     85        (WebKit::WebsiteDataStore::removeAllStorageAccessHandler): Deleted.
     86        (WebKit::WebsiteDataStore::removePrevalentDomains): Deleted.
     87        (WebKit::WebsiteDataStore::isGrandfathered): Deleted.
     88        * UIProcess/WebsiteData/WebsiteDataStore.h:
     89
    1902019-01-28  Antoine Quint  <graouts@apple.com>
    291
  • trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp

    r240498 r240586  
    11/*
    2  * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2017-2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    898898#if ENABLE(RESOURCE_LOAD_STATISTICS)
    899899    RunLoop::main().dispatch([store = makeRef(m_store), seconds = m_parameters.clientSideCookiesAgeCapTime] () {
    900         if (auto* websiteDataStore = store->websiteDataStore())
    901             websiteDataStore->setAgeCapForClientSideCookies(seconds, [] { });
    902900        if (auto* networkSession = store->networkSession())
    903901            networkSession->networkStorageSession().setAgeCapForClientSideCookies(seconds);
  • trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp

    r240498 r240586  
    4444#include "WebResourceLoadStatisticsTelemetry.h"
    4545#include "WebsiteDataFetchOption.h"
    46 #include "WebsiteDataStore.h"
    4746#include <WebCore/DiagnosticLoggingClient.h>
    4847#include <WebCore/DiagnosticLoggingKeys.h>
     
    139138}
    140139
    141 WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore(WebsiteDataStore& websiteDataStore)
    142     : m_websiteDataStore(makeWeakPtr(websiteDataStore))
    143     , m_statisticsQueue(WorkQueue::create("WebResourceLoadStatisticsStore Process Data Queue", WorkQueue::Type::Serial, WorkQueue::QOS::Utility))
    144     , m_dailyTasksTimer(RunLoop::main(), this, &WebResourceLoadStatisticsStore::performDailyTasks)
    145 {
    146     ASSERT(RunLoop::isMain());
    147 
    148     postTask([this, resourceLoadStatisticsDirectory = websiteDataStore.resolvedResourceLoadStatisticsDirectory().isolatedCopy()] {
    149         m_memoryStore = std::make_unique<ResourceLoadStatisticsMemoryStore>(*this, m_statisticsQueue);
    150         m_persistentStorage = std::make_unique<ResourceLoadStatisticsPersistentStorage>(*m_memoryStore, m_statisticsQueue, resourceLoadStatisticsDirectory);
    151     });
    152 
    153     m_dailyTasksTimer.startRepeating(24_h);
    154 }
    155 
    156140WebResourceLoadStatisticsStore::WebResourceLoadStatisticsStore(NetworkSession& networkSession, const String& resourceLoadStatisticsDirectory)
    157141    : m_networkSession(makeWeakPtr(networkSession))
     
    222206        postTaskReply(WTFMove(completionHandler));
    223207    });
    224 }
    225 
    226 void WebResourceLoadStatisticsStore::setPrevalentResourceForDebugMode(const URL& url, CompletionHandler<void()>&& completionHandler)
    227 {
    228     ASSERT(RunLoop::isMain());
    229 
    230     setPrevalentResourceForDebugMode(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler));
    231208}
    232209
     
    309286    ASSERT(RunLoop::isMain());
    310287
    311     if (m_websiteDataStore) {
    312         m_websiteDataStore->hasStorageAccessForFrameHandler(resourceDomain, firstPartyDomain, frameID, pageID, WTFMove(callback));
    313         return;
    314     }
    315 
    316288    if (m_networkSession) {
    317289        callback(m_networkSession->networkStorageSession().hasStorageAccess(resourceDomain, firstPartyDomain, frameID, pageID));
     
    404376    ASSERT(RunLoop::isMain());
    405377
    406     if (m_websiteDataStore) {
    407         m_websiteDataStore->grantStorageAccessHandler(subFramePrimaryDomain, topFramePrimaryDomain, frameID, pageID, WTFMove(callback));
    408         return;
    409     }
    410 
    411378    callback(grantStorageAccess(subFramePrimaryDomain, topFramePrimaryDomain, frameID, pageID));
    412379}
     
    426393{
    427394    ASSERT(RunLoop::isMain());
    428 
    429     if (m_websiteDataStore) {
    430         m_websiteDataStore->removeAllStorageAccessHandler(WTFMove(completionHandler));
    431         return;
    432     }
    433395
    434396    if (m_networkSession)
     
    537499}
    538500
    539 void WebResourceLoadStatisticsStore::logUserInteraction(const URL& url, CompletionHandler<void()>&& completionHandler)
    540 {
    541     ASSERT(RunLoop::isMain());
    542 
    543     if (url.protocolIsAbout() || url.isEmpty()) {
    544         completionHandler();
    545         return;
    546     }
    547 
    548     logUserInteraction(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler));
    549 }
    550 
    551501void WebResourceLoadStatisticsStore::logUserInteraction(const String& targetPrimaryDomain, CompletionHandler<void()>&& completionHandler)
    552502{
     
    560510}
    561511
    562 void WebResourceLoadStatisticsStore::clearUserInteraction(const URL& url, CompletionHandler<void()>&& completionHandler)
    563 {
    564     ASSERT(RunLoop::isMain());
    565 
    566     if (url.protocolIsAbout() || url.isEmpty()) {
    567         completionHandler();
    568         return;
    569     }
    570 
    571     clearUserInteraction(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler));
    572 }
    573 
    574512void WebResourceLoadStatisticsStore::clearUserInteraction(const String& targetPrimaryDomain, CompletionHandler<void()>&& completionHandler)
    575513{
     
    581519        postTaskReply(WTFMove(completionHandler));
    582520    });
    583 }
    584 
    585 void WebResourceLoadStatisticsStore::hasHadUserInteraction(const URL& url, CompletionHandler<void (bool)>&& completionHandler)
    586 {
    587     ASSERT(RunLoop::isMain());
    588 
    589     if (url.protocolIsAbout() || url.isEmpty()) {
    590         completionHandler(false);
    591         return;
    592     }
    593 
    594     hasHadUserInteraction(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler));
    595521}
    596522
     
    605531}
    606532
    607 void WebResourceLoadStatisticsStore::setLastSeen(const URL& url, Seconds seconds, CompletionHandler<void()>&& completionHandler)
    608 {
    609     ASSERT(RunLoop::isMain());
    610 
    611     if (url.protocolIsAbout() || url.isEmpty()) {
    612         completionHandler();
    613         return;
    614     }
    615 
    616     setLastSeen(WebCore::ResourceLoadStatistics::primaryDomain(url), seconds, WTFMove(completionHandler));
    617 }
    618 
    619533void WebResourceLoadStatisticsStore::setLastSeen(const String& resourceDomain, Seconds seconds, CompletionHandler<void()>&& completionHandler)
    620534{
     
    628542}
    629543   
    630 void WebResourceLoadStatisticsStore::setPrevalentResource(const URL& url, CompletionHandler<void()>&& completionHandler)
    631 {
    632     ASSERT(RunLoop::isMain());
    633 
    634     if (url.protocolIsAbout() || url.isEmpty()) {
    635         completionHandler();
    636         return;
    637     }
    638 
    639     setPrevalentResource(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler));
    640 }
    641 
    642544void WebResourceLoadStatisticsStore::setPrevalentResource(const String& resourceDomain, CompletionHandler<void()>&& completionHandler)
    643545{
     
    649551        postTaskReply(WTFMove(completionHandler));
    650552    });
    651 }
    652 
    653 void WebResourceLoadStatisticsStore::setVeryPrevalentResource(const URL& url, CompletionHandler<void()>&& completionHandler)
    654 {
    655     ASSERT(RunLoop::isMain());
    656 
    657     if (url.protocolIsAbout() || url.isEmpty()) {
    658         completionHandler();
    659         return;
    660     }
    661 
    662     setVeryPrevalentResource(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler));
    663553}
    664554
     
    686576}
    687577
    688 void WebResourceLoadStatisticsStore::isPrevalentResource(const URL& url, CompletionHandler<void (bool)>&& completionHandler)
    689 {
    690     ASSERT(RunLoop::isMain());
    691 
    692     if (url.protocolIsAbout() || url.isEmpty()) {
    693         completionHandler(false);
    694         return;
    695     }
    696 
    697     isPrevalentResource(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler));
    698 }
    699 
    700578void WebResourceLoadStatisticsStore::isPrevalentResource(const String& primaryDomain, CompletionHandler<void(bool)>&& completionHandler)
    701579{
     
    710588}
    711589   
    712 void WebResourceLoadStatisticsStore::isVeryPrevalentResource(const URL& url, CompletionHandler<void(bool)>&& completionHandler)
    713 {
    714     ASSERT(RunLoop::isMain());
    715 
    716     if (url.protocolIsAbout() || url.isEmpty()) {
    717         completionHandler(false);
    718         return;
    719     }
    720    
    721     isVeryPrevalentResource(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler));
    722 }
    723 
    724590void WebResourceLoadStatisticsStore::isVeryPrevalentResource(const String& primaryDomain, CompletionHandler<void(bool)>&& completionHandler)
    725591{
     
    734600}
    735601
    736 void WebResourceLoadStatisticsStore::isRegisteredAsSubresourceUnder(const URL& subresource, const URL& topFrame, CompletionHandler<void(bool)>&& completionHandler)
    737 {
    738     ASSERT(RunLoop::isMain());
    739 
    740     isRegisteredAsSubresourceUnder(WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), WTFMove(completionHandler));
    741 }
    742 
    743602void WebResourceLoadStatisticsStore::isRegisteredAsSubresourceUnder(const String& subresource, const String& topFrame, CompletionHandler<void(bool)>&& completionHandler)
    744603{
     
    753612}
    754613
    755 void WebResourceLoadStatisticsStore::isRegisteredAsSubFrameUnder(const URL& subFrame, const URL& topFrame, CompletionHandler<void (bool)>&& completionHandler)
    756 {
    757     ASSERT(RunLoop::isMain());
    758 
    759     isRegisteredAsSubFrameUnder(WebCore::ResourceLoadStatistics::primaryDomain(subFrame), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), WTFMove(completionHandler));
    760 }
    761 
    762614void WebResourceLoadStatisticsStore::isRegisteredAsSubFrameUnder(const String& subFrame, const String& topFrame, CompletionHandler<void(bool)>&& completionHandler)
    763615{
     
    772624}
    773625
    774 void WebResourceLoadStatisticsStore::isRegisteredAsRedirectingTo(const URL& hostRedirectedFrom, const URL& hostRedirectedTo, CompletionHandler<void (bool)>&& completionHandler)
    775 {
    776     ASSERT(RunLoop::isMain());
    777 
    778     isRegisteredAsRedirectingTo(WebCore::ResourceLoadStatistics::primaryDomain(hostRedirectedFrom), WebCore::ResourceLoadStatistics::primaryDomain(hostRedirectedTo), WTFMove(completionHandler));
    779 }
    780 
    781626void WebResourceLoadStatisticsStore::isRegisteredAsRedirectingTo(const String& hostRedirectedFrom, const String& hostRedirectedTo, CompletionHandler<void(bool)>&& completionHandler)
    782627{
     
    791636}
    792637
    793 void WebResourceLoadStatisticsStore::clearPrevalentResource(const URL& url, CompletionHandler<void()>&& completionHandler)
    794 {
    795     ASSERT(RunLoop::isMain());
    796 
    797     if (url.protocolIsAbout() || url.isEmpty()) {
    798         completionHandler();
    799         return;
    800     }
    801 
    802     clearPrevalentResource(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler));
    803 }
    804 
    805638void WebResourceLoadStatisticsStore::clearPrevalentResource(const String& resourceDomain, CompletionHandler<void()>&& completionHandler)
    806639{
     
    814647}
    815648
    816 void WebResourceLoadStatisticsStore::setGrandfathered(const URL& url, bool value, CompletionHandler<void()>&& completionHandler)
    817 {
    818     ASSERT(RunLoop::isMain());
    819 
    820     if (url.protocolIsAbout() || url.isEmpty())
    821         return;
    822 
    823     setGrandfathered(WebCore::ResourceLoadStatistics::primaryDomain(url), value, WTFMove(completionHandler));
    824 }
    825 
    826649void WebResourceLoadStatisticsStore::setGrandfathered(const String& domain, bool value, CompletionHandler<void()>&& completionHandler)
    827650{
     
    835658}
    836659   
    837 void WebResourceLoadStatisticsStore::isGrandfathered(const URL& url, CompletionHandler<void (bool)>&& completionHandler)
    838 {
    839     ASSERT(RunLoop::isMain());
    840 
    841     if (url.protocolIsAbout() || url.isEmpty()) {
    842         completionHandler(false);
    843         return;
    844     }
    845 
    846     isGrandfathered(WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler));
    847 }
    848 
    849660void WebResourceLoadStatisticsStore::isGrandfathered(const String& primaryDomain, CompletionHandler<void(bool)>&& completionHandler)
    850661{
     
    859670}
    860671
    861 void WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame, CompletionHandler<void()>&& completionHandler)
    862 {
    863     ASSERT(RunLoop::isMain());
    864 
    865     if (subframe.protocolIsAbout() || subframe.isEmpty() || topFrame.protocolIsAbout() || topFrame.isEmpty()) {
    866         completionHandler();
    867         return;
    868     }
    869 
    870     setSubframeUnderTopFrameOrigin(WebCore::ResourceLoadStatistics::primaryDomain(subframe), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), WTFMove(completionHandler));
    871 }
    872 
    873672void WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin(const String& subframe, const String& topFrame, CompletionHandler<void()>&& completionHandler)
    874673{
     
    882681}
    883682
    884 void WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin(const URL& subresource, const URL& topFrame, CompletionHandler<void()>&& completionHandler)
    885 {
    886     ASSERT(RunLoop::isMain());
    887 
    888     if (subresource.protocolIsAbout() || subresource.isEmpty() || topFrame.protocolIsAbout() || topFrame.isEmpty()) {
    889         completionHandler();
    890         return;
    891     }
    892 
    893     setSubresourceUnderTopFrameOrigin(WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), WTFMove(completionHandler));
    894 }
    895 
    896683void WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin(const String& subresource, const String& topFrame, CompletionHandler<void()>&& completionHandler)
    897684{
     
    905692}
    906693
    907 void WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler)
    908 {
    909     ASSERT(RunLoop::isMain());
    910 
    911     if (subresource.protocolIsAbout() || subresource.isEmpty() || hostNameRedirectedTo.protocolIsAbout() || hostNameRedirectedTo.isEmpty()) {
    912         completionHandler();
    913         return;
    914     }
    915 
    916     setSubresourceUniqueRedirectTo(WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedTo), WTFMove(completionHandler));
    917 }
    918 
    919694void WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo(const String& subresource, const String& hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler)
    920695{
     
    928703}
    929704
    930 void WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectFrom(const URL& subresource, const URL& hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler)
    931 {
    932     ASSERT(RunLoop::isMain());
    933 
    934     if (subresource.protocolIsAbout() || subresource.isEmpty() || hostNameRedirectedFrom.protocolIsAbout() || hostNameRedirectedFrom.isEmpty()) {
    935         completionHandler();
    936         return;
    937     }
    938 
    939     setSubresourceUniqueRedirectFrom(WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedFrom), WTFMove(completionHandler));
    940 }
    941 
    942705void WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectFrom(const String& subresource, const String& hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler)
    943706{
     
    951714}
    952715
    953 void WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectTo(const URL& topFrameHostName, const URL& hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler)
    954 {
    955     ASSERT(RunLoop::isMain());
    956 
    957     if (topFrameHostName.protocolIsAbout() || topFrameHostName.isEmpty() || hostNameRedirectedTo.protocolIsAbout() || hostNameRedirectedTo.isEmpty()) {
    958         completionHandler();
    959         return;
    960     }
    961 
    962     setTopFrameUniqueRedirectTo(WebCore::ResourceLoadStatistics::primaryDomain(topFrameHostName), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedTo), WTFMove(completionHandler));
    963 }
    964 
    965716void WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectTo(const String& topFrameHostName, const String& hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler)
    966717{
     
    972723        postTaskReply(WTFMove(completionHandler));
    973724    });
    974 }
    975 
    976 void WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectFrom(const URL& topFrameHostName, const URL& hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler)
    977 {
    978     ASSERT(RunLoop::isMain());
    979 
    980     if (topFrameHostName.protocolIsAbout() || topFrameHostName.isEmpty() || hostNameRedirectedFrom.protocolIsAbout() || hostNameRedirectedFrom.isEmpty()) {
    981         completionHandler();
    982         return;
    983     }
    984 
    985     setTopFrameUniqueRedirectFrom(WebCore::ResourceLoadStatistics::primaryDomain(topFrameHostName), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedFrom), WTFMove(completionHandler));
    986725}
    987726
     
    1118857    ASSERT(seconds >= 0_s);
    1119858   
    1120     if (m_websiteDataStore) {
    1121         m_websiteDataStore->setCacheMaxAgeCapForPrevalentResources(seconds, WTFMove(completionHandler));
    1122         return;
    1123     }
    1124 
    1125859    if (m_networkSession)
    1126860        m_networkSession->networkStorageSession().setCacheMaxAgeCapForPrevalentResources(seconds);
     
    1133867    ASSERT(RunLoop::isMain());
    1134868
    1135     if (m_websiteDataStore) {
    1136         m_websiteDataStore->updatePrevalentDomainsToBlockCookiesFor(domainsToBlock, WTFMove(completionHandler));
    1137         return;
    1138     }
    1139 
    1140869    if (m_networkSession)
    1141870        m_networkSession->networkStorageSession().setPrevalentDomainsToBlockCookiesFor(domainsToBlock);
     
    1154883    ASSERT(RunLoop::isMain());
    1155884
    1156     if (m_websiteDataStore)
    1157         m_websiteDataStore->removePrevalentDomains(domains);
    1158885    removePrevalentDomains(domains);
    1159886}
     
    1197924{
    1198925    ASSERT(RunLoop::isMain());
    1199 
    1200     if (m_websiteDataStore) {
    1201         m_websiteDataStore->logTestingEvent(event);
    1202         return;
    1203     }
    1204926
    1205927    if (m_networkSession)
     
    1211933    ASSERT(RunLoop::isMain());
    1212934   
    1213     if (m_websiteDataStore)
    1214         WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed();
    1215 
    1216935    if (m_networkSession)
    1217936        m_networkSession->notifyResourceLoadStatisticsProcessed();
     
    1222941    ASSERT(RunLoop::isMain());
    1223942   
    1224     if (m_websiteDataStore) {
    1225         WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(dataTypes, WTFMove(topPrivatelyControlledDomains), shouldNotifyPage, WTFMove(completionHandler));
    1226         return;
    1227     }
    1228 
    1229943    if (m_networkSession) {
    1230944        m_networkSession->deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(dataTypes, WTFMove(topPrivatelyControlledDomains), shouldNotifyPage, WTFMove(completionHandler));
     
    1239953    ASSERT(RunLoop::isMain());
    1240954   
    1241     if (m_websiteDataStore) {
    1242         WebProcessProxy::topPrivatelyControlledDomainsWithWebsiteData(dataTypes, shouldNotifyPage, WTFMove(completionHandler));
    1243         return;
    1244     }
    1245 
    1246955    if (m_networkSession) {
    1247956        m_networkSession->topPrivatelyControlledDomainsWithWebsiteData(dataTypes, shouldNotifyPage, WTFMove(completionHandler));
     
    1254963void WebResourceLoadStatisticsStore::sendDiagnosticMessageWithValue(const String& message, const String& description, unsigned value, unsigned sigDigits, WebCore::ShouldSample shouldSample) const
    1255964{
    1256     if (m_websiteDataStore) {
    1257         if (auto* webPageProxy = WebPageProxy::nonEphemeralWebPageProxy())
    1258             webPageProxy->logDiagnosticMessageWithValue(message, description, value, sigDigits, shouldSample);
    1259     }
    1260 
    1261965    if (m_networkSession)
    1262966        const_cast<WebResourceLoadStatisticsStore*>(this)->networkSession()->logDiagnosticMessageWithValue(message, description, value, sigDigits, shouldSample);
     
    1265969void WebResourceLoadStatisticsStore::notifyPageStatisticsTelemetryFinished(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins) const
    1266970{
    1267     if (m_websiteDataStore) {
    1268         API::Dictionary::MapType messageBody;
    1269         messageBody.set("TotalPrevalentResources"_s, API::UInt64::create(totalPrevalentResources));
    1270         messageBody.set("TotalPrevalentResourcesWithUserInteraction"_s, API::UInt64::create(totalPrevalentResourcesWithUserInteraction));
    1271         messageBody.set("Top3SubframeUnderTopFrameOrigins"_s, API::UInt64::create(top3SubframeUnderTopFrameOrigins));
    1272         WebProcessProxy::notifyPageStatisticsTelemetryFinished(API::Dictionary::create(messageBody).ptr());
    1273     }
    1274 
    1275971    if (m_networkSession)
    1276972        const_cast<WebResourceLoadStatisticsStore*>(this)->networkSession()->notifyPageStatisticsTelemetryFinished(totalPrevalentResources, totalPrevalentResourcesWithUserInteraction, top3SubframeUnderTopFrameOrigins);
  • trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h

    r240498 r240586  
    5656class WebFrameProxy;
    5757class WebProcessProxy;
    58 class WebsiteDataStore;
    5958enum class ShouldGrandfatherStatistics : bool;
    6059
    6160class WebResourceLoadStatisticsStore final : public ThreadSafeRefCounted<WebResourceLoadStatisticsStore, WTF::DestructionThread::Main>, public IPC::MessageReceiver {
    6261public:
    63     static Ref<WebResourceLoadStatisticsStore> create(WebsiteDataStore& websiteDataStore)
    64     {
    65         return adoptRef(*new WebResourceLoadStatisticsStore(websiteDataStore));
    66     }
    67 
    6862    static Ref<WebResourceLoadStatisticsStore> create(NetworkSession& networkSession, const String& resourceLoadStatisticsDirectory)
    6963    {
     
    9084    void logFrameNavigation(const WebFrameProxy&, const URL& pageURL, const WebCore::ResourceRequest&, const URL& redirectURL);
    9185    void logFrameNavigation(const String& targetPrimaryDomain, const String& mainFramePrimaryDomain, const String& sourcePrimaryDomain, const String& targetHost, const String& mainFrameHost, bool isRedirect, bool isMainFrame);
    92     void logUserInteraction(const URL&, CompletionHandler<void()>&&);
    9386    void logUserInteraction(const String& targetPrimaryDomain, CompletionHandler<void()>&&);
    9487    void logWebSocketLoading(const String& targetPrimaryDomain, const String& mainFramePrimaryDomain, WallTime lastSeen, CompletionHandler<void()>&&);
    9588    void logSubresourceLoading(const String& targetPrimaryDomain, const String& mainFramePrimaryDomain, WallTime lastSeen, CompletionHandler<void()>&&);
    9689    void logSubresourceRedirect(const String& sourcePrimaryDomain, const String& targetPrimaryDomain, CompletionHandler<void()>&&);
    97     void clearUserInteraction(const URL&, CompletionHandler<void()>&&);
    9890    void clearUserInteraction(const String& targetPrimaryDomain, CompletionHandler<void()>&&);
    9991    void deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType>, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&&);
    10092    void topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType>, bool shouldNotifyPage, CompletionHandler<void(HashSet<String>&&)>&&);
    10193    bool grantStorageAccess(const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID);
    102     void hasHadUserInteraction(const URL&, CompletionHandler<void(bool)>&&);
    10394    void hasHadUserInteraction(const String& resourceDomain, CompletionHandler<void(bool)>&&);
    10495    void hasStorageAccess(const String& subFrameHost, const String& topFrameHost, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback);
     
    10697    void requestStorageAccess(const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&&);
    10798    void requestUpdate();
    108     void setLastSeen(const URL&, Seconds, CompletionHandler<void()>&&);
    10999    void setLastSeen(const String& resourceDomain, Seconds, CompletionHandler<void()>&&);
    110     void setPrevalentResource(const URL&, CompletionHandler<void()>&&);
    111100    void setPrevalentResource(const String& resourceDomain, CompletionHandler<void()>&&);
    112     void setVeryPrevalentResource(const URL&, CompletionHandler<void()>&&);
    113101    void setVeryPrevalentResource(const String& resourceDomain, CompletionHandler<void()>&&);
    114102    void dumpResourceLoadStatistics(CompletionHandler<void(String)>&&);
    115     void isPrevalentResource(const URL&, CompletionHandler<void(bool)>&&);
    116103    void isPrevalentResource(const String&, CompletionHandler<void(bool)>&&);
    117     void isVeryPrevalentResource(const URL&, CompletionHandler<void(bool)>&&);
    118104    void isVeryPrevalentResource(const String&, CompletionHandler<void(bool)>&&);
    119     void isRegisteredAsSubresourceUnder(const URL& subresource, const URL& topFrame, CompletionHandler<void(bool)>&&);
    120105    void isRegisteredAsSubresourceUnder(const String& subresource, const String& topFrame, CompletionHandler<void(bool)>&&);
    121     void isRegisteredAsSubFrameUnder(const URL& subFrame, const URL& topFrame, CompletionHandler<void(bool)>&&);
    122106    void isRegisteredAsSubFrameUnder(const String& subFrame, const String& topFrame, CompletionHandler<void(bool)>&&);
    123     void isRegisteredAsRedirectingTo(const URL& hostRedirectedFrom, const URL& hostRedirectedTo, CompletionHandler<void(bool)>&&);
    124107    void isRegisteredAsRedirectingTo(const String& hostRedirectedFrom, const String& hostRedirectedTo, CompletionHandler<void(bool)>&&);
    125     void clearPrevalentResource(const URL&, CompletionHandler<void()>&&);
    126108    void clearPrevalentResource(const String&, CompletionHandler<void()>&&);
    127     void setGrandfathered(const URL&, bool, CompletionHandler<void()>&&);
    128109    void setGrandfathered(const String&, bool, CompletionHandler<void()>&&);
    129     void isGrandfathered(const URL&, CompletionHandler<void(bool)>&&);
    130110    void isGrandfathered(const String&, CompletionHandler<void(bool)>&&);
    131111    void removePrevalentDomains(const Vector<String>& domainsToBlock);
    132112    void setNotifyPagesWhenDataRecordsWereScanned(bool, CompletionHandler<void()>&&);
    133     void setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame, CompletionHandler<void()>&&);
    134113    void setSubframeUnderTopFrameOrigin(const String& subframe, const String& topFrame, CompletionHandler<void()>&&);
    135     void setSubresourceUnderTopFrameOrigin(const URL& subresource, const URL& topFrame, CompletionHandler<void()>&&);
    136114    void setSubresourceUnderTopFrameOrigin(const String& subresource, const String& topFrame, CompletionHandler<void()>&&);
    137     void setSubresourceUniqueRedirectTo(const URL& subresource, const URL& hostNameRedirectedTo, CompletionHandler<void()>&&);
    138115    void setSubresourceUniqueRedirectTo(const String& subresource, const String& hostNameRedirectedTo, CompletionHandler<void()>&&);
    139     void setSubresourceUniqueRedirectFrom(const URL& subresource, const URL& hostNameRedirectedFrom, CompletionHandler<void()>&&);
    140116    void setSubresourceUniqueRedirectFrom(const String& subresource, const String& hostNameRedirectedFrom, CompletionHandler<void()>&&);
    141     void setTopFrameUniqueRedirectTo(const URL& topFrameHostName, const URL& hostNameRedirectedTo, CompletionHandler<void()>&&);
    142117    void setTopFrameUniqueRedirectTo(const String& topFrameHostName, const String& hostNameRedirectedTo, CompletionHandler<void()>&&);
    143     void setTopFrameUniqueRedirectFrom(const URL& topFrameHostName, const URL& hostNameRedirectedFrom, CompletionHandler<void()>&&);
    144118    void setTopFrameUniqueRedirectFrom(const String& topFrameHostName, const String& hostNameRedirectedFrom, CompletionHandler<void()>&&);
    145119    void scheduleCookieBlockingUpdate(CompletionHandler<void()>&&);
     
    161135
    162136    void setResourceLoadStatisticsDebugMode(bool, CompletionHandler<void()>&&);
    163     void setPrevalentResourceForDebugMode(const URL&, CompletionHandler<void()>&&);
    164137    void setPrevalentResourceForDebugMode(const String& resourceDomain, CompletionHandler<void()>&&);
    165138
     
    175148    void notifyResourceLoadStatisticsProcessed();
    176149
    177     WebsiteDataStore* websiteDataStore() { return m_websiteDataStore.get(); }
    178150    NetworkSession* networkSession() { return m_networkSession.get(); }
    179151
     
    182154
    183155private:
    184     explicit WebResourceLoadStatisticsStore(WebsiteDataStore&);
    185156    explicit WebResourceLoadStatisticsStore(NetworkSession&, const String&);
    186157
     
    201172    void flushAndDestroyPersistentStore();
    202173
    203     WeakPtr<WebsiteDataStore> m_websiteDataStore;
    204174    WeakPtr<NetworkSession> m_networkSession;
    205175    Ref<WorkQueue> m_statisticsQueue;
  • trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp

    r240243 r240586  
    286286
    287287#if ENABLE(RESOURCE_LOAD_STATISTICS)
    288 void WebProcessProxy::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType> dataTypes, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, CompletionHandler<void (const HashSet<String>&)>&& completionHandler)
    289 {
    290     // We expect this to be called on the main thread so we get the default website data store.
    291     ASSERT(isMainThreadOrCheckDisabled());
    292    
    293     struct CallbackAggregator : ThreadSafeRefCounted<CallbackAggregator> {
    294         explicit CallbackAggregator(CompletionHandler<void(HashSet<String>)>&& completionHandler)
    295             : completionHandler(WTFMove(completionHandler))
    296         {
    297         }
    298         void addDomainsWithDeletedWebsiteData(const HashSet<String>& domains)
    299         {
    300             domainsWithDeletedWebsiteData.add(domains.begin(), domains.end());
    301         }
    302        
    303         void addPendingCallback()
    304         {
    305             ++pendingCallbacks;
    306         }
    307        
    308         void removePendingCallback()
    309         {
    310             ASSERT(pendingCallbacks);
    311             --pendingCallbacks;
    312            
    313             callIfNeeded();
    314         }
    315        
    316         void callIfNeeded()
    317         {
    318             if (!pendingCallbacks)
    319                 completionHandler(domainsWithDeletedWebsiteData);
    320         }
    321        
    322         unsigned pendingCallbacks = 0;
    323         CompletionHandler<void(HashSet<String>)> completionHandler;
    324         HashSet<String> domainsWithDeletedWebsiteData;
    325     };
    326    
    327     RefPtr<CallbackAggregator> callbackAggregator = adoptRef(new CallbackAggregator(WTFMove(completionHandler)));
    328     OptionSet<WebsiteDataFetchOption> fetchOptions = WebsiteDataFetchOption::DoNotCreateProcesses;
    329 
    330     HashSet<PAL::SessionID> visitedSessionIDs;
    331     for (auto& page : globalPageMap()) {
    332         auto& dataStore = page.value->websiteDataStore();
    333         if (!dataStore.isPersistent() || visitedSessionIDs.contains(dataStore.sessionID()))
    334             continue;
    335         visitedSessionIDs.add(dataStore.sessionID());
    336         callbackAggregator->addPendingCallback();
    337         dataStore.removeDataForTopPrivatelyControlledDomains(dataTypes, fetchOptions, topPrivatelyControlledDomains, [callbackAggregator, shouldNotifyPage, page](HashSet<String>&& domainsWithDeletedWebsiteData) {
    338             // When completing the task, we should be getting called on the main thread.
    339             ASSERT(isMainThreadOrCheckDisabled());
    340            
    341             if (shouldNotifyPage)
    342                 page.value->postMessageToInjectedBundle("WebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished", nullptr);
    343            
    344             callbackAggregator->addDomainsWithDeletedWebsiteData(WTFMove(domainsWithDeletedWebsiteData));
    345             callbackAggregator->removePendingCallback();
    346         });
    347     }
    348 }
    349 
    350 void WebProcessProxy::topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType> dataTypes, bool shouldNotifyPage, CompletionHandler<void(HashSet<String>&&)>&& completionHandler)
    351 {
    352     // We expect this to be called on the main thread so we get the default website data store.
    353     ASSERT(isMainThreadOrCheckDisabled());
    354    
    355     struct CallbackAggregator : ThreadSafeRefCounted<CallbackAggregator> {
    356         explicit CallbackAggregator(CompletionHandler<void(HashSet<String>&&)>&& completionHandler)
    357             : completionHandler(WTFMove(completionHandler))
    358         {
    359         }
    360        
    361         void addDomainsWithDeletedWebsiteData(HashSet<String>&& domains)
    362         {
    363             domainsWithDeletedWebsiteData.add(domains.begin(), domains.end());
    364         }
    365        
    366         void addPendingCallback()
    367         {
    368             ++pendingCallbacks;
    369         }
    370        
    371         void removePendingCallback()
    372         {
    373             ASSERT(pendingCallbacks);
    374             --pendingCallbacks;
    375            
    376             callIfNeeded();
    377         }
    378        
    379         void callIfNeeded()
    380         {
    381             if (!pendingCallbacks)
    382                 completionHandler(WTFMove(domainsWithDeletedWebsiteData));
    383         }
    384        
    385         unsigned pendingCallbacks = 0;
    386         CompletionHandler<void(HashSet<String>&&)> completionHandler;
    387         HashSet<String> domainsWithDeletedWebsiteData;
    388     };
    389    
    390     RefPtr<CallbackAggregator> callbackAggregator = adoptRef(new CallbackAggregator(WTFMove(completionHandler)));
    391    
    392     HashSet<PAL::SessionID> visitedSessionIDs;
    393     for (auto& page : globalPageMap().values()) {
    394         auto& dataStore = page->websiteDataStore();
    395         if (!dataStore.isPersistent() || visitedSessionIDs.contains(dataStore.sessionID()))
    396             continue;
    397         visitedSessionIDs.add(dataStore.sessionID());
    398         callbackAggregator->addPendingCallback();
    399         dataStore.topPrivatelyControlledDomainsWithWebsiteData(dataTypes, { }, [callbackAggregator, shouldNotifyPage, page = makeRef(*page)](HashSet<String>&& domainsWithDataRecords) {
    400             // When completing the task, we should be getting called on the main thread.
    401             ASSERT(isMainThreadOrCheckDisabled());
    402            
    403             if (shouldNotifyPage)
    404                 page->postMessageToInjectedBundle("WebsiteDataScanForTopPrivatelyControlledDomainsFinished", nullptr);
    405            
    406             callbackAggregator->addDomainsWithDeletedWebsiteData(WTFMove(domainsWithDataRecords));
    407             callbackAggregator->removePendingCallback();
    408         });
    409     }
    410 
    411     // FIXME: It's bizarre that this call is on WebProcessProxy and that it doesn't work if there are no visited pages.
    412     // This should actually be a function of WebsiteDataStore and it should work even if there are no WebViews instances.
    413     callbackAggregator->callIfNeeded();
    414 }
    415    
    416288void WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed()
    417289{
  • trunk/Source/WebKit/UIProcess/WebProcessProxy.h

    r240243 r240586  
    174174
    175175#if ENABLE(RESOURCE_LOAD_STATISTICS)
    176     static void deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType>, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPages, CompletionHandler<void (const HashSet<String>&)>&&);
    177     static void topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType> dataTypes, bool shouldNotifyPage, CompletionHandler<void(HashSet<String>&&)>&&);
    178 
    179176    static void notifyPageStatisticsAndDataRecordsProcessed();
    180177    static void notifyPageStatisticsTelemetryFinished(API::Object* messageBody);
  • trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp

    r240555 r240586  
    143143    platformDestroy();
    144144
    145 #if ENABLE(RESOURCE_LOAD_STATISTICS)
    146     unregisterWebResourceLoadStatisticsStoreAsMessageReceiver();
    147 #endif
    148 
    149145    if (m_sessionID.isValid() && m_sessionID != PAL::SessionID::defaultSessionID()) {
    150146        ASSERT(nonDefaultDataStores().get(m_sessionID) == this);
     
    650646    });
    651647}
    652    
    653 void WebsiteDataStore::topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType> dataTypes, OptionSet<WebsiteDataFetchOption> fetchOptions, Function<void(HashSet<String>&&)>&& completionHandler)
    654 {
    655     fetchData(dataTypes, fetchOptions, [completionHandler = WTFMove(completionHandler), protectedThis = makeRef(*this)](auto&& existingDataRecords) {
    656         HashSet<String> domainsWithDataRecords;
    657         for (auto&& dataRecord : existingDataRecords) {
    658             String domain = dataRecord.topPrivatelyControlledDomain();
    659             if (domain.isEmpty())
    660                 continue;
    661             domainsWithDataRecords.add(WTFMove(domain));
    662         }
    663         completionHandler(WTFMove(domainsWithDataRecords));
    664     });
    665 }
    666648#endif
    667649
     
    950932#if ENABLE(RESOURCE_LOAD_STATISTICS)
    951933    if (dataTypes.contains(WebsiteDataType::ResourceLoadStatistics)) {
    952         auto deletedTypesRaw = dataTypes.toRaw();
    953         auto monitoredTypesRaw = WebResourceLoadStatisticsStore::monitoredDataTypes().toRaw();
    954        
    955         // If we are deleting all of the data types that the resource load statistics store monitors
    956         // we do not need to re-grandfather old data.
    957         auto shouldGrandfather = ((monitoredTypesRaw & deletedTypesRaw) == monitoredTypesRaw) ? ShouldGrandfatherStatistics::No : ShouldGrandfatherStatistics::Yes;
    958        
    959         if (m_resourceLoadStatistics) {
    960             callbackAggregator->addPendingCallback();
    961             m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(modifiedSince, shouldGrandfather, [callbackAggregator] {
    962                 callbackAggregator->removePendingCallback();
    963             });
    964         } else if (!didNotifyNetworkProcessToDeleteWebsiteData) {
     934        if (!didNotifyNetworkProcessToDeleteWebsiteData) {
    965935            for (auto& processPool : processPools()) {
    966936                if (auto* process = processPool->networkProcess()) {
     
    12541224#endif
    12551225
    1256 #if ENABLE(RESOURCE_LOAD_STATISTICS)
    1257     // FIXME <rdar://problem/33491222>; scheduleClearInMemoryAndPersistent does not have a completion handler,
    1258     // so the completion handler for this removeData() call can be called prematurely.
    1259     if (dataTypes.contains(WebsiteDataType::ResourceLoadStatistics) && m_resourceLoadStatistics) {
    1260         auto deletedTypesRaw = dataTypes.toRaw();
    1261         auto monitoredTypesRaw = WebResourceLoadStatisticsStore::monitoredDataTypes().toRaw();
    1262 
    1263         // If we are deleting all of the data types that the resource load statistics store monitors
    1264         // we do not need to re-grandfather old data.
    1265         auto shouldGrandfather = ((monitoredTypesRaw & deletedTypesRaw) == monitoredTypesRaw) ? ShouldGrandfatherStatistics::No : ShouldGrandfatherStatistics::Yes;
    1266 
    1267         callbackAggregator->addPendingCallback();
    1268         m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(shouldGrandfather, [callbackAggregator] {
    1269             callbackAggregator->removePendingCallback();
    1270         });
    1271 
    1272         callbackAggregator->addPendingCallback();
    1273         clearResourceLoadStatisticsInWebProcesses([callbackAggregator] {
    1274             callbackAggregator->removePendingCallback();
    1275         });
    1276     }
    1277 #endif
    1278 
    12791226    // There's a chance that we don't have any pending callbacks. If so, we want to dispatch the completion handler right away.
    12801227    callbackAggregator->callIfNeeded();
     
    12821229
    12831230#if ENABLE(RESOURCE_LOAD_STATISTICS)
    1284 void WebsiteDataStore::removeDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType> dataTypes, OptionSet<WebsiteDataFetchOption> fetchOptions, const Vector<String>& topPrivatelyControlledDomains, Function<void(HashSet<String>&&)>&& completionHandler)
    1285 {
    1286     fetchDataForTopPrivatelyControlledDomains(dataTypes, fetchOptions, topPrivatelyControlledDomains, [dataTypes, completionHandler = WTFMove(completionHandler), this, protectedThis = makeRef(*this)](Vector<WebsiteDataRecord>&& websiteDataRecords, HashSet<String>&& domainsWithDataRecords) mutable {
    1287         this->removeData(dataTypes, websiteDataRecords, [domainsWithDataRecords = WTFMove(domainsWithDataRecords), completionHandler = WTFMove(completionHandler)]() mutable {
    1288             completionHandler(WTFMove(domainsWithDataRecords));
    1289         });
    1290     });
    1291 }
    1292 
    12931231void WebsiteDataStore::setMaxStatisticsEntries(size_t maximumEntryCount, CompletionHandler<void()>&& completionHandler)
    12941232{
    12951233    ASSERT(RunLoop::isMain());
    12961234
    1297     if (m_resourceLoadStatistics) {
    1298         m_resourceLoadStatistics->setMaxStatisticsEntries(maximumEntryCount, WTFMove(completionHandler));
    1299         return;
    1300     }
    1301    
    13021235    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    13031236
     
    13101243    ASSERT(RunLoop::isMain());
    13111244   
    1312     if (m_resourceLoadStatistics) {
    1313         m_resourceLoadStatistics->setPruneEntriesDownTo(pruneTargetCount, WTFMove(completionHandler));
    1314         return;
    1315     }
    1316 
    13171245    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    13181246
     
    13261254    ASSERT(RunLoop::isMain());
    13271255
    1328     if (m_resourceLoadStatistics) {
    1329         m_resourceLoadStatistics->setGrandfatheringTime(seconds, WTFMove(completionHandler));
    1330         return;
    1331     }
    1332    
    13331256    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    13341257
     
    13371260}
    13381261
    1339 void WebsiteDataStore::setCacheMaxAgeCap(Seconds seconds, CompletionHandler<void()>&& completionHandler)
    1340 {
    1341     ASSERT(RunLoop::isMain());
    1342     ASSERT(seconds >= 0_s);
    1343    
    1344     if (m_resourceLoadStatistics) {
    1345         setCacheMaxAgeCap(seconds, WTFMove(completionHandler));
    1346         return;
    1347     }
    1348 
    1349     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    1350 
    1351     for (auto& processPool : processPools())
    1352         processPool->ensureNetworkProcess().setCacheMaxAgeCap(m_sessionID, seconds, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
    1353 }
    1354 
    13551262void WebsiteDataStore::setMinimumTimeBetweenDataRecordsRemoval(Seconds seconds, CompletionHandler<void()>&& completionHandler)
    13561263{
    13571264    ASSERT(RunLoop::isMain());
    13581265
    1359     if (m_resourceLoadStatistics) {
    1360         m_resourceLoadStatistics->setMinimumTimeBetweenDataRecordsRemoval(seconds, WTFMove(completionHandler));
    1361         return;
    1362     }
    1363    
    13641266    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    13651267
     
    13721274    ASSERT(RunLoop::isMain());
    13731275
    1374     if (m_resourceLoadStatistics) {
    1375         m_resourceLoadStatistics->dumpResourceLoadStatistics(WTFMove(completionHandler));
    1376         return;
    1377     }
    1378    
    13791276    for (auto& processPool : processPools()) {
    13801277        if (auto* process = processPool->networkProcess()) {
     
    13951292    }
    13961293
    1397     if (m_resourceLoadStatistics) {
    1398         m_resourceLoadStatistics->isPrevalentResource(url, WTFMove(completionHandler));
    1399         return;
    1400     }
    1401 
    14021294    for (auto& processPool : processPools()) {
    14031295        if (auto* process = processPool->networkProcess()) {
     
    14181310    }
    14191311   
    1420     if (m_resourceLoadStatistics) {
    1421         m_resourceLoadStatistics->setPrevalentResource(url, WTFMove(completionHandler));
    1422         return;
    1423     }
    1424 
    14251312    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    14261313
     
    14391326    }
    14401327   
    1441     if (m_resourceLoadStatistics) {
    1442         m_resourceLoadStatistics->setPrevalentResourceForDebugMode(url, WTFMove(completionHandler));
    1443         return;
    1444     }
    1445    
    14461328    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    14471329   
     
    14581340    if (url.protocolIsAbout() || url.isEmpty()) {
    14591341        completionHandler(false);
    1460         return;
    1461     }
    1462    
    1463     if (m_resourceLoadStatistics) {
    1464         m_resourceLoadStatistics->isVeryPrevalentResource(url, WTFMove(completionHandler));
    14651342        return;
    14661343    }
     
    14841361    }
    14851362   
    1486     if (m_resourceLoadStatistics) {
    1487         m_resourceLoadStatistics->setVeryPrevalentResource(url, WTFMove(completionHandler));
    1488         return;
    1489     }
    1490    
    14911363    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    14921364   
     
    15011373    ASSERT(RunLoop::isMain());
    15021374   
    1503     if (m_resourceLoadStatistics) {
    1504         m_resourceLoadStatistics->setShouldClassifyResourcesBeforeDataRecordsRemoval(value, WTFMove(completionHandler));
    1505         return;
    1506     }
    1507    
    15081375    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    15091376
     
    15211388    }
    15221389
    1523     if (m_resourceLoadStatistics) {
    1524         m_resourceLoadStatistics->setSubframeUnderTopFrameOrigin(subframe, topFrame, WTFMove(completionHandler));
    1525         return;
    1526     }
    1527    
    15281390    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    15291391   
     
    15381400    ASSERT(RunLoop::isMain());
    15391401
    1540     if (m_resourceLoadStatistics) {
    1541         m_resourceLoadStatistics->isRegisteredAsSubFrameUnder(subFrame, topFrame, WTFMove(completionHandler));
    1542         return;
    1543     }
    1544    
    15451402    for (auto& processPool : processPools()) {
    15461403        if (auto* process = processPool->networkProcess()) {
     
    15611418    }
    15621419
    1563     if (m_resourceLoadStatistics) {
    1564         m_resourceLoadStatistics->setSubresourceUnderTopFrameOrigin(subresource, topFrame, WTFMove(completionHandler));
    1565         return;
    1566     }
    1567 
    15681420    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    15691421   
     
    15781430    ASSERT(RunLoop::isMain());
    15791431   
    1580     if (m_resourceLoadStatistics) {
    1581         m_resourceLoadStatistics->isRegisteredAsSubresourceUnder(subresource, topFrame, WTFMove(completionHandler));
    1582         return;
    1583     }
    1584 
    15851432    for (auto& processPool : processPools()) {
    15861433        if (auto* process = processPool->networkProcess()) {
     
    16011448    }
    16021449
    1603     if (m_resourceLoadStatistics) {
    1604         m_resourceLoadStatistics->setSubresourceUniqueRedirectTo(subresource, hostNameRedirectedTo, WTFMove(completionHandler));
    1605         return;
    1606     }
    1607    
    16081450    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    16091451   
     
    16231465    }
    16241466
    1625     if (m_resourceLoadStatistics) {
    1626         m_resourceLoadStatistics->setSubresourceUniqueRedirectFrom(subresource, hostNameRedirectedFrom, WTFMove(completionHandler));
    1627         return;
    1628     }
    1629    
    16301467    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    16311468   
     
    16451482    }
    16461483
    1647     if (m_resourceLoadStatistics) {
    1648         m_resourceLoadStatistics->setTopFrameUniqueRedirectTo(topFrameHostName, hostNameRedirectedTo, WTFMove(completionHandler));
    1649         return;
    1650     }
    1651    
    16521484    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    16531485   
     
    16671499    }
    16681500
    1669     if (m_resourceLoadStatistics) {
    1670         m_resourceLoadStatistics->setTopFrameUniqueRedirectFrom(topFrameHostName, hostNameRedirectedFrom, WTFMove(completionHandler));
    1671         return;
    1672     }
    1673    
    16741501    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    16751502   
     
    16841511    ASSERT(RunLoop::isMain());
    16851512   
    1686     if (m_resourceLoadStatistics) {
    1687         m_resourceLoadStatistics->isRegisteredAsRedirectingTo(hostRedirectedFrom, hostRedirectedTo, WTFMove(completionHandler));
    1688         return;
    1689     }
    1690 
    16911513    for (auto& processPool : processPools()) {
    16921514        if (auto* process = processPool->networkProcess()) {
     
    17071529    }
    17081530
    1709     if (m_resourceLoadStatistics) {
    1710         m_resourceLoadStatistics->clearPrevalentResource(url, WTFMove(completionHandler));
    1711         return;
    1712     }
    1713 
    17141531    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    17151532
     
    17251542    ASSERT(RunLoop::isMain());
    17261543
    1727     if (m_resourceLoadStatistics) {
    1728         m_resourceLoadStatistics->resetParametersToDefaultValues(WTFMove(completionHandler));
    1729         return;
    1730     }
    1731 
    17321544    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    17331545   
     
    17421554    ASSERT(RunLoop::isMain());
    17431555   
    1744     if (m_resourceLoadStatistics) {
    1745         m_resourceLoadStatistics->submitTelemetry([] { });
    1746         return;
    1747     }
    1748    
    17491556    for (auto& processPool : processPools()) {
    17501557        if (auto* process = processPool->networkProcess())
     
    17571564    ASSERT(RunLoop::isMain());
    17581565   
    1759     if (m_resourceLoadStatistics) {
    1760         m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(modifiedSince, shouldGrandfather, WTFMove(completionHandler));
    1761         return;
    1762     }
    1763    
    17641566    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    17651567
     
    17741576    ASSERT(RunLoop::isMain());
    17751577   
    1776     if (m_resourceLoadStatistics) {
    1777         m_resourceLoadStatistics->scheduleClearInMemoryAndPersistent(shouldGrandfather, WTFMove(completionHandler));
    1778         return;
    1779     }
    1780 
    17811578    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    17821579
     
    17891586void WebsiteDataStore::scheduleCookieBlockingUpdate(CompletionHandler<void()>&& completionHandler)
    17901587{
    1791     if (m_resourceLoadStatistics) {
    1792         m_resourceLoadStatistics->scheduleCookieBlockingUpdate(WTFMove(completionHandler));
    1793         return;
    1794     }
    1795 
    17961588    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    17971589
     
    18061598    ASSERT(RunLoop::isMain());
    18071599   
    1808     if (m_resourceLoadStatistics) {
    1809         m_resourceLoadStatistics->scheduleStatisticsAndDataRecordsProcessing(WTFMove(completionHandler));
    1810         return;
    1811     }
    1812    
    18131600    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    18141601   
     
    18191606}
    18201607
    1821 #if ENABLE(RESOURCE_LOAD_STATISTICS)
    1822 void WebsiteDataStore::updatePrevalentDomainsToBlockCookiesFor(const Vector<String>& domainsToBlock, CompletionHandler<void()>&& completionHandler)
    1823 {
    1824     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    1825 
    1826     for (auto& processPool : processPools()) {
    1827         if (auto* process = processPool->networkProcess())
    1828             process->updatePrevalentDomainsToBlockCookiesFor(m_sessionID, domainsToBlock, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
    1829     }
    1830 }
    1831 #endif
    1832 
    1833 void WebsiteDataStore::setAgeCapForClientSideCookies(Optional<Seconds> seconds, CompletionHandler<void()>&& completionHandler)
    1834 {
    1835     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    1836    
    1837     for (auto& processPool : processPools())
    1838         processPool->ensureNetworkProcess().setAgeCapForClientSideCookies(m_sessionID, seconds, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
    1839 }
    1840 
    18411608void WebsiteDataStore::setLastSeen(const URL& url, Seconds seconds, CompletionHandler<void()>&& completionHandler)
    18421609{
     
    18461613    }
    18471614
    1848     if (m_resourceLoadStatistics) {
    1849         m_resourceLoadStatistics->setLastSeen(url, seconds, WTFMove(completionHandler));
    1850         return;
    1851     }
    1852 
    18531615    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    18541616
     
    18621624void WebsiteDataStore::setNotifyPagesWhenDataRecordsWereScanned(bool value, CompletionHandler<void()>&& completionHandler)
    18631625{
    1864     if (m_resourceLoadStatistics) {
    1865         m_resourceLoadStatistics->setNotifyPagesWhenDataRecordsWereScanned(value, WTFMove(completionHandler));
    1866         return;
    1867     }
    1868 
    18691626    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    18701627
     
    18751632void WebsiteDataStore::setNotifyPagesWhenTelemetryWasCaptured(bool value, CompletionHandler<void()>&& completionHandler)
    18761633{
    1877     if (m_resourceLoadStatistics) {
    1878         m_resourceLoadStatistics->setNotifyPagesWhenTelemetryWasCaptured(value, WTFMove(completionHandler));
    1879         return;
    1880     }
    1881    
    18821634    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    18831635   
     
    18861638}
    18871639
    1888 void WebsiteDataStore::hasStorageAccessForFrameHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool hasAccess)>&& completionHandler)
    1889 {
     1640void WebsiteDataStore::getAllStorageAccessEntries(uint64_t pageID, CompletionHandler<void(Vector<String>&& domains)>&& completionHandler)
     1641{
     1642    auto* webPage = WebProcessProxy::webPage(pageID);
     1643    if (!webPage) {
     1644        completionHandler({ });
     1645        return;
     1646    }
     1647   
     1648    auto& networkProcess = webPage->process().processPool().ensureNetworkProcess();
     1649    networkProcess.getAllStorageAccessEntries(m_sessionID, WTFMove(completionHandler));
     1650}
     1651
     1652void WebsiteDataStore::hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler)
     1653{
     1654    if (!resourceLoadStatisticsEnabled()) {
     1655        completionHandler(false);
     1656        return;
     1657    }
     1658
    18901659    auto* webPage = WebProcessProxy::webPage(pageID);
    18911660    if (!webPage) {
     
    18941663    }
    18951664
    1896     auto& networkProcess = webPage->process().processPool().ensureNetworkProcess();
    1897     networkProcess.hasStorageAccessForFrame(m_sessionID, resourceDomain, firstPartyDomain, frameID, pageID, WTFMove(completionHandler));
    1898 }
    1899 
    1900 void WebsiteDataStore::getAllStorageAccessEntries(uint64_t pageID, CompletionHandler<void(Vector<String>&& domains)>&& completionHandler)
    1901 {
     1665    if (auto networkProcess = webPage->process().processPool().networkProcess())
     1666        networkProcess->hasStorageAccess(m_sessionID, WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, WTFMove(completionHandler));
     1667}
     1668
     1669void WebsiteDataStore::requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&& completionHandler)
     1670{
     1671    if (!resourceLoadStatisticsEnabled()) {
     1672        completionHandler(StorageAccessStatus::CannotRequestAccess);
     1673        return;
     1674    }
     1675   
    19021676    auto* webPage = WebProcessProxy::webPage(pageID);
    19031677    if (!webPage) {
    1904         completionHandler({ });
    1905         return;
    1906     }
    1907    
    1908     auto& networkProcess = webPage->process().processPool().ensureNetworkProcess();
    1909     networkProcess.getAllStorageAccessEntries(m_sessionID, WTFMove(completionHandler));
    1910 }
    1911 
    1912 void WebsiteDataStore::grantStorageAccessHandler(const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool wasGranted)>&& completionHandler)
    1913 {
     1678        completionHandler(StorageAccessStatus::CannotRequestAccess);
     1679        return;
     1680    }
     1681
     1682    if (auto networkProcess = webPage->process().processPool().networkProcess())
     1683        networkProcess->requestStorageAccess(m_sessionID, WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, promptEnabled, WTFMove(completionHandler));
     1684}
     1685
     1686void WebsiteDataStore::grantStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPrompted, CompletionHandler<void(bool)>&& completionHandler)
     1687{
     1688    if (!resourceLoadStatisticsEnabled()) {
     1689        completionHandler(false);
     1690        return;
     1691    }
     1692   
    19141693    auto* webPage = WebProcessProxy::webPage(pageID);
    19151694    if (!webPage) {
     
    19181697    }
    19191698
    1920     auto& networkProcess = webPage->process().processPool().ensureNetworkProcess();
    1921     networkProcess.grantStorageAccess(m_sessionID, resourceDomain, firstPartyDomain, frameID, pageID, false, WTFMove(completionHandler));
    1922 }
    1923 
    1924 void WebsiteDataStore::removeAllStorageAccessHandler(CompletionHandler<void()>&& completionHandler)
    1925 {
    1926     auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    1927    
    1928     for (auto& processPool : processPools()) {
    1929         if (auto networkProcess = processPool->networkProcess())
    1930             networkProcess->removeAllStorageAccess(m_sessionID, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });
    1931     }
    1932 }
    1933 
    1934 void WebsiteDataStore::removePrevalentDomains(const Vector<String>& domains)
    1935 {
    1936     for (auto& processPool : processPools())
    1937         processPool->sendToNetworkingProcess(Messages::NetworkProcess::RemovePrevalentDomains(m_sessionID, domains));
    1938 }
    1939 
    1940 void WebsiteDataStore::hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler)
    1941 {
    1942     if (!resourceLoadStatisticsEnabled()) {
    1943         completionHandler(false);
    1944         return;
    1945     }
    1946 
    1947     if (m_resourceLoadStatistics) {
    1948         m_resourceLoadStatistics->hasStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, WTFMove(completionHandler));
    1949         return;
    1950     }
    1951 
    1952     auto* webPage = WebProcessProxy::webPage(pageID);
    1953     if (!webPage) {
    1954         completionHandler(false);
    1955         return;
    1956     }
    1957 
    1958     if (auto networkProcess = webPage->process().processPool().networkProcess())
    1959         networkProcess->hasStorageAccess(m_sessionID, WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, WTFMove(completionHandler));
    1960 }
    1961 
    1962 void WebsiteDataStore::requestStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&& completionHandler)
    1963 {
    1964     if (!resourceLoadStatisticsEnabled()) {
    1965         completionHandler(StorageAccessStatus::CannotRequestAccess);
    1966         return;
    1967     }
    1968    
    1969     if (m_resourceLoadStatistics) {
    1970         m_resourceLoadStatistics->requestStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, promptEnabled, WTFMove(completionHandler));
    1971         return;
    1972     }
    1973 
    1974     auto* webPage = WebProcessProxy::webPage(pageID);
    1975     if (!webPage) {
    1976         completionHandler(StorageAccessStatus::CannotRequestAccess);
    1977         return;
    1978     }
    1979 
    1980     if (auto networkProcess = webPage->process().processPool().networkProcess())
    1981         networkProcess->requestStorageAccess(m_sessionID, WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, promptEnabled, WTFMove(completionHandler));
    1982 }
    1983 
    1984 void WebsiteDataStore::grantStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPrompted, CompletionHandler<void(bool)>&& completionHandler)
    1985 {
    1986     if (!resourceLoadStatisticsEnabled()) {
    1987         completionHandler(false);
    1988         return;
    1989     }
    1990    
    1991     if (m_resourceLoadStatistics) {
    1992         m_resourceLoadStatistics->grantStorageAccess(WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, userWasPrompted, WTFMove(completionHandler));
    1993         return;
    1994     }
    1995 
    1996     auto* webPage = WebProcessProxy::webPage(pageID);
    1997     if (!webPage) {
    1998         completionHandler(false);
    1999         return;
    2000     }
    2001 
    20021699    if (auto networkProcess = webPage->process().processPool().networkProcess())
    20031700        networkProcess->grantStorageAccess(m_sessionID, WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, userWasPrompted, WTFMove(completionHandler));
     
    20061703void WebsiteDataStore::setTimeToLiveUserInteraction(Seconds seconds, CompletionHandler<void()>&& completionHandler)
    20071704{
    2008     if (m_resourceLoadStatistics) {
    2009         m_resourceLoadStatistics->setTimeToLiveUserInteraction(seconds, WTFMove(completionHandler));
    2010         return;
    2011     }
    2012 
    20131705    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    20141706   
     
    20261718    }
    20271719   
    2028     if (m_resourceLoadStatistics) {
    2029         m_resourceLoadStatistics->logUserInteraction(url, WTFMove(completionHandler));
    2030         return;
    2031     }
    2032 
    20331720    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    20341721
     
    20451732    if (url.protocolIsAbout() || url.isEmpty()) {
    20461733        completionHandler(false);
    2047         return;
    2048     }
    2049    
    2050     if (m_resourceLoadStatistics) {
    2051         m_resourceLoadStatistics->hasHadUserInteraction(url, WTFMove(completionHandler));
    20521734        return;
    20531735    }
     
    20711753    }
    20721754   
    2073     if (m_resourceLoadStatistics) {
    2074         m_resourceLoadStatistics->clearUserInteraction(url, WTFMove(completionHandler));
    2075         return;
    2076     }
    2077    
    20781755    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    20791756
     
    20841761}
    20851762
    2086 void WebsiteDataStore::isGrandfathered(const URL& url, CompletionHandler<void(bool)>&& completionHandler)
    2087 {
    2088     ASSERT(RunLoop::isMain());
    2089    
    2090     if (url.protocolIsAbout() || url.isEmpty()) {
    2091         completionHandler(false);
    2092         return;
    2093     }
    2094    
    2095     if (m_resourceLoadStatistics) {
    2096         m_resourceLoadStatistics->isGrandfathered(url, WTFMove(completionHandler));
    2097         return;
    2098     }
    2099    
    2100     for (auto& processPool : processPools()) {
    2101         if (auto* process = processPool->networkProcess()) {
    2102             process->isGrandfathered(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler));
    2103             ASSERT(processPools().size() == 1);
    2104             break;
    2105         }
    2106     }
    2107 }
    2108 
    21091763void WebsiteDataStore::setGrandfathered(const URL& url, bool isGrandfathered, CompletionHandler<void()>&& completionHandler)
    21101764{
     
    21131767    if (url.protocolIsAbout() || url.isEmpty()) {
    21141768        completionHandler();
    2115         return;
    2116     }
    2117    
    2118     if (m_resourceLoadStatistics) {
    2119         m_resourceLoadStatistics->setGrandfathered(url, isGrandfathered, WTFMove(completionHandler));
    21201769        return;
    21211770    }
     
    21731822    if (m_storageManager)
    21741823        m_storageManager->processWillOpenConnection(webProcessProxy, connection);
    2175 
    2176 #if ENABLE(RESOURCE_LOAD_STATISTICS)
    2177     if (m_resourceLoadStatistics)
    2178         webProcessProxy.addMessageReceiver(Messages::WebResourceLoadStatisticsStore::messageReceiverName(), *m_resourceLoadStatistics);
    2179 #endif
    21801824}
    21811825
     
    21941838void WebsiteDataStore::webProcessDidCloseConnection(WebProcessProxy& webProcessProxy, IPC::Connection& connection)
    21951839{
    2196 #if ENABLE(RESOURCE_LOAD_STATISTICS)
    2197     if (m_resourceLoadStatistics)
    2198         webProcessProxy.removeMessageReceiver(Messages::WebResourceLoadStatisticsStore::messageReceiverName());
    2199 #endif
    2200 
    22011840    if (m_storageManager)
    22021841        m_storageManager->processDidCloseConnection(webProcessProxy, connection);
     
    23551994#if ENABLE(RESOURCE_LOAD_STATISTICS)
    23561995    m_resourceLoadStatisticsDebugMode = enabled;
    2357     if (m_resourceLoadStatistics) {
    2358         m_resourceLoadStatistics->setResourceLoadStatisticsDebugMode(enabled, WTFMove(completionHandler));
    2359         return;
    2360     }
    2361    
     1996
    23621997    auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler));
    23631998   
     
    23712006
    23722007#if ENABLE(RESOURCE_LOAD_STATISTICS)
    2373 void WebsiteDataStore::unregisterWebResourceLoadStatisticsStoreAsMessageReceiver()
    2374 {
    2375     if (!m_resourceLoadStatistics)
    2376         return;
    2377 
    2378     for (auto* webProcessProxy : processes())
    2379         webProcessProxy->removeMessageReceiver(Messages::WebResourceLoadStatisticsStore::messageReceiverName());
    2380 }
    2381 
    2382 void WebsiteDataStore::registerWebResourceLoadStatisticsStoreAsMessageReceiver()
    2383 {
    2384     ASSERT(m_resourceLoadStatistics);
    2385     if (!m_resourceLoadStatistics)
    2386         return;
    2387 
    2388     for (auto* webProcessProxy : processes())
    2389         webProcessProxy->addMessageReceiver(Messages::WebResourceLoadStatisticsStore::messageReceiverName(), *m_resourceLoadStatistics);
    2390 }
    2391 
    23922008void WebsiteDataStore::enableResourceLoadStatisticsAndSetTestingCallback(Function<void (const String&)>&& callback)
    23932009{
     
    24922108void WebsiteDataStore::didCreateNetworkProcess()
    24932109{
    2494 #if ENABLE(RESOURCE_LOAD_STATISTICS)
    2495     if (m_resourceLoadStatistics)
    2496         m_resourceLoadStatistics->didCreateNetworkProcess();
    2497 #endif
    2498 }
    2499 
    2500 }
     2110}
     2111
     2112}
  • trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h

    r240555 r240586  
    120120#if ENABLE(RESOURCE_LOAD_STATISTICS)
    121121    void fetchDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, const Vector<String>& topPrivatelyControlledDomains, Function<void(Vector<WebsiteDataRecord>&&, HashSet<String>&&)>&& completionHandler);
    122     void topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType> dataTypes, OptionSet<WebsiteDataFetchOption> fetchOptions, Function<void(HashSet<String>&&)>&& completionHandler);
    123     void removeDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, const Vector<String>& topPrivatelyControlledDomains, Function<void(HashSet<String>&&)>&& completionHandler);
    124122
    125123    void clearPrevalentResource(const URL&, CompletionHandler<void()>&&);
    126124    void clearUserInteraction(const URL&, CompletionHandler<void()>&&);
    127     void deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType>, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPages, CompletionHandler<void(const HashSet<String>&)>&&);
    128125    void dumpResourceLoadStatistics(CompletionHandler<void(const String&)>&&);
    129126    void logTestingEvent(const String&);
    130127    void logUserInteraction(const URL&, CompletionHandler<void()>&&);
    131     void updatePrevalentDomainsToBlockCookiesFor(const Vector<String>& domainsToBlock, CompletionHandler<void()>&&);
    132     void setAgeCapForClientSideCookies(Optional<Seconds>, CompletionHandler<void()>&&);
    133     void hasStorageAccessForFrameHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool hasAccess)>&&);
    134128    void getAllStorageAccessEntries(uint64_t pageID, CompletionHandler<void(Vector<String>&& domains)>&&);
    135     void grantStorageAccessHandler(const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool wasGranted)>&&);
    136129    void hasHadUserInteraction(const URL&, CompletionHandler<void(bool)>&&);
    137     void isGrandfathered(const URL&, CompletionHandler<void(bool)>&&);
    138130    void isPrevalentResource(const URL&, CompletionHandler<void(bool)>&&);
    139131    void isRegisteredAsRedirectingTo(const URL& hostRedirectedFrom, const URL& hostRedirectedTo, CompletionHandler<void(bool)>&&);
     
    141133    void isRegisteredAsSubFrameUnder(const URL& subFrame, const URL& topFrame, CompletionHandler<void(bool)>&&);
    142134    void isVeryPrevalentResource(const URL&, CompletionHandler<void(bool)>&&);
    143     void removeAllStorageAccessHandler(CompletionHandler<void()>&&);
    144     void removePrevalentDomains(const Vector<String>& domains);
    145135    void resetParametersToDefaultValues(CompletionHandler<void()>&&);
    146136    void scheduleCookieBlockingUpdate(CompletionHandler<void()>&&);
     
    149139    void scheduleStatisticsAndDataRecordsProcessing(CompletionHandler<void()>&&);
    150140    void submitTelemetry();
    151     void setCacheMaxAgeCap(Seconds, CompletionHandler<void()>&&);
    152141    void setGrandfathered(const URL&, bool, CompletionHandler<void()>&&);
    153142    void setGrandfatheringTime(Seconds, CompletionHandler<void()>&&);
     
    261250    static void platformRemoveRecentSearches(WallTime);
    262251
    263 #if ENABLE(RESOURCE_LOAD_STATISTICS)
    264     void registerWebResourceLoadStatisticsStoreAsMessageReceiver();
    265     void unregisterWebResourceLoadStatisticsStoreAsMessageReceiver();
    266 #endif
    267 
    268252    HashSet<RefPtr<WebProcessPool>> processPools(size_t count = std::numeric_limits<size_t>::max(), bool ensureAPoolExists = true) const;
    269253
Note: See TracChangeset for help on using the changeset viewer.