Changeset 242056 in webkit
- Timestamp:
- Feb 25, 2019, 1:52:56 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 48 edited
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/WebCore.xcodeproj/project.pbxproj (modified) (4 diffs)
-
Source/WebCore/dom/Document.cpp (modified) (1 diff)
-
Source/WebCore/dom/Document.h (modified) (3 diffs)
-
Source/WebCore/html/HTMLAnchorElement.cpp (modified) (2 diffs)
-
Source/WebCore/html/HTMLMediaElement.cpp (modified) (2 diffs)
-
Source/WebCore/loader/AdClickAttribution.cpp (modified) (3 diffs)
-
Source/WebCore/loader/AdClickAttribution.h (modified) (9 diffs)
-
Source/WebCore/loader/ResourceLoadObserver.cpp (modified) (23 diffs)
-
Source/WebCore/loader/ResourceLoadObserver.h (modified) (4 diffs)
-
Source/WebCore/loader/ResourceLoadStatistics.cpp (modified) (5 diffs)
-
Source/WebCore/loader/ResourceLoadStatistics.h (modified) (4 diffs)
-
Source/WebCore/page/Page.cpp (modified) (2 diffs)
-
Source/WebCore/page/Page.h (modified) (2 diffs)
-
Source/WebCore/page/PerformanceMonitor.cpp (modified) (2 diffs)
-
Source/WebCore/platform/RegistrableDomain.h (added)
-
Source/WebCore/platform/network/NetworkStorageSession.cpp (modified) (6 diffs)
-
Source/WebCore/platform/network/NetworkStorageSession.h (modified) (3 diffs)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp (modified) (40 diffs)
-
Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h (modified) (8 diffs)
-
Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp (modified) (30 diffs)
-
Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h (modified) (5 diffs)
-
Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp (modified) (4 diffs)
-
Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h (modified) (3 diffs)
-
Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in (modified) (1 diff)
-
Source/WebKit/NetworkProcess/NetworkProcess.cpp (modified) (28 diffs)
-
Source/WebKit/NetworkProcess/NetworkProcess.h (modified) (5 diffs)
-
Source/WebKit/NetworkProcess/NetworkProcess.messages.in (modified) (3 diffs)
-
Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp (modified) (2 diffs)
-
Source/WebKit/NetworkProcess/NetworkSession.cpp (modified) (1 diff)
-
Source/WebKit/NetworkProcess/NetworkSession.h (modified) (2 diffs)
-
Source/WebKit/Shared/WebCoreArgumentCoders.cpp (modified) (3 diffs)
-
Source/WebKit/UIProcess/Cocoa/ResourceLoadStatisticsMemoryStoreCocoa.mm (modified) (2 diffs)
-
Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (modified) (28 diffs)
-
Source/WebKit/UIProcess/Network/NetworkProcessProxy.h (modified) (1 diff)
-
Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in (modified) (1 diff)
-
Source/WebKit/UIProcess/WebPageProxy.cpp (modified) (2 diffs)
-
Source/WebKit/UIProcess/WebProcessProxy.cpp (modified) (1 diff)
-
Source/WebKit/UIProcess/WebProcessProxy.h (modified) (1 diff)
-
Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.messages.in (modified) (1 diff)
-
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (modified) (29 diffs)
-
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h (modified) (2 diffs)
-
Source/WebKit/WebProcess/WebPage/WebPage.cpp (modified) (3 diffs)
-
Source/WebKit/WebProcess/WebProcess.cpp (modified) (3 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (modified) (4 diffs)
-
Tools/TestWebKitAPI/Tests/WebCore/AdClickAttribution.cpp (modified) (2 diffs)
-
Tools/TestWebKitAPI/Tests/WebCore/RegistrableDomain.cpp (added)
-
Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r242051 r242056 1 2019-02-25 John Wilander <wilander@apple.com> 2 3 Introduce and adopt new class RegistrableDomain for eTLD+1 4 https://bugs.webkit.org/show_bug.cgi?id=194791 5 <rdar://problem/48179240> 6 7 Reviewed by Alex Christensen, Fujii Hironori, and Brent Fulgham. 8 9 A new API test was added. Plenty of existing layout tests under 10 http/tests/resourceLoadStatistics/ and http/tests/storageAccess/ test the code. 11 12 This patch introduces and adopts a new class called WebCore::RegistrableDomain 13 which represents a domain's eTLD+1 (effective top level domain plus one) and is 14 the basis for the term "site," as in same-site. Other popular names include 15 high-level domain, primary domain, and top privately controlled/owned domain. 16 Effective top level domains are enumerated on the Public Suffix List 17 (https://publicsuffix.org). 18 19 This class just uses the full domain for when the Public Suffix List cannot help 20 finding the registrable domain and for WebKit ports that haven't enabled 21 PUBLIC_SUFFIX_LIST. It also uses the string "nullOrigin" as a representation 22 for the null or unique origin (this matches how these origins were handled 23 before). 24 25 The implementation is a wrapper around a String and the functions and class 26 members that now make use of this new class used to handle regular String 27 objects which didn't help much in terms of type safety or guarantees that the 28 string had already been converted to an eTLD+1. 29 30 We've at least two bad bugs in the Storage Access API because of confusion 31 between a URL's eTLD+1 and its host. The usage of WebCore::RegistrableDomain 32 will prohibit such bugs in the future. 33 34 Partitioning in WebKit also uses eTLD+1 to a large extent. I plan to adopt 35 WebCore::RegistrableDomain for partitioning in a later patch. 36 37 This patch also enhances parameter naming by: 38 - Removing parts that refer to "primary" as in primaryDomain. 39 - Replacing references to "TopPrivatelyControlledDomain" with "RegistrableDomain." 40 - Replacing references to "TopPrivatelyOwnedDomain" with "RegistrableDomain." 41 - Using the term "domain" consistently instead of e.g. "host." 42 43 * WebCore.xcodeproj/project.pbxproj: 44 * dom/Document.cpp: 45 (WebCore::Document::hasRequestedPageSpecificStorageAccessWithUserInteraction): 46 (WebCore::Document::setHasRequestedPageSpecificStorageAccessWithUserInteraction): 47 * dom/Document.h: 48 * html/HTMLAnchorElement.cpp: 49 (WebCore::HTMLAnchorElement::parseAdClickAttribution const): 50 * html/HTMLMediaElement.cpp: 51 (WebCore::HTMLMediaElement::mediaSessionTitle const): 52 * loader/AdClickAttribution.cpp: 53 (WebCore::AdClickAttribution::url const): 54 (WebCore::AdClickAttribution::referrer const): 55 (WebCore::AdClickAttribution::toString const): 56 * loader/AdClickAttribution.h: 57 (WebCore::AdClickAttribution::Source::Source): 58 (WebCore::AdClickAttribution::Source::matches const): 59 (WebCore::AdClickAttribution::Source::deleteValue): 60 (WebCore::AdClickAttribution::Destination::Destination): 61 (WebCore::AdClickAttribution::Destination::matches const): 62 (WebCore::AdClickAttribution::Destination::deleteValue): 63 * loader/ResourceLoadObserver.cpp: 64 (WebCore::ResourceLoadObserver::setRequestStorageAccessUnderOpenerCallback): 65 (WebCore::ResourceLoadObserver::setLogUserInteractionNotificationCallback): 66 (WebCore::ResourceLoadObserver::setLogWebSocketLoadingNotificationCallback): 67 (WebCore::ResourceLoadObserver::setLogSubresourceLoadingNotificationCallback): 68 (WebCore::ResourceLoadObserver::setLogSubresourceRedirectNotificationCallback): 69 (WebCore::ResourceLoadObserver::logSubresourceLoading): 70 (WebCore::ResourceLoadObserver::logWebSocketLoading): 71 (WebCore::ResourceLoadObserver::logUserInteractionWithReducedTimeResolution): 72 (WebCore::ResourceLoadObserver::requestStorageAccessUnderOpener): 73 (WebCore::ResourceLoadObserver::logFontLoad): 74 (WebCore::ResourceLoadObserver::logCanvasRead): 75 (WebCore::ResourceLoadObserver::logCanvasWriteOrMeasure): 76 (WebCore::ResourceLoadObserver::logNavigatorAPIAccessed): 77 (WebCore::ResourceLoadObserver::logScreenAPIAccessed): 78 (WebCore::ResourceLoadObserver::ensureResourceStatisticsForRegistrableDomain): 79 (WebCore::ResourceLoadObserver::statisticsForOrigin): 80 (WebCore::primaryDomain): Deleted. 81 (WebCore::ResourceLoadObserver::ensureResourceStatisticsForPrimaryDomain): Deleted. 82 * loader/ResourceLoadObserver.h: 83 * loader/ResourceLoadStatistics.cpp: 84 (WebCore::ResourceLoadStatistics::encode const): 85 (WebCore::ResourceLoadStatistics::decode): 86 (WebCore::ResourceLoadStatistics::toString const): 87 (WebCore::ResourceLoadStatistics::merge): 88 (WebCore::ResourceLoadStatistics::primaryDomain): Deleted. 89 * loader/ResourceLoadStatistics.h: 90 (WebCore::ResourceLoadStatistics::ResourceLoadStatistics): 91 * page/Page.cpp: 92 (WebCore::Page::logNavigation): 93 (WebCore::Page::mainFrameLoadStarted): 94 * page/Page.h: 95 * page/PerformanceMonitor.cpp: 96 (WebCore::reportPageOverPostLoadResourceThreshold): 97 * platform/RegistrableDomain.h: Added. 98 (WebCore::RegistrableDomain::RegistrableDomain): 99 (WebCore::RegistrableDomain::isEmpty const): 100 (WebCore::RegistrableDomain::string const): 101 (WebCore::RegistrableDomain::operator!= const): 102 (WebCore::RegistrableDomain::operator== const): 103 (WebCore::RegistrableDomain::matches const): 104 (WebCore::RegistrableDomain::isolatedCopy const): 105 (WebCore::RegistrableDomain::isHashTableDeletedValue const): 106 (WebCore::RegistrableDomain::hash const): 107 (WebCore::RegistrableDomain::RegistrableDomainHash::hash): 108 (WebCore::RegistrableDomain::RegistrableDomainHash::equal): 109 (WebCore::RegistrableDomain::encode const): 110 (WebCore::RegistrableDomain::decode): 111 * platform/network/NetworkStorageSession.cpp: 112 (WebCore::NetworkStorageSession::shouldBlockThirdPartyCookies const): 113 (WebCore::NetworkStorageSession::shouldBlockCookies const): 114 (WebCore::NetworkStorageSession::setPrevalentDomainsToBlockCookiesFor): 115 (WebCore::NetworkStorageSession::removePrevalentDomains): 116 (WebCore::NetworkStorageSession::hasStorageAccess const): 117 (WebCore::NetworkStorageSession::getAllStorageAccessEntries const): 118 (WebCore::NetworkStorageSession::grantStorageAccess): 119 (WebCore::getPartitioningDomain): Deleted. 120 * platform/network/NetworkStorageSession.h: 121 1 122 2019-02-25 Chris Fleizach <cfleizach@apple.com> 2 123 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r242032 r242056 2012 2012 6B0A07F221FA4B5C00D57391 /* AdClickAttribution.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B0A07F021FA4B5C00D57391 /* AdClickAttribution.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2013 2013 6B3480940EEF50D400AC1B41 /* NativeImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B3480920EEF50D400AC1B41 /* NativeImage.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2014 6B4E8613221B713F0022F389 /* RegistrableDomain.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B4E8612221B713F0022F389 /* RegistrableDomain.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2014 2015 6B693A2E1C51A82E00B03BEF /* ResourceLoadObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 6B693A2D1C51A82E00B03BEF /* ResourceLoadObserver.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2015 2016 6C4C96DF1AD4483500363F64 /* JSReadableByteStreamController.h in Headers */ = {isa = PBXBuildFile; fileRef = 6C4C96DB1AD4483500363F64 /* JSReadableByteStreamController.h */; }; … … 9137 9138 6B0A07F121FA4B5C00D57391 /* AdClickAttribution.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AdClickAttribution.cpp; sourceTree = "<group>"; }; 9138 9139 6B3480920EEF50D400AC1B41 /* NativeImage.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = NativeImage.h; sourceTree = "<group>"; }; 9140 6B4E8612221B713F0022F389 /* RegistrableDomain.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RegistrableDomain.h; sourceTree = "<group>"; }; 9139 9141 6B693A2D1C51A82E00B03BEF /* ResourceLoadObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadObserver.h; sourceTree = "<group>"; }; 9140 9142 6B693A331C51A95D00B03BEF /* ResourceLoadObserver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadObserver.cpp; sourceTree = "<group>"; }; … … 25599 25601 CA1635DC2072E76900E7D2CE /* ReferrerPolicy.cpp */, 25600 25602 9831AE49154225A200FE2644 /* ReferrerPolicy.h */, 25603 6B4E8612221B713F0022F389 /* RegistrableDomain.h */, 25601 25604 CDFC360318CA61C20026E56F /* RemoteCommandListener.cpp */, 25602 25605 CDFC360418CA61C20026E56F /* RemoteCommandListener.h */, … … 31191 31194 26B9998F1803AE7200D01121 /* RegisterAllocator.h in Headers */, 31192 31195 85031B4C0A44EFC700F992E0 /* RegisteredEventListener.h in Headers */, 31196 6B4E8613221B713F0022F389 /* RegistrableDomain.h in Headers */, 31193 31197 51B914101FD2782D00EE2859 /* RegistrationDatabase.h in Headers */, 31194 31198 51B914111FD2782D00EE2859 /* RegistrationStore.h in Headers */, -
trunk/Source/WebCore/dom/Document.cpp
r242032 r242056 8465 8465 } 8466 8466 8467 bool Document::hasRequestedPageSpecificStorageAccessWithUserInteraction(const String& primaryDomain)8468 { 8469 return m_ primaryDomainRequestedPageSpecificStorageAccessWithUserInteraction == primaryDomain;8470 } 8471 8472 void Document::setHasRequestedPageSpecificStorageAccessWithUserInteraction(const String& primaryDomain)8473 { 8474 m_ primaryDomainRequestedPageSpecificStorageAccessWithUserInteraction = primaryDomain;8467 bool Document::hasRequestedPageSpecificStorageAccessWithUserInteraction(const RegistrableDomain& domain) 8468 { 8469 return m_registrableDomainRequestedPageSpecificStorageAccessWithUserInteraction == domain; 8470 } 8471 8472 void Document::setHasRequestedPageSpecificStorageAccessWithUserInteraction(const RegistrableDomain& domain) 8473 { 8474 m_registrableDomainRequestedPageSpecificStorageAccessWithUserInteraction = domain; 8475 8475 } 8476 8476 #endif -
trunk/Source/WebCore/dom/Document.h
r241932 r242056 45 45 #include "ReferrerPolicy.h" 46 46 #include "Region.h" 47 #include "RegistrableDomain.h" 47 48 #include "RenderPtr.h" 48 49 #include "ScriptExecutionContext.h" … … 1495 1496 1496 1497 #if ENABLE(RESOURCE_LOAD_STATISTICS) 1497 bool hasRequestedPageSpecificStorageAccessWithUserInteraction(const String& primaryDomain);1498 void setHasRequestedPageSpecificStorageAccessWithUserInteraction(const String& primaryDomain);1498 bool hasRequestedPageSpecificStorageAccessWithUserInteraction(const RegistrableDomain&); 1499 void setHasRequestedPageSpecificStorageAccessWithUserInteraction(const RegistrableDomain&); 1499 1500 #endif 1500 1501 … … 2060 2061 2061 2062 #if ENABLE(RESOURCE_LOAD_STATISTICS) 2062 String m_primaryDomainRequestedPageSpecificStorageAccessWithUserInteraction { };2063 RegistrableDomain m_registrableDomainRequestedPageSpecificStorageAccessWithUserInteraction { }; 2063 2064 #endif 2064 2065 -
trunk/Source/WebCore/html/HTMLAnchorElement.cpp
r241490 r242056 43 43 #include "PingLoader.h" 44 44 #include "PlatformMouseEvent.h" 45 #include " PublicSuffix.h"45 #include "RegistrableDomain.h" 46 46 #include "RenderImage.h" 47 47 #include "ResourceRequest.h" … … 443 443 444 444 auto documentDomain = document().domain(); 445 auto adDestinationHost = adDestinationURL.host().toString(); 446 #if ENABLE(PUBLIC_SUFFIX_LIST) 447 if (topPrivatelyControlledDomain(documentDomain) == topPrivatelyControlledDomain(adDestinationHost)) { 448 #else 449 if (documentDomain == adDestinationHost) { 450 #endif 445 if (RegistrableDomain(documentDomain).matches(adDestinationURL)) { 451 446 document().addConsoleMessage(MessageSource::Other, MessageLevel::Warning, "addestination can not be the same site as the current website."_s); 452 447 return WTF::nullopt; -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r241945 r242056 74 74 #include "PlatformMediaSessionManager.h" 75 75 #include "ProgressTracker.h" 76 #include "PublicSuffix.h"77 76 #include "Quirks.h" 77 #include "RegistrableDomain.h" 78 78 #include "RenderLayerCompositor.h" 79 79 #include "RenderTheme.h" … … 7663 7663 title = decodeHostName(title); 7664 7664 #endif 7665 #if ENABLE(PUBLIC_SUFFIX_LIST)7666 7665 if (!title.isEmpty()) { 7667 auto domain = topPrivatelyControlledDomain(title);7666 auto domain = RegistrableDomain { title }; 7668 7667 if (!domain.isEmpty()) 7669 title = domain; 7670 } 7671 #endif 7668 title = domain.string(); 7669 } 7672 7670 7673 7671 return title; -
trunk/Source/WebCore/loader/AdClickAttribution.cpp
r241451 r242056 61 61 StringBuilder builder; 62 62 builder.appendLiteral("https://"); 63 builder.append(m_source.registrableDomain );63 builder.append(m_source.registrableDomain.string()); 64 64 builder.appendLiteral("/.well-known/ad-click-attribution/"); 65 65 builder.appendNumber(m_conversion.value().data); … … 81 81 StringBuilder builder; 82 82 builder.appendLiteral("https://"); 83 builder.append(m_destination.registrableDomain );83 builder.append(m_destination.registrableDomain.string()); 84 84 builder.append('/'); 85 85 … … 95 95 StringBuilder builder; 96 96 builder.appendLiteral("Source: "); 97 builder.append(m_source.registrableDomain );97 builder.append(m_source.registrableDomain.string()); 98 98 builder.appendLiteral("\nDestination: "); 99 builder.append(m_destination.registrableDomain );99 builder.append(m_destination.registrableDomain.string()); 100 100 builder.appendLiteral("\nCampaign ID: "); 101 101 builder.appendNumber(m_campaign.id); -
trunk/Source/WebCore/loader/AdClickAttribution.h
r241451 r242056 26 26 #pragma once 27 27 28 #include " PublicSuffix.h"28 #include "RegistrableDomain.h" 29 29 #include <wtf/Optional.h> 30 30 #include <wtf/URL.h> … … 61 61 Source() = default; 62 62 explicit Source(const String& host) 63 #if ENABLE(PUBLIC_SUFFIX_LIST) 64 : registrableDomain { topPrivatelyControlledDomain(host) } 65 #else 66 : registrableDomain { emptyString() } 67 #endif 63 : registrableDomain { host } 68 64 { 69 65 } … … 81 77 bool matches(const URL& url) const 82 78 { 83 #if ENABLE(PUBLIC_SUFFIX_LIST) 84 return registrableDomain == topPrivatelyControlledDomain(url.host().toString()); 85 #else 86 return registrableDomain == url.host().toString(); 87 #endif 79 return registrableDomain.matches(url); 88 80 } 89 81 … … 106 98 void deleteValue() 107 99 { 108 registrableDomain = String{ WTF::HashTableDeletedValue };100 registrableDomain = RegistrableDomain { WTF::HashTableDeletedValue }; 109 101 } 110 102 … … 114 106 } 115 107 116 StringregistrableDomain;108 RegistrableDomain registrableDomain; 117 109 }; 118 110 … … 134 126 Destination() = default; 135 127 explicit Destination(const String& host) 136 #if ENABLE(PUBLIC_SUFFIX_LIST) 137 : registrableDomain { topPrivatelyControlledDomain(host) } 138 #else 139 : registrableDomain { emptyString() } 140 #endif 128 : registrableDomain { RegistrableDomain { host } } 141 129 { 142 130 } … … 149 137 bool matches(const URL& url) const 150 138 { 151 #if ENABLE(PUBLIC_SUFFIX_LIST) 152 return registrableDomain == topPrivatelyControlledDomain(url.host().toString()); 153 #else 154 return registrableDomain == url.host().toString(); 155 #endif 139 return registrableDomain == RegistrableDomain { url }; 156 140 } 157 141 … … 174 158 void deleteValue() 175 159 { 176 registrableDomain = String{ WTF::HashTableDeletedValue };160 registrableDomain = RegistrableDomain { WTF::HashTableDeletedValue }; 177 161 } 178 162 … … 182 166 } 183 167 184 StringregistrableDomain;168 RegistrableDomain registrableDomain; 185 169 }; 186 170 -
trunk/Source/WebCore/loader/ResourceLoadObserver.cpp
r241743 r242056 34 34 #include "Logging.h" 35 35 #include "Page.h" 36 #include "RegistrableDomain.h" 36 37 #include "ResourceLoadStatistics.h" 37 38 #include "ResourceRequest.h" … … 45 46 namespace WebCore { 46 47 47 template<typename T> static inline String primaryDomain(const T& value)48 {49 return ResourceLoadStatistics::primaryDomain(value);50 }51 52 48 static const Seconds minimumNotificationInterval { 5_s }; 53 49 … … 64 60 } 65 61 66 void ResourceLoadObserver::setRequestStorageAccessUnderOpenerCallback(WTF::Function<void(const String& domainInNeedOfStorageAccess, uint64_t openerPageID, const String& openerDomain)>&& callback)62 void ResourceLoadObserver::setRequestStorageAccessUnderOpenerCallback(WTF::Function<void(const RegistrableDomain& domainInNeedOfStorageAccess, uint64_t openerPageID, const RegistrableDomain& openerDomain)>&& callback) 67 63 { 68 64 ASSERT(!m_requestStorageAccessUnderOpenerCallback); … … 70 66 } 71 67 72 void ResourceLoadObserver::setLogUserInteractionNotificationCallback(Function<void(PAL::SessionID, const String&)>&& callback)68 void ResourceLoadObserver::setLogUserInteractionNotificationCallback(Function<void(PAL::SessionID, const RegistrableDomain&)>&& callback) 73 69 { 74 70 ASSERT(!m_logUserInteractionNotificationCallback); … … 76 72 } 77 73 78 void ResourceLoadObserver::setLogWebSocketLoadingNotificationCallback(Function<void(PAL::SessionID, const String&, const String&, WallTime)>&& callback)74 void ResourceLoadObserver::setLogWebSocketLoadingNotificationCallback(Function<void(PAL::SessionID, const RegistrableDomain&, const RegistrableDomain&, WallTime)>&& callback) 79 75 { 80 76 ASSERT(!m_logWebSocketLoadingNotificationCallback); … … 82 78 } 83 79 84 void ResourceLoadObserver::setLogSubresourceLoadingNotificationCallback(Function<void(PAL::SessionID, const String&, const String&, WallTime)>&& callback)80 void ResourceLoadObserver::setLogSubresourceLoadingNotificationCallback(Function<void(PAL::SessionID, const RegistrableDomain&, const RegistrableDomain&, WallTime)>&& callback) 85 81 { 86 82 ASSERT(!m_logSubresourceLoadingNotificationCallback); … … 88 84 } 89 85 90 void ResourceLoadObserver::setLogSubresourceRedirectNotificationCallback(Function<void(PAL::SessionID, const String&, const String&)>&& callback)86 void ResourceLoadObserver::setLogSubresourceRedirectNotificationCallback(Function<void(PAL::SessionID, const RegistrableDomain&, const RegistrableDomain&)>&& callback) 91 87 { 92 88 ASSERT(!m_logSubresourceRedirectNotificationCallback); … … 131 127 return; 132 128 133 auto targetPrimaryDomain = primaryDomain(targetURL);134 auto mainFramePrimaryDomain = primaryDomain(mainFrameURL);135 auto sourcePrimaryDomain = primaryDomain(sourceURL);136 137 if (target PrimaryDomain == mainFramePrimaryDomain || (isRedirect && targetPrimaryDomain == sourcePrimaryDomain))129 RegistrableDomain targetDomain { targetURL }; 130 RegistrableDomain mainFrameDomain { mainFrameURL }; 131 RegistrableDomain sourceDomain { sourceURL }; 132 133 if (targetDomain == mainFrameDomain || (isRedirect && targetDomain == sourceDomain)) 138 134 return; 139 135 140 136 bool shouldCallNotificationCallback = false; 141 137 { 142 auto& targetStatistics = ensureResourceStatisticsFor PrimaryDomain(targetPrimaryDomain);138 auto& targetStatistics = ensureResourceStatisticsForRegistrableDomain(targetDomain); 143 139 auto lastSeen = ResourceLoadStatistics::reduceTimeResolution(WallTime::now()); 144 140 targetStatistics.lastSeen = lastSeen; 145 if (targetStatistics.subresourceUnderTopFrameOrigins.add(mainFrame PrimaryDomain).isNewEntry)141 if (targetStatistics.subresourceUnderTopFrameOrigins.add(mainFrameDomain.string()).isNewEntry) 146 142 shouldCallNotificationCallback = true; 147 143 148 m_logSubresourceLoadingNotificationCallback(page->sessionID(), target PrimaryDomain, mainFramePrimaryDomain, lastSeen);144 m_logSubresourceLoadingNotificationCallback(page->sessionID(), targetDomain, mainFrameDomain, lastSeen); 149 145 } 150 146 151 147 if (isRedirect) { 152 auto& redirectingOriginStatistics = ensureResourceStatisticsFor PrimaryDomain(sourcePrimaryDomain);153 bool isNewRedirectToEntry = redirectingOriginStatistics.subresourceUniqueRedirectsTo.add(target PrimaryDomain).isNewEntry;154 auto& targetStatistics = ensureResourceStatisticsFor PrimaryDomain(targetPrimaryDomain);155 bool isNewRedirectFromEntry = targetStatistics.subresourceUniqueRedirectsFrom.add(source PrimaryDomain).isNewEntry;148 auto& redirectingOriginStatistics = ensureResourceStatisticsForRegistrableDomain(sourceDomain); 149 bool isNewRedirectToEntry = redirectingOriginStatistics.subresourceUniqueRedirectsTo.add(targetDomain.string()).isNewEntry; 150 auto& targetStatistics = ensureResourceStatisticsForRegistrableDomain(targetDomain); 151 bool isNewRedirectFromEntry = targetStatistics.subresourceUniqueRedirectsFrom.add(sourceDomain.string()).isNewEntry; 156 152 157 153 if (isNewRedirectToEntry || isNewRedirectFromEntry) 158 154 shouldCallNotificationCallback = true; 159 155 160 m_logSubresourceRedirectNotificationCallback(page->sessionID(), source PrimaryDomain, targetPrimaryDomain);156 m_logSubresourceRedirectNotificationCallback(page->sessionID(), sourceDomain, targetDomain); 161 157 } 162 158 … … 176 172 return; 177 173 178 auto targetPrimaryDomain = primaryDomain(targetURL);179 auto mainFramePrimaryDomain = primaryDomain(mainFrameURL);180 181 if (target PrimaryDomain == mainFramePrimaryDomain)174 RegistrableDomain targetDomain { targetURL }; 175 RegistrableDomain mainFrameDomain { mainFrameURL }; 176 177 if (targetDomain == mainFrameDomain) 182 178 return; 183 179 184 180 auto lastSeen = ResourceLoadStatistics::reduceTimeResolution(WallTime::now()); 185 181 186 auto& targetStatistics = ensureResourceStatisticsFor PrimaryDomain(targetPrimaryDomain);182 auto& targetStatistics = ensureResourceStatisticsForRegistrableDomain(targetDomain); 187 183 targetStatistics.lastSeen = lastSeen; 188 if (targetStatistics.subresourceUnderTopFrameOrigins.add(mainFrame PrimaryDomain).isNewEntry)189 scheduleNotificationIfNeeded(); 190 191 m_logWebSocketLoadingNotificationCallback(sessionID, target PrimaryDomain, mainFramePrimaryDomain, lastSeen);184 if (targetStatistics.subresourceUnderTopFrameOrigins.add(mainFrameDomain.string()).isNewEntry) 185 scheduleNotificationIfNeeded(); 186 187 m_logWebSocketLoadingNotificationCallback(sessionID, targetDomain, mainFrameDomain, lastSeen); 192 188 } 193 189 … … 198 194 199 195 auto& url = document.url(); 200 if (url.protocolIsAbout() || url.is Empty())201 return; 202 203 auto domain = primaryDomain(url);196 if (url.protocolIsAbout() || url.isLocalFile() || url.isEmpty()) 197 return; 198 199 RegistrableDomain domain { url }; 204 200 auto newTime = ResourceLoadStatistics::reduceTimeResolution(WallTime::now()); 205 201 auto lastReportedUserInteraction = m_lastReportedUserInteractionMap.get(domain); … … 209 205 m_lastReportedUserInteractionMap.set(domain, newTime); 210 206 211 auto& statistics = ensureResourceStatisticsFor PrimaryDomain(domain);207 auto& statistics = ensureResourceStatisticsForRegistrableDomain(domain); 212 208 statistics.hadUserInteraction = true; 213 209 statistics.lastSeen = newTime; … … 243 239 }; 244 240 auto escapedURL = escapeForJSON(url.string()); 245 auto escapedDomain = escapeForJSON(domain );241 auto escapedDomain = escapeForJSON(domain.string()); 246 242 247 243 LOCAL_LOG(R"({ "url": "%{public}s",)", escapedURL.utf8().data()); … … 255 251 256 252 #if ENABLE(RESOURCE_LOAD_STATISTICS) 257 void ResourceLoadObserver::requestStorageAccessUnderOpener(const String& domainInNeedOfStorageAccess, uint64_t openerPageID, Document& openerDocument)253 void ResourceLoadObserver::requestStorageAccessUnderOpener(const RegistrableDomain& domainInNeedOfStorageAccess, uint64_t openerPageID, Document& openerDocument) 258 254 { 259 255 auto openerUrl = openerDocument.url(); 260 auto openerPrimaryDomain = primaryDomain(openerUrl);261 if (domainInNeedOfStorageAccess != opener PrimaryDomain256 RegistrableDomain openerDomain { openerUrl }; 257 if (domainInNeedOfStorageAccess != openerDomain 262 258 && !openerDocument.hasRequestedPageSpecificStorageAccessWithUserInteraction(domainInNeedOfStorageAccess) 263 259 && !equalIgnoringASCIICase(openerUrl.string(), WTF::blankURL())) { 264 m_requestStorageAccessUnderOpenerCallback(domainInNeedOfStorageAccess, openerPageID, opener PrimaryDomain);260 m_requestStorageAccessUnderOpenerCallback(domainInNeedOfStorageAccess, openerPageID, openerDomain); 265 261 // Remember user interaction-based requests since they don't need to be repeated. 266 262 openerDocument.setHasRequestedPageSpecificStorageAccessWithUserInteraction(domainInNeedOfStorageAccess); … … 274 270 if (!shouldLog(document.sessionID().isEphemeral())) 275 271 return; 276 auto registrableDomain = primaryDomain(document.url());277 auto& statistics = ensureResourceStatisticsFor PrimaryDomain(registrableDomain);272 RegistrableDomain registrableDomain { document.url() }; 273 auto& statistics = ensureResourceStatisticsForRegistrableDomain(registrableDomain); 278 274 bool shouldCallNotificationCallback = false; 279 275 if (!loadStatus) { … … 284 280 shouldCallNotificationCallback = true; 285 281 } 286 auto mainFrameRegistrableDomain = primaryDomain(document.topDocument().url());287 if (statistics.topFrameRegistrableDomainsWhichAccessedWebAPIs.add(mainFrameRegistrableDomain ).isNewEntry)282 RegistrableDomain mainFrameRegistrableDomain { document.topDocument().url() }; 283 if (statistics.topFrameRegistrableDomainsWhichAccessedWebAPIs.add(mainFrameRegistrableDomain.string()).isNewEntry) 288 284 shouldCallNotificationCallback = true; 289 285 if (shouldCallNotificationCallback) … … 301 297 if (!shouldLog(document.sessionID().isEphemeral())) 302 298 return; 303 auto registrableDomain = primaryDomain(document.url());304 auto& statistics = ensureResourceStatisticsFor PrimaryDomain(registrableDomain);305 auto mainFrameRegistrableDomain = primaryDomain(document.topDocument().url());299 RegistrableDomain registrableDomain { document.url() }; 300 auto& statistics = ensureResourceStatisticsForRegistrableDomain(registrableDomain); 301 RegistrableDomain mainFrameRegistrableDomain { document.topDocument().url() }; 306 302 statistics.canvasActivityRecord.wasDataRead = true; 307 if (statistics.topFrameRegistrableDomainsWhichAccessedWebAPIs.add(mainFrameRegistrableDomain ).isNewEntry)303 if (statistics.topFrameRegistrableDomainsWhichAccessedWebAPIs.add(mainFrameRegistrableDomain.string()).isNewEntry) 308 304 scheduleNotificationIfNeeded(); 309 305 #else … … 317 313 if (!shouldLog(document.sessionID().isEphemeral())) 318 314 return; 319 auto registrableDomain = primaryDomain(document.url());320 auto& statistics = ensureResourceStatisticsFor PrimaryDomain(registrableDomain);315 RegistrableDomain registrableDomain { document.url() }; 316 auto& statistics = ensureResourceStatisticsForRegistrableDomain(registrableDomain); 321 317 bool shouldCallNotificationCallback = false; 322 auto mainFrameRegistrableDomain = primaryDomain(document.topDocument().url());318 RegistrableDomain mainFrameRegistrableDomain { document.topDocument().url() }; 323 319 if (statistics.canvasActivityRecord.recordWrittenOrMeasuredText(textWritten)) 324 320 shouldCallNotificationCallback = true; 325 if (statistics.topFrameRegistrableDomainsWhichAccessedWebAPIs.add(mainFrameRegistrableDomain ).isNewEntry)321 if (statistics.topFrameRegistrableDomainsWhichAccessedWebAPIs.add(mainFrameRegistrableDomain.string()).isNewEntry) 326 322 shouldCallNotificationCallback = true; 327 323 if (shouldCallNotificationCallback) … … 338 334 if (!shouldLog(document.sessionID().isEphemeral())) 339 335 return; 340 auto registrableDomain = primaryDomain(document.url());341 auto& statistics = ensureResourceStatisticsFor PrimaryDomain(registrableDomain);336 RegistrableDomain registrableDomain { document.url() }; 337 auto& statistics = ensureResourceStatisticsForRegistrableDomain(registrableDomain); 342 338 bool shouldCallNotificationCallback = false; 343 339 if (!statistics.navigatorFunctionsAccessed.contains(functionName)) { … … 345 341 shouldCallNotificationCallback = true; 346 342 } 347 auto mainFrameRegistrableDomain = primaryDomain(document.topDocument().url());348 if (statistics.topFrameRegistrableDomainsWhichAccessedWebAPIs.add(mainFrameRegistrableDomain ).isNewEntry)343 RegistrableDomain mainFrameRegistrableDomain { document.topDocument().url() }; 344 if (statistics.topFrameRegistrableDomainsWhichAccessedWebAPIs.add(mainFrameRegistrableDomain.string()).isNewEntry) 349 345 shouldCallNotificationCallback = true; 350 346 if (shouldCallNotificationCallback) … … 361 357 if (!shouldLog(document.sessionID().isEphemeral())) 362 358 return; 363 auto registrableDomain = primaryDomain(document.url());364 auto& statistics = ensureResourceStatisticsFor PrimaryDomain(registrableDomain);359 RegistrableDomain registrableDomain { document.url() }; 360 auto& statistics = ensureResourceStatisticsForRegistrableDomain(registrableDomain); 365 361 bool shouldCallNotificationCallback = false; 366 362 if (!statistics.screenFunctionsAccessed.contains(functionName)) { … … 368 364 shouldCallNotificationCallback = true; 369 365 } 370 auto mainFrameRegistrableDomain = primaryDomain(document.topDocument().url());371 if (statistics.topFrameRegistrableDomainsWhichAccessedWebAPIs.add(mainFrameRegistrableDomain ).isNewEntry)366 RegistrableDomain mainFrameRegistrableDomain { document.topDocument().url() }; 367 if (statistics.topFrameRegistrableDomainsWhichAccessedWebAPIs.add(mainFrameRegistrableDomain.string()).isNewEntry) 372 368 shouldCallNotificationCallback = true; 373 369 if (shouldCallNotificationCallback) … … 379 375 } 380 376 381 ResourceLoadStatistics& ResourceLoadObserver::ensureResourceStatisticsFor PrimaryDomain(const String& primaryDomain)382 { 383 auto addResult = m_resourceStatisticsMap.ensure( primaryDomain, [&primaryDomain] {384 return ResourceLoadStatistics( primaryDomain);377 ResourceLoadStatistics& ResourceLoadObserver::ensureResourceStatisticsForRegistrableDomain(const RegistrableDomain& domain) 378 { 379 auto addResult = m_resourceStatisticsMap.ensure(domain, [&domain] { 380 return ResourceLoadStatistics(domain); 385 381 }); 386 382 return addResult.iterator->value; … … 408 404 String ResourceLoadObserver::statisticsForOrigin(const String& origin) 409 405 { 410 auto iter = m_resourceStatisticsMap.find( origin);406 auto iter = m_resourceStatisticsMap.find(RegistrableDomain { origin }); 411 407 if (iter == m_resourceStatisticsMap.end()) 412 408 return emptyString(); -
trunk/Source/WebCore/loader/ResourceLoadObserver.h
r240498 r242056 49 49 class Frame; 50 50 class Page; 51 class RegistrableDomain; 51 52 class ResourceRequest; 52 53 class ResourceResponse; … … 73 74 74 75 WEBCORE_EXPORT void setNotificationCallback(WTF::Function<void (Vector<ResourceLoadStatistics>&&)>&&); 75 WEBCORE_EXPORT void setRequestStorageAccessUnderOpenerCallback(Function<void(const String&, uint64_t, const String&)>&&);76 WEBCORE_EXPORT void setLogUserInteractionNotificationCallback(Function<void(PAL::SessionID, const String&)>&&);77 WEBCORE_EXPORT void setLogWebSocketLoadingNotificationCallback(Function<void(PAL::SessionID, const String&, const String&, WallTime)>&&);78 WEBCORE_EXPORT void setLogSubresourceLoadingNotificationCallback(Function<void(PAL::SessionID, const String&, const String&, WallTime)>&&);79 WEBCORE_EXPORT void setLogSubresourceRedirectNotificationCallback(Function<void(PAL::SessionID, const String&, const String&)>&&);76 WEBCORE_EXPORT void setRequestStorageAccessUnderOpenerCallback(Function<void(const RegistrableDomain&, uint64_t, const RegistrableDomain&)>&&); 77 WEBCORE_EXPORT void setLogUserInteractionNotificationCallback(Function<void(PAL::SessionID, const RegistrableDomain&)>&&); 78 WEBCORE_EXPORT void setLogWebSocketLoadingNotificationCallback(Function<void(PAL::SessionID, const RegistrableDomain&, const RegistrableDomain&, WallTime)>&&); 79 WEBCORE_EXPORT void setLogSubresourceLoadingNotificationCallback(Function<void(PAL::SessionID, const RegistrableDomain&, const RegistrableDomain&, WallTime)>&&); 80 WEBCORE_EXPORT void setLogSubresourceRedirectNotificationCallback(Function<void(PAL::SessionID, const RegistrableDomain&, const RegistrableDomain&)>&&); 80 81 81 82 WEBCORE_EXPORT void notifyObserver(); … … 91 92 92 93 bool shouldLog(bool usesEphemeralSession) const; 93 ResourceLoadStatistics& ensureResourceStatisticsFor PrimaryDomain(const String&);94 ResourceLoadStatistics& ensureResourceStatisticsForRegistrableDomain(const RegistrableDomain&); 94 95 95 96 void scheduleNotificationIfNeeded(); … … 97 98 98 99 #if ENABLE(RESOURCE_LOAD_STATISTICS) 99 void requestStorageAccessUnderOpener(const String& domainInNeedOfStorageAccess, uint64_t openerPageID, Document& openerDocument);100 void requestStorageAccessUnderOpener(const RegistrableDomain& domainInNeedOfStorageAccess, uint64_t openerPageID, Document& openerDocument); 100 101 #endif 101 102 102 HashMap< String, ResourceLoadStatistics> m_resourceStatisticsMap;103 HashMap< String, WTF::WallTime> m_lastReportedUserInteractionMap;103 HashMap<RegistrableDomain, ResourceLoadStatistics> m_resourceStatisticsMap; 104 HashMap<RegistrableDomain, WTF::WallTime> m_lastReportedUserInteractionMap; 104 105 Function<void(Vector<ResourceLoadStatistics>&&)> m_notificationCallback; 105 Function<void(const String&, uint64_t, const String&)> m_requestStorageAccessUnderOpenerCallback;106 Function<void(PAL::SessionID, const String&)> m_logUserInteractionNotificationCallback;107 Function<void(PAL::SessionID, const String&, const String&, WallTime)> m_logWebSocketLoadingNotificationCallback;108 Function<void(PAL::SessionID, const String&, const String&, WallTime)> m_logSubresourceLoadingNotificationCallback;109 Function<void(PAL::SessionID, const String&, const String&)> m_logSubresourceRedirectNotificationCallback;106 Function<void(const RegistrableDomain&, uint64_t, const RegistrableDomain&)> m_requestStorageAccessUnderOpenerCallback; 107 Function<void(PAL::SessionID, const RegistrableDomain&)> m_logUserInteractionNotificationCallback; 108 Function<void(PAL::SessionID, const RegistrableDomain&, const RegistrableDomain&, WallTime)> m_logWebSocketLoadingNotificationCallback; 109 Function<void(PAL::SessionID, const RegistrableDomain&, const RegistrableDomain&, WallTime)> m_logSubresourceLoadingNotificationCallback; 110 Function<void(PAL::SessionID, const RegistrableDomain&, const RegistrableDomain&)> m_logSubresourceRedirectNotificationCallback; 110 111 111 112 Timer m_notificationTimer; -
trunk/Source/WebCore/loader/ResourceLoadStatistics.cpp
r239888 r242056 95 95 void ResourceLoadStatistics::encode(KeyedEncoder& encoder) const 96 96 { 97 encoder.encodeString("PrevalentResourceOrigin", highLevelDomain);97 encoder.encodeString("PrevalentResourceOrigin", registrableDomain.string()); 98 98 99 99 encoder.encodeDouble("lastSeen", lastSeen.secondsSinceEpoch().value()); … … 203 203 bool ResourceLoadStatistics::decode(KeyedDecoder& decoder, unsigned modelVersion) 204 204 { 205 if (!decoder.decodeString("PrevalentResourceOrigin", highLevelDomain)) 206 return false; 207 205 String registrableDomainAsString; 206 if (!decoder.decodeString("PrevalentResourceOrigin", registrableDomainAsString)) 207 return false; 208 registrableDomain = RegistrableDomain(registrableDomainAsString); 209 208 210 // User interaction 209 211 if (!decoder.decodeBool("hadUserInteraction", hadUserInteraction)) … … 397 399 StringBuilder builder; 398 400 builder.appendLiteral("High level domain: "); 399 builder.append( highLevelDomain);401 builder.append(registrableDomain.string()); 400 402 builder.append('\n'); 401 403 builder.appendLiteral(" lastSeen: "); … … 467 469 void ResourceLoadStatistics::merge(const ResourceLoadStatistics& other) 468 470 { 469 ASSERT(other. highLevelDomain == highLevelDomain);471 ASSERT(other.registrableDomain == registrableDomain); 470 472 471 473 if (lastSeen < other.lastSeen) … … 516 518 } 517 519 518 String ResourceLoadStatistics::primaryDomain(const URL& url)519 {520 return primaryDomain(url.host());521 }522 523 String ResourceLoadStatistics::primaryDomain(StringView host)524 {525 if (host.isNull() || host.isEmpty())526 return "nullOrigin"_s;527 528 String hostString = host.toString();529 #if ENABLE(PUBLIC_SUFFIX_LIST)530 String primaryDomain = topPrivatelyControlledDomain(hostString);531 // We will have an empty string here if there is no TLD. Use the host as a fallback.532 if (!primaryDomain.isEmpty())533 return primaryDomain;534 #endif535 536 return hostString;537 }538 539 520 WallTime ResourceLoadStatistics::reduceTimeResolution(WallTime time) 540 521 { -
trunk/Source/WebCore/loader/ResourceLoadStatistics.h
r239888 r242056 27 27 28 28 #include "CanvasActivityRecord.h" 29 #include "RegistrableDomain.h" 29 30 #include <wtf/HashCountedSet.h> 30 31 #include <wtf/HashSet.h> … … 41 42 42 43 struct ResourceLoadStatistics { 43 explicit ResourceLoadStatistics(const String& primaryDomain)44 : highLevelDomain(primaryDomain)44 explicit ResourceLoadStatistics(const RegistrableDomain& domain) 45 : registrableDomain { domain } 45 46 { 46 47 } … … 53 54 ResourceLoadStatistics& operator=(ResourceLoadStatistics&&) = default; 54 55 55 WEBCORE_EXPORT static String primaryDomain(const URL&);56 WEBCORE_EXPORT static String primaryDomain(StringView host);57 58 56 WEBCORE_EXPORT static WallTime reduceTimeResolution(WallTime); 59 57 … … 65 63 WEBCORE_EXPORT void merge(const ResourceLoadStatistics&); 66 64 67 String highLevelDomain;65 RegistrableDomain registrableDomain; 68 66 69 67 WallTime lastSeen; -
trunk/Source/WebCore/page/Page.cpp
r241978 r242056 90 90 #include "PointerLockController.h" 91 91 #include "ProgressTracker.h" 92 #include "PublicSuffix.h"93 92 #include "RenderLayerCompositor.h" 94 93 #include "RenderTheme.h" … … 2370 2369 2371 2370 if (!navigation.domain.isEmpty()) 2372 diagnosticLoggingClient().logDiagnosticMessageWithEnhancedPrivacy(DiagnosticLoggingKeys::domainVisitedKey(), navigation.domain , ShouldSample::Yes);2371 diagnosticLoggingClient().logDiagnosticMessageWithEnhancedPrivacy(DiagnosticLoggingKeys::domainVisitedKey(), navigation.domain.string(), ShouldSample::Yes); 2373 2372 } 2374 2373 2375 2374 void Page::mainFrameLoadStarted(const URL& destinationURL, FrameLoadType type) 2376 2375 { 2377 String domain; 2378 #if ENABLE(PUBLIC_SUFFIX_LIST) 2379 domain = topPrivatelyControlledDomain(destinationURL.host().toString()); 2380 #else 2381 UNUSED_PARAM(destinationURL); 2382 #endif 2383 2384 Navigation navigation = { domain, type }; 2376 Navigation navigation = { RegistrableDomain { destinationURL }, type }; 2385 2377 2386 2378 // To avoid being too verbose, we only log navigations if the page is or becomes visible. This avoids logging non-user observable loads. -
trunk/Source/WebCore/page/Page.h
r242032 r242056 33 33 #include "RTCController.h" 34 34 #include "Region.h" 35 #include "RegistrableDomain.h" 35 36 #include "ScrollTypes.h" 36 37 #include "Supplementable.h" … … 705 706 private: 706 707 struct Navigation { 707 Stringdomain;708 RegistrableDomain domain; 708 709 FrameLoadType type; 709 710 }; -
trunk/Source/WebCore/page/PerformanceMonitor.cpp
r239427 r242056 36 36 #include "Page.h" 37 37 #include "PerformanceLogging.h" 38 #include " PublicSuffix.h"38 #include "RegistrableDomain.h" 39 39 40 40 namespace WebCore { … … 149 149 return; 150 150 151 String domain = topPrivatelyControlledDomain(document->url().host().toString());152 if ( domain.isEmpty())151 RegistrableDomain registrableDomain { document->url() }; 152 if (registrableDomain.isEmpty()) 153 153 return; 154 154 155 155 switch (reason) { 156 156 case ReportingReason::HighCPUUsage: 157 page.diagnosticLoggingClient().logDiagnosticMessageWithEnhancedPrivacy(DiagnosticLoggingKeys::domainCausingEnergyDrainKey(), domain, ShouldSample::No);157 page.diagnosticLoggingClient().logDiagnosticMessageWithEnhancedPrivacy(DiagnosticLoggingKeys::domainCausingEnergyDrainKey(), registrableDomain.string(), ShouldSample::No); 158 158 break; 159 159 case ReportingReason::HighMemoryUsage: 160 page.diagnosticLoggingClient().logDiagnosticMessageWithEnhancedPrivacy(DiagnosticLoggingKeys::domainCausingJetsamKey(), domain, ShouldSample::No);160 page.diagnosticLoggingClient().logDiagnosticMessageWithEnhancedPrivacy(DiagnosticLoggingKeys::domainCausingJetsamKey(), registrableDomain.string(), ShouldSample::No); 161 161 break; 162 162 } -
trunk/Source/WebCore/platform/network/NetworkStorageSession.cpp
r240292 r242056 59 59 #if ENABLE(RESOURCE_LOAD_STATISTICS) 60 60 61 static inline String getPartitioningDomain(const URL& url) 62 { 63 #if ENABLE(PUBLIC_SUFFIX_LIST) 64 auto domain = topPrivatelyControlledDomain(url.host().toString()); 65 if (domain.isEmpty()) 66 domain = url.host().toString(); 67 #else 68 auto domain = url.host().toString(); 69 #endif 70 return domain; 71 } 72 73 bool NetworkStorageSession::shouldBlockThirdPartyCookies(const String& topPrivatelyControlledDomain) const 74 { 75 if (topPrivatelyControlledDomain.isEmpty()) 76 return false; 77 78 return m_topPrivatelyControlledDomainsToBlock.contains(topPrivatelyControlledDomain); 61 bool NetworkStorageSession::shouldBlockThirdPartyCookies(const RegistrableDomain& registrableDomain) const 62 { 63 if (registrableDomain.isEmpty()) 64 return false; 65 66 return m_registrableDomainsToBlockCookieFor.contains(registrableDomain); 79 67 } 80 68 … … 86 74 bool NetworkStorageSession::shouldBlockCookies(const URL& firstPartyForCookies, const URL& resource, Optional<uint64_t> frameID, Optional<uint64_t> pageID) const 87 75 { 88 auto firstPartyDomain = getPartitioningDomain(firstPartyForCookies);76 RegistrableDomain firstPartyDomain { firstPartyForCookies }; 89 77 if (firstPartyDomain.isEmpty()) 90 78 return false; 91 79 92 auto resourceDomain = getPartitioningDomain(resource);80 RegistrableDomain resourceDomain { resource }; 93 81 if (resourceDomain.isEmpty()) 94 82 return false; … … 115 103 } 116 104 117 void NetworkStorageSession::setPrevalentDomainsToBlockCookiesFor(const Vector< String>& domains)118 { 119 m_ topPrivatelyControlledDomainsToBlock.clear();120 m_ topPrivatelyControlledDomainsToBlock.add(domains.begin(), domains.end());121 } 122 123 void NetworkStorageSession::removePrevalentDomains(const Vector< String>& domains)105 void NetworkStorageSession::setPrevalentDomainsToBlockCookiesFor(const Vector<RegistrableDomain>& domains) 106 { 107 m_registrableDomainsToBlockCookieFor.clear(); 108 m_registrableDomainsToBlockCookieFor.add(domains.begin(), domains.end()); 109 } 110 111 void NetworkStorageSession::removePrevalentDomains(const Vector<RegistrableDomain>& domains) 124 112 { 125 113 for (auto& domain : domains) 126 m_ topPrivatelyControlledDomainsToBlock.remove(domain);127 } 128 129 bool NetworkStorageSession::hasStorageAccess(const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID) const114 m_registrableDomainsToBlockCookieFor.remove(domain); 115 } 116 117 bool NetworkStorageSession::hasStorageAccess(const RegistrableDomain& resourceDomain, const RegistrableDomain& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID) const 130 118 { 131 119 if (frameID) { … … 155 143 for (auto& innerMap : m_framesGrantedStorageAccess.values()) { 156 144 for (auto& value : innerMap.values()) 157 entries.append(value );145 entries.append(value.string()); 158 146 } 159 147 return entries; 160 148 } 161 149 162 void NetworkStorageSession::grantStorageAccess(const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID)150 void NetworkStorageSession::grantStorageAccess(const RegistrableDomain& resourceDomain, const RegistrableDomain& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID) 163 151 { 164 152 if (!frameID) { … … 167 155 auto pagesGrantedIterator = m_pagesGrantedStorageAccess.find(pageID); 168 156 if (pagesGrantedIterator == m_pagesGrantedStorageAccess.end()) { 169 HashMap< String, String> entry;157 HashMap<RegistrableDomain, RegistrableDomain> entry; 170 158 entry.add(firstPartyDomain, resourceDomain); 171 159 m_pagesGrantedStorageAccess.add(pageID, entry); … … 182 170 auto pagesGrantedIterator = m_framesGrantedStorageAccess.find(pageID); 183 171 if (pagesGrantedIterator == m_framesGrantedStorageAccess.end()) { 184 HashMap<uint64_t, String, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>> entry;172 HashMap<uint64_t, RegistrableDomain, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>> entry; 185 173 entry.add(frameID.value(), resourceDomain); 186 174 m_framesGrantedStorageAccess.add(pageID, entry); -
trunk/Source/WebCore/platform/network/NetworkStorageSession.h
r240835 r242056 27 27 28 28 #include "CredentialStorage.h" 29 #include "RegistrableDomain.h" 29 30 #include <pal/SessionID.h> 30 31 #include <wtf/Function.h> … … 142 143 WEBCORE_EXPORT bool shouldBlockCookies(const ResourceRequest&, Optional<uint64_t> frameID, Optional<uint64_t> pageID) const; 143 144 WEBCORE_EXPORT bool shouldBlockCookies(const URL& firstPartyForCookies, const URL& resource, Optional<uint64_t> frameID, Optional<uint64_t> pageID) const; 144 WEBCORE_EXPORT void setPrevalentDomainsToBlockCookiesFor(const Vector< String>&);145 WEBCORE_EXPORT void setPrevalentDomainsToBlockCookiesFor(const Vector<RegistrableDomain>&); 145 146 WEBCORE_EXPORT void setAgeCapForClientSideCookies(Optional<Seconds>); 146 WEBCORE_EXPORT void removePrevalentDomains(const Vector< String>& domains);147 WEBCORE_EXPORT bool hasStorageAccess(const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID) const;147 WEBCORE_EXPORT void removePrevalentDomains(const Vector<RegistrableDomain>& domains); 148 WEBCORE_EXPORT bool hasStorageAccess(const RegistrableDomain& resourceDomain, const RegistrableDomain& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID) const; 148 149 WEBCORE_EXPORT Vector<String> getAllStorageAccessEntries() const; 149 WEBCORE_EXPORT void grantStorageAccess(const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID);150 WEBCORE_EXPORT void grantStorageAccess(const RegistrableDomain& resourceDomain, const RegistrableDomain& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID); 150 151 WEBCORE_EXPORT void removeStorageAccessForFrame(uint64_t frameID, uint64_t pageID); 151 152 WEBCORE_EXPORT void removeStorageAccessForAllFramesOnPage(uint64_t pageID); … … 177 178 178 179 #if ENABLE(RESOURCE_LOAD_STATISTICS) 179 bool shouldBlockThirdPartyCookies(const String& topPrivatelyControlledDomain) const;180 HashSet< String> m_topPrivatelyControlledDomainsToBlock;181 HashMap<uint64_t, HashMap<uint64_t, String, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>>, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>> m_framesGrantedStorageAccess;182 HashMap<uint64_t, HashMap< String, String>, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>> m_pagesGrantedStorageAccess;180 bool shouldBlockThirdPartyCookies(const RegistrableDomain&) const; 181 HashSet<RegistrableDomain> m_registrableDomainsToBlockCookieFor; 182 HashMap<uint64_t, HashMap<uint64_t, RegistrableDomain, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>>, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>> m_framesGrantedStorageAccess; 183 HashMap<uint64_t, HashMap<RegistrableDomain, RegistrableDomain>, DefaultHash<uint64_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint64_t>> m_pagesGrantedStorageAccess; 183 184 Optional<Seconds> m_cacheMaxAgeCapForPrevalentResources { }; 184 185 Optional<Seconds> m_ageCapForClientSideCookies { }; -
trunk/Source/WebKit/ChangeLog
r242055 r242056 1 2019-02-25 John Wilander <wilander@apple.com> 2 3 Introduce and adopt new class RegistrableDomain for eTLD+1 4 https://bugs.webkit.org/show_bug.cgi?id=194791 5 <rdar://problem/48179240> 6 7 Reviewed by Alex Christensen, Fujii Hironori, and Brent Fulgham. 8 9 A new API test was added. Plenty of existing layout tests under 10 http/tests/resourceLoadStatistics/ and http/tests/storageAccess/ test the code. 11 12 This patch introduces and adopts a new class called WebCore::RegistrableDomain 13 which represents a domain's eTLD+1 (effective top level domain plus one) and is 14 the basis for the term "site," as in same-site. Other popular names include 15 high-level domain, primary domain, and top privately controlled/owned domain. 16 Effective top level domains are enumerated on the Public Suffix List 17 (https://publicsuffix.org). 18 19 This class just uses the full domain for when the Public Suffix List cannot help 20 finding the registrable domain and for WebKit ports that haven't enabled 21 PUBLIC_SUFFIX_LIST. It also uses the string "nullOrigin" as a representation 22 for the null or unique origin (this matches how these origins were handled 23 before). 24 25 The implementation is a wrapper around a String and the functions and class 26 members that now make use of this new class used to handle regular String 27 objects which didn't help much in terms of type safety or guarantees that the 28 string had already been converted to an eTLD+1. 29 30 We've at least two bad bugs in the Storage Access API because of confusion 31 between a URL's eTLD+1 and its host. The usage of WebCore::RegistrableDomain 32 will prohibit such bugs in the future. 33 34 Partitioning in WebKit also uses eTLD+1 to a large extent. I plan to adopt 35 WebCore::RegistrableDomain for partitioning in a later patch. 36 37 This patch also enhances parameter naming by: 38 - Removing parts that refer to "primary" as in primaryDomain. 39 - Replacing references to "TopPrivatelyControlledDomain" with "RegistrableDomain." 40 - Replacing references to "TopPrivatelyOwnedDomain" with "RegistrableDomain." 41 - Using the term "domain" consistently instead of e.g. "host." 42 43 A follow-up patch will continue backwards in call chains to create 44 WebCore::RegistrableDomain objects as early as possible instead of using strings. 45 I did not do that work here in the interest of patch size. 46 47 * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp: 48 (WebKit::domainsToString): 49 (WebKit::pruneResources): 50 (WebKit::ResourceLoadStatisticsMemoryStore::removeDataRecords): 51 (WebKit::ResourceLoadStatisticsMemoryStore::recursivelyGetAllDomainsThatHaveRedirectedToThisDomain const): 52 (WebKit::ResourceLoadStatisticsMemoryStore::markAsPrevalentIfHasRedirectedToPrevalent): 53 (WebKit::ResourceLoadStatisticsMemoryStore::isPrevalentDueToDebugMode): 54 (WebKit::ResourceLoadStatisticsMemoryStore::hasStorageAccess): 55 (WebKit::ResourceLoadStatisticsMemoryStore::requestStorageAccess): 56 (WebKit::ResourceLoadStatisticsMemoryStore::requestStorageAccessUnderOpener): 57 (WebKit::ResourceLoadStatisticsMemoryStore::grantStorageAccess): 58 (WebKit::ResourceLoadStatisticsMemoryStore::grantStorageAccessInternal): 59 (WebKit::ResourceLoadStatisticsMemoryStore::grandfatherExistingWebsiteData): 60 (WebKit::ResourceLoadStatisticsMemoryStore::ensurePrevalentResourcesForDebugMode): 61 (WebKit::ResourceLoadStatisticsMemoryStore::setPrevalentResourceForDebugMode): 62 (WebKit::ResourceLoadStatisticsMemoryStore::logFrameNavigation): 63 (WebKit::ResourceLoadStatisticsMemoryStore::logSubresourceLoading): 64 (WebKit::ResourceLoadStatisticsMemoryStore::logSubresourceRedirect): 65 (WebKit::ResourceLoadStatisticsMemoryStore::logUserInteraction): 66 (WebKit::ResourceLoadStatisticsMemoryStore::clearUserInteraction): 67 (WebKit::ResourceLoadStatisticsMemoryStore::hasHadUserInteraction): 68 (WebKit::ResourceLoadStatisticsMemoryStore::setPrevalentResource): 69 (WebKit::ResourceLoadStatisticsMemoryStore::isPrevalentResource const): 70 (WebKit::ResourceLoadStatisticsMemoryStore::isVeryPrevalentResource const): 71 (WebKit::ResourceLoadStatisticsMemoryStore::isRegisteredAsSubresourceUnder const): 72 (WebKit::ResourceLoadStatisticsMemoryStore::isRegisteredAsSubFrameUnder const): 73 (WebKit::ResourceLoadStatisticsMemoryStore::isRegisteredAsRedirectingTo const): 74 (WebKit::ResourceLoadStatisticsMemoryStore::clearPrevalentResource): 75 (WebKit::ResourceLoadStatisticsMemoryStore::setGrandfathered): 76 (WebKit::ResourceLoadStatisticsMemoryStore::isGrandfathered const): 77 (WebKit::ResourceLoadStatisticsMemoryStore::setSubframeUnderTopFrameOrigin): 78 (WebKit::ResourceLoadStatisticsMemoryStore::setSubresourceUnderTopFrameOrigin): 79 (WebKit::ResourceLoadStatisticsMemoryStore::setSubresourceUniqueRedirectTo): 80 (WebKit::ResourceLoadStatisticsMemoryStore::setSubresourceUniqueRedirectFrom): 81 (WebKit::ResourceLoadStatisticsMemoryStore::setTopFrameUniqueRedirectTo): 82 (WebKit::ResourceLoadStatisticsMemoryStore::setTopFrameUniqueRedirectFrom): 83 (WebKit::ResourceLoadStatisticsMemoryStore::ensureResourceStatisticsForRegistrableDomain): 84 (WebKit::ResourceLoadStatisticsMemoryStore::mergeStatistics): 85 (WebKit::ResourceLoadStatisticsMemoryStore::hasUserGrantedStorageAccessThroughPrompt): 86 (WebKit::debugLogDomainsInBatches): 87 (WebKit::ResourceLoadStatisticsMemoryStore::updateCookieBlocking): 88 (WebKit::ResourceLoadStatisticsMemoryStore::updateCookieBlockingForDomains): 89 (WebKit::ResourceLoadStatisticsMemoryStore::clearBlockingStateForDomains): 90 (WebKit::ResourceLoadStatisticsMemoryStore::registrableDomainsToRemoveWebsiteDataFor): 91 (WebKit::ResourceLoadStatisticsMemoryStore::pruneStatisticsIfNeeded): 92 (WebKit::ResourceLoadStatisticsMemoryStore::setLastSeen): 93 (WebKit::ResourceLoadStatisticsMemoryStore::setVeryPrevalentResource): 94 (WebKit::ResourceLoadStatisticsMemoryStore::ensureResourceStatisticsForPrimaryDomain): Deleted. 95 (WebKit::ResourceLoadStatisticsMemoryStore::topPrivatelyControlledDomainsToRemoveWebsiteDataFor): Deleted. 96 * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h: 97 * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp: 98 (WebKit::WebResourceLoadStatisticsStore::setPrevalentResourceForDebugMode): 99 (WebKit::WebResourceLoadStatisticsStore::hasStorageAccess): 100 (WebKit::WebResourceLoadStatisticsStore::hasStorageAccessForFrame): 101 (WebKit::WebResourceLoadStatisticsStore::callHasStorageAccessForFrameHandler): 102 (WebKit::WebResourceLoadStatisticsStore::requestStorageAccessGranted): 103 (WebKit::WebResourceLoadStatisticsStore::requestStorageAccess): 104 (WebKit::WebResourceLoadStatisticsStore::requestStorageAccessUnderOpener): 105 (WebKit::WebResourceLoadStatisticsStore::grantStorageAccess): 106 (WebKit::WebResourceLoadStatisticsStore::callGrantStorageAccessHandler): 107 (WebKit::WebResourceLoadStatisticsStore::logFrameNavigation): 108 (WebKit::WebResourceLoadStatisticsStore::logWebSocketLoading): 109 (WebKit::WebResourceLoadStatisticsStore::logSubresourceLoading): 110 (WebKit::WebResourceLoadStatisticsStore::logSubresourceRedirect): 111 (WebKit::WebResourceLoadStatisticsStore::logUserInteraction): 112 (WebKit::WebResourceLoadStatisticsStore::clearUserInteraction): 113 (WebKit::WebResourceLoadStatisticsStore::hasHadUserInteraction): 114 (WebKit::WebResourceLoadStatisticsStore::setLastSeen): 115 (WebKit::WebResourceLoadStatisticsStore::setPrevalentResource): 116 (WebKit::WebResourceLoadStatisticsStore::setVeryPrevalentResource): 117 (WebKit::WebResourceLoadStatisticsStore::isPrevalentResource): 118 (WebKit::WebResourceLoadStatisticsStore::isVeryPrevalentResource): 119 (WebKit::WebResourceLoadStatisticsStore::isRegisteredAsSubresourceUnder): 120 (WebKit::WebResourceLoadStatisticsStore::isRegisteredAsSubFrameUnder): 121 (WebKit::WebResourceLoadStatisticsStore::isRegisteredAsRedirectingTo): 122 (WebKit::WebResourceLoadStatisticsStore::clearPrevalentResource): 123 (WebKit::WebResourceLoadStatisticsStore::setGrandfathered): 124 (WebKit::WebResourceLoadStatisticsStore::isGrandfathered): 125 (WebKit::WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin): 126 (WebKit::WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin): 127 (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo): 128 (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectFrom): 129 (WebKit::WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectTo): 130 (WebKit::WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectFrom): 131 (WebKit::WebResourceLoadStatisticsStore::scheduleCookieBlockingUpdateForDomains): 132 (WebKit::WebResourceLoadStatisticsStore::scheduleClearBlockingStateForDomains): 133 (WebKit::WebResourceLoadStatisticsStore::callUpdatePrevalentDomainsToBlockCookiesForHandler): 134 (WebKit::WebResourceLoadStatisticsStore::removePrevalentDomains): 135 (WebKit::WebResourceLoadStatisticsStore::callRemoveDomainsHandler): 136 (WebKit::WebResourceLoadStatisticsStore::deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores): 137 (WebKit::WebResourceLoadStatisticsStore::registrableDomainsWithWebsiteData): 138 (WebKit::isolatedPrimaryDomain): Deleted. 139 (WebKit::WebResourceLoadStatisticsStore::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores): Deleted. 140 (WebKit::WebResourceLoadStatisticsStore::topPrivatelyControlledDomainsWithWebsiteData): Deleted. 141 * NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h: 142 * NetworkProcess/NetworkConnectionToWebProcess.cpp: 143 (WebKit::NetworkConnectionToWebProcess::logUserInteraction): 144 (WebKit::NetworkConnectionToWebProcess::logWebSocketLoading): 145 (WebKit::NetworkConnectionToWebProcess::logSubresourceLoading): 146 (WebKit::NetworkConnectionToWebProcess::logSubresourceRedirect): 147 (WebKit::NetworkConnectionToWebProcess::hasStorageAccess): 148 (WebKit::NetworkConnectionToWebProcess::requestStorageAccess): 149 * NetworkProcess/NetworkConnectionToWebProcess.h: 150 * NetworkProcess/NetworkConnectionToWebProcess.messages.in: 151 * NetworkProcess/NetworkProcess.cpp: 152 (WebKit::NetworkProcess::updatePrevalentDomainsToBlockCookiesFor): 153 (WebKit::NetworkProcess::isGrandfathered): 154 (WebKit::NetworkProcess::isPrevalentResource): 155 (WebKit::NetworkProcess::isVeryPrevalentResource): 156 (WebKit::NetworkProcess::setGrandfathered): 157 (WebKit::NetworkProcess::setPrevalentResource): 158 (WebKit::NetworkProcess::setPrevalentResourceForDebugMode): 159 (WebKit::NetworkProcess::setVeryPrevalentResource): 160 (WebKit::NetworkProcess::clearPrevalentResource): 161 (WebKit::NetworkProcess::setSubframeUnderTopFrameOrigin): 162 (WebKit::NetworkProcess::isRegisteredAsRedirectingTo): 163 (WebKit::NetworkProcess::isRegisteredAsSubFrameUnder): 164 (WebKit::NetworkProcess::setSubresourceUnderTopFrameOrigin): 165 (WebKit::NetworkProcess::setSubresourceUniqueRedirectTo): 166 (WebKit::NetworkProcess::setSubresourceUniqueRedirectFrom): 167 (WebKit::NetworkProcess::isRegisteredAsSubresourceUnder): 168 (WebKit::NetworkProcess::setTopFrameUniqueRedirectTo): 169 (WebKit::NetworkProcess::setTopFrameUniqueRedirectFrom): 170 (WebKit::NetworkProcess::setLastSeen): 171 (WebKit::NetworkProcess::hasStorageAccessForFrame): 172 (WebKit::NetworkProcess::hasStorageAccess): 173 (WebKit::NetworkProcess::requestStorageAccess): 174 (WebKit::NetworkProcess::requestStorageAccessGranted): 175 (WebKit::NetworkProcess::grantStorageAccess): 176 (WebKit::NetworkProcess::logFrameNavigation): 177 (WebKit::NetworkProcess::logUserInteraction): 178 (WebKit::NetworkProcess::hadUserInteraction): 179 (WebKit::NetworkProcess::clearUserInteraction): 180 (WebKit::NetworkProcess::removePrevalentDomains): 181 (WebKit::filterForRegistrableDomains): 182 (WebKit::NetworkProcess::deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores): 183 (WebKit::NetworkProcess::registrableDomainsWithWebsiteData): 184 (WebKit::filterForTopLevelDomains): Deleted. 185 (WebKit::NetworkProcess::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores): Deleted. 186 (WebKit::NetworkProcess::topPrivatelyControlledDomainsWithWebsiteData): Deleted. 187 * NetworkProcess/NetworkProcess.h: 188 * NetworkProcess/NetworkProcess.messages.in: 189 * NetworkProcess/NetworkResourceLoader.cpp: 190 (WebKit::logCookieInformationInternal): 191 * NetworkProcess/NetworkSession.cpp: 192 (WebKit::NetworkSession::deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores): 193 (WebKit::NetworkSession::registrableDomainsWithWebsiteData): 194 (WebKit::NetworkSession::deleteWebsiteDataForTopPrivatelyControlledDomainsInAllPersistentDataStores): Deleted. 195 (WebKit::NetworkSession::topPrivatelyControlledDomainsWithWebsiteData): Deleted. 196 * NetworkProcess/NetworkSession.h: 197 * Shared/WebCoreArgumentCoders.cpp: 198 (IPC::ArgumentCoder<ResourceLoadStatistics>::encode): 199 (IPC::ArgumentCoder<ResourceLoadStatistics>::decode): 200 * UIProcess/Cocoa/ResourceLoadStatisticsMemoryStoreCocoa.mm: 201 (WebKit::ResourceLoadStatisticsMemoryStore::registerUserDefaultsIfNeeded): 202 * UIProcess/Network/NetworkProcessProxy.cpp: 203 (WebKit::NetworkProcessProxy::updatePrevalentDomainsToBlockCookiesFor): 204 (WebKit::NetworkProcessProxy::isPrevalentResource): 205 (WebKit::NetworkProcessProxy::isVeryPrevalentResource): 206 (WebKit::NetworkProcessProxy::setPrevalentResource): 207 (WebKit::NetworkProcessProxy::setPrevalentResourceForDebugMode): 208 (WebKit::NetworkProcessProxy::setVeryPrevalentResource): 209 (WebKit::NetworkProcessProxy::setLastSeen): 210 (WebKit::NetworkProcessProxy::clearPrevalentResource): 211 (WebKit::NetworkProcessProxy::logUserInteraction): 212 (WebKit::NetworkProcessProxy::hasHadUserInteraction): 213 (WebKit::NetworkProcessProxy::clearUserInteraction): 214 (WebKit::NetworkProcessProxy::setSubframeUnderTopFrameOrigin): 215 (WebKit::NetworkProcessProxy::isRegisteredAsRedirectingTo): 216 (WebKit::NetworkProcessProxy::isRegisteredAsSubFrameUnder): 217 (WebKit::NetworkProcessProxy::setSubresourceUnderTopFrameOrigin): 218 (WebKit::NetworkProcessProxy::isRegisteredAsSubresourceUnder): 219 (WebKit::NetworkProcessProxy::setSubresourceUniqueRedirectTo): 220 (WebKit::NetworkProcessProxy::setSubresourceUniqueRedirectFrom): 221 (WebKit::NetworkProcessProxy::setTopFrameUniqueRedirectTo): 222 (WebKit::NetworkProcessProxy::setTopFrameUniqueRedirectFrom): 223 (WebKit::NetworkProcessProxy::isGrandfathered): 224 (WebKit::NetworkProcessProxy::setGrandfathered): 225 (WebKit::NetworkProcessProxy::hasStorageAccessForFrame): 226 (WebKit::NetworkProcessProxy::hasStorageAccess): 227 (WebKit::NetworkProcessProxy::requestStorageAccess): 228 (WebKit::NetworkProcessProxy::grantStorageAccess): 229 (WebKit::NetworkProcessProxy::notifyWebsiteDataDeletionForRegistrableDomainsFinished): 230 (WebKit::NetworkProcessProxy::notifyWebsiteDataScanForRegistrableDomainsFinished): 231 (WebKit::NetworkProcessProxy::notifyWebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished): Deleted. 232 (WebKit::NetworkProcessProxy::notifyWebsiteDataScanForTopPrivatelyControlledDomainsFinished): Deleted. 233 * UIProcess/Network/NetworkProcessProxy.h: 234 * UIProcess/Network/NetworkProcessProxy.messages.in: 235 * UIProcess/WebPageProxy.cpp: 236 (WebKit::WebPageProxy::logFrameNavigation): 237 (WebKit::WebPageProxy::requestStorageAccessConfirm): 238 * UIProcess/WebProcessProxy.cpp: 239 (WebKit::WebProcessProxy::notifyPageStatisticsAndDataRecordsProcessed): 240 (WebKit::WebProcessProxy::notifyWebsiteDataScanForRegistrableDomainsFinished): 241 (WebKit::WebProcessProxy::notifyWebsiteDataDeletionForRegistrableDomainsFinished): 242 (WebKit::WebProcessProxy::notifyWebsiteDataScanForTopPrivatelyControlledDomainsFinished): Deleted. 243 (WebKit::WebProcessProxy::notifyWebsiteDataDeletionForTopPrivatelyOwnedDomainsFinished): Deleted. 244 * UIProcess/WebProcessProxy.h: 245 * UIProcess/WebResourceLoadStatisticsStore.messages.in: 246 * UIProcess/WebsiteData/WebsiteDataStore.cpp: 247 (WebKit::WebsiteDataStore::isPrevalentResource): 248 (WebKit::WebsiteDataStore::setPrevalentResource): 249 (WebKit::WebsiteDataStore::setPrevalentResourceForDebugMode): 250 (WebKit::WebsiteDataStore::isVeryPrevalentResource): 251 (WebKit::WebsiteDataStore::setVeryPrevalentResource): 252 (WebKit::WebsiteDataStore::setSubframeUnderTopFrameOrigin): 253 (WebKit::WebsiteDataStore::isRegisteredAsSubFrameUnder): 254 (WebKit::WebsiteDataStore::setSubresourceUnderTopFrameOrigin): 255 (WebKit::WebsiteDataStore::isRegisteredAsSubresourceUnder): 256 (WebKit::WebsiteDataStore::setSubresourceUniqueRedirectTo): 257 (WebKit::WebsiteDataStore::setSubresourceUniqueRedirectFrom): 258 (WebKit::WebsiteDataStore::setTopFrameUniqueRedirectTo): 259 (WebKit::WebsiteDataStore::setTopFrameUniqueRedirectFrom): 260 (WebKit::WebsiteDataStore::isRegisteredAsRedirectingTo): 261 (WebKit::WebsiteDataStore::clearPrevalentResource): 262 (WebKit::WebsiteDataStore::setLastSeen): 263 (WebKit::WebsiteDataStore::hasStorageAccess): 264 (WebKit::WebsiteDataStore::requestStorageAccess): 265 (WebKit::WebsiteDataStore::grantStorageAccess): 266 (WebKit::WebsiteDataStore::logUserInteraction): 267 (WebKit::WebsiteDataStore::hasHadUserInteraction): 268 (WebKit::WebsiteDataStore::clearUserInteraction): 269 (WebKit::WebsiteDataStore::setGrandfathered): 270 (WebKit::WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains): Deleted. 271 * UIProcess/WebsiteData/WebsiteDataStore.h: 272 * WebProcess/WebPage/WebPage.cpp: 273 (WebKit::WebPage::hasStorageAccess): 274 (WebKit::WebPage::requestStorageAccess): 275 * WebProcess/WebProcess.cpp: 276 (WebKit::m_nonVisibleProcessCleanupTimer): 277 (WebKit::WebProcess::initializeWebProcess): 278 1 279 2019-02-25 Adrian Perez de Castro <aperez@igalia.com> 2 280 -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp
r241924 r242056 54 54 constexpr unsigned operatingDatesWindow { 30 }; 55 55 constexpr unsigned maxImportance { 3 }; 56 static const char* debugStaticPrevalentResource { "3rdpartytestwebkit.org" };57 56 58 57 #if !RELEASE_LOG_DISABLED 59 static String domainsToString(const Vector< String>& domains)58 static String domainsToString(const Vector<RegistrableDomain>& domains) 60 59 { 61 60 StringBuilder builder; … … 63 62 if (!builder.isEmpty()) 64 63 builder.appendLiteral(", "); 65 builder.append(domain );64 builder.append(domain.string()); 66 65 } 67 66 return builder.toString(); … … 141 140 142 141 struct StatisticsLastSeen { 143 String topPrivatelyOwnedDomain;142 RegistrableDomain domain; 144 143 WallTime lastSeen; 145 144 }; 146 145 147 static void pruneResources(HashMap< String, WebCore::ResourceLoadStatistics>& statisticsMap, Vector<StatisticsLastSeen>& statisticsToPrune, size_t& numberOfEntriesToPrune)146 static void pruneResources(HashMap<RegistrableDomain, ResourceLoadStatistics>& statisticsMap, Vector<StatisticsLastSeen>& statisticsToPrune, size_t& numberOfEntriesToPrune) 148 147 { 149 148 if (statisticsToPrune.size() > numberOfEntriesToPrune) { … … 154 153 155 154 for (size_t i = 0, end = std::min(numberOfEntriesToPrune, statisticsToPrune.size()); i != end; ++i, --numberOfEntriesToPrune) 156 statisticsMap.remove(statisticsToPrune[i]. topPrivatelyOwnedDomain);155 statisticsMap.remove(statisticsToPrune[i].domain); 157 156 } 158 157 … … 235 234 #endif 236 235 237 auto prevalentResourceDomains = topPrivatelyControlledDomainsToRemoveWebsiteDataFor();236 auto prevalentResourceDomains = registrableDomainsToRemoveWebsiteDataFor(); 238 237 if (prevalentResourceDomains.isEmpty()) { 239 238 callback(); … … 253 252 } 254 253 255 weakThis->m_store.deleteWebsiteDataFor TopPrivatelyControlledDomainsInAllPersistentDataStores(WebResourceLoadStatisticsStore::monitoredDataTypes(), WTFMove(prevalentResourceDomains), shouldNotifyPagesWhenDataRecordsWereScanned, [callback = WTFMove(callback), weakThis = WTFMove(weakThis), workQueue = workQueue.copyRef()](const HashSet<String>& domainsWithDeletedWebsiteData) mutable {256 workQueue->dispatch([ topDomains= crossThreadCopy(domainsWithDeletedWebsiteData), callback = WTFMove(callback), weakThis = WTFMove(weakThis)] () mutable {254 weakThis->m_store.deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores(WebResourceLoadStatisticsStore::monitoredDataTypes(), WTFMove(prevalentResourceDomains), shouldNotifyPagesWhenDataRecordsWereScanned, [callback = WTFMove(callback), weakThis = WTFMove(weakThis), workQueue = workQueue.copyRef()](const HashSet<String>& domainsWithDeletedWebsiteData) mutable { 255 workQueue->dispatch([domainsWithDeletedWebsiteData = crossThreadCopy(domainsWithDeletedWebsiteData), callback = WTFMove(callback), weakThis = WTFMove(weakThis)] () mutable { 257 256 if (!weakThis) { 258 257 callback(); 259 258 return; 260 259 } 261 for (auto& prevalentResourceDomain : topDomains) {262 auto& statistic = weakThis->ensureResourceStatisticsFor PrimaryDomain(prevalentResourceDomain);260 for (auto& domain : domainsWithDeletedWebsiteData) { 261 auto& statistic = weakThis->ensureResourceStatisticsForRegistrableDomain(RegistrableDomain { domain }); 263 262 ++statistic.dataRecordsRemoved; 264 263 } … … 273 272 } 274 273 275 unsigned ResourceLoadStatisticsMemoryStore::recursivelyGetAllDomainsThatHaveRedirectedToThisDomain(const WebCore::ResourceLoadStatistics& resourceStatistic, HashSet<String>& domainsThatHaveRedirectedTo, unsigned numberOfRecursiveCalls) const274 unsigned ResourceLoadStatisticsMemoryStore::recursivelyGetAllDomainsThatHaveRedirectedToThisDomain(const ResourceLoadStatistics& resourceStatistic, HashSet<RegistrableDomain>& domainsThatHaveRedirectedTo, unsigned numberOfRecursiveCalls) const 276 275 { 277 276 ASSERT(!RunLoop::isMain()); … … 288 287 289 288 for (auto& subresourceUniqueRedirectFromDomain : resourceStatistic.subresourceUniqueRedirectsFrom.values()) { 290 auto mapEntry = m_resourceStatisticsMap.find( subresourceUniqueRedirectFromDomain);289 auto mapEntry = m_resourceStatisticsMap.find(RegistrableDomain { subresourceUniqueRedirectFromDomain }); 291 290 if (mapEntry == m_resourceStatisticsMap.end() || mapEntry->value.isPrevalentResource) 292 291 continue; 293 if (domainsThatHaveRedirectedTo.add(mapEntry->value. highLevelDomain).isNewEntry)292 if (domainsThatHaveRedirectedTo.add(mapEntry->value.registrableDomain).isNewEntry) 294 293 numberOfRecursiveCalls = recursivelyGetAllDomainsThatHaveRedirectedToThisDomain(mapEntry->value, domainsThatHaveRedirectedTo, numberOfRecursiveCalls); 295 294 } 296 295 for (auto& topFrameUniqueRedirectFromDomain : resourceStatistic.topFrameUniqueRedirectsFrom.values()) { 297 auto mapEntry = m_resourceStatisticsMap.find( topFrameUniqueRedirectFromDomain);296 auto mapEntry = m_resourceStatisticsMap.find(RegistrableDomain { topFrameUniqueRedirectFromDomain }); 298 297 if (mapEntry == m_resourceStatisticsMap.end() || mapEntry->value.isPrevalentResource) 299 298 continue; 300 if (domainsThatHaveRedirectedTo.add(mapEntry->value. highLevelDomain).isNewEntry)299 if (domainsThatHaveRedirectedTo.add(mapEntry->value.registrableDomain).isNewEntry) 301 300 numberOfRecursiveCalls = recursivelyGetAllDomainsThatHaveRedirectedToThisDomain(mapEntry->value, domainsThatHaveRedirectedTo, numberOfRecursiveCalls); 302 301 } … … 305 304 } 306 305 307 void ResourceLoadStatisticsMemoryStore::markAsPrevalentIfHasRedirectedToPrevalent( WebCore::ResourceLoadStatistics& resourceStatistic)306 void ResourceLoadStatisticsMemoryStore::markAsPrevalentIfHasRedirectedToPrevalent(ResourceLoadStatistics& resourceStatistic) 308 307 { 309 308 ASSERT(!RunLoop::isMain()); … … 313 312 314 313 for (auto& subresourceDomainRedirectedTo : resourceStatistic.subresourceUniqueRedirectsTo.values()) { 315 auto mapEntry = m_resourceStatisticsMap.find( subresourceDomainRedirectedTo);314 auto mapEntry = m_resourceStatisticsMap.find(RegistrableDomain { subresourceDomainRedirectedTo }); 316 315 if (mapEntry != m_resourceStatisticsMap.end() && mapEntry->value.isPrevalentResource) { 317 316 setPrevalentResource(resourceStatistic, ResourceLoadPrevalence::High); … … 321 320 322 321 for (auto& topFrameDomainRedirectedTo : resourceStatistic.topFrameUniqueRedirectsTo.values()) { 323 auto mapEntry = m_resourceStatisticsMap.find( topFrameDomainRedirectedTo);322 auto mapEntry = m_resourceStatisticsMap.find(RegistrableDomain { topFrameDomainRedirectedTo }); 324 323 if (mapEntry != m_resourceStatisticsMap.end() && mapEntry->value.isPrevalentResource) { 325 324 setPrevalentResource(resourceStatistic, ResourceLoadPrevalence::High); … … 334 333 return false; 335 334 336 return resourceStatistic. highLevelDomain == debugStaticPrevalentResource || resourceStatistic.highLevelDomain == m_debugManualPrevalentResource;335 return resourceStatistic.registrableDomain == m_debugStaticPrevalentResource || resourceStatistic.registrableDomain == m_debugManualPrevalentResource; 337 336 } 338 337 … … 377 376 } 378 377 379 void ResourceLoadStatisticsMemoryStore::hasStorageAccess(const String& subFramePrimaryDomain, const String& topFramePrimaryDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler)380 { 381 ASSERT(!RunLoop::isMain()); 382 383 auto& subFrameStatistic = ensureResourceStatisticsFor PrimaryDomain(subFramePrimaryDomain);378 void ResourceLoadStatisticsMemoryStore::hasStorageAccess(const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler) 379 { 380 ASSERT(!RunLoop::isMain()); 381 382 auto& subFrameStatistic = ensureResourceStatisticsForRegistrableDomain(subFrameDomain); 384 383 if (shouldBlockAndPurgeCookies(subFrameStatistic)) { 385 384 completionHandler(false); … … 392 391 } 393 392 394 RunLoop::main().dispatch([store = makeRef(m_store), subFrame PrimaryDomain = subFramePrimaryDomain.isolatedCopy(), topFramePrimaryDomain = topFramePrimaryDomain.isolatedCopy(), frameID, pageID, completionHandler = WTFMove(completionHandler)]() mutable {395 store->callHasStorageAccessForFrameHandler(subFrame PrimaryDomain, topFramePrimaryDomain, frameID.value(), pageID, [store = store.copyRef(), completionHandler = WTFMove(completionHandler)](bool result) mutable {393 RunLoop::main().dispatch([store = makeRef(m_store), subFrameDomain = subFrameDomain.isolatedCopy(), topFrameDomain = topFrameDomain.isolatedCopy(), frameID, pageID, completionHandler = WTFMove(completionHandler)]() mutable { 394 store->callHasStorageAccessForFrameHandler(subFrameDomain, topFrameDomain, frameID.value(), pageID, [store = store.copyRef(), completionHandler = WTFMove(completionHandler)](bool result) mutable { 396 395 store->statisticsQueue().dispatch([completionHandler = WTFMove(completionHandler), result] () mutable { 397 396 completionHandler(result); … … 401 400 } 402 401 403 void ResourceLoadStatisticsMemoryStore::requestStorageAccess( String&& subFramePrimaryDomain, String&& topFramePrimaryDomain, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&& completionHandler)404 { 405 ASSERT(!RunLoop::isMain()); 406 407 auto& subFrameStatistic = ensureResourceStatisticsFor PrimaryDomain(subFramePrimaryDomain);402 void ResourceLoadStatisticsMemoryStore::requestStorageAccess(RegistrableDomain&& subFrameDomain, RegistrableDomain&& topFrameDomain, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&& completionHandler) 403 { 404 ASSERT(!RunLoop::isMain()); 405 406 auto& subFrameStatistic = ensureResourceStatisticsForRegistrableDomain(subFrameDomain); 408 407 if (shouldBlockAndPurgeCookies(subFrameStatistic)) { 409 408 #if !RELEASE_LOG_DISABLED 410 RELEASE_LOG_INFO_IF(m_debugLoggingEnabled, ResourceLoadStatisticsDebug, "Cannot grant storage access to %{public}s since its cookies are blocked in third-party contexts and it has not received user interaction as first-party.", subFrame PrimaryDomain.utf8().data());409 RELEASE_LOG_INFO_IF(m_debugLoggingEnabled, ResourceLoadStatisticsDebug, "Cannot grant storage access to %{public}s since its cookies are blocked in third-party contexts and it has not received user interaction as first-party.", subFrameDomain.string().utf8().data()); 411 410 #endif 412 411 completionHandler(StorageAccessStatus::CannotRequestAccess); … … 416 415 if (!shouldBlockAndKeepCookies(subFrameStatistic)) { 417 416 #if !RELEASE_LOG_DISABLED 418 RELEASE_LOG_INFO_IF(m_debugLoggingEnabled, ResourceLoadStatisticsDebug, "No need to grant storage access to %{public}s since its cookies are not blocked in third-party contexts.", subFrame PrimaryDomain.utf8().data());417 RELEASE_LOG_INFO_IF(m_debugLoggingEnabled, ResourceLoadStatisticsDebug, "No need to grant storage access to %{public}s since its cookies are not blocked in third-party contexts.", subFrameDomain.string().utf8().data()); 419 418 #endif 420 419 completionHandler(StorageAccessStatus::HasAccess); … … 422 421 } 423 422 424 auto userWasPromptedEarlier = promptEnabled && hasUserGrantedStorageAccessThroughPrompt(subFrameStatistic, topFrame PrimaryDomain);423 auto userWasPromptedEarlier = promptEnabled && hasUserGrantedStorageAccessThroughPrompt(subFrameStatistic, topFrameDomain); 425 424 if (promptEnabled && !userWasPromptedEarlier) { 426 425 #if !RELEASE_LOG_DISABLED 427 RELEASE_LOG_INFO_IF(m_debugLoggingEnabled, ResourceLoadStatisticsDebug, "About to ask the user whether they want to grant storage access to %{public}s under %{public}s or not.", subFrame PrimaryDomain.utf8().data(), topFramePrimaryDomain.utf8().data());426 RELEASE_LOG_INFO_IF(m_debugLoggingEnabled, ResourceLoadStatisticsDebug, "About to ask the user whether they want to grant storage access to %{public}s under %{public}s or not.", subFrameDomain.string().utf8().data(), topFrameDomain.string().utf8().data()); 428 427 #endif 429 428 completionHandler(StorageAccessStatus::RequiresUserPrompt); … … 431 430 } else if (userWasPromptedEarlier) { 432 431 #if !RELEASE_LOG_DISABLED 433 RELEASE_LOG_INFO_IF(m_debugLoggingEnabled, ResourceLoadStatisticsDebug, "Storage access was granted to %{public}s under %{public}s.", subFrame PrimaryDomain.utf8().data(), topFramePrimaryDomain.utf8().data());432 RELEASE_LOG_INFO_IF(m_debugLoggingEnabled, ResourceLoadStatisticsDebug, "Storage access was granted to %{public}s under %{public}s.", subFrameDomain.string().utf8().data(), topFrameDomain.string().utf8().data()); 434 433 #endif 435 434 } … … 437 436 subFrameStatistic.timesAccessedAsFirstPartyDueToStorageAccessAPI++; 438 437 439 grantStorageAccessInternal(WTFMove(subFrame PrimaryDomain), WTFMove(topFramePrimaryDomain), frameID, pageID, userWasPromptedEarlier, [completionHandler = WTFMove(completionHandler)] (bool wasGrantedAccess) mutable {438 grantStorageAccessInternal(WTFMove(subFrameDomain), WTFMove(topFrameDomain), frameID, pageID, userWasPromptedEarlier, [completionHandler = WTFMove(completionHandler)] (bool wasGrantedAccess) mutable { 440 439 completionHandler(wasGrantedAccess ? StorageAccessStatus::HasAccess : StorageAccessStatus::CannotRequestAccess); 441 440 }); 442 441 } 443 442 444 void ResourceLoadStatisticsMemoryStore::requestStorageAccessUnderOpener( String&& primaryDomainInNeedOfStorageAccess, uint64_t openerPageID, String&& openerPrimaryDomain)445 { 446 ASSERT( primaryDomainInNeedOfStorageAccess != openerPrimaryDomain);447 ASSERT(!RunLoop::isMain()); 448 449 if ( primaryDomainInNeedOfStorageAccess == openerPrimaryDomain)450 return; 451 452 auto& domainInNeedOfStorageAccessStatistic = ensureResourceStatisticsFor PrimaryDomain(primaryDomainInNeedOfStorageAccess);443 void ResourceLoadStatisticsMemoryStore::requestStorageAccessUnderOpener(RegistrableDomain&& domainInNeedOfStorageAccess, uint64_t openerPageID, RegistrableDomain&& openerDomain) 444 { 445 ASSERT(domainInNeedOfStorageAccess != openerDomain); 446 ASSERT(!RunLoop::isMain()); 447 448 if (domainInNeedOfStorageAccess == openerDomain) 449 return; 450 451 auto& domainInNeedOfStorageAccessStatistic = ensureResourceStatisticsForRegistrableDomain(domainInNeedOfStorageAccess); 453 452 auto cookiesBlockedAndPurged = shouldBlockAndPurgeCookies(domainInNeedOfStorageAccessStatistic); 454 453 … … 458 457 459 458 #if !RELEASE_LOG_DISABLED 460 RELEASE_LOG_INFO_IF(m_debugLoggingEnabled, ResourceLoadStatisticsDebug, "[Temporary combatibility fix] Storage access was granted for %{public}s under opener page from %{public}s, with user interaction in the opened window.", primaryDomainInNeedOfStorageAccess.utf8().data(), openerPrimaryDomain.utf8().data()); 461 #endif 462 grantStorageAccessInternal(WTFMove(primaryDomainInNeedOfStorageAccess), WTFMove(openerPrimaryDomain), WTF::nullopt, openerPageID, false, [](bool) { }); 463 } 464 465 void ResourceLoadStatisticsMemoryStore::grantStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPromptedNow, CompletionHandler<void(bool)>&& completionHandler) 466 { 467 ASSERT(!RunLoop::isMain()); 468 469 auto subFramePrimaryDomain = ResourceLoadStatistics::primaryDomain(subFrameHost); 470 auto topFramePrimaryDomain = ResourceLoadStatistics::primaryDomain(topFrameHost); 459 RELEASE_LOG_INFO_IF(m_debugLoggingEnabled, ResourceLoadStatisticsDebug, "[Temporary combatibility fix] Storage access was granted for %{public}s under opener page from %{public}s, with user interaction in the opened window.", domainInNeedOfStorageAccess.string().utf8().data(), openerDomain.string().utf8().data()); 460 #endif 461 grantStorageAccessInternal(WTFMove(domainInNeedOfStorageAccess), WTFMove(openerDomain), WTF::nullopt, openerPageID, false, [](bool) { }); 462 } 463 464 void ResourceLoadStatisticsMemoryStore::grantStorageAccess(RegistrableDomain&& subFrameDomain, RegistrableDomain&& topFrameDomain, uint64_t frameID, uint64_t pageID, bool userWasPromptedNow, CompletionHandler<void(bool)>&& completionHandler) 465 { 466 ASSERT(!RunLoop::isMain()); 467 471 468 if (userWasPromptedNow) { 472 auto& subFrameStatistic = ensureResourceStatisticsFor PrimaryDomain(subFramePrimaryDomain);469 auto& subFrameStatistic = ensureResourceStatisticsForRegistrableDomain(subFrameDomain); 473 470 ASSERT(subFrameStatistic.hadUserInteraction); 474 subFrameStatistic.storageAccessUnderTopFrameOrigins.add(topFrame PrimaryDomain);475 } 476 grantStorageAccessInternal(WTFMove(subFrame PrimaryDomain), WTFMove(topFramePrimaryDomain), frameID, pageID, userWasPromptedNow, WTFMove(completionHandler));477 } 478 479 void ResourceLoadStatisticsMemoryStore::grantStorageAccessInternal( String&& subFramePrimaryDomain, String&& topFramePrimaryDomain, Optional<uint64_t> frameID, uint64_t pageID, bool userWasPromptedNowOrEarlier, CompletionHandler<void(bool)>&& callback)480 { 481 ASSERT(!RunLoop::isMain()); 482 483 if (subFrame PrimaryDomain == topFramePrimaryDomain) {471 subFrameStatistic.storageAccessUnderTopFrameOrigins.add(topFrameDomain.string()); 472 } 473 grantStorageAccessInternal(WTFMove(subFrameDomain), WTFMove(topFrameDomain), frameID, pageID, userWasPromptedNow, WTFMove(completionHandler)); 474 } 475 476 void ResourceLoadStatisticsMemoryStore::grantStorageAccessInternal(RegistrableDomain&& subFrameDomain, RegistrableDomain&& topFrameDomain, Optional<uint64_t> frameID, uint64_t pageID, bool userWasPromptedNowOrEarlier, CompletionHandler<void(bool)>&& callback) 477 { 478 ASSERT(!RunLoop::isMain()); 479 480 if (subFrameDomain == topFrameDomain) { 484 481 callback(true); 485 482 return; … … 488 485 // FIXME: Remove m_storageAccessPromptsEnabled check if prompting is no longer experimental. 489 486 if (userWasPromptedNowOrEarlier && m_storageAccessPromptsEnabled) { 490 auto& subFrameStatistic = ensureResourceStatisticsFor PrimaryDomain(subFramePrimaryDomain);487 auto& subFrameStatistic = ensureResourceStatisticsForRegistrableDomain(subFrameDomain); 491 488 ASSERT(subFrameStatistic.hadUserInteraction); 492 ASSERT(subFrameStatistic.storageAccessUnderTopFrameOrigins.contains(topFrame PrimaryDomain));489 ASSERT(subFrameStatistic.storageAccessUnderTopFrameOrigins.contains(topFrameDomain.string())); 493 490 subFrameStatistic.mostRecentUserInteractionTime = WallTime::now(); 494 491 } 495 492 496 RunLoop::main().dispatch([subFrame PrimaryDomain = subFramePrimaryDomain.isolatedCopy(), topFramePrimaryDomain = topFramePrimaryDomain.isolatedCopy(), frameID, pageID, store = makeRef(m_store), callback = WTFMove(callback)]() mutable {497 store->callGrantStorageAccessHandler(subFrame PrimaryDomain, topFramePrimaryDomain, frameID, pageID, [callback = WTFMove(callback), store = store.copyRef()](bool value) mutable {493 RunLoop::main().dispatch([subFrameDomain = subFrameDomain.isolatedCopy(), topFrameDomain = topFrameDomain.isolatedCopy(), frameID, pageID, store = makeRef(m_store), callback = WTFMove(callback)]() mutable { 494 store->callGrantStorageAccessHandler(subFrameDomain, topFrameDomain, frameID, pageID, [callback = WTFMove(callback), store = store.copyRef()](bool value) mutable { 498 495 store->statisticsQueue().dispatch([callback = WTFMove(callback), value] () mutable { 499 496 callback(value); … … 508 505 509 506 RunLoop::main().dispatch([weakThis = makeWeakPtr(*this), callback = WTFMove(callback), shouldNotifyPagesWhenDataRecordsWereScanned = m_parameters.shouldNotifyPagesWhenDataRecordsWereScanned, workQueue = m_workQueue.copyRef(), store = makeRef(m_store)] () mutable { 510 store-> topPrivatelyControlledDomainsWithWebsiteData(WebResourceLoadStatisticsStore::monitoredDataTypes(), shouldNotifyPagesWhenDataRecordsWereScanned, [weakThis = WTFMove(weakThis), callback = WTFMove(callback), workQueue = workQueue.copyRef()] (HashSet<String>&& topDomainsWithWebsiteData) mutable {511 workQueue->dispatch([weakThis = WTFMove(weakThis), topDomains = crossThreadCopy(topDomainsWithWebsiteData), callback = WTFMove(callback)] () mutable {507 store->registrableDomainsWithWebsiteData(WebResourceLoadStatisticsStore::monitoredDataTypes(), shouldNotifyPagesWhenDataRecordsWereScanned, [weakThis = WTFMove(weakThis), callback = WTFMove(callback), workQueue = workQueue.copyRef()] (HashSet<RegistrableDomain>&& domainsWithWebsiteData) mutable { 508 workQueue->dispatch([weakThis = WTFMove(weakThis), domainsWithWebsiteData = crossThreadCopy(domainsWithWebsiteData), callback = WTFMove(callback)] () mutable { 512 509 if (!weakThis) { 513 510 callback(); … … 515 512 } 516 513 517 for (auto& topPrivatelyControlledDomain : topDomains) {518 auto& statistic = weakThis->ensureResourceStatisticsFor PrimaryDomain(topPrivatelyControlledDomain);514 for (auto& domain : domainsWithWebsiteData) { 515 auto& statistic = weakThis->ensureResourceStatisticsForRegistrableDomain(domain); 519 516 statistic.grandfathered = true; 520 517 } … … 529 526 } 530 527 531 Vector< String> ResourceLoadStatisticsMemoryStore::ensurePrevalentResourcesForDebugMode()528 Vector<RegistrableDomain> ResourceLoadStatisticsMemoryStore::ensurePrevalentResourcesForDebugMode() 532 529 { 533 530 if (!m_debugModeEnabled) 534 531 return { }; 535 532 536 Vector< String> primaryDomainsToBlock;537 primaryDomainsToBlock.reserveInitialCapacity(2);538 539 auto& staticSesourceStatistic = ensureResourceStatisticsFor PrimaryDomain(debugStaticPrevalentResource);533 Vector<RegistrableDomain> domainsToBlock; 534 domainsToBlock.reserveInitialCapacity(2); 535 536 auto& staticSesourceStatistic = ensureResourceStatisticsForRegistrableDomain(m_debugStaticPrevalentResource); 540 537 setPrevalentResource(staticSesourceStatistic, ResourceLoadPrevalence::High); 541 primaryDomainsToBlock.uncheckedAppend(debugStaticPrevalentResource);538 domainsToBlock.uncheckedAppend(m_debugStaticPrevalentResource); 542 539 543 540 if (!m_debugManualPrevalentResource.isEmpty()) { 544 auto& manualResourceStatistic = ensureResourceStatisticsFor PrimaryDomain(m_debugManualPrevalentResource);541 auto& manualResourceStatistic = ensureResourceStatisticsForRegistrableDomain(m_debugManualPrevalentResource); 545 542 setPrevalentResource(manualResourceStatistic, ResourceLoadPrevalence::High); 546 primaryDomainsToBlock.uncheckedAppend(m_debugManualPrevalentResource);543 domainsToBlock.uncheckedAppend(m_debugManualPrevalentResource); 547 544 #if !RELEASE_LOG_DISABLED 548 RELEASE_LOG_INFO(ResourceLoadStatisticsDebug, "Did set %{public}s as prevalent resource for the purposes of ITP Debug Mode.", m_debugManualPrevalentResource. utf8().data());545 RELEASE_LOG_INFO(ResourceLoadStatisticsDebug, "Did set %{public}s as prevalent resource for the purposes of ITP Debug Mode.", m_debugManualPrevalentResource.string().utf8().data()); 549 546 #endif 550 547 } 551 548 552 return primaryDomainsToBlock;549 return domainsToBlock; 553 550 } 554 551 … … 571 568 } 572 569 573 void ResourceLoadStatisticsMemoryStore::setPrevalentResourceForDebugMode(const String& domain)570 void ResourceLoadStatisticsMemoryStore::setPrevalentResourceForDebugMode(const RegistrableDomain& domain) 574 571 { 575 572 m_debugManualPrevalentResource = domain; … … 602 599 } 603 600 604 void ResourceLoadStatisticsMemoryStore::logFrameNavigation(const String& targetPrimaryDomain, const String& mainFramePrimaryDomain, const String& sourcePrimaryDomain, const String& targetHost, const String& mainFrameHost, bool isRedirect, bool isMainFrame)605 { 606 ASSERT(!RunLoop::isMain()); 607 608 bool areTargetAnd MainFrameDomainsAssociated = targetPrimaryDomain == mainFramePrimaryDomain;609 bool areTargetAndSourceDomains Associated = targetPrimaryDomain == sourcePrimaryDomain;601 void ResourceLoadStatisticsMemoryStore::logFrameNavigation(const RegistrableDomain& targetDomain, const RegistrableDomain& topFrameDomain, const RegistrableDomain& sourceDomain, bool isRedirect, bool isMainFrame) 602 { 603 ASSERT(!RunLoop::isMain()); 604 605 bool areTargetAndTopFrameDomainsSameSite = targetDomain == topFrameDomain; 606 bool areTargetAndSourceDomainsSameSite = targetDomain == sourceDomain; 610 607 611 608 bool statisticsWereUpdated = false; 612 if (!isMainFrame && targetHost != mainFrameHost && !(areTargetAndMainFrameDomainsAssociated || areTargetAndSourceDomainsAssociated)) {613 auto& targetStatistics = ensureResourceStatisticsFor PrimaryDomain(targetPrimaryDomain);609 if (!isMainFrame && !(areTargetAndTopFrameDomainsSameSite || areTargetAndSourceDomainsSameSite)) { 610 auto& targetStatistics = ensureResourceStatisticsForRegistrableDomain(targetDomain); 614 611 targetStatistics.lastSeen = ResourceLoadStatistics::reduceTimeResolution(WallTime::now()); 615 if (targetStatistics.subframeUnderTopFrameOrigins.add( mainFramePrimaryDomain).isNewEntry)612 if (targetStatistics.subframeUnderTopFrameOrigins.add(topFrameDomain.string()).isNewEntry) 616 613 statisticsWereUpdated = true; 617 614 } 618 615 619 if (isRedirect && !areTargetAndSourceDomains Associated) {616 if (isRedirect && !areTargetAndSourceDomainsSameSite) { 620 617 if (isMainFrame) { 621 auto& redirectingOriginStatistics = ensureResourceStatisticsFor PrimaryDomain(sourcePrimaryDomain);622 if (redirectingOriginStatistics.topFrameUniqueRedirectsTo.add(target PrimaryDomain).isNewEntry)618 auto& redirectingOriginStatistics = ensureResourceStatisticsForRegistrableDomain(sourceDomain); 619 if (redirectingOriginStatistics.topFrameUniqueRedirectsTo.add(targetDomain.string()).isNewEntry) 623 620 statisticsWereUpdated = true; 624 auto& targetStatistics = ensureResourceStatisticsFor PrimaryDomain(targetPrimaryDomain);625 if (targetStatistics.topFrameUniqueRedirectsFrom.add(source PrimaryDomain).isNewEntry)621 auto& targetStatistics = ensureResourceStatisticsForRegistrableDomain(targetDomain); 622 if (targetStatistics.topFrameUniqueRedirectsFrom.add(sourceDomain.string()).isNewEntry) 626 623 statisticsWereUpdated = true; 627 624 } else { 628 auto& redirectingOriginStatistics = ensureResourceStatisticsFor PrimaryDomain(sourcePrimaryDomain);629 if (redirectingOriginStatistics.subresourceUniqueRedirectsTo.add(target PrimaryDomain).isNewEntry)625 auto& redirectingOriginStatistics = ensureResourceStatisticsForRegistrableDomain(sourceDomain); 626 if (redirectingOriginStatistics.subresourceUniqueRedirectsTo.add(targetDomain.string()).isNewEntry) 630 627 statisticsWereUpdated = true; 631 auto& targetStatistics = ensureResourceStatisticsFor PrimaryDomain(targetPrimaryDomain);632 if (targetStatistics.subresourceUniqueRedirectsFrom.add(source PrimaryDomain).isNewEntry)628 auto& targetStatistics = ensureResourceStatisticsForRegistrableDomain(targetDomain); 629 if (targetStatistics.subresourceUniqueRedirectsFrom.add(sourceDomain.string()).isNewEntry) 633 630 statisticsWereUpdated = true; 634 631 } … … 639 636 } 640 637 641 void ResourceLoadStatisticsMemoryStore::logSubresourceLoading(const String& targetPrimaryDomain, const String& mainFramePrimaryDomain, WallTime lastSeen)642 { 643 ASSERT(!RunLoop::isMain()); 644 645 auto& targetStatistics = ensureResourceStatisticsFor PrimaryDomain(targetPrimaryDomain);638 void ResourceLoadStatisticsMemoryStore::logSubresourceLoading(const RegistrableDomain& targetDomain, const RegistrableDomain& topFrameDomain, WallTime lastSeen) 639 { 640 ASSERT(!RunLoop::isMain()); 641 642 auto& targetStatistics = ensureResourceStatisticsForRegistrableDomain(targetDomain); 646 643 targetStatistics.lastSeen = lastSeen; 647 if (targetStatistics.subresourceUnderTopFrameOrigins.add( mainFramePrimaryDomain).isNewEntry)644 if (targetStatistics.subresourceUnderTopFrameOrigins.add(topFrameDomain.string()).isNewEntry) 648 645 scheduleStatisticsProcessingRequestIfNecessary(); 649 646 } 650 647 651 void ResourceLoadStatisticsMemoryStore::logSubresourceRedirect(const String& sourcePrimaryDomain, const String& targetPrimaryDomain)652 { 653 ASSERT(!RunLoop::isMain()); 654 655 auto& redirectingOriginStatistics = ensureResourceStatisticsFor PrimaryDomain(sourcePrimaryDomain);656 bool isNewRedirectToEntry = redirectingOriginStatistics.subresourceUniqueRedirectsTo.add(target PrimaryDomain).isNewEntry;657 auto& targetStatistics = ensureResourceStatisticsFor PrimaryDomain(targetPrimaryDomain);658 bool isNewRedirectFromEntry = targetStatistics.subresourceUniqueRedirectsFrom.add(source PrimaryDomain).isNewEntry;659 648 void ResourceLoadStatisticsMemoryStore::logSubresourceRedirect(const RegistrableDomain& sourceDomain, const RegistrableDomain& targetDomain) 649 { 650 ASSERT(!RunLoop::isMain()); 651 652 auto& redirectingOriginStatistics = ensureResourceStatisticsForRegistrableDomain(sourceDomain); 653 bool isNewRedirectToEntry = redirectingOriginStatistics.subresourceUniqueRedirectsTo.add(targetDomain.string()).isNewEntry; 654 auto& targetStatistics = ensureResourceStatisticsForRegistrableDomain(targetDomain); 655 bool isNewRedirectFromEntry = targetStatistics.subresourceUniqueRedirectsFrom.add(sourceDomain.string()).isNewEntry; 656 660 657 if (isNewRedirectToEntry || isNewRedirectFromEntry) 661 658 scheduleStatisticsProcessingRequestIfNecessary(); 662 659 } 663 660 664 void ResourceLoadStatisticsMemoryStore::logUserInteraction(const String& primaryDomain)665 { 666 ASSERT(!RunLoop::isMain()); 667 668 auto& statistics = ensureResourceStatisticsFor PrimaryDomain(primaryDomain);661 void ResourceLoadStatisticsMemoryStore::logUserInteraction(const RegistrableDomain& domain) 662 { 663 ASSERT(!RunLoop::isMain()); 664 665 auto& statistics = ensureResourceStatisticsForRegistrableDomain(domain); 669 666 statistics.hadUserInteraction = true; 670 667 statistics.mostRecentUserInteractionTime = WallTime::now(); 671 668 } 672 669 673 void ResourceLoadStatisticsMemoryStore::clearUserInteraction(const String& primaryDomain)674 { 675 ASSERT(!RunLoop::isMain()); 676 677 auto& statistics = ensureResourceStatisticsFor PrimaryDomain(primaryDomain);670 void ResourceLoadStatisticsMemoryStore::clearUserInteraction(const RegistrableDomain& domain) 671 { 672 ASSERT(!RunLoop::isMain()); 673 674 auto& statistics = ensureResourceStatisticsForRegistrableDomain(domain); 678 675 statistics.hadUserInteraction = false; 679 676 statistics.mostRecentUserInteractionTime = { }; 680 677 } 681 678 682 bool ResourceLoadStatisticsMemoryStore::hasHadUserInteraction(const String& primaryDomain)683 { 684 ASSERT(!RunLoop::isMain()); 685 686 auto mapEntry = m_resourceStatisticsMap.find( primaryDomain);679 bool ResourceLoadStatisticsMemoryStore::hasHadUserInteraction(const RegistrableDomain& domain) 680 { 681 ASSERT(!RunLoop::isMain()); 682 683 auto mapEntry = m_resourceStatisticsMap.find(domain); 687 684 return mapEntry == m_resourceStatisticsMap.end() ? false: hasHadUnexpiredRecentUserInteraction(mapEntry->value); 688 685 } 689 686 690 void ResourceLoadStatisticsMemoryStore::setPrevalentResource( WebCore::ResourceLoadStatistics& resourceStatistic, ResourceLoadPrevalence newPrevalence)687 void ResourceLoadStatisticsMemoryStore::setPrevalentResource(ResourceLoadStatistics& resourceStatistic, ResourceLoadPrevalence newPrevalence) 691 688 { 692 689 ASSERT(!RunLoop::isMain()); … … 694 691 resourceStatistic.isPrevalentResource = true; 695 692 resourceStatistic.isVeryPrevalentResource = newPrevalence == ResourceLoadPrevalence::VeryHigh; 696 HashSet< String> domainsThatHaveRedirectedTo;693 HashSet<RegistrableDomain> domainsThatHaveRedirectedTo; 697 694 recursivelyGetAllDomainsThatHaveRedirectedToThisDomain(resourceStatistic, domainsThatHaveRedirectedTo, 0); 698 695 for (auto& domain : domainsThatHaveRedirectedTo) { … … 716 713 } 717 714 718 bool ResourceLoadStatisticsMemoryStore::isPrevalentResource(const String& primaryDomain) const719 { 720 ASSERT(!RunLoop::isMain()); 721 722 auto mapEntry = m_resourceStatisticsMap.find( primaryDomain);715 bool ResourceLoadStatisticsMemoryStore::isPrevalentResource(const RegistrableDomain& domain) const 716 { 717 ASSERT(!RunLoop::isMain()); 718 719 auto mapEntry = m_resourceStatisticsMap.find(domain); 723 720 return mapEntry == m_resourceStatisticsMap.end() ? false : mapEntry->value.isPrevalentResource; 724 721 } 725 722 726 bool ResourceLoadStatisticsMemoryStore::isVeryPrevalentResource(const String& primaryDomain) const727 { 728 ASSERT(!RunLoop::isMain()); 729 730 auto mapEntry = m_resourceStatisticsMap.find( primaryDomain);723 bool ResourceLoadStatisticsMemoryStore::isVeryPrevalentResource(const RegistrableDomain& domain) const 724 { 725 ASSERT(!RunLoop::isMain()); 726 727 auto mapEntry = m_resourceStatisticsMap.find(domain); 731 728 return mapEntry == m_resourceStatisticsMap.end() ? false : mapEntry->value.isPrevalentResource && mapEntry->value.isVeryPrevalentResource; 732 729 } 733 730 734 bool ResourceLoadStatisticsMemoryStore::isRegisteredAsSubresourceUnder(const String& subresourcePrimaryDomain, const String& topFramePrimaryDomain) const735 { 736 ASSERT(!RunLoop::isMain()); 737 738 auto mapEntry = m_resourceStatisticsMap.find(subresource PrimaryDomain);739 return mapEntry == m_resourceStatisticsMap.end() ? false : mapEntry->value.subresourceUnderTopFrameOrigins.contains(topFrame PrimaryDomain);740 } 741 742 bool ResourceLoadStatisticsMemoryStore::isRegisteredAsSubFrameUnder(const String& subFramePrimaryDomain, const String& topFramePrimaryDomain) const743 { 744 ASSERT(!RunLoop::isMain()); 745 746 auto mapEntry = m_resourceStatisticsMap.find(subFrame PrimaryDomain);747 return mapEntry == m_resourceStatisticsMap.end() ? false : mapEntry->value.subframeUnderTopFrameOrigins.contains(topFrame PrimaryDomain);748 } 749 750 bool ResourceLoadStatisticsMemoryStore::isRegisteredAsRedirectingTo(const String& hostRedirectedFromPrimaryDomain, const String& hostRedirectedToPrimaryDomain) const751 { 752 ASSERT(!RunLoop::isMain()); 753 754 auto mapEntry = m_resourceStatisticsMap.find( hostRedirectedFromPrimaryDomain);755 return mapEntry == m_resourceStatisticsMap.end() ? false : mapEntry->value.subresourceUniqueRedirectsTo.contains( hostRedirectedToPrimaryDomain);756 } 757 758 void ResourceLoadStatisticsMemoryStore::clearPrevalentResource(const String& primaryDomain)759 { 760 ASSERT(!RunLoop::isMain()); 761 762 auto& statistics = ensureResourceStatisticsFor PrimaryDomain(primaryDomain);731 bool ResourceLoadStatisticsMemoryStore::isRegisteredAsSubresourceUnder(const RegistrableDomain& subresourceDomain, const RegistrableDomain& topFrameDomain) const 732 { 733 ASSERT(!RunLoop::isMain()); 734 735 auto mapEntry = m_resourceStatisticsMap.find(subresourceDomain); 736 return mapEntry == m_resourceStatisticsMap.end() ? false : mapEntry->value.subresourceUnderTopFrameOrigins.contains(topFrameDomain.string()); 737 } 738 739 bool ResourceLoadStatisticsMemoryStore::isRegisteredAsSubFrameUnder(const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain) const 740 { 741 ASSERT(!RunLoop::isMain()); 742 743 auto mapEntry = m_resourceStatisticsMap.find(subFrameDomain); 744 return mapEntry == m_resourceStatisticsMap.end() ? false : mapEntry->value.subframeUnderTopFrameOrigins.contains(topFrameDomain.string()); 745 } 746 747 bool ResourceLoadStatisticsMemoryStore::isRegisteredAsRedirectingTo(const RegistrableDomain& redirectedFromDomain, const RegistrableDomain& redirectedToDomain) const 748 { 749 ASSERT(!RunLoop::isMain()); 750 751 auto mapEntry = m_resourceStatisticsMap.find(redirectedFromDomain); 752 return mapEntry == m_resourceStatisticsMap.end() ? false : mapEntry->value.subresourceUniqueRedirectsTo.contains(redirectedToDomain.string()); 753 } 754 755 void ResourceLoadStatisticsMemoryStore::clearPrevalentResource(const RegistrableDomain& domain) 756 { 757 ASSERT(!RunLoop::isMain()); 758 759 auto& statistics = ensureResourceStatisticsForRegistrableDomain(domain); 763 760 statistics.isPrevalentResource = false; 764 761 statistics.isVeryPrevalentResource = false; 765 762 } 766 763 767 void ResourceLoadStatisticsMemoryStore::setGrandfathered(const String& primaryDomain, bool value)768 { 769 ASSERT(!RunLoop::isMain()); 770 771 auto& statistics = ensureResourceStatisticsFor PrimaryDomain(primaryDomain);764 void ResourceLoadStatisticsMemoryStore::setGrandfathered(const RegistrableDomain& domain, bool value) 765 { 766 ASSERT(!RunLoop::isMain()); 767 768 auto& statistics = ensureResourceStatisticsForRegistrableDomain(domain); 772 769 statistics.grandfathered = value; 773 770 } 774 771 775 bool ResourceLoadStatisticsMemoryStore::isGrandfathered(const String& primaryDomain) const776 { 777 ASSERT(!RunLoop::isMain()); 778 779 auto mapEntry = m_resourceStatisticsMap.find( primaryDomain);772 bool ResourceLoadStatisticsMemoryStore::isGrandfathered(const RegistrableDomain& domain) const 773 { 774 ASSERT(!RunLoop::isMain()); 775 776 auto mapEntry = m_resourceStatisticsMap.find(domain); 780 777 return mapEntry == m_resourceStatisticsMap.end() ? false : mapEntry->value.grandfathered; 781 778 } 782 779 783 void ResourceLoadStatisticsMemoryStore::setSubframeUnderTopFrameOrigin(const String& primarySubFrameDomain, const String& primaryTopFrameDomain)784 { 785 ASSERT(!RunLoop::isMain()); 786 787 auto& statistics = ensureResourceStatisticsFor PrimaryDomain(primarySubFrameDomain);788 statistics.subframeUnderTopFrameOrigins.add( primaryTopFrameDomain);780 void ResourceLoadStatisticsMemoryStore::setSubframeUnderTopFrameOrigin(const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain) 781 { 782 ASSERT(!RunLoop::isMain()); 783 784 auto& statistics = ensureResourceStatisticsForRegistrableDomain(subFrameDomain); 785 statistics.subframeUnderTopFrameOrigins.add(topFrameDomain.string()); 789 786 // For consistency, make sure we also have a statistics entry for the top frame domain. 790 ensureResourceStatisticsFor PrimaryDomain(primaryTopFrameDomain);791 } 792 793 void ResourceLoadStatisticsMemoryStore::setSubresourceUnderTopFrameOrigin(const String& primarySubresourceDomain, const String& primaryTopFrameDomain)794 { 795 ASSERT(!RunLoop::isMain()); 796 797 auto& statistics = ensureResourceStatisticsFor PrimaryDomain(primarySubresourceDomain);798 statistics.subresourceUnderTopFrameOrigins.add( primaryTopFrameDomain);787 ensureResourceStatisticsForRegistrableDomain(topFrameDomain); 788 } 789 790 void ResourceLoadStatisticsMemoryStore::setSubresourceUnderTopFrameOrigin(const RegistrableDomain& subresourceDomain, const RegistrableDomain& topFrameDomain) 791 { 792 ASSERT(!RunLoop::isMain()); 793 794 auto& statistics = ensureResourceStatisticsForRegistrableDomain(subresourceDomain); 795 statistics.subresourceUnderTopFrameOrigins.add(topFrameDomain.string()); 799 796 // For consistency, make sure we also have a statistics entry for the top frame domain. 800 ensureResourceStatisticsFor PrimaryDomain(primaryTopFrameDomain);801 } 802 803 void ResourceLoadStatisticsMemoryStore::setSubresourceUniqueRedirectTo(const String& primarySubresourceDomain, const String& primaryRedirectDomain)804 { 805 ASSERT(!RunLoop::isMain()); 806 807 auto& statistics = ensureResourceStatisticsFor PrimaryDomain(primarySubresourceDomain);808 statistics.subresourceUniqueRedirectsTo.add( primaryRedirectDomain);797 ensureResourceStatisticsForRegistrableDomain(topFrameDomain); 798 } 799 800 void ResourceLoadStatisticsMemoryStore::setSubresourceUniqueRedirectTo(const RegistrableDomain& subresourceDomain, const RegistrableDomain& redirectDomain) 801 { 802 ASSERT(!RunLoop::isMain()); 803 804 auto& statistics = ensureResourceStatisticsForRegistrableDomain(subresourceDomain); 805 statistics.subresourceUniqueRedirectsTo.add(redirectDomain.string()); 809 806 // For consistency, make sure we also have a statistics entry for the redirect domain. 810 ensureResourceStatisticsFor PrimaryDomain(primaryRedirectDomain);811 } 812 813 void ResourceLoadStatisticsMemoryStore::setSubresourceUniqueRedirectFrom(const String& primarySubresourceDomain, const String& primaryRedirectDomain)814 { 815 ASSERT(!RunLoop::isMain()); 816 817 auto& statistics = ensureResourceStatisticsFor PrimaryDomain(primarySubresourceDomain);818 statistics.subresourceUniqueRedirectsFrom.add( primaryRedirectDomain);807 ensureResourceStatisticsForRegistrableDomain(redirectDomain); 808 } 809 810 void ResourceLoadStatisticsMemoryStore::setSubresourceUniqueRedirectFrom(const RegistrableDomain& subresourceDomain, const RegistrableDomain& redirectDomain) 811 { 812 ASSERT(!RunLoop::isMain()); 813 814 auto& statistics = ensureResourceStatisticsForRegistrableDomain(subresourceDomain); 815 statistics.subresourceUniqueRedirectsFrom.add(redirectDomain.string()); 819 816 // For consistency, make sure we also have a statistics entry for the redirect domain. 820 ensureResourceStatisticsFor PrimaryDomain(primaryRedirectDomain);821 } 822 823 void ResourceLoadStatisticsMemoryStore::setTopFrameUniqueRedirectTo(const String& topFramePrimaryDomain, const String& primaryRedirectDomain)824 { 825 ASSERT(!RunLoop::isMain()); 826 827 auto& statistics = ensureResourceStatisticsFor PrimaryDomain(topFramePrimaryDomain);828 statistics.topFrameUniqueRedirectsTo.add( primaryRedirectDomain);817 ensureResourceStatisticsForRegistrableDomain(redirectDomain); 818 } 819 820 void ResourceLoadStatisticsMemoryStore::setTopFrameUniqueRedirectTo(const RegistrableDomain& topFrameDomain, const RegistrableDomain& redirectDomain) 821 { 822 ASSERT(!RunLoop::isMain()); 823 824 auto& statistics = ensureResourceStatisticsForRegistrableDomain(topFrameDomain); 825 statistics.topFrameUniqueRedirectsTo.add(redirectDomain.string()); 829 826 // For consistency, make sure we also have a statistics entry for the redirect domain. 830 ensureResourceStatisticsFor PrimaryDomain(primaryRedirectDomain);831 } 832 833 void ResourceLoadStatisticsMemoryStore::setTopFrameUniqueRedirectFrom(const String& topFramePrimaryDomain, const String& primaryRedirectDomain)834 { 835 ASSERT(!RunLoop::isMain()); 836 837 auto& statistics = ensureResourceStatisticsFor PrimaryDomain(topFramePrimaryDomain);838 statistics.topFrameUniqueRedirectsFrom.add( primaryRedirectDomain);827 ensureResourceStatisticsForRegistrableDomain(redirectDomain); 828 } 829 830 void ResourceLoadStatisticsMemoryStore::setTopFrameUniqueRedirectFrom(const RegistrableDomain& topFrameDomain, const RegistrableDomain& redirectDomain) 831 { 832 ASSERT(!RunLoop::isMain()); 833 834 auto& statistics = ensureResourceStatisticsForRegistrableDomain(topFrameDomain); 835 statistics.topFrameUniqueRedirectsFrom.add(redirectDomain.string()); 839 836 // For consistency, make sure we also have a statistics entry for the redirect domain. 840 ensureResourceStatisticsFor PrimaryDomain(primaryRedirectDomain);837 ensureResourceStatisticsForRegistrableDomain(redirectDomain); 841 838 } 842 839 … … 930 927 } 931 928 932 ResourceLoadStatistics& ResourceLoadStatisticsMemoryStore::ensureResourceStatisticsFor PrimaryDomain(const String& primaryDomain)933 { 934 ASSERT(!RunLoop::isMain()); 935 936 return m_resourceStatisticsMap.ensure( primaryDomain, [&primaryDomain] {937 return ResourceLoadStatistics( primaryDomain);929 ResourceLoadStatistics& ResourceLoadStatisticsMemoryStore::ensureResourceStatisticsForRegistrableDomain(const RegistrableDomain& domain) 930 { 931 ASSERT(!RunLoop::isMain()); 932 933 return m_resourceStatisticsMap.ensure(domain, [&domain] { 934 return ResourceLoadStatistics(domain); 938 935 }).iterator->value; 939 936 } … … 1034 1031 1035 1032 for (auto& statistic : statistics) { 1036 auto result = m_resourceStatisticsMap.ensure(statistic. highLevelDomain, [&statistic] {1033 auto result = m_resourceStatisticsMap.ensure(statistic.registrableDomain, [&statistic] { 1037 1034 return WTFMove(statistic); 1038 1035 }); … … 1055 1052 } 1056 1053 1057 bool ResourceLoadStatisticsMemoryStore::hasUserGrantedStorageAccessThroughPrompt(const ResourceLoadStatistics& statistic, const String& firstPartyPrimaryDomain)1058 { 1059 return statistic.storageAccessUnderTopFrameOrigins.contains(firstParty PrimaryDomain);1060 } 1061 1062 static void debugLogDomainsInBatches(const char* action, const Vector< String>& domains)1054 bool ResourceLoadStatisticsMemoryStore::hasUserGrantedStorageAccessThroughPrompt(const ResourceLoadStatistics& statistic, const RegistrableDomain& firstPartyDomain) 1055 { 1056 return statistic.storageAccessUnderTopFrameOrigins.contains(firstPartyDomain.string()); 1057 } 1058 1059 static void debugLogDomainsInBatches(const char* action, const Vector<RegistrableDomain>& domains) 1063 1060 { 1064 1061 #if !RELEASE_LOG_DISABLED … … 1072 1069 } 1073 1070 1074 Vector< String> batch;1071 Vector<RegistrableDomain> batch; 1075 1072 batch.reserveInitialCapacity(maxNumberOfDomainsInOneLogStatement); 1076 1073 auto batchNumber = 1; … … 1097 1094 ASSERT(!RunLoop::isMain()); 1098 1095 1099 Vector< String> domainsToBlock;1096 Vector<RegistrableDomain> domainsToBlock; 1100 1097 for (auto& resourceStatistic : m_resourceStatisticsMap.values()) { 1101 1098 if (resourceStatistic.isPrevalentResource) 1102 domainsToBlock.append(resourceStatistic. highLevelDomain);1099 domainsToBlock.append(resourceStatistic.registrableDomain); 1103 1100 } 1104 1101 … … 1125 1122 } 1126 1123 1127 void ResourceLoadStatisticsMemoryStore::updateCookieBlockingForDomains(const Vector< String>& domainsToBlock, CompletionHandler<void()>&& completionHandler)1124 void ResourceLoadStatisticsMemoryStore::updateCookieBlockingForDomains(const Vector<RegistrableDomain>& domainsToBlock, CompletionHandler<void()>&& completionHandler) 1128 1125 { 1129 1126 ASSERT(!RunLoop::isMain()); … … 1138 1135 } 1139 1136 1140 void ResourceLoadStatisticsMemoryStore::clearBlockingStateForDomains(const Vector< String>& domains, CompletionHandler<void()>&& completionHandler)1137 void ResourceLoadStatisticsMemoryStore::clearBlockingStateForDomains(const Vector<RegistrableDomain>& domains, CompletionHandler<void()>&& completionHandler) 1141 1138 { 1142 1139 ASSERT(!RunLoop::isMain()); … … 1178 1175 } 1179 1176 1180 Vector< String> ResourceLoadStatisticsMemoryStore::topPrivatelyControlledDomainsToRemoveWebsiteDataFor()1177 Vector<RegistrableDomain> ResourceLoadStatisticsMemoryStore::registrableDomainsToRemoveWebsiteDataFor() 1181 1178 { 1182 1179 ASSERT(!RunLoop::isMain()); … … 1188 1185 m_endOfGrandfatheringTimestamp = { }; 1189 1186 1190 Vector< String> prevalentResources;1187 Vector<RegistrableDomain> prevalentResources; 1191 1188 for (auto& statistic : m_resourceStatisticsMap.values()) { 1192 1189 if (statistic.isPrevalentResource && !hasHadUnexpiredRecentUserInteraction(statistic) && (!shouldCheckForGrandfathering || !statistic.grandfathered)) 1193 prevalentResources.append(statistic. highLevelDomain);1190 prevalentResources.append(statistic.registrableDomain); 1194 1191 1195 1192 if (shouldClearGrandfathering && statistic.grandfathered) … … 1260 1257 Vector<StatisticsLastSeen> resourcesToPrunePerImportance[maxImportance + 1]; 1261 1258 for (auto& resourceStatistic : m_resourceStatisticsMap.values()) 1262 resourcesToPrunePerImportance[computeImportance(resourceStatistic)].append({ resourceStatistic. highLevelDomain, resourceStatistic.lastSeen });1259 resourcesToPrunePerImportance[computeImportance(resourceStatistic)].append({ resourceStatistic.registrableDomain, resourceStatistic.lastSeen }); 1263 1260 1264 1261 for (unsigned importance = 0; numberOfEntriesLeftToPrune && importance <= maxImportance; ++importance) … … 1284 1281 } 1285 1282 1286 void ResourceLoadStatisticsMemoryStore::setLastSeen(const String& primaryDomain, Seconds seconds)1287 { 1288 ASSERT(!RunLoop::isMain()); 1289 1290 auto& statistics = ensureResourceStatisticsFor PrimaryDomain(primaryDomain);1283 void ResourceLoadStatisticsMemoryStore::setLastSeen(const RegistrableDomain& domain, Seconds seconds) 1284 { 1285 ASSERT(!RunLoop::isMain()); 1286 1287 auto& statistics = ensureResourceStatisticsForRegistrableDomain(domain); 1291 1288 statistics.lastSeen = WallTime::fromRawSeconds(seconds.seconds()); 1292 1289 } 1293 1290 1294 void ResourceLoadStatisticsMemoryStore::setPrevalentResource(const String& primaryDomain)1295 { 1296 ASSERT(!RunLoop::isMain()); 1297 1298 auto& resourceStatistic = ensureResourceStatisticsFor PrimaryDomain(primaryDomain);1291 void ResourceLoadStatisticsMemoryStore::setPrevalentResource(const RegistrableDomain& domain) 1292 { 1293 ASSERT(!RunLoop::isMain()); 1294 1295 auto& resourceStatistic = ensureResourceStatisticsForRegistrableDomain(domain); 1299 1296 setPrevalentResource(resourceStatistic, ResourceLoadPrevalence::High); 1300 1297 } 1301 1298 1302 void ResourceLoadStatisticsMemoryStore::setVeryPrevalentResource(const String& primaryDomain)1303 { 1304 ASSERT(!RunLoop::isMain()); 1305 1306 auto& resourceStatistic = ensureResourceStatisticsFor PrimaryDomain(primaryDomain);1299 void ResourceLoadStatisticsMemoryStore::setVeryPrevalentResource(const RegistrableDomain& domain) 1300 { 1301 ASSERT(!RunLoop::isMain()); 1302 1303 auto& resourceStatistic = ensureResourceStatisticsForRegistrableDomain(domain); 1307 1304 setPrevalentResource(resourceStatistic, ResourceLoadPrevalence::VeryHigh); 1308 1305 } -
trunk/Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.h
r240498 r242056 53 53 class ResourceLoadStatisticsMemoryStore : public CanMakeWeakPtr<ResourceLoadStatisticsMemoryStore> { 54 54 public: 55 using ResourceLoadStatistics = WebCore::ResourceLoadStatistics; 56 using RegistrableDomain = WebCore::RegistrableDomain; 57 using TopFrameDomain = WebCore::RegistrableDomain; 58 using SubFrameDomain = WebCore::RegistrableDomain; 59 using SubResourceDomain = WebCore::RegistrableDomain; 60 using RedirectDomain = WebCore::RegistrableDomain; 61 using RedirectedFromDomain = WebCore::RegistrableDomain; 62 using RedirectedToDomain = WebCore::RegistrableDomain; 63 using NavigatedFromDomain = WebCore::RegistrableDomain; 64 using NavigatedToDomain = WebCore::RegistrableDomain; 65 using DomainInNeedOfStorageAccess = WebCore::RegistrableDomain; 66 using OpenerDomain = WebCore::RegistrableDomain; 67 using OpenerPageID = uint64_t; 68 using PageID = uint64_t; 69 using FrameID = uint64_t; 70 55 71 ResourceLoadStatisticsMemoryStore(WebResourceLoadStatisticsStore&, WorkQueue&); 56 72 ~ResourceLoadStatisticsMemoryStore(); … … 64 80 void mergeWithDataFromDecoder(WebCore::KeyedDecoder&); 65 81 66 void mergeStatistics(Vector< WebCore::ResourceLoadStatistics>&&);67 void processStatistics(const Function<void(const WebCore::ResourceLoadStatistics&)>&) const;82 void mergeStatistics(Vector<ResourceLoadStatistics>&&); 83 void processStatistics(const Function<void(const ResourceLoadStatistics&)>&) const; 68 84 69 85 void updateCookieBlocking(CompletionHandler<void()>&&); 70 void updateCookieBlockingForDomains(const Vector< String>& domainsToBlock, CompletionHandler<void()>&&);71 void clearBlockingStateForDomains(const Vector< String>& domains, CompletionHandler<void()>&&);86 void updateCookieBlockingForDomains(const Vector<RegistrableDomain>&, CompletionHandler<void()>&&); 87 void clearBlockingStateForDomains(const Vector<RegistrableDomain>&, CompletionHandler<void()>&&); 72 88 73 89 void includeTodayAsOperatingDateIfNecessary(); 74 90 void processStatisticsAndDataRecords(); 75 91 76 void requestStorageAccessUnderOpener( String&& primaryDomainInNeedOfStorageAccess, uint64_t openerPageID, String&& openerPrimaryDomain);92 void requestStorageAccessUnderOpener(DomainInNeedOfStorageAccess&&, OpenerPageID, OpenerDomain&&); 77 93 void removeAllStorageAccess(CompletionHandler<void()>&&); 78 94 … … 80 96 void cancelPendingStatisticsProcessingRequest(); 81 97 82 bool isRegisteredAsSubresourceUnder(const S tring& subresourcePrimaryDomain, const String& topFramePrimaryDomain) const;83 bool isRegisteredAsSubFrameUnder(const S tring& subFramePrimaryDomain, const String& topFramePrimaryDomain) const;84 bool isRegisteredAsRedirectingTo(const String& hostRedirectedFromPrimaryDomain, const String& hostRedirectedToPrimaryDomain) const;85 86 void clearPrevalentResource(const String& primaryDomain);98 bool isRegisteredAsSubresourceUnder(const SubResourceDomain&, const TopFrameDomain&) const; 99 bool isRegisteredAsSubFrameUnder(const SubFrameDomain&, const TopFrameDomain&) const; 100 bool isRegisteredAsRedirectingTo(const RedirectedFromDomain&, const RedirectedToDomain&) const; 101 102 void clearPrevalentResource(const RegistrableDomain&); 87 103 String dumpResourceLoadStatistics() const; 88 bool isPrevalentResource(const String& primaryDomain) const;89 bool isVeryPrevalentResource(const String& primaryDomain) const;90 void setPrevalentResource(const String& primaryDomain);91 void setVeryPrevalentResource(const String& primaryDomain);92 93 void setGrandfathered(const String& primaryDomain, bool value);94 bool isGrandfathered(const String& primaryDomain) const;95 96 void setSubframeUnderTopFrameOrigin(const S tring& primarySubFrameDomain, const String& primaryTopFrameDomain);97 void setSubresourceUnderTopFrameOrigin(const S tring& primarySubresourceDomain, const String& primaryTopFrameDomain);98 void setSubresourceUniqueRedirectTo(const S tring& primarySubresourceDomain, const String& primaryRedirectDomain);99 void setSubresourceUniqueRedirectFrom(const S tring& primarySubresourceDomain, const String& primaryRedirectDomain);100 void setTopFrameUniqueRedirectTo(const String& topFramePrimaryDomain, const String& primaryRedirectDomain);101 void setTopFrameUniqueRedirectFrom(const String& topFramePrimaryDomain, const String& primaryRedirectDomain);104 bool isPrevalentResource(const RegistrableDomain&) const; 105 bool isVeryPrevalentResource(const RegistrableDomain&) const; 106 void setPrevalentResource(const RegistrableDomain&); 107 void setVeryPrevalentResource(const RegistrableDomain&); 108 109 void setGrandfathered(const RegistrableDomain&, bool value); 110 bool isGrandfathered(const RegistrableDomain&) const; 111 112 void setSubframeUnderTopFrameOrigin(const SubFrameDomain&, const TopFrameDomain&); 113 void setSubresourceUnderTopFrameOrigin(const SubResourceDomain&, const TopFrameDomain&); 114 void setSubresourceUniqueRedirectTo(const SubResourceDomain&, const RedirectDomain&); 115 void setSubresourceUniqueRedirectFrom(const SubResourceDomain&, const RedirectDomain&); 116 void setTopFrameUniqueRedirectTo(const TopFrameDomain&, const RedirectDomain&); 117 void setTopFrameUniqueRedirectFrom(const TopFrameDomain&, const RedirectDomain&); 102 118 103 119 void logTestingEvent(const String&); … … 117 133 void setResourceLoadStatisticsDebugMode(bool); 118 134 bool isDebugModeEnabled() const { return m_debugModeEnabled; }; 119 void setPrevalentResourceForDebugMode(const String& domain);120 121 void hasStorageAccess(const S tring& subFramePrimaryDomain, const String& topFramePrimaryDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&&);122 void requestStorageAccess(S tring&& subFramePrimaryDomain, String&& topFramePrimaryDomain, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&&);123 void grantStorageAccess(S tring&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPromptedNow, CompletionHandler<void(bool)>&&);124 125 void logFrameNavigation(const String& targetPrimaryDomain, const String& mainFramePrimaryDomain, const String& sourcePrimaryDomain, const String& targetHost, const String& mainFrameHost, bool isRedirect, bool isMainFrame);126 void logUserInteraction(const String& primaryDomain);127 void logSubresourceLoading(const S tring& targetPrimaryDomain, const String& mainFramePrimaryDomain, WallTime lastSeen);128 void logSubresourceRedirect(const String& sourcePrimaryDomain, const String& targetPrimaryDomain);129 130 void clearUserInteraction(const String& primaryDomain);131 bool hasHadUserInteraction(const String& primaryDomain);132 133 void setLastSeen(const String& primaryDomain, Seconds);135 void setPrevalentResourceForDebugMode(const RegistrableDomain&); 136 137 void hasStorageAccess(const SubFrameDomain&, const TopFrameDomain&, Optional<FrameID>, PageID, CompletionHandler<void(bool)>&&); 138 void requestStorageAccess(SubFrameDomain&&, TopFrameDomain&&, FrameID, PageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&&); 139 void grantStorageAccess(SubFrameDomain&&, TopFrameDomain&&, FrameID, PageID, bool userWasPromptedNow, CompletionHandler<void(bool)>&&); 140 141 void logFrameNavigation(const NavigatedToDomain&, const TopFrameDomain&, const NavigatedFromDomain&, bool isRedirect, bool isMainFrame); 142 void logUserInteraction(const TopFrameDomain&); 143 void logSubresourceLoading(const SubResourceDomain&, const TopFrameDomain&, WallTime lastSeen); 144 void logSubresourceRedirect(const RedirectedFromDomain&, const RedirectedToDomain&); 145 146 void clearUserInteraction(const RegistrableDomain&); 147 bool hasHadUserInteraction(const RegistrableDomain&); 148 149 void setLastSeen(const RegistrableDomain&, Seconds); 134 150 135 151 void didCreateNetworkProcess(); … … 138 154 139 155 private: 140 static bool shouldBlockAndKeepCookies(const WebCore::ResourceLoadStatistics&);141 static bool shouldBlockAndPurgeCookies(const WebCore::ResourceLoadStatistics&);142 static bool hasUserGrantedStorageAccessThroughPrompt(const WebCore::ResourceLoadStatistics&, const String& firstPartyPrimaryDomain);143 bool hasHadUnexpiredRecentUserInteraction( WebCore::ResourceLoadStatistics&) const;144 bool hasStatisticsExpired(const WebCore::ResourceLoadStatistics&) const;145 bool wasAccessedAsFirstPartyDueToUserInteraction(const WebCore::ResourceLoadStatistics& current, const WebCore::ResourceLoadStatistics& updated) const;146 void setPrevalentResource( WebCore::ResourceLoadStatistics&, ResourceLoadPrevalence);147 unsigned recursivelyGetAllDomainsThatHaveRedirectedToThisDomain(const WebCore::ResourceLoadStatistics&, HashSet<String>& domainsThatHaveRedirectedTo, unsigned numberOfRecursiveCalls) const;156 static bool shouldBlockAndKeepCookies(const ResourceLoadStatistics&); 157 static bool shouldBlockAndPurgeCookies(const ResourceLoadStatistics&); 158 static bool hasUserGrantedStorageAccessThroughPrompt(const ResourceLoadStatistics&, const RegistrableDomain&); 159 bool hasHadUnexpiredRecentUserInteraction(ResourceLoadStatistics&) const; 160 bool hasStatisticsExpired(const ResourceLoadStatistics&) const; 161 bool wasAccessedAsFirstPartyDueToUserInteraction(const ResourceLoadStatistics& current, const ResourceLoadStatistics& updated) const; 162 void setPrevalentResource(ResourceLoadStatistics&, ResourceLoadPrevalence); 163 unsigned recursivelyGetAllDomainsThatHaveRedirectedToThisDomain(const ResourceLoadStatistics&, HashSet<RedirectedToDomain>&, unsigned numberOfRecursiveCalls) const; 148 164 void setStorageAccessPromptsEnabled(bool enabled) { m_storageAccessPromptsEnabled = enabled; } 149 165 bool shouldRemoveDataRecords() const; … … 151 167 void setDataRecordsBeingRemoved(bool); 152 168 void scheduleStatisticsProcessingRequestIfNecessary(); 153 void grantStorageAccessInternal(S tring&& subFrameHost, String&& topFrameHost, Optional<uint64_t> frameID, uint64_t pageID, bool userWasPromptedNowOrEarlier, CompletionHandler<void(bool)>&&);154 void markAsPrevalentIfHasRedirectedToPrevalent( WebCore::ResourceLoadStatistics&);155 bool isPrevalentDueToDebugMode( WebCore::ResourceLoadStatistics&);156 Vector< String> ensurePrevalentResourcesForDebugMode();169 void grantStorageAccessInternal(SubFrameDomain&&, TopFrameDomain&&, Optional<FrameID>, PageID, bool userWasPromptedNowOrEarlier, CompletionHandler<void(bool)>&&); 170 void markAsPrevalentIfHasRedirectedToPrevalent(ResourceLoadStatistics&); 171 bool isPrevalentDueToDebugMode(ResourceLoadStatistics&); 172 Vector<RegistrableDomain> ensurePrevalentResourcesForDebugMode(); 157 173 void removeDataRecords(CompletionHandler<void()>&&); 158 174 void pruneStatisticsIfNeeded(); 159 WebCore::ResourceLoadStatistics& ensureResourceStatisticsForPrimaryDomain(const String&);160 Vector< String> topPrivatelyControlledDomainsToRemoveWebsiteDataFor();175 ResourceLoadStatistics& ensureResourceStatisticsForRegistrableDomain(const RegistrableDomain&); 176 Vector<RegistrableDomain> registrableDomainsToRemoveWebsiteDataFor(); 161 177 void setCacheMaxAgeCap(Seconds); 162 178 void updateCacheMaxAgeCap(); … … 184 200 Ref<WorkQueue> m_workQueue; 185 201 WeakPtr<ResourceLoadStatisticsPersistentStorage> m_persistentStorage; 186 HashMap< String, WebCore::ResourceLoadStatistics> m_resourceStatisticsMap;202 HashMap<RegistrableDomain, ResourceLoadStatistics> m_resourceStatisticsMap; 187 203 #if HAVE(CORE_PREDICTION) 188 204 ResourceLoadStatisticsClassifierCocoa m_resourceLoadStatisticsClassifier; … … 198 214 bool m_debugLoggingEnabled { false }; 199 215 bool m_debugModeEnabled { false }; 200 String m_debugManualPrevalentResource; 216 const RegistrableDomain m_debugStaticPrevalentResource { "3rdpartytestwebkit.org"_s }; 217 RegistrableDomain m_debugManualPrevalentResource; 201 218 bool m_storageAccessPromptsEnabled { false }; 202 219 bool m_dataRecordsBeingRemoved { false }; -
trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.cpp
r241924 r242056 57 57 using namespace WebCore; 58 58 59 template<typename T> static inline String isolatedPrimaryDomain(const T& value)60 {61 return ResourceLoadStatistics::primaryDomain(value).isolatedCopy();62 }63 64 59 const OptionSet<WebsiteDataType>& WebResourceLoadStatisticsStore::monitoredDataTypes() 65 60 { … … 209 204 } 210 205 211 void WebResourceLoadStatisticsStore::setPrevalentResourceForDebugMode(const String& primaryDomain, CompletionHandler<void()>&& completionHandler)212 { 213 ASSERT(RunLoop::isMain()); 214 215 postTask([this, primaryDomain = isolatedPrimaryDomain(primaryDomain), completionHandler = WTFMove(completionHandler)]() mutable {216 if (m_memoryStore) 217 m_memoryStore->setPrevalentResourceForDebugMode( primaryDomain);206 void WebResourceLoadStatisticsStore::setPrevalentResourceForDebugMode(const RegistrableDomain& domain, CompletionHandler<void()>&& completionHandler) 207 { 208 ASSERT(RunLoop::isMain()); 209 210 postTask([this, domain = domain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { 211 if (m_memoryStore) 212 m_memoryStore->setPrevalentResourceForDebugMode(domain); 218 213 postTaskReply(WTFMove(completionHandler)); 219 214 }); … … 258 253 } 259 254 260 void WebResourceLoadStatisticsStore::hasStorageAccess(const String& subFrameHost, const String& topFrameHost, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler)261 { 262 ASSERT(subFrame Host != topFrameHost);263 ASSERT(RunLoop::isMain()); 264 265 postTask([this, subFrame PrimaryDomain = isolatedPrimaryDomain(subFrameHost), topFramePrimaryDomain = isolatedPrimaryDomain(topFrameHost), frameID, pageID, completionHandler = WTFMove(completionHandler)]() mutable {255 void WebResourceLoadStatisticsStore::hasStorageAccess(const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler) 256 { 257 ASSERT(subFrameDomain != topFrameDomain); 258 ASSERT(RunLoop::isMain()); 259 260 postTask([this, subFrameDomain = subFrameDomain.isolatedCopy(), topFrameDomain = topFrameDomain.isolatedCopy(), frameID, pageID, completionHandler = WTFMove(completionHandler)]() mutable { 266 261 if (!m_memoryStore) { 267 262 postTaskReply([completionHandler = WTFMove(completionHandler)]() mutable { … … 270 265 return; 271 266 } 272 m_memoryStore->hasStorageAccess(subFrame PrimaryDomain, topFramePrimaryDomain, frameID, pageID, [completionHandler = WTFMove(completionHandler)](bool hasStorageAccess) mutable {267 m_memoryStore->hasStorageAccess(subFrameDomain, topFrameDomain, frameID, pageID, [completionHandler = WTFMove(completionHandler)](bool hasStorageAccess) mutable { 273 268 postTaskReply([completionHandler = WTFMove(completionHandler), hasStorageAccess]() mutable { 274 269 completionHandler(hasStorageAccess); … … 278 273 } 279 274 280 bool WebResourceLoadStatisticsStore::hasStorageAccessForFrame(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID)275 bool WebResourceLoadStatisticsStore::hasStorageAccessForFrame(const RegistrableDomain& resourceDomain, const RegistrableDomain& firstPartyDomain, uint64_t frameID, uint64_t pageID) 281 276 { 282 277 return m_networkSession ? m_networkSession->networkStorageSession().hasStorageAccess(resourceDomain, firstPartyDomain, frameID, pageID) : false; 283 278 } 284 279 285 void WebResourceLoadStatisticsStore::callHasStorageAccessForFrameHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool hasAccess)>&& callback)280 void WebResourceLoadStatisticsStore::callHasStorageAccessForFrameHandler(const RegistrableDomain& resourceDomain, const RegistrableDomain& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool hasAccess)>&& callback) 286 281 { 287 282 ASSERT(RunLoop::isMain()); … … 295 290 } 296 291 297 void WebResourceLoadStatisticsStore::requestStorageAccessGranted(const String& subFrameHost, const String& topFrameHost, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(bool)>&& completionHandler)298 { 299 auto statusHandler = [this, protectedThis = makeRef(*this), subFrame Host = isolatedPrimaryDomain(subFrameHost), topFrameHost = isolatedPrimaryDomain(topFrameHost), promptEnabled, frameID, pageID, completionHandler = WTFMove(completionHandler)](StorageAccessStatus status) mutable {292 void WebResourceLoadStatisticsStore::requestStorageAccessGranted(const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(bool)>&& completionHandler) 293 { 294 auto statusHandler = [this, protectedThis = makeRef(*this), subFrameDomain = subFrameDomain.isolatedCopy(), topFrameDomain = topFrameDomain.isolatedCopy(), promptEnabled, frameID, pageID, completionHandler = WTFMove(completionHandler)](StorageAccessStatus status) mutable { 300 295 switch (status) { 301 296 case StorageAccessStatus::CannotRequestAccess: … … 305 300 { 306 301 ASSERT_UNUSED(promptEnabled, promptEnabled); 307 auto subFramePrimaryDomain = ResourceLoadStatistics::primaryDomain(subFrameHost); 308 auto topFramePrimaryDomain = ResourceLoadStatistics::primaryDomain(topFrameHost); 309 CompletionHandler<void(bool)> requestConfirmationCompletionHandler = [this, protectedThis = protectedThis.copyRef(), subFrameHost = WTFMove(subFrameHost), topFrameHost = WTFMove(topFrameHost), frameID, pageID, completionHandler = WTFMove(completionHandler)] (bool userDidGrantAccess) mutable { 302 CompletionHandler<void(bool)> requestConfirmationCompletionHandler = [this, protectedThis = protectedThis.copyRef(), subFrameDomain, topFrameDomain, frameID, pageID, completionHandler = WTFMove(completionHandler)] (bool userDidGrantAccess) mutable { 310 303 if (userDidGrantAccess) 311 grantStorageAccess( WTFMove(subFrameHost), WTFMove(topFrameHost), frameID, pageID, userDidGrantAccess, WTFMove(completionHandler));304 grantStorageAccess(subFrameDomain, topFrameDomain, frameID, pageID, userDidGrantAccess, WTFMove(completionHandler)); 312 305 else 313 306 completionHandler(false); 314 307 }; 315 m_networkSession->networkProcess().parentProcessConnection()->sendWithAsyncReply(Messages::NetworkProcessProxy::RequestStorageAccessConfirm(pageID, frameID, subFrame PrimaryDomain, topFramePrimaryDomain), WTFMove(requestConfirmationCompletionHandler));308 m_networkSession->networkProcess().parentProcessConnection()->sendWithAsyncReply(Messages::NetworkProcessProxy::RequestStorageAccessConfirm(pageID, frameID, subFrameDomain.string(), topFrameDomain.string()), WTFMove(requestConfirmationCompletionHandler)); 316 309 } 317 310 return; … … 322 315 }; 323 316 324 requestStorageAccess(subFrameHost, topFrameHost, frameID, pageID, promptEnabled, WTFMove(statusHandler)); 325 } 326 327 void WebResourceLoadStatisticsStore::requestStorageAccess(const String& subFrameHost, const String& topFrameHost, Optional<uint64_t> frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&& completionHandler) 328 { 329 auto subFramePrimaryDomain = isolatedPrimaryDomain(subFrameHost); 330 auto topFramePrimaryDomain = isolatedPrimaryDomain(topFrameHost); 331 if (subFramePrimaryDomain == topFramePrimaryDomain) { 317 requestStorageAccess(subFrameDomain, topFrameDomain, frameID, pageID, promptEnabled, WTFMove(statusHandler)); 318 } 319 320 void WebResourceLoadStatisticsStore::requestStorageAccess(const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, Optional<uint64_t> frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&& completionHandler) 321 { 322 if (subFrameDomain == topFrameDomain) { 332 323 completionHandler(StorageAccessStatus::HasAccess); 333 324 return; 334 325 } 335 326 336 postTask([this, subFrame PrimaryDomain = crossThreadCopy(subFramePrimaryDomain), topFramePrimaryDomain = crossThreadCopy(topFramePrimaryDomain), frameID, pageID, promptEnabled, completionHandler = WTFMove(completionHandler)]() mutable {327 postTask([this, subFrameDomain = subFrameDomain.isolatedCopy(), topFrameDomain = topFrameDomain.isolatedCopy(), frameID, pageID, promptEnabled, completionHandler = WTFMove(completionHandler)]() mutable { 337 328 if (!m_memoryStore) { 338 329 postTaskReply([completionHandler = WTFMove(completionHandler)]() mutable { … … 342 333 } 343 334 344 m_memoryStore->requestStorageAccess(WTFMove(subFrame PrimaryDomain), WTFMove(topFramePrimaryDomain), frameID.value(), pageID, promptEnabled, [completionHandler = WTFMove(completionHandler)](StorageAccessStatus status) mutable {335 m_memoryStore->requestStorageAccess(WTFMove(subFrameDomain), WTFMove(topFrameDomain), frameID.value(), pageID, promptEnabled, [completionHandler = WTFMove(completionHandler)](StorageAccessStatus status) mutable { 345 336 postTaskReply([completionHandler = WTFMove(completionHandler), status]() mutable { 346 337 completionHandler(status); … … 350 341 } 351 342 352 void WebResourceLoadStatisticsStore::requestStorageAccessUnderOpener( String&& primaryDomainInNeedOfStorageAccess, uint64_t openerPageID, String&& openerPrimaryDomain)343 void WebResourceLoadStatisticsStore::requestStorageAccessUnderOpener(RegistrableDomain&& domainInNeedOfStorageAccess, uint64_t openerPageID, RegistrableDomain&& openerDomain) 353 344 { 354 345 ASSERT(RunLoop::isMain()); … … 357 348 // coming from IPC. Strings which are safe to move to other threads as long as nobody on this thread holds a reference 358 349 // to those strings. 359 postTask([this, primaryDomainInNeedOfStorageAccess = WTFMove(primaryDomainInNeedOfStorageAccess), openerPageID, openerPrimaryDomain = WTFMove(openerPrimaryDomain)]() mutable {360 if (m_memoryStore) 361 m_memoryStore->requestStorageAccessUnderOpener(WTFMove( primaryDomainInNeedOfStorageAccess), openerPageID, WTFMove(openerPrimaryDomain));362 }); 363 } 364 365 void WebResourceLoadStatisticsStore::grantStorageAccess(const String& subFrameHost, const String& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPromptedNow, CompletionHandler<void(bool)>&& completionHandler)366 { 367 ASSERT(RunLoop::isMain()); 368 postTask([this, subFrame Host = crossThreadCopy(subFrameHost), topFrameHost = crossThreadCopy(topFrameHost), frameID, pageID, userWasPromptedNow, completionHandler = WTFMove(completionHandler)]() mutable {350 postTask([this, domainInNeedOfStorageAccess = WTFMove(domainInNeedOfStorageAccess), openerPageID, openerDomain = WTFMove(openerDomain)]() mutable { 351 if (m_memoryStore) 352 m_memoryStore->requestStorageAccessUnderOpener(WTFMove(domainInNeedOfStorageAccess), openerPageID, WTFMove(openerDomain)); 353 }); 354 } 355 356 void WebResourceLoadStatisticsStore::grantStorageAccess(const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, uint64_t frameID, uint64_t pageID, bool userWasPromptedNow, CompletionHandler<void(bool)>&& completionHandler) 357 { 358 ASSERT(RunLoop::isMain()); 359 postTask([this, subFrameDomain = subFrameDomain.isolatedCopy(), topFrameDomain = topFrameDomain.isolatedCopy(), frameID, pageID, userWasPromptedNow, completionHandler = WTFMove(completionHandler)]() mutable { 369 360 if (!m_memoryStore) { 370 361 postTaskReply([completionHandler = WTFMove(completionHandler)]() mutable { … … 374 365 } 375 366 376 m_memoryStore->grantStorageAccess(WTFMove(subFrame Host), WTFMove(topFrameHost), frameID, pageID, userWasPromptedNow, [completionHandler = WTFMove(completionHandler)](bool wasGrantedAccess) mutable {367 m_memoryStore->grantStorageAccess(WTFMove(subFrameDomain), WTFMove(topFrameDomain), frameID, pageID, userWasPromptedNow, [completionHandler = WTFMove(completionHandler)](bool wasGrantedAccess) mutable { 377 368 postTaskReply([completionHandler = WTFMove(completionHandler), wasGrantedAccess]() mutable { 378 369 completionHandler(wasGrantedAccess); … … 382 373 } 383 374 384 bool WebResourceLoadStatisticsStore::grantStorageAccess(const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID)375 bool WebResourceLoadStatisticsStore::grantStorageAccess(const RegistrableDomain& resourceDomain, const RegistrableDomain& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID) 385 376 { 386 377 bool isStorageGranted = false; … … 395 386 } 396 387 397 void WebResourceLoadStatisticsStore::callGrantStorageAccessHandler(const String& subFramePrimaryDomain, const String& topFramePrimaryDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback)398 { 399 ASSERT(RunLoop::isMain()); 400 401 callback(grantStorageAccess(subFrame PrimaryDomain, topFramePrimaryDomain, frameID, pageID));388 void WebResourceLoadStatisticsStore::callGrantStorageAccessHandler(const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback) 389 { 390 ASSERT(RunLoop::isMain()); 391 392 callback(grantStorageAccess(subFrameDomain, topFrameDomain, frameID, pageID)); 402 393 } 403 394 … … 476 467 return; 477 468 478 auto targetPrimaryDomain = ResourceLoadStatistics::primaryDomain(targetURL);479 auto mainFramePrimaryDomain = ResourceLoadStatistics::primaryDomain(pageURL);480 auto sourcePrimaryDomain = ResourceLoadStatistics::primaryDomain(sourceURL);481 482 logFrameNavigation(target PrimaryDomain, mainFramePrimaryDomain, sourcePrimaryDomain, targetHost.toString(), mainFrameHost.toString(), isRedirect, frame.isMainFrame());483 } 484 485 void WebResourceLoadStatisticsStore::logFrameNavigation(const String& targetPrimaryDomain, const String& mainFramePrimaryDomain, const String& sourcePrimaryDomain, const String& targetHost, const String& mainFrameHost, bool isRedirect, bool isMainFrame)486 { 487 postTask([this, target PrimaryDomain = isolatedPrimaryDomain(targetPrimaryDomain), mainFramePrimaryDomain = isolatedPrimaryDomain(mainFramePrimaryDomain), sourcePrimaryDomain = isolatedPrimaryDomain(sourcePrimaryDomain), targetHost = isolatedPrimaryDomain(targetHost), mainFrameHost = isolatedPrimaryDomain(mainFrameHost), isRedirect, isMainFrame] {488 489 if (m_memoryStore) 490 m_memoryStore->logFrameNavigation(target PrimaryDomain, mainFramePrimaryDomain, sourcePrimaryDomain, targetHost, mainFrameHost, isRedirect, isMainFrame);491 }); 492 } 493 494 void WebResourceLoadStatisticsStore::logWebSocketLoading(const String& targetPrimaryDomain, const String& mainFramePrimaryDomain, WallTime lastSeen, CompletionHandler<void()>&& completionHandler)495 { 496 postTask([this, target PrimaryDomain = isolatedPrimaryDomain(targetPrimaryDomain), mainFramePrimaryDomain = isolatedPrimaryDomain(mainFramePrimaryDomain), lastSeen, completionHandler = WTFMove(completionHandler)]() mutable {497 if (m_memoryStore) 498 m_memoryStore->logSubresourceLoading(target PrimaryDomain, mainFramePrimaryDomain, lastSeen);499 500 postTaskReply(WTFMove(completionHandler)); 501 }); 502 } 503 504 void WebResourceLoadStatisticsStore::logSubresourceLoading(const String& targetPrimaryDomain, const String& mainFramePrimaryDomain, WallTime lastSeen, CompletionHandler<void()>&& completionHandler)505 { 506 postTask([this, target PrimaryDomain = isolatedPrimaryDomain(targetPrimaryDomain), mainFramePrimaryDomain = isolatedPrimaryDomain(mainFramePrimaryDomain), lastSeen, completionHandler = WTFMove(completionHandler)]() mutable {507 if (m_memoryStore) 508 m_memoryStore->logSubresourceLoading(target PrimaryDomain, mainFramePrimaryDomain, lastSeen);509 510 postTaskReply(WTFMove(completionHandler)); 511 }); 512 } 513 514 void WebResourceLoadStatisticsStore::logSubresourceRedirect(const String& sourcePrimaryDomain, const String& targetPrimaryDomain, CompletionHandler<void()>&& completionHandler)515 { 516 postTask([this, source PrimaryDomain = isolatedPrimaryDomain(sourcePrimaryDomain), targetPrimaryDomain = isolatedPrimaryDomain(targetPrimaryDomain), completionHandler = WTFMove(completionHandler)]() mutable {517 if (m_memoryStore) 518 m_memoryStore->logSubresourceRedirect(source PrimaryDomain, targetPrimaryDomain);519 520 postTaskReply(WTFMove(completionHandler)); 521 }); 522 } 523 524 void WebResourceLoadStatisticsStore::logUserInteraction(const String& targetPrimaryDomain, CompletionHandler<void()>&& completionHandler)525 { 526 ASSERT(RunLoop::isMain()); 527 528 postTask([this, primaryDomain = isolatedPrimaryDomain(targetPrimaryDomain), completionHandler = WTFMove(completionHandler)]() mutable {529 if (m_memoryStore) 530 m_memoryStore->logUserInteraction( primaryDomain);531 postTaskReply(WTFMove(completionHandler)); 532 }); 533 } 534 535 void WebResourceLoadStatisticsStore::clearUserInteraction(const String& targetPrimaryDomain, CompletionHandler<void()>&& completionHandler)536 { 537 ASSERT(RunLoop::isMain()); 538 539 postTask([this, primaryDomain = isolatedPrimaryDomain(targetPrimaryDomain), completionHandler = WTFMove(completionHandler)]() mutable {540 if (m_memoryStore) 541 m_memoryStore->clearUserInteraction( primaryDomain);542 postTaskReply(WTFMove(completionHandler)); 543 }); 544 } 545 546 void WebResourceLoadStatisticsStore::hasHadUserInteraction(const String& primaryDomain, CompletionHandler<void(bool)>&& completionHandler)547 { 548 postTask([this, primaryDomain = isolatedPrimaryDomain(primaryDomain), completionHandler = WTFMove(completionHandler)]() mutable {549 bool hadUserInteraction = m_memoryStore ? m_memoryStore->hasHadUserInteraction( primaryDomain) : false;469 RegistrableDomain targetDomain { targetURL }; 470 RegistrableDomain topFrameDomain { pageURL }; 471 RegistrableDomain sourceDomain { sourceURL }; 472 473 logFrameNavigation(targetDomain, topFrameDomain, sourceDomain, isRedirect, frame.isMainFrame()); 474 } 475 476 void WebResourceLoadStatisticsStore::logFrameNavigation(const RegistrableDomain& targetDomain, const RegistrableDomain& topFrameDomain, const RegistrableDomain& sourceDomain, bool isRedirect, bool isMainFrame) 477 { 478 postTask([this, targetDomain = targetDomain.isolatedCopy(), topFrameDomain = topFrameDomain.isolatedCopy(), sourceDomain = sourceDomain.isolatedCopy(), isRedirect, isMainFrame] { 479 480 if (m_memoryStore) 481 m_memoryStore->logFrameNavigation(targetDomain, topFrameDomain, sourceDomain, isRedirect, isMainFrame); 482 }); 483 } 484 485 void WebResourceLoadStatisticsStore::logWebSocketLoading(const RegistrableDomain& targetDomain, const RegistrableDomain& topFrameDomain, WallTime lastSeen, CompletionHandler<void()>&& completionHandler) 486 { 487 postTask([this, targetDomain = targetDomain.isolatedCopy(), topFrameDomain = topFrameDomain.isolatedCopy(), lastSeen, completionHandler = WTFMove(completionHandler)]() mutable { 488 if (m_memoryStore) 489 m_memoryStore->logSubresourceLoading(targetDomain, topFrameDomain, lastSeen); 490 491 postTaskReply(WTFMove(completionHandler)); 492 }); 493 } 494 495 void WebResourceLoadStatisticsStore::logSubresourceLoading(const RegistrableDomain& targetDomain, const RegistrableDomain& topFrameDomain, WallTime lastSeen, CompletionHandler<void()>&& completionHandler) 496 { 497 postTask([this, targetDomain = targetDomain.isolatedCopy(), topFrameDomain = topFrameDomain.isolatedCopy(), lastSeen, completionHandler = WTFMove(completionHandler)]() mutable { 498 if (m_memoryStore) 499 m_memoryStore->logSubresourceLoading(targetDomain, topFrameDomain, lastSeen); 500 501 postTaskReply(WTFMove(completionHandler)); 502 }); 503 } 504 505 void WebResourceLoadStatisticsStore::logSubresourceRedirect(const RegistrableDomain& sourceDomain, const RegistrableDomain& targetDomain, CompletionHandler<void()>&& completionHandler) 506 { 507 postTask([this, sourceDomain = sourceDomain.isolatedCopy(), targetDomain = targetDomain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { 508 if (m_memoryStore) 509 m_memoryStore->logSubresourceRedirect(sourceDomain, targetDomain); 510 511 postTaskReply(WTFMove(completionHandler)); 512 }); 513 } 514 515 void WebResourceLoadStatisticsStore::logUserInteraction(const RegistrableDomain& domain, CompletionHandler<void()>&& completionHandler) 516 { 517 ASSERT(RunLoop::isMain()); 518 519 postTask([this, domain = domain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { 520 if (m_memoryStore) 521 m_memoryStore->logUserInteraction(domain); 522 postTaskReply(WTFMove(completionHandler)); 523 }); 524 } 525 526 void WebResourceLoadStatisticsStore::clearUserInteraction(const RegistrableDomain& domain, CompletionHandler<void()>&& completionHandler) 527 { 528 ASSERT(RunLoop::isMain()); 529 530 postTask([this, domain = domain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { 531 if (m_memoryStore) 532 m_memoryStore->clearUserInteraction(domain); 533 postTaskReply(WTFMove(completionHandler)); 534 }); 535 } 536 537 void WebResourceLoadStatisticsStore::hasHadUserInteraction(const RegistrableDomain& domain, CompletionHandler<void(bool)>&& completionHandler) 538 { 539 postTask([this, domain, completionHandler = WTFMove(completionHandler)]() mutable { 540 bool hadUserInteraction = m_memoryStore ? m_memoryStore->hasHadUserInteraction(domain) : false; 550 541 postTaskReply([hadUserInteraction, completionHandler = WTFMove(completionHandler)]() mutable { 551 542 completionHandler(hadUserInteraction); … … 554 545 } 555 546 556 void WebResourceLoadStatisticsStore::setLastSeen(const String& resourceDomain, Seconds seconds, CompletionHandler<void()>&& completionHandler)557 { 558 ASSERT(RunLoop::isMain()); 559 560 postTask([this, resourceDomain = isolatedPrimaryDomain(resourceDomain), seconds, completionHandler = WTFMove(completionHandler)]() mutable {561 if (m_memoryStore) 562 m_memoryStore->setLastSeen( resourceDomain, seconds);563 postTaskReply(WTFMove(completionHandler)); 564 }); 565 } 566 567 void WebResourceLoadStatisticsStore::setPrevalentResource(const String& resourceDomain, CompletionHandler<void()>&& completionHandler)568 { 569 ASSERT(RunLoop::isMain()); 570 571 postTask([this, resourceDomain = isolatedPrimaryDomain(resourceDomain), completionHandler = WTFMove(completionHandler)]() mutable {572 if (m_memoryStore) 573 m_memoryStore->setPrevalentResource( resourceDomain);574 postTaskReply(WTFMove(completionHandler)); 575 }); 576 } 577 578 void WebResourceLoadStatisticsStore::setVeryPrevalentResource(const String& primaryDomain, CompletionHandler<void()>&& completionHandler)579 { 580 ASSERT(RunLoop::isMain()); 581 582 postTask([this, primaryDomain = isolatedPrimaryDomain(primaryDomain), completionHandler = WTFMove(completionHandler)]() mutable {583 if (m_memoryStore) 584 m_memoryStore->setVeryPrevalentResource( primaryDomain);547 void WebResourceLoadStatisticsStore::setLastSeen(const RegistrableDomain& domain, Seconds seconds, CompletionHandler<void()>&& completionHandler) 548 { 549 ASSERT(RunLoop::isMain()); 550 551 postTask([this, domain = domain.isolatedCopy(), seconds, completionHandler = WTFMove(completionHandler)]() mutable { 552 if (m_memoryStore) 553 m_memoryStore->setLastSeen(domain, seconds); 554 postTaskReply(WTFMove(completionHandler)); 555 }); 556 } 557 558 void WebResourceLoadStatisticsStore::setPrevalentResource(const RegistrableDomain& domain, CompletionHandler<void()>&& completionHandler) 559 { 560 ASSERT(RunLoop::isMain()); 561 562 postTask([this, domain = domain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { 563 if (m_memoryStore) 564 m_memoryStore->setPrevalentResource(domain); 565 postTaskReply(WTFMove(completionHandler)); 566 }); 567 } 568 569 void WebResourceLoadStatisticsStore::setVeryPrevalentResource(const RegistrableDomain& domain, CompletionHandler<void()>&& completionHandler) 570 { 571 ASSERT(RunLoop::isMain()); 572 573 postTask([this, domain = domain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { 574 if (m_memoryStore) 575 m_memoryStore->setVeryPrevalentResource(domain); 585 576 postTaskReply(WTFMove(completionHandler)); 586 577 }); … … 599 590 } 600 591 601 void WebResourceLoadStatisticsStore::isPrevalentResource(const String& primaryDomain, CompletionHandler<void(bool)>&& completionHandler)602 { 603 ASSERT(RunLoop::isMain()); 604 605 postTask([this, primaryDomain = isolatedPrimaryDomain(primaryDomain), completionHandler = WTFMove(completionHandler)]() mutable {606 bool isPrevalentResource = m_memoryStore ? m_memoryStore->isPrevalentResource( primaryDomain) : false;592 void WebResourceLoadStatisticsStore::isPrevalentResource(const RegistrableDomain& domain, CompletionHandler<void(bool)>&& completionHandler) 593 { 594 ASSERT(RunLoop::isMain()); 595 596 postTask([this, domain = domain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { 597 bool isPrevalentResource = m_memoryStore ? m_memoryStore->isPrevalentResource(domain) : false; 607 598 postTaskReply([isPrevalentResource, completionHandler = WTFMove(completionHandler)]() mutable { 608 599 completionHandler(isPrevalentResource); … … 611 602 } 612 603 613 void WebResourceLoadStatisticsStore::isVeryPrevalentResource(const String& primaryDomain, CompletionHandler<void(bool)>&& completionHandler)614 { 615 ASSERT(RunLoop::isMain()); 616 617 postTask([this, primaryDomain = isolatedPrimaryDomain(primaryDomain), completionHandler = WTFMove(completionHandler)]() mutable {618 bool isVeryPrevalentResource = m_memoryStore ? m_memoryStore->isVeryPrevalentResource( primaryDomain) : false;604 void WebResourceLoadStatisticsStore::isVeryPrevalentResource(const RegistrableDomain& domain, CompletionHandler<void(bool)>&& completionHandler) 605 { 606 ASSERT(RunLoop::isMain()); 607 608 postTask([this, domain = domain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { 609 bool isVeryPrevalentResource = m_memoryStore ? m_memoryStore->isVeryPrevalentResource(domain) : false; 619 610 postTaskReply([isVeryPrevalentResource, completionHandler = WTFMove(completionHandler)]() mutable { 620 611 completionHandler(isVeryPrevalentResource); … … 623 614 } 624 615 625 void WebResourceLoadStatisticsStore::isRegisteredAsSubresourceUnder(const String& subresource, const String& topFrame, CompletionHandler<void(bool)>&& completionHandler)626 { 627 ASSERT(RunLoop::isMain()); 628 629 postTask([this, subresource PrimaryDomain = isolatedPrimaryDomain(subresource), topFramePrimaryDomain = isolatedPrimaryDomain(topFrame), completionHandler = WTFMove(completionHandler)]() mutable {630 bool isRegisteredAsSubresourceUnder = m_memoryStore ? m_memoryStore->isRegisteredAsSubresourceUnder(subresource PrimaryDomain, topFramePrimaryDomain) : false;616 void WebResourceLoadStatisticsStore::isRegisteredAsSubresourceUnder(const RegistrableDomain& subresourceDomain, const RegistrableDomain& topFrameDomain, CompletionHandler<void(bool)>&& completionHandler) 617 { 618 ASSERT(RunLoop::isMain()); 619 620 postTask([this, subresourceDomain = subresourceDomain.isolatedCopy(), topFrameDomain = topFrameDomain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { 621 bool isRegisteredAsSubresourceUnder = m_memoryStore ? m_memoryStore->isRegisteredAsSubresourceUnder(subresourceDomain, topFrameDomain) : false; 631 622 postTaskReply([isRegisteredAsSubresourceUnder, completionHandler = WTFMove(completionHandler)]() mutable { 632 623 completionHandler(isRegisteredAsSubresourceUnder); … … 635 626 } 636 627 637 void WebResourceLoadStatisticsStore::isRegisteredAsSubFrameUnder(const String& subFrame, const String& topFrame, CompletionHandler<void(bool)>&& completionHandler)638 { 639 ASSERT(RunLoop::isMain()); 640 641 postTask([this, subFrame PrimaryDomain = isolatedPrimaryDomain(subFrame), topFramePrimaryDomain = isolatedPrimaryDomain(topFrame), completionHandler = WTFMove(completionHandler)]() mutable {642 bool isRegisteredAsSubFrameUnder = m_memoryStore ? m_memoryStore->isRegisteredAsSubFrameUnder(subFrame PrimaryDomain, topFramePrimaryDomain) : false;628 void WebResourceLoadStatisticsStore::isRegisteredAsSubFrameUnder(const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, CompletionHandler<void(bool)>&& completionHandler) 629 { 630 ASSERT(RunLoop::isMain()); 631 632 postTask([this, subFrameDomain = subFrameDomain.isolatedCopy(), topFrameDomain = topFrameDomain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { 633 bool isRegisteredAsSubFrameUnder = m_memoryStore ? m_memoryStore->isRegisteredAsSubFrameUnder(subFrameDomain, topFrameDomain) : false; 643 634 postTaskReply([isRegisteredAsSubFrameUnder, completionHandler = WTFMove(completionHandler)]() mutable { 644 635 completionHandler(isRegisteredAsSubFrameUnder); … … 647 638 } 648 639 649 void WebResourceLoadStatisticsStore::isRegisteredAsRedirectingTo(const String& hostRedirectedFrom, const String& hostRedirectedTo, CompletionHandler<void(bool)>&& completionHandler)650 { 651 ASSERT(RunLoop::isMain()); 652 653 postTask([this, hostRedirectedFromPrimaryDomain = isolatedPrimaryDomain(hostRedirectedFrom), hostRedirectedToPrimaryDomain = isolatedPrimaryDomain(hostRedirectedTo), completionHandler = WTFMove(completionHandler)]() mutable {654 bool isRegisteredAsRedirectingTo = m_memoryStore ? m_memoryStore->isRegisteredAsRedirectingTo( hostRedirectedFromPrimaryDomain, hostRedirectedToPrimaryDomain) : false;640 void WebResourceLoadStatisticsStore::isRegisteredAsRedirectingTo(const RegistrableDomain& domainRedirectedFrom, const RegistrableDomain& domainRedirectedTo, CompletionHandler<void(bool)>&& completionHandler) 641 { 642 ASSERT(RunLoop::isMain()); 643 644 postTask([this, domainRedirectedFrom = domainRedirectedFrom.isolatedCopy(), domainRedirectedTo = domainRedirectedTo.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { 645 bool isRegisteredAsRedirectingTo = m_memoryStore ? m_memoryStore->isRegisteredAsRedirectingTo(domainRedirectedFrom, domainRedirectedTo) : false; 655 646 postTaskReply([isRegisteredAsRedirectingTo, completionHandler = WTFMove(completionHandler)]() mutable { 656 647 completionHandler(isRegisteredAsRedirectingTo); … … 659 650 } 660 651 661 void WebResourceLoadStatisticsStore::clearPrevalentResource(const String& resourceDomain, CompletionHandler<void()>&& completionHandler)662 { 663 ASSERT(RunLoop::isMain()); 664 665 postTask([this, resourceDomain = isolatedPrimaryDomain(resourceDomain), completionHandler = WTFMove(completionHandler)]() mutable {666 if (m_memoryStore) 667 m_memoryStore->clearPrevalentResource( resourceDomain);668 postTaskReply(WTFMove(completionHandler)); 669 }); 670 } 671 672 void WebResourceLoadStatisticsStore::setGrandfathered(const String& domain, bool value, CompletionHandler<void()>&& completionHandler)673 { 674 ASSERT(RunLoop::isMain()); 675 676 postTask([this, primaryDomain = isolatedPrimaryDomain(domain), value, completionHandler = WTFMove(completionHandler)]() mutable {677 if (m_memoryStore) 678 m_memoryStore->setGrandfathered( primaryDomain, value);679 postTaskReply(WTFMove(completionHandler)); 680 }); 681 } 682 683 void WebResourceLoadStatisticsStore::isGrandfathered(const String& primaryDomain, CompletionHandler<void(bool)>&& completionHandler)684 { 685 ASSERT(RunLoop::isMain()); 686 687 postTask([this, completionHandler = WTFMove(completionHandler), primaryDomain = isolatedPrimaryDomain(primaryDomain)]() mutable {688 bool isGrandFathered = m_memoryStore ? m_memoryStore->isGrandfathered( primaryDomain) : false;652 void WebResourceLoadStatisticsStore::clearPrevalentResource(const RegistrableDomain& domain, CompletionHandler<void()>&& completionHandler) 653 { 654 ASSERT(RunLoop::isMain()); 655 656 postTask([this, domain = domain.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable { 657 if (m_memoryStore) 658 m_memoryStore->clearPrevalentResource(domain); 659 postTaskReply(WTFMove(completionHandler)); 660 }); 661 } 662 663 void WebResourceLoadStatisticsStore::setGrandfathered(const RegistrableDomain& domain, bool value, CompletionHandler<void()>&& completionHandler) 664 { 665 ASSERT(RunLoop::isMain()); 666 667 postTask([this, domain = domain.isolatedCopy(), value, completionHandler = WTFMove(completionHandler)]() mutable { 668 if (m_memoryStore) 669 m_memoryStore->setGrandfathered(domain, value); 670 postTaskReply(WTFMove(completionHandler)); 671 }); 672 } 673 674 void WebResourceLoadStatisticsStore::isGrandfathered(const RegistrableDomain& domain, CompletionHandler<void(bool)>&& completionHandler) 675 { 676 ASSERT(RunLoop::isMain()); 677 678 postTask([this, completionHandler = WTFMove(completionHandler), domain = domain.isolatedCopy()]() mutable { 679 bool isGrandFathered = m_memoryStore ? m_memoryStore->isGrandfathered(domain) : false; 689 680 postTaskReply([isGrandFathered, completionHandler = WTFMove(completionHandler)]() mutable { 690 681 completionHandler(isGrandFathered); … … 693 684 } 694 685 695 void WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin(const String& subframe, const String& topFrame, CompletionHandler<void()>&& completionHandler)696 { 697 ASSERT(RunLoop::isMain()); 698 699 postTask([this, completionHandler = WTFMove(completionHandler), primaryTopFrameDomain = isolatedPrimaryDomain(topFrame), primarySubFrameDomain = isolatedPrimaryDomain(subframe)]() mutable {700 if (m_memoryStore) 701 m_memoryStore->setSubframeUnderTopFrameOrigin( primarySubFrameDomain, primaryTopFrameDomain);702 postTaskReply(WTFMove(completionHandler)); 703 }); 704 } 705 706 void WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin(const String& subresource, const String& topFrame, CompletionHandler<void()>&& completionHandler)707 { 708 ASSERT(RunLoop::isMain()); 709 710 postTask([this, completionHandler = WTFMove(completionHandler), primaryTopFrameDomain = isolatedPrimaryDomain(topFrame), primarySubresourceDomain = isolatedPrimaryDomain(subresource)]() mutable {711 if (m_memoryStore) 712 m_memoryStore->setSubresourceUnderTopFrameOrigin( primarySubresourceDomain, primaryTopFrameDomain);713 postTaskReply(WTFMove(completionHandler)); 714 }); 715 } 716 717 void WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo(const String& subresource, const String& hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler)718 { 719 ASSERT(RunLoop::isMain()); 720 721 postTask([this, completionHandler = WTFMove(completionHandler), primaryRedirectDomain = isolatedPrimaryDomain(hostNameRedirectedTo), primarySubresourceDomain = isolatedPrimaryDomain(subresource)]() mutable {722 if (m_memoryStore) 723 m_memoryStore->setSubresourceUniqueRedirectTo( primarySubresourceDomain, primaryRedirectDomain);724 postTaskReply(WTFMove(completionHandler)); 725 }); 726 } 727 728 void WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectFrom(const String& subresource, const String& hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler)729 { 730 ASSERT(RunLoop::isMain()); 731 732 postTask([this, completionHandler = WTFMove(completionHandler), primaryRedirectDomain = isolatedPrimaryDomain(hostNameRedirectedFrom), primarySubresourceDomain = isolatedPrimaryDomain(subresource)]() mutable {733 if (m_memoryStore) 734 m_memoryStore->setSubresourceUniqueRedirectFrom( primarySubresourceDomain, primaryRedirectDomain);735 postTaskReply(WTFMove(completionHandler)); 736 }); 737 } 738 739 void WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectTo(const String& topFrameHostName, const String& hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler)740 { 741 ASSERT(RunLoop::isMain()); 742 743 postTask([this, completionHandler = WTFMove(completionHandler), topFrame PrimaryDomain = isolatedPrimaryDomain(topFrameHostName), primaryRedirectDomain = isolatedPrimaryDomain(hostNameRedirectedTo)]() mutable {744 if (m_memoryStore) 745 m_memoryStore->setTopFrameUniqueRedirectTo(topFrame PrimaryDomain, primaryRedirectDomain);746 postTaskReply(WTFMove(completionHandler)); 747 }); 748 } 749 750 void WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectFrom(const String& topFrameHostName, const String& hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler)751 { 752 ASSERT(RunLoop::isMain()); 753 754 postTask([this, completionHandler = WTFMove(completionHandler), topFrame PrimaryDomain = isolatedPrimaryDomain(topFrameHostName), primaryRedirectDomain = isolatedPrimaryDomain(hostNameRedirectedFrom)]() mutable {755 if (m_memoryStore) 756 m_memoryStore->setTopFrameUniqueRedirectFrom(topFrame PrimaryDomain, primaryRedirectDomain);686 void WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin(const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, CompletionHandler<void()>&& completionHandler) 687 { 688 ASSERT(RunLoop::isMain()); 689 690 postTask([this, completionHandler = WTFMove(completionHandler), subFrameDomain = subFrameDomain.isolatedCopy(), topFrameDomain = topFrameDomain.isolatedCopy()]() mutable { 691 if (m_memoryStore) 692 m_memoryStore->setSubframeUnderTopFrameOrigin(subFrameDomain, topFrameDomain); 693 postTaskReply(WTFMove(completionHandler)); 694 }); 695 } 696 697 void WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin(const RegistrableDomain& subresourceDomain, const RegistrableDomain& topFrameDomain, CompletionHandler<void()>&& completionHandler) 698 { 699 ASSERT(RunLoop::isMain()); 700 701 postTask([this, completionHandler = WTFMove(completionHandler), subresourceDomain = subresourceDomain.isolatedCopy(), topFrameDomain = topFrameDomain.isolatedCopy()]() mutable { 702 if (m_memoryStore) 703 m_memoryStore->setSubresourceUnderTopFrameOrigin(subresourceDomain, topFrameDomain); 704 postTaskReply(WTFMove(completionHandler)); 705 }); 706 } 707 708 void WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo(const RegistrableDomain& subresourceDomain, const RegistrableDomain& domainRedirectedTo, CompletionHandler<void()>&& completionHandler) 709 { 710 ASSERT(RunLoop::isMain()); 711 712 postTask([this, completionHandler = WTFMove(completionHandler), subresourceDomain = subresourceDomain.isolatedCopy(), domainRedirectedTo = domainRedirectedTo.isolatedCopy()]() mutable { 713 if (m_memoryStore) 714 m_memoryStore->setSubresourceUniqueRedirectTo(subresourceDomain, domainRedirectedTo); 715 postTaskReply(WTFMove(completionHandler)); 716 }); 717 } 718 719 void WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectFrom(const RegistrableDomain& subresourceDomain, const RegistrableDomain& domainRedirectedFrom, CompletionHandler<void()>&& completionHandler) 720 { 721 ASSERT(RunLoop::isMain()); 722 723 postTask([this, completionHandler = WTFMove(completionHandler), subresourceDomain = subresourceDomain.isolatedCopy(), domainRedirectedFrom = domainRedirectedFrom.isolatedCopy()]() mutable { 724 if (m_memoryStore) 725 m_memoryStore->setSubresourceUniqueRedirectFrom(subresourceDomain, domainRedirectedFrom); 726 postTaskReply(WTFMove(completionHandler)); 727 }); 728 } 729 730 void WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectTo(const RegistrableDomain& topFrameDomain, const RegistrableDomain& domainRedirectedTo, CompletionHandler<void()>&& completionHandler) 731 { 732 ASSERT(RunLoop::isMain()); 733 734 postTask([this, completionHandler = WTFMove(completionHandler), topFrameDomain = topFrameDomain.isolatedCopy(), domainRedirectedTo = domainRedirectedTo.isolatedCopy()]() mutable { 735 if (m_memoryStore) 736 m_memoryStore->setTopFrameUniqueRedirectTo(topFrameDomain, domainRedirectedTo); 737 postTaskReply(WTFMove(completionHandler)); 738 }); 739 } 740 741 void WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectFrom(const RegistrableDomain& topFrameDomain, const RegistrableDomain& domainRedirectedFrom, CompletionHandler<void()>&& completionHandler) 742 { 743 ASSERT(RunLoop::isMain()); 744 745 postTask([this, completionHandler = WTFMove(completionHandler), topFrameDomain = topFrameDomain.isolatedCopy(), domainRedirectedFrom = domainRedirectedFrom.isolatedCopy()]() mutable { 746 if (m_memoryStore) 747 m_memoryStore->setTopFrameUniqueRedirectFrom(topFrameDomain, domainRedirectedFrom); 757 748 postTaskReply(WTFMove(completionHandler)); 758 749 }); … … 775 766 } 776 767 777 void WebResourceLoadStatisticsStore::scheduleCookieBlockingUpdateForDomains(const Vector< String>& domainsToBlock, CompletionHandler<void()>&& completionHandler)768 void WebResourceLoadStatisticsStore::scheduleCookieBlockingUpdateForDomains(const Vector<RegistrableDomain>& domainsToBlock, CompletionHandler<void()>&& completionHandler) 778 769 { 779 770 // Helper function used by testing system. Should only be called from the main thread. … … 791 782 } 792 783 793 void WebResourceLoadStatisticsStore::scheduleClearBlockingStateForDomains(const Vector< String>& domains, CompletionHandler<void()>&& completionHandler)784 void WebResourceLoadStatisticsStore::scheduleClearBlockingStateForDomains(const Vector<RegistrableDomain>& domains, CompletionHandler<void()>&& completionHandler) 794 785 { 795 786 // Helper function used by testing system. Should only be called from the main thread. … … 886 877 } 887 878 888 void WebResourceLoadStatisticsStore::callUpdatePrevalentDomainsToBlockCookiesForHandler(const Vector< String>& domainsToBlock, CompletionHandler<void()>&& completionHandler)879 void WebResourceLoadStatisticsStore::callUpdatePrevalentDomainsToBlockCookiesForHandler(const Vector<RegistrableDomain>& domainsToBlock, CompletionHandler<void()>&& completionHandler) 889 880 { 890 881 ASSERT(RunLoop::isMain()); … … 896 887 } 897 888 898 void WebResourceLoadStatisticsStore::removePrevalentDomains(const Vector< String>& domains)889 void WebResourceLoadStatisticsStore::removePrevalentDomains(const Vector<RegistrableDomain>& domains) 899 890 { 900 891 if (m_networkSession) … … 902 893 } 903 894 904 void WebResourceLoadStatisticsStore::callRemoveDomainsHandler(const Vector< String>& domains)895 void WebResourceLoadStatisticsStore::callRemoveDomainsHandler(const Vector<RegistrableDomain>& domains) 905 896 { 906 897 ASSERT(RunLoop::isMain()); … … 960 951 } 961 952 962 void WebResourceLoadStatisticsStore::deleteWebsiteDataFor TopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType> dataTypes, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&& completionHandler)953 void WebResourceLoadStatisticsStore::deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType> dataTypes, Vector<RegistrableDomain>&& domains, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&& completionHandler) 963 954 { 964 955 ASSERT(RunLoop::isMain()); 965 956 966 957 if (m_networkSession) { 967 m_networkSession->deleteWebsiteDataFor TopPrivatelyControlledDomainsInAllPersistentDataStores(dataTypes, WTFMove(topPrivatelyControlledDomains), shouldNotifyPage, WTFMove(completionHandler));958 m_networkSession->deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores(dataTypes, WTFMove(domains), shouldNotifyPage, WTFMove(completionHandler)); 968 959 return; 969 960 } … … 972 963 } 973 964 974 void WebResourceLoadStatisticsStore:: topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType> dataTypes, bool shouldNotifyPage, CompletionHandler<void(HashSet<String>&&)>&& completionHandler)965 void WebResourceLoadStatisticsStore::registrableDomainsWithWebsiteData(OptionSet<WebsiteDataType> dataTypes, bool shouldNotifyPage, CompletionHandler<void(HashSet<RegistrableDomain>&&)>&& completionHandler) 975 966 { 976 967 ASSERT(RunLoop::isMain()); 977 968 978 969 if (m_networkSession) { 979 m_networkSession-> topPrivatelyControlledDomainsWithWebsiteData(dataTypes, shouldNotifyPage, WTFMove(completionHandler));970 m_networkSession->registrableDomainsWithWebsiteData(dataTypes, shouldNotifyPage, WTFMove(completionHandler)); 980 971 return; 981 972 } -
trunk/Source/WebKit/NetworkProcess/Classifier/WebResourceLoadStatisticsStore.h
r240676 r242056 31 31 #include "StorageAccessStatus.h" 32 32 #include "WebsiteDataType.h" 33 #include <WebCore/RegistrableDomain.h> 33 34 #include <wtf/CompletionHandler.h> 34 35 #include <wtf/RunLoop.h> … … 60 61 class WebResourceLoadStatisticsStore final : public ThreadSafeRefCounted<WebResourceLoadStatisticsStore, WTF::DestructionThread::Main>, public IPC::MessageReceiver { 61 62 public: 63 using ResourceLoadStatistics = WebCore::ResourceLoadStatistics; 64 using RegistrableDomain = WebCore::RegistrableDomain; 65 using TopFrameDomain = WebCore::RegistrableDomain; 66 using SubFrameDomain = WebCore::RegistrableDomain; 67 using SubResourceDomain = WebCore::RegistrableDomain; 68 using RedirectDomain = WebCore::RegistrableDomain; 69 using RedirectedFromDomain = WebCore::RegistrableDomain; 70 using RedirectedToDomain = WebCore::RegistrableDomain; 71 using NavigatedFromDomain = WebCore::RegistrableDomain; 72 using NavigatedToDomain = WebCore::RegistrableDomain; 73 using DomainInNeedOfStorageAccess = WebCore::RegistrableDomain; 74 using OpenerDomain = WebCore::RegistrableDomain; 75 using OpenerPageID = uint64_t; 76 using PageID = uint64_t; 77 using FrameID = uint64_t; 78 62 79 static Ref<WebResourceLoadStatisticsStore> create(NetworkSession& networkSession, const String& resourceLoadStatisticsDirectory) 63 80 { … … 76 93 void setShouldSubmitTelemetry(bool); 77 94 78 void grantStorageAccess(const S tring& subFrameHost, const String& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPromptedNow, CompletionHandler<void(bool)>&&);95 void grantStorageAccess(const SubFrameDomain&, const TopFrameDomain&, FrameID, PageID, bool userWasPromptedNow, CompletionHandler<void(bool)>&&); 79 96 80 97 void applicationWillTerminate(); 81 98 82 99 void logFrameNavigation(const WebFrameProxy&, const URL& pageURL, const WebCore::ResourceRequest&, const URL& redirectURL); 83 void logFrameNavigation(const String& targetPrimaryDomain, const String& mainFramePrimaryDomain, const String& sourcePrimaryDomain, const String& targetHost, const String& mainFrameHost, bool isRedirect, bool isMainFrame);84 void logUserInteraction(const String& targetPrimaryDomain, CompletionHandler<void()>&&);85 void logWebSocketLoading(const S tring& targetPrimaryDomain, const String& mainFramePrimaryDomain, WallTime lastSeen, CompletionHandler<void()>&&);86 void logSubresourceLoading(const S tring& targetPrimaryDomain, const String& mainFramePrimaryDomain, WallTime lastSeen, CompletionHandler<void()>&&);87 void logSubresourceRedirect(const String& sourcePrimaryDomain, const String& targetPrimaryDomain, CompletionHandler<void()>&&);88 void clearUserInteraction(const String& targetPrimaryDomain, CompletionHandler<void()>&&);89 void deleteWebsiteDataFor TopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType>, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&&);90 void topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType>, bool shouldNotifyPage, CompletionHandler<void(HashSet<String>&&)>&&);91 bool grantStorageAccess(const S tring& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID);92 void hasHadUserInteraction(const String& resourceDomain, CompletionHandler<void(bool)>&&);93 void hasStorageAccess(const S tring& subFrameHost, const String& topFrameHost, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& callback);94 bool hasStorageAccessForFrame(const S tring& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID);95 void requestStorageAccess(const S tring& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&&);96 void requestStorageAccessGranted(const S tring& subFrameHost, const String& topFrameHost, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(bool)>&&);100 void logFrameNavigation(const NavigatedToDomain&, const TopFrameDomain&, const NavigatedFromDomain&, bool isRedirect, bool isMainFrame); 101 void logUserInteraction(const TopFrameDomain&, CompletionHandler<void()>&&); 102 void logWebSocketLoading(const SubResourceDomain&, const TopFrameDomain&, WallTime lastSeen, CompletionHandler<void()>&&); 103 void logSubresourceLoading(const SubResourceDomain&, const TopFrameDomain&, WallTime lastSeen, CompletionHandler<void()>&&); 104 void logSubresourceRedirect(const RedirectedFromDomain&, const RedirectedToDomain&, CompletionHandler<void()>&&); 105 void clearUserInteraction(const TopFrameDomain&, CompletionHandler<void()>&&); 106 void deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType>, Vector<RegistrableDomain>&&, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&&); 107 void registrableDomainsWithWebsiteData(OptionSet<WebsiteDataType>, bool shouldNotifyPage, CompletionHandler<void(HashSet<RegistrableDomain>&&)>&&); 108 bool grantStorageAccess(const SubFrameDomain&, const TopFrameDomain&, Optional<FrameID>, PageID); 109 void hasHadUserInteraction(const RegistrableDomain&, CompletionHandler<void(bool)>&&); 110 void hasStorageAccess(const SubFrameDomain&, const TopFrameDomain&, Optional<FrameID>, PageID, CompletionHandler<void(bool)>&& callback); 111 bool hasStorageAccessForFrame(const SubFrameDomain&, const TopFrameDomain&, FrameID, PageID); 112 void requestStorageAccess(const SubFrameDomain&, const TopFrameDomain&, Optional<FrameID>, PageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&&); 113 void requestStorageAccessGranted(const SubFrameDomain&, const TopFrameDomain&, FrameID, PageID, bool promptEnabled, CompletionHandler<void(bool)>&&); 97 114 void requestUpdate(); 98 void setLastSeen(const String& resourceDomain, Seconds, CompletionHandler<void()>&&);99 void setPrevalentResource(const String& resourceDomain, CompletionHandler<void()>&&);100 void setVeryPrevalentResource(const String& resourceDomain, CompletionHandler<void()>&&);115 void setLastSeen(const RegistrableDomain&, Seconds, CompletionHandler<void()>&&); 116 void setPrevalentResource(const RegistrableDomain&, CompletionHandler<void()>&&); 117 void setVeryPrevalentResource(const RegistrableDomain&, CompletionHandler<void()>&&); 101 118 void dumpResourceLoadStatistics(CompletionHandler<void(String)>&&); 102 void isPrevalentResource(const String&, CompletionHandler<void(bool)>&&);103 void isVeryPrevalentResource(const String&, CompletionHandler<void(bool)>&&);104 void isRegisteredAsSubresourceUnder(const S tring& subresource, const String& topFrame, CompletionHandler<void(bool)>&&);105 void isRegisteredAsSubFrameUnder(const S tring& subFrame, const String& topFrame, CompletionHandler<void(bool)>&&);106 void isRegisteredAsRedirectingTo(const String& hostRedirectedFrom, const String& hostRedirectedTo, CompletionHandler<void(bool)>&&);107 void clearPrevalentResource(const String&, CompletionHandler<void()>&&);108 void setGrandfathered(const String&, bool, CompletionHandler<void()>&&);109 void isGrandfathered(const String&, CompletionHandler<void(bool)>&&);110 void removePrevalentDomains(const Vector< String>& domainsToBlock);119 void isPrevalentResource(const RegistrableDomain&, CompletionHandler<void(bool)>&&); 120 void isVeryPrevalentResource(const RegistrableDomain&, CompletionHandler<void(bool)>&&); 121 void isRegisteredAsSubresourceUnder(const SubResourceDomain&, const TopFrameDomain&, CompletionHandler<void(bool)>&&); 122 void isRegisteredAsSubFrameUnder(const SubFrameDomain&, const TopFrameDomain&, CompletionHandler<void(bool)>&&); 123 void isRegisteredAsRedirectingTo(const RedirectedFromDomain&, const RedirectedToDomain&, CompletionHandler<void(bool)>&&); 124 void clearPrevalentResource(const RegistrableDomain&, CompletionHandler<void()>&&); 125 void setGrandfathered(const RegistrableDomain&, bool, CompletionHandler<void()>&&); 126 void isGrandfathered(const RegistrableDomain&, CompletionHandler<void(bool)>&&); 127 void removePrevalentDomains(const Vector<RegistrableDomain>&); 111 128 void setNotifyPagesWhenDataRecordsWereScanned(bool, CompletionHandler<void()>&&); 112 void setSubframeUnderTopFrameOrigin(const S tring& subframe, const String& topFrame, CompletionHandler<void()>&&);113 void setSubresourceUnderTopFrameOrigin(const S tring& subresource, const String& topFrame, CompletionHandler<void()>&&);114 void setSubresourceUniqueRedirectTo(const S tring& subresource, const String& hostNameRedirectedTo, CompletionHandler<void()>&&);115 void setSubresourceUniqueRedirectFrom(const S tring& subresource, const String& hostNameRedirectedFrom, CompletionHandler<void()>&&);116 void setTopFrameUniqueRedirectTo(const String& topFrameHostName, const String& hostNameRedirectedTo, CompletionHandler<void()>&&);117 void setTopFrameUniqueRedirectFrom(const String& topFrameHostName, const String& hostNameRedirectedFrom, CompletionHandler<void()>&&);129 void setSubframeUnderTopFrameOrigin(const SubFrameDomain&, const TopFrameDomain&, CompletionHandler<void()>&&); 130 void setSubresourceUnderTopFrameOrigin(const SubResourceDomain&, const TopFrameDomain&, CompletionHandler<void()>&&); 131 void setSubresourceUniqueRedirectTo(const SubResourceDomain&, const RedirectedToDomain&, CompletionHandler<void()>&&); 132 void setSubresourceUniqueRedirectFrom(const SubResourceDomain&, const RedirectedFromDomain&, CompletionHandler<void()>&&); 133 void setTopFrameUniqueRedirectTo(const TopFrameDomain&, const RedirectedToDomain&, CompletionHandler<void()>&&); 134 void setTopFrameUniqueRedirectFrom(const TopFrameDomain&, const RedirectedFromDomain&, CompletionHandler<void()>&&); 118 135 void scheduleCookieBlockingUpdate(CompletionHandler<void()>&&); 119 void scheduleCookieBlockingUpdateForDomains(const Vector< String>& domainsToBlock, CompletionHandler<void()>&&);120 void scheduleClearBlockingStateForDomains(const Vector< String>& domains, CompletionHandler<void()>&&);136 void scheduleCookieBlockingUpdateForDomains(const Vector<RegistrableDomain>&, CompletionHandler<void()>&&); 137 void scheduleClearBlockingStateForDomains(const Vector<RegistrableDomain>&, CompletionHandler<void()>&&); 121 138 void scheduleStatisticsAndDataRecordsProcessing(CompletionHandler<void()>&&); 122 139 void submitTelemetry(CompletionHandler<void()>&&); … … 134 151 135 152 void setResourceLoadStatisticsDebugMode(bool, CompletionHandler<void()>&&); 136 void setPrevalentResourceForDebugMode(const String& resourceDomain, CompletionHandler<void()>&&);153 void setPrevalentResourceForDebugMode(const RegistrableDomain&, CompletionHandler<void()>&&); 137 154 138 155 void logTestingEvent(const String&); 139 void callGrantStorageAccessHandler(const S tring& subFramePrimaryDomain, const String& topFramePrimaryDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&&);156 void callGrantStorageAccessHandler(const SubFrameDomain&, const TopFrameDomain&, Optional<FrameID>, PageID, CompletionHandler<void(bool)>&&); 140 157 void removeAllStorageAccess(CompletionHandler<void()>&&); 141 void callUpdatePrevalentDomainsToBlockCookiesForHandler(const Vector< String>& domainsToBlock, CompletionHandler<void()>&&);142 void callRemoveDomainsHandler(const Vector< String>& domains);143 void callHasStorageAccessForFrameHandler(const S tring& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&&);158 void callUpdatePrevalentDomainsToBlockCookiesForHandler(const Vector<RegistrableDomain>&, CompletionHandler<void()>&&); 159 void callRemoveDomainsHandler(const Vector<RegistrableDomain>&); 160 void callHasStorageAccessForFrameHandler(const SubFrameDomain&, const TopFrameDomain&, FrameID, PageID, CompletionHandler<void(bool)>&&); 144 161 145 162 void didCreateNetworkProcess(); … … 162 179 163 180 // IPC message handlers. 164 void resourceLoadStatisticsUpdated(Vector< WebCore::ResourceLoadStatistics>&& origins);165 void requestStorageAccessUnderOpener( String&& primaryDomainInNeedOfStorageAccess, uint64_t openerPageID, String&& openerPrimaryDomain);181 void resourceLoadStatisticsUpdated(Vector<ResourceLoadStatistics>&& origins); 182 void requestStorageAccessUnderOpener(DomainInNeedOfStorageAccess&&, uint64_t openerPageID, OpenerDomain&&); 166 183 167 184 void performDailyTasks(); -
trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp
r241743 r242056 64 64 namespace WebKit { 65 65 using namespace WebCore; 66 using RegistrableDomain = WebCore::RegistrableDomain; 66 67 67 68 Ref<NetworkConnectionToWebProcess> NetworkConnectionToWebProcess::create(NetworkProcess& networkProcess, IPC::Connection::Identifier connectionIdentifier) … … 586 587 } 587 588 588 void NetworkConnectionToWebProcess::logUserInteraction(PAL::SessionID sessionID, const String& topLevelOrigin)589 void NetworkConnectionToWebProcess::logUserInteraction(PAL::SessionID sessionID, const RegistrableDomain& domain) 589 590 { 590 591 ASSERT(sessionID.isValid()); … … 594 595 if (auto networkSession = networkProcess().networkSession(sessionID)) { 595 596 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 596 resourceLoadStatistics->logUserInteraction( topLevelOrigin, [] { });597 } 598 } 599 600 void NetworkConnectionToWebProcess::logWebSocketLoading(PAL::SessionID sessionID, const String& targetPrimaryDomain, const String& mainFramePrimaryDomain, WallTime lastSeen)597 resourceLoadStatistics->logUserInteraction(domain, [] { }); 598 } 599 } 600 601 void NetworkConnectionToWebProcess::logWebSocketLoading(PAL::SessionID sessionID, const RegistrableDomain& targetDomain, const RegistrableDomain& topFrameDomain, WallTime lastSeen) 601 602 { 602 603 if (auto networkSession = networkProcess().networkSession(sessionID)) { 603 604 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 604 resourceLoadStatistics->logWebSocketLoading(target PrimaryDomain, mainFramePrimaryDomain, lastSeen, [] { });605 } 606 } 607 608 void NetworkConnectionToWebProcess::logSubresourceLoading(PAL::SessionID sessionID, const String& targetPrimaryDomain, const String& mainFramePrimaryDomain, WallTime lastSeen)605 resourceLoadStatistics->logWebSocketLoading(targetDomain, topFrameDomain, lastSeen, [] { }); 606 } 607 } 608 609 void NetworkConnectionToWebProcess::logSubresourceLoading(PAL::SessionID sessionID, const RegistrableDomain& targetDomain, const RegistrableDomain& topFrameDomain, WallTime lastSeen) 609 610 { 610 611 if (auto networkSession = networkProcess().networkSession(sessionID)) { 611 612 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 612 resourceLoadStatistics->logSubresourceLoading(target PrimaryDomain, mainFramePrimaryDomain, lastSeen, [] { });613 } 614 } 615 616 void NetworkConnectionToWebProcess::logSubresourceRedirect(PAL::SessionID sessionID, const String& sourcePrimaryDomain, const String& targetPrimaryDomain)613 resourceLoadStatistics->logSubresourceLoading(targetDomain, topFrameDomain, lastSeen, [] { }); 614 } 615 } 616 617 void NetworkConnectionToWebProcess::logSubresourceRedirect(PAL::SessionID sessionID, const RegistrableDomain& sourceDomain, const RegistrableDomain& targetDomain) 617 618 { 618 619 if (auto networkSession = networkProcess().networkSession(sessionID)) { 619 620 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 620 resourceLoadStatistics->logSubresourceRedirect(source PrimaryDomain, targetPrimaryDomain, [] { });621 resourceLoadStatistics->logSubresourceRedirect(sourceDomain, targetDomain, [] { }); 621 622 } 622 623 } … … 633 634 } 634 635 635 void NetworkConnectionToWebProcess::hasStorageAccess(PAL::SessionID sessionID, const String& subFrameHost, const String& topFrameHost, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler)636 { 637 networkProcess().hasStorageAccess(sessionID, subFrame Host, topFrameHost, frameID, pageID, WTFMove(completionHandler));638 } 639 640 void NetworkConnectionToWebProcess::requestStorageAccess(PAL::SessionID sessionID, const String& subFrameHost, const String& topFrameHost, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(bool)>&& completionHandler)641 { 642 networkProcess().requestStorageAccessGranted(sessionID, subFrame Host, topFrameHost, frameID, pageID, promptEnabled, WTFMove(completionHandler));636 void NetworkConnectionToWebProcess::hasStorageAccess(PAL::SessionID sessionID, const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler) 637 { 638 networkProcess().hasStorageAccess(sessionID, subFrameDomain, topFrameDomain, frameID, pageID, WTFMove(completionHandler)); 639 } 640 641 void NetworkConnectionToWebProcess::requestStorageAccess(PAL::SessionID sessionID, const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(bool)>&& completionHandler) 642 { 643 networkProcess().requestStorageAccessGranted(sessionID, subFrameDomain, topFrameDomain, frameID, pageID, promptEnabled, WTFMove(completionHandler)); 643 644 } 644 645 #endif -
trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h
r241317 r242056 34 34 #include "NetworkRTCProvider.h" 35 35 #include <WebCore/NetworkLoadInformation.h> 36 #include <WebCore/RegistrableDomain.h> 36 37 #include <wtf/RefCounted.h> 37 38 … … 65 66 class NetworkConnectionToWebProcess : public RefCounted<NetworkConnectionToWebProcess>, IPC::Connection::Client { 66 67 public: 68 using RegistrableDomain = WebCore::RegistrableDomain; 69 67 70 static Ref<NetworkConnectionToWebProcess> create(NetworkProcess&, IPC::Connection::Identifier); 68 71 virtual ~NetworkConnectionToWebProcess(); … … 200 203 void removeStorageAccessForAllFramesOnPage(PAL::SessionID, uint64_t pageID); 201 204 202 void logUserInteraction(PAL::SessionID, const String& topLevelOrigin);203 void logWebSocketLoading(PAL::SessionID, const String& targetPrimaryDomain, const String& mainFramePrimaryDomain, WallTime lastSeen);204 void logSubresourceLoading(PAL::SessionID, const String& targetPrimaryDomain, const String& mainFramePrimaryDomain, WallTime lastSeen);205 void logSubresourceRedirect(PAL::SessionID, const String& sourcePrimaryDomain, const String& targetPrimaryDomain);205 void logUserInteraction(PAL::SessionID, const RegistrableDomain&); 206 void logWebSocketLoading(PAL::SessionID, const RegistrableDomain& targetDomain, const RegistrableDomain& topFrameDomain, WallTime lastSeen); 207 void logSubresourceLoading(PAL::SessionID, const RegistrableDomain& targetDomain, const RegistrableDomain& topFrameDomain, WallTime lastSeen); 208 void logSubresourceRedirect(PAL::SessionID, const RegistrableDomain& sourceDomain, const RegistrableDomain& targetDomain); 206 209 void requestResourceLoadStatisticsUpdate(); 207 void hasStorageAccess(PAL::SessionID, const String& subFrameHost, const String& topFrameHost, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&&);208 void requestStorageAccess(PAL::SessionID, const String& subFrameHost, const String& topFrameHost, uint64_t frameID, uint64_t pageID, bool prompt, CompletionHandler<void(bool)>&&);210 void hasStorageAccess(PAL::SessionID, const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&&); 211 void requestStorageAccess(PAL::SessionID, const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, uint64_t frameID, uint64_t pageID, bool prompt, CompletionHandler<void(bool)>&&); 209 212 #endif 210 213 -
trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in
r241317 r242056 59 59 RemoveStorageAccessForFrame(PAL::SessionID sessionID, uint64_t frameID, uint64_t pageID); 60 60 RemoveStorageAccessForAllFramesOnPage(PAL::SessionID sessionID, uint64_t pageID); 61 LogUserInteraction(PAL::SessionID sessionID, String topLevelOrigin)62 LogWebSocketLoading(PAL::SessionID sessionID, String targetPrimaryDomain, String mainFramePrimaryDomain, WallTime lastSeen)63 LogSubresourceLoading(PAL::SessionID sessionID, String targetPrimaryDomain, String mainFramePrimaryDomain, WallTime lastSeen)64 LogSubresourceRedirect(PAL::SessionID sessionID, String sourcePrimaryDomain, String targetPrimaryDomain)61 LogUserInteraction(PAL::SessionID sessionID, WebCore::RegistrableDomain domain) 62 LogWebSocketLoading(PAL::SessionID sessionID, WebCore::RegistrableDomain targetDomain, WebCore::RegistrableDomain topFrameDomain, WallTime lastSeen) 63 LogSubresourceLoading(PAL::SessionID sessionID, WebCore::RegistrableDomain targetDomain, WebCore::RegistrableDomain topFrameDomain, WallTime lastSeen) 64 LogSubresourceRedirect(PAL::SessionID sessionID, WebCore::RegistrableDomain sourceDomain, WebCore::RegistrableDomain targetDomain) 65 65 RequestResourceLoadStatisticsUpdate(); 66 HasStorageAccess(PAL::SessionID sessionID, String subFrameHost, String topFrameHost, uint64_t frameID, uint64_t pageID) -> (bool hasStorageAccess) Async67 RequestStorageAccess(PAL::SessionID sessionID, String subFrameHost, String topFrameHost, uint64_t frameID, uint64_t pageID, bool prompt) -> (bool accessGranted) Async66 HasStorageAccess(PAL::SessionID sessionID, WebCore::RegistrableDomain subFrameDomain, WebCore::RegistrableDomain topFrameDomain, uint64_t frameID, uint64_t pageID) -> (bool hasStorageAccess) Async 67 RequestStorageAccess(PAL::SessionID sessionID, WebCore::RegistrableDomain subFrameDomain, WebCore::RegistrableDomain topFrameDomain, uint64_t frameID, uint64_t pageID, bool prompt) -> (bool accessGranted) Async 68 68 #endif 69 69 -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp
r241603 r242056 578 578 } 579 579 580 void NetworkProcess::updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID sessionID, const Vector< String>& domainsToBlock, CompletionHandler<void()>&& completionHandler)580 void NetworkProcess::updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID sessionID, const Vector<RegistrableDomain>& domainsToBlock, CompletionHandler<void()>&& completionHandler) 581 581 { 582 582 if (auto* networkStorageSession = storageSession(sessionID)) … … 585 585 } 586 586 587 void NetworkProcess::isGrandfathered(PAL::SessionID sessionID, const String& targetPrimaryDomain, CompletionHandler<void(bool)>&& completionHandler)588 { 589 if (auto* networkSession = this->networkSession(sessionID)) { 590 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 591 resourceLoadStatistics->isGrandfathered( targetPrimaryDomain, WTFMove(completionHandler));587 void NetworkProcess::isGrandfathered(PAL::SessionID sessionID, const RegistrableDomain& domain, CompletionHandler<void(bool)>&& completionHandler) 588 { 589 if (auto* networkSession = this->networkSession(sessionID)) { 590 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 591 resourceLoadStatistics->isGrandfathered(domain, WTFMove(completionHandler)); 592 592 else 593 593 completionHandler(false); … … 598 598 } 599 599 600 void NetworkProcess::isPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void(bool)>&& completionHandler)601 { 602 if (auto* networkSession = this->networkSession(sessionID)) { 603 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 604 resourceLoadStatistics->isPrevalentResource( resourceDomain, WTFMove(completionHandler));600 void NetworkProcess::isPrevalentResource(PAL::SessionID sessionID, const RegistrableDomain& domain, CompletionHandler<void(bool)>&& completionHandler) 601 { 602 if (auto* networkSession = this->networkSession(sessionID)) { 603 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 604 resourceLoadStatistics->isPrevalentResource(domain, WTFMove(completionHandler)); 605 605 else 606 606 completionHandler(false); … … 611 611 } 612 612 613 void NetworkProcess::isVeryPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void(bool)>&& completionHandler)614 { 615 if (auto* networkSession = this->networkSession(sessionID)) { 616 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 617 resourceLoadStatistics->isVeryPrevalentResource( resourceDomain, WTFMove(completionHandler));613 void NetworkProcess::isVeryPrevalentResource(PAL::SessionID sessionID, const RegistrableDomain& domain, CompletionHandler<void(bool)>&& completionHandler) 614 { 615 if (auto* networkSession = this->networkSession(sessionID)) { 616 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 617 resourceLoadStatistics->isVeryPrevalentResource(domain, WTFMove(completionHandler)); 618 618 else 619 619 completionHandler(false); … … 631 631 } 632 632 633 void NetworkProcess::setGrandfathered(PAL::SessionID sessionID, const String& resourceDomain, bool isGrandfathered, CompletionHandler<void()>&& completionHandler)634 { 635 if (auto* networkSession = this->networkSession(sessionID)) { 636 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 637 resourceLoadStatistics->setGrandfathered( resourceDomain, isGrandfathered, WTFMove(completionHandler));638 else 639 completionHandler(); 640 } else { 641 ASSERT_NOT_REACHED(); 642 completionHandler(); 643 } 644 } 645 646 void NetworkProcess::setPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void()>&& completionHandler)647 { 648 if (auto* networkSession = this->networkSession(sessionID)) { 649 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 650 resourceLoadStatistics->setPrevalentResource( resourceDomain, WTFMove(completionHandler));651 else 652 completionHandler(); 653 } else { 654 ASSERT_NOT_REACHED(); 655 completionHandler(); 656 } 657 } 658 659 void NetworkProcess::setPrevalentResourceForDebugMode(PAL::SessionID sessionID, String resourceDomain, CompletionHandler<void()>&& completionHandler)660 { 661 if (auto* networkSession = this->networkSession(sessionID)) { 662 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 663 resourceLoadStatistics->setPrevalentResourceForDebugMode( resourceDomain, WTFMove(completionHandler));664 else 665 completionHandler(); 666 } else { 667 ASSERT_NOT_REACHED(); 668 completionHandler(); 669 } 670 } 671 672 void NetworkProcess::setVeryPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void()>&& completionHandler)673 { 674 if (auto* networkSession = this->networkSession(sessionID)) { 675 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 676 resourceLoadStatistics->setVeryPrevalentResource( resourceDomain, WTFMove(completionHandler));677 else 678 completionHandler(); 679 } else { 680 ASSERT_NOT_REACHED(); 681 completionHandler(); 682 } 683 } 684 685 void NetworkProcess::clearPrevalentResource(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void()>&& completionHandler)686 { 687 if (auto* networkSession = this->networkSession(sessionID)) { 688 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 689 resourceLoadStatistics->clearPrevalentResource( resourceDomain, WTFMove(completionHandler));633 void NetworkProcess::setGrandfathered(PAL::SessionID sessionID, const RegistrableDomain& domain, bool isGrandfathered, CompletionHandler<void()>&& completionHandler) 634 { 635 if (auto* networkSession = this->networkSession(sessionID)) { 636 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 637 resourceLoadStatistics->setGrandfathered(domain, isGrandfathered, WTFMove(completionHandler)); 638 else 639 completionHandler(); 640 } else { 641 ASSERT_NOT_REACHED(); 642 completionHandler(); 643 } 644 } 645 646 void NetworkProcess::setPrevalentResource(PAL::SessionID sessionID, const RegistrableDomain& domain, CompletionHandler<void()>&& completionHandler) 647 { 648 if (auto* networkSession = this->networkSession(sessionID)) { 649 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 650 resourceLoadStatistics->setPrevalentResource(domain, WTFMove(completionHandler)); 651 else 652 completionHandler(); 653 } else { 654 ASSERT_NOT_REACHED(); 655 completionHandler(); 656 } 657 } 658 659 void NetworkProcess::setPrevalentResourceForDebugMode(PAL::SessionID sessionID, const RegistrableDomain& domain, CompletionHandler<void()>&& completionHandler) 660 { 661 if (auto* networkSession = this->networkSession(sessionID)) { 662 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 663 resourceLoadStatistics->setPrevalentResourceForDebugMode(domain, WTFMove(completionHandler)); 664 else 665 completionHandler(); 666 } else { 667 ASSERT_NOT_REACHED(); 668 completionHandler(); 669 } 670 } 671 672 void NetworkProcess::setVeryPrevalentResource(PAL::SessionID sessionID, const RegistrableDomain& domain, CompletionHandler<void()>&& completionHandler) 673 { 674 if (auto* networkSession = this->networkSession(sessionID)) { 675 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 676 resourceLoadStatistics->setVeryPrevalentResource(domain, WTFMove(completionHandler)); 677 else 678 completionHandler(); 679 } else { 680 ASSERT_NOT_REACHED(); 681 completionHandler(); 682 } 683 } 684 685 void NetworkProcess::clearPrevalentResource(PAL::SessionID sessionID, const RegistrableDomain& domain, CompletionHandler<void()>&& completionHandler) 686 { 687 if (auto* networkSession = this->networkSession(sessionID)) { 688 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 689 resourceLoadStatistics->clearPrevalentResource(domain, WTFMove(completionHandler)); 690 690 else 691 691 completionHandler(); … … 790 790 } 791 791 792 void NetworkProcess::setSubframeUnderTopFrameOrigin(PAL::SessionID sessionID, String subframe, String topFrame, CompletionHandler<void()>&& completionHandler)793 { 794 if (auto* networkSession = this->networkSession(sessionID)) { 795 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 796 resourceLoadStatistics->setSubframeUnderTopFrameOrigin(sub frame, topFrame, WTFMove(completionHandler));797 else 798 completionHandler(); 799 } else { 800 ASSERT_NOT_REACHED(); 801 completionHandler(); 802 } 803 } 804 805 void NetworkProcess::isRegisteredAsRedirectingTo(PAL::SessionID sessionID, const String& redirectedFrom, const String& redirectedTo, CompletionHandler<void(bool)>&& completionHandler)806 { 807 if (auto* networkSession = this->networkSession(sessionID)) { 808 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 809 resourceLoadStatistics->isRegisteredAsRedirectingTo( redirectedFrom, redirectedTo, WTFMove(completionHandler));792 void NetworkProcess::setSubframeUnderTopFrameOrigin(PAL::SessionID sessionID, const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, CompletionHandler<void()>&& completionHandler) 793 { 794 if (auto* networkSession = this->networkSession(sessionID)) { 795 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 796 resourceLoadStatistics->setSubframeUnderTopFrameOrigin(subFrameDomain, topFrameDomain, WTFMove(completionHandler)); 797 else 798 completionHandler(); 799 } else { 800 ASSERT_NOT_REACHED(); 801 completionHandler(); 802 } 803 } 804 805 void NetworkProcess::isRegisteredAsRedirectingTo(PAL::SessionID sessionID, const RegistrableDomain& domainRedirectedFrom, const RegistrableDomain& domainRedirectedTo, CompletionHandler<void(bool)>&& completionHandler) 806 { 807 if (auto* networkSession = this->networkSession(sessionID)) { 808 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 809 resourceLoadStatistics->isRegisteredAsRedirectingTo(domainRedirectedFrom, domainRedirectedTo, WTFMove(completionHandler)); 810 810 else 811 811 completionHandler(false); … … 816 816 } 817 817 818 void NetworkProcess::isRegisteredAsSubFrameUnder(PAL::SessionID sessionID, const String& subframe, const String& topFrame, CompletionHandler<void(bool)>&& completionHandler)819 { 820 if (auto* networkSession = this->networkSession(sessionID)) { 821 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 822 resourceLoadStatistics->isRegisteredAsSubFrameUnder(sub frame, topFrame, WTFMove(completionHandler));818 void NetworkProcess::isRegisteredAsSubFrameUnder(PAL::SessionID sessionID, const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, CompletionHandler<void(bool)>&& completionHandler) 819 { 820 if (auto* networkSession = this->networkSession(sessionID)) { 821 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 822 resourceLoadStatistics->isRegisteredAsSubFrameUnder(subFrameDomain, topFrameDomain, WTFMove(completionHandler)); 823 823 else 824 824 completionHandler(false); … … 829 829 } 830 830 831 void NetworkProcess::setSubresourceUnderTopFrameOrigin(PAL::SessionID sessionID, String subresource, String topFrame, CompletionHandler<void()>&& completionHandler)832 { 833 if (auto* networkSession = this->networkSession(sessionID)) { 834 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 835 resourceLoadStatistics->setSubresourceUnderTopFrameOrigin(subresource , topFrame, WTFMove(completionHandler));836 else 837 completionHandler(); 838 } else { 839 ASSERT_NOT_REACHED(); 840 completionHandler(); 841 } 842 } 843 844 void NetworkProcess::setSubresourceUniqueRedirectTo(PAL::SessionID sessionID, String subresource, String hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler)845 { 846 if (auto* networkSession = this->networkSession(sessionID)) { 847 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 848 resourceLoadStatistics->setSubresourceUniqueRedirectTo(subresource , hostNameRedirectedTo, WTFMove(completionHandler));849 else 850 completionHandler(); 851 } else { 852 ASSERT_NOT_REACHED(); 853 completionHandler(); 854 } 855 } 856 857 void NetworkProcess::setSubresourceUniqueRedirectFrom(PAL::SessionID sessionID, String subresource, String hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler)858 { 859 if (auto* networkSession = this->networkSession(sessionID)) { 860 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 861 resourceLoadStatistics->setSubresourceUniqueRedirectFrom(subresource , hostNameRedirectedFrom, WTFMove(completionHandler));862 else 863 completionHandler(); 864 } else { 865 ASSERT_NOT_REACHED(); 866 completionHandler(); 867 } 868 } 869 870 void NetworkProcess::isRegisteredAsSubresourceUnder(PAL::SessionID sessionID, const String& subresource, const String& topFrame, CompletionHandler<void(bool)>&& completionHandler)871 { 872 if (auto* networkSession = this->networkSession(sessionID)) { 873 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 874 resourceLoadStatistics->isRegisteredAsSubresourceUnder(subresource , topFrame, WTFMove(completionHandler));831 void NetworkProcess::setSubresourceUnderTopFrameOrigin(PAL::SessionID sessionID, const RegistrableDomain& subresourceDomain, const RegistrableDomain& topFrameDomain, CompletionHandler<void()>&& completionHandler) 832 { 833 if (auto* networkSession = this->networkSession(sessionID)) { 834 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 835 resourceLoadStatistics->setSubresourceUnderTopFrameOrigin(subresourceDomain, topFrameDomain, WTFMove(completionHandler)); 836 else 837 completionHandler(); 838 } else { 839 ASSERT_NOT_REACHED(); 840 completionHandler(); 841 } 842 } 843 844 void NetworkProcess::setSubresourceUniqueRedirectTo(PAL::SessionID sessionID, const RegistrableDomain& subresourceDomain, const RegistrableDomain& domainRedirectedTo, CompletionHandler<void()>&& completionHandler) 845 { 846 if (auto* networkSession = this->networkSession(sessionID)) { 847 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 848 resourceLoadStatistics->setSubresourceUniqueRedirectTo(subresourceDomain, domainRedirectedTo, WTFMove(completionHandler)); 849 else 850 completionHandler(); 851 } else { 852 ASSERT_NOT_REACHED(); 853 completionHandler(); 854 } 855 } 856 857 void NetworkProcess::setSubresourceUniqueRedirectFrom(PAL::SessionID sessionID, const RegistrableDomain& subresourceDomain, const RegistrableDomain& domainRedirectedFrom, CompletionHandler<void()>&& completionHandler) 858 { 859 if (auto* networkSession = this->networkSession(sessionID)) { 860 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 861 resourceLoadStatistics->setSubresourceUniqueRedirectFrom(subresourceDomain, domainRedirectedFrom, WTFMove(completionHandler)); 862 else 863 completionHandler(); 864 } else { 865 ASSERT_NOT_REACHED(); 866 completionHandler(); 867 } 868 } 869 870 void NetworkProcess::isRegisteredAsSubresourceUnder(PAL::SessionID sessionID, const RegistrableDomain& subresourceDomain, const RegistrableDomain& topFrameDomain, CompletionHandler<void(bool)>&& completionHandler) 871 { 872 if (auto* networkSession = this->networkSession(sessionID)) { 873 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 874 resourceLoadStatistics->isRegisteredAsSubresourceUnder(subresourceDomain, topFrameDomain, WTFMove(completionHandler)); 875 875 else 876 876 completionHandler(false); … … 881 881 } 882 882 883 void NetworkProcess::setTopFrameUniqueRedirectTo(PAL::SessionID sessionID, String topFrameHostName, String hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler)884 { 885 if (auto* networkSession = this->networkSession(sessionID)) { 886 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 887 resourceLoadStatistics->setTopFrameUniqueRedirectTo(topFrame HostName, hostNameRedirectedTo, WTFMove(completionHandler));888 else 889 completionHandler(); 890 } else { 891 ASSERT_NOT_REACHED(); 892 completionHandler(); 893 } 894 } 895 896 void NetworkProcess::setTopFrameUniqueRedirectFrom(PAL::SessionID sessionID, String topFrameHostName, String hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler)897 { 898 if (auto* networkSession = this->networkSession(sessionID)) { 899 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 900 resourceLoadStatistics->setTopFrameUniqueRedirectFrom(topFrame HostName, hostNameRedirectedFrom, WTFMove(completionHandler));901 else 902 completionHandler(); 903 } else { 904 ASSERT_NOT_REACHED(); 905 completionHandler(); 906 } 907 } 908 909 910 void NetworkProcess::setLastSeen(PAL::SessionID sessionID, const String& resourceDomain, Seconds seconds, CompletionHandler<void()>&& completionHandler)911 { 912 if (auto* networkSession = this->networkSession(sessionID)) { 913 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 914 resourceLoadStatistics->setLastSeen( resourceDomain, seconds, WTFMove(completionHandler));915 else 916 completionHandler(); 917 } else { 918 ASSERT_NOT_REACHED(); 919 completionHandler(); 920 } 921 } 922 923 void NetworkProcess::hasStorageAccessForFrame(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler)883 void NetworkProcess::setTopFrameUniqueRedirectTo(PAL::SessionID sessionID, const RegistrableDomain& topFrameDomain, const RegistrableDomain& domainRedirectedTo, CompletionHandler<void()>&& completionHandler) 884 { 885 if (auto* networkSession = this->networkSession(sessionID)) { 886 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 887 resourceLoadStatistics->setTopFrameUniqueRedirectTo(topFrameDomain, domainRedirectedTo, WTFMove(completionHandler)); 888 else 889 completionHandler(); 890 } else { 891 ASSERT_NOT_REACHED(); 892 completionHandler(); 893 } 894 } 895 896 void NetworkProcess::setTopFrameUniqueRedirectFrom(PAL::SessionID sessionID, const RegistrableDomain& topFrameDomain, const RegistrableDomain& domainRedirectedFrom, CompletionHandler<void()>&& completionHandler) 897 { 898 if (auto* networkSession = this->networkSession(sessionID)) { 899 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 900 resourceLoadStatistics->setTopFrameUniqueRedirectFrom(topFrameDomain, domainRedirectedFrom, WTFMove(completionHandler)); 901 else 902 completionHandler(); 903 } else { 904 ASSERT_NOT_REACHED(); 905 completionHandler(); 906 } 907 } 908 909 910 void NetworkProcess::setLastSeen(PAL::SessionID sessionID, const RegistrableDomain& domain, Seconds seconds, CompletionHandler<void()>&& completionHandler) 911 { 912 if (auto* networkSession = this->networkSession(sessionID)) { 913 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 914 resourceLoadStatistics->setLastSeen(domain, seconds, WTFMove(completionHandler)); 915 else 916 completionHandler(); 917 } else { 918 ASSERT_NOT_REACHED(); 919 completionHandler(); 920 } 921 } 922 923 void NetworkProcess::hasStorageAccessForFrame(PAL::SessionID sessionID, const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler) 924 924 { 925 925 bool hasStorageAccess = false; 926 926 if (auto* networkStorageSession = storageSession(sessionID)) 927 hasStorageAccess = networkStorageSession->hasStorageAccess( resourceDomain, firstPartyDomain, frameID, pageID);927 hasStorageAccess = networkStorageSession->hasStorageAccess(subFrameDomain, topFrameDomain, frameID, pageID); 928 928 else 929 929 ASSERT_NOT_REACHED(); … … 942 942 } 943 943 944 void NetworkProcess::hasStorageAccess(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler)945 { 946 if (auto* networkSession = this->networkSession(sessionID)) { 947 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 948 resourceLoadStatistics->hasStorageAccess( resourceDomain, firstPartyDomain, frameID, pageID, WTFMove(completionHandler));944 void NetworkProcess::hasStorageAccess(PAL::SessionID sessionID, const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler) 945 { 946 if (auto* networkSession = this->networkSession(sessionID)) { 947 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 948 resourceLoadStatistics->hasStorageAccess(subFrameDomain, topFrameDomain, frameID, pageID, WTFMove(completionHandler)); 949 949 else 950 950 completionHandler(false); … … 955 955 } 956 956 957 void NetworkProcess::requestStorageAccess(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&& completionHandler)958 { 959 if (auto* networkSession = this->networkSession(sessionID)) { 960 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 961 resourceLoadStatistics->requestStorageAccess( resourceDomain, firstPartyDomain, frameID.value(), pageID, promptEnabled, WTFMove(completionHandler));957 void NetworkProcess::requestStorageAccess(PAL::SessionID sessionID, const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, Optional<uint64_t> frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&& completionHandler) 958 { 959 if (auto* networkSession = this->networkSession(sessionID)) { 960 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 961 resourceLoadStatistics->requestStorageAccess(subFrameDomain, topFrameDomain, frameID.value(), pageID, promptEnabled, WTFMove(completionHandler)); 962 962 else 963 963 completionHandler(StorageAccessStatus::CannotRequestAccess); … … 968 968 } 969 969 970 void NetworkProcess::requestStorageAccessGranted(PAL::SessionID sessionID, const String& subFrameHost, const String& topFrameHost, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(bool)>&& completionHandler)971 { 972 if (auto* networkSession = this->networkSession(sessionID)) { 973 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 974 resourceLoadStatistics->requestStorageAccessGranted(subFrame Host, topFrameHost, frameID, pageID, promptEnabled, WTFMove(completionHandler));970 void NetworkProcess::requestStorageAccessGranted(PAL::SessionID sessionID, const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(bool)>&& completionHandler) 971 { 972 if (auto* networkSession = this->networkSession(sessionID)) { 973 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 974 resourceLoadStatistics->requestStorageAccessGranted(subFrameDomain, topFrameDomain, frameID, pageID, promptEnabled, WTFMove(completionHandler)); 975 975 else 976 976 completionHandler(false); … … 981 981 } 982 982 983 void NetworkProcess::grantStorageAccess(PAL::SessionID sessionID, const String& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool userWasPrompted, CompletionHandler<void(bool)>&& completionHandler) 984 { 985 if (auto* networkSession = this->networkSession(sessionID)) { 986 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 987 resourceLoadStatistics->grantStorageAccess(resourceDomain, firstPartyDomain, frameID.value(), pageID, userWasPrompted, WTFMove(completionHandler)); 983 void NetworkProcess::grantStorageAccess(PAL::SessionID sessionID, const RegistrableDomain& subFrameDomain, const RegistrableDomain& topFrameDomain, Optional<uint64_t> frameID, uint64_t pageID, bool userWasPrompted, CompletionHandler<void(bool)>&& completionHandler) 984 { 985 // FIXME: We should not accept an optional frame ID since we call frameID.value() unconditionally. 986 if (!frameID) { 987 completionHandler(false); 988 return; 989 } 990 991 if (auto* networkSession = this->networkSession(sessionID)) { 992 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 993 resourceLoadStatistics->grantStorageAccess(subFrameDomain, topFrameDomain, frameID.value(), pageID, userWasPrompted, WTFMove(completionHandler)); 988 994 else 989 995 completionHandler(false); … … 994 1000 } 995 1001 996 void NetworkProcess::logFrameNavigation(PAL::SessionID sessionID, const String& targetPrimaryDomain, const String& mainFramePrimaryDomain, const String& sourcePrimaryDomain, const String& targetHost, const String& mainFrameHost, bool isRedirect, bool isMainFrame)997 { 998 if (auto* networkSession = this->networkSession(sessionID)) { 999 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 1000 resourceLoadStatistics->logFrameNavigation(target PrimaryDomain, mainFramePrimaryDomain, sourcePrimaryDomain, targetHost, mainFrameHost, isRedirect, isMainFrame);1002 void NetworkProcess::logFrameNavigation(PAL::SessionID sessionID, const RegistrableDomain& targetDomain, const RegistrableDomain& topFrameDomain, const RegistrableDomain& sourceDomain, bool isRedirect, bool isMainFrame) 1003 { 1004 if (auto* networkSession = this->networkSession(sessionID)) { 1005 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 1006 resourceLoadStatistics->logFrameNavigation(targetDomain, topFrameDomain, sourceDomain, isRedirect, isMainFrame); 1001 1007 } else 1002 1008 ASSERT_NOT_REACHED(); 1003 1009 } 1004 1010 1005 void NetworkProcess::logUserInteraction(PAL::SessionID sessionID, const String& targetPrimaryDomain, CompletionHandler<void()>&& completionHandler)1006 { 1007 if (auto* networkSession = this->networkSession(sessionID)) { 1008 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 1009 resourceLoadStatistics->logUserInteraction( targetPrimaryDomain, WTFMove(completionHandler));1010 else 1011 completionHandler(); 1012 } else { 1013 ASSERT_NOT_REACHED(); 1014 completionHandler(); 1015 } 1016 } 1017 1018 void NetworkProcess::hadUserInteraction(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void(bool)>&& completionHandler)1019 { 1020 if (auto* networkSession = this->networkSession(sessionID)) { 1021 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 1022 resourceLoadStatistics->hasHadUserInteraction( resourceDomain, WTFMove(completionHandler));1011 void NetworkProcess::logUserInteraction(PAL::SessionID sessionID, const RegistrableDomain& domain, CompletionHandler<void()>&& completionHandler) 1012 { 1013 if (auto* networkSession = this->networkSession(sessionID)) { 1014 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 1015 resourceLoadStatistics->logUserInteraction(domain, WTFMove(completionHandler)); 1016 else 1017 completionHandler(); 1018 } else { 1019 ASSERT_NOT_REACHED(); 1020 completionHandler(); 1021 } 1022 } 1023 1024 void NetworkProcess::hadUserInteraction(PAL::SessionID sessionID, const RegistrableDomain& domain, CompletionHandler<void(bool)>&& completionHandler) 1025 { 1026 if (auto* networkSession = this->networkSession(sessionID)) { 1027 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 1028 resourceLoadStatistics->hasHadUserInteraction(domain, WTFMove(completionHandler)); 1023 1029 else 1024 1030 completionHandler(false); … … 1029 1035 } 1030 1036 1031 void NetworkProcess::clearUserInteraction(PAL::SessionID sessionID, const String& resourceDomain, CompletionHandler<void()>&& completionHandler)1032 { 1033 if (auto* networkSession = this->networkSession(sessionID)) { 1034 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 1035 resourceLoadStatistics->clearUserInteraction( resourceDomain, WTFMove(completionHandler));1037 void NetworkProcess::clearUserInteraction(PAL::SessionID sessionID, const RegistrableDomain& domain, CompletionHandler<void()>&& completionHandler) 1038 { 1039 if (auto* networkSession = this->networkSession(sessionID)) { 1040 if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics()) 1041 resourceLoadStatistics->clearUserInteraction(domain, WTFMove(completionHandler)); 1036 1042 else 1037 1043 completionHandler(); … … 1051 1057 } 1052 1058 1053 void NetworkProcess::removePrevalentDomains(PAL::SessionID sessionID, const Vector< String>& domains)1059 void NetworkProcess::removePrevalentDomains(PAL::SessionID sessionID, const Vector<RegistrableDomain>& domains) 1054 1060 { 1055 1061 if (auto* networkStorageSession = storageSession(sessionID)) … … 1416 1422 1417 1423 #if ENABLE(RESOURCE_LOAD_STATISTICS) 1418 static Vector<String> filterFor TopLevelDomains(const Vector<String>& topLevelDomains, const HashSet<String>& foundValues)1424 static Vector<String> filterForRegistrableDomains(const Vector<RegistrableDomain>& registrableDomains, const HashSet<String>& foundValues) 1419 1425 { 1420 1426 Vector<String> result; 1421 for (const auto& hostname : topLevelDomains) {1422 if (foundValues.contains( hostname))1423 result.append( hostname);1427 for (const auto& domain : registrableDomains) { 1428 if (foundValues.contains(domain.string())) 1429 result.append(domain.string()); 1424 1430 } 1425 1431 … … 1427 1433 } 1428 1434 1429 static Vector<WebsiteData::Entry> filterFor TopLevelDomains(const Vector<String>& topLevelDomains, const Vector<WebsiteData::Entry>& foundValues)1435 static Vector<WebsiteData::Entry> filterForRegistrableDomains(const Vector<RegistrableDomain>& registrableDomains, const Vector<WebsiteData::Entry>& foundValues) 1430 1436 { 1431 1437 Vector<WebsiteData::Entry> result; 1432 1438 for (const auto& value : foundValues) { 1433 if ( topLevelDomains.contains(value.origin.host))1439 if (registrableDomains.contains(RegistrableDomain { value.origin.host })) 1434 1440 result.append(value); 1435 1441 } … … 1438 1444 } 1439 1445 1440 void NetworkProcess::deleteWebsiteDataFor TopPrivatelyControlledDomainsInAllPersistentDataStores(PAL::SessionID sessionID, OptionSet<WebsiteDataType> websiteDataTypes, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&& completionHandler)1446 void NetworkProcess::deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores(PAL::SessionID sessionID, OptionSet<WebsiteDataType> websiteDataTypes, Vector<RegistrableDomain>&& domains, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&& completionHandler) 1441 1447 { 1442 1448 OptionSet<WebsiteDataFetchOption> fetchOptions = WebsiteDataFetchOption::DoNotCreateProcesses; … … 1469 1475 }; 1470 1476 1471 auto callbackAggregator = adoptRef(*new CallbackAggregator([this, completionHandler = WTFMove(completionHandler), shouldNotifyPage] (const HashSet<String>& originsWithData) mutable {1477 auto callbackAggregator = adoptRef(*new CallbackAggregator([this, completionHandler = WTFMove(completionHandler), shouldNotifyPage] (const HashSet<String>& domainsWithData) mutable { 1472 1478 if (shouldNotifyPage) 1473 parentProcessConnection()->send(Messages::NetworkProcessProxy::NotifyWebsiteDataDeletionFor TopPrivatelyOwnedDomainsFinished(), 0);1479 parentProcessConnection()->send(Messages::NetworkProcessProxy::NotifyWebsiteDataDeletionForRegistrableDomainsFinished(), 0); 1474 1480 1475 RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler), originsWithData = crossThreadCopy(originsWithData)] () mutable {1476 completionHandler( originsWithData);1481 RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler), domainsWithData = crossThreadCopy(domainsWithData)] () mutable { 1482 completionHandler(domainsWithData); 1477 1483 }); 1478 1484 })); … … 1484 1490 if (auto* networkStorageSession = storageSession(sessionID)) { 1485 1491 networkStorageSession->getHostnamesWithCookies(websiteDataStore.hostNamesWithCookies); 1486 hostnamesWithCookiesToDelete = filterFor TopLevelDomains(topPrivatelyControlledDomains, websiteDataStore.hostNamesWithCookies);1492 hostnamesWithCookiesToDelete = filterForRegistrableDomains(domains, websiteDataStore.hostNamesWithCookies); 1487 1493 networkStorageSession->deleteCookiesForHostnames(hostnamesWithCookiesToDelete); 1488 1494 } … … 1494 1500 if (auto* networkStorageSession = storageSession(sessionID)) { 1495 1501 getHostNamesWithHSTSCache(*networkStorageSession, websiteDataStore.hostNamesWithHSTSCache); 1496 hostnamesWithHSTSToDelete = filterFor TopLevelDomains(topPrivatelyControlledDomains, websiteDataStore.hostNamesWithHSTSCache);1502 hostnamesWithHSTSToDelete = filterForRegistrableDomains(domains, websiteDataStore.hostNamesWithHSTSCache); 1497 1503 deleteHSTSCacheForHostNames(*networkStorageSession, hostnamesWithHSTSToDelete); 1498 1504 } … … 1509 1515 1510 1516 if (websiteDataTypes.contains(WebsiteDataType::DOMCache)) { 1511 CacheStorage::Engine::fetchEntries(*this, sessionID, fetchOptions.contains(WebsiteDataFetchOption::ComputeSizes), [this, topPrivatelyControlledDomains, sessionID, callbackAggregator = callbackAggregator.copyRef()](auto entries) mutable {1517 CacheStorage::Engine::fetchEntries(*this, sessionID, fetchOptions.contains(WebsiteDataFetchOption::ComputeSizes), [this, domains, sessionID, callbackAggregator = callbackAggregator.copyRef()](auto entries) mutable { 1512 1518 1513 auto entriesToDelete = filterFor TopLevelDomains(topPrivatelyControlledDomains, entries);1519 auto entriesToDelete = filterForRegistrableDomains(domains, entries); 1514 1520 1515 1521 callbackAggregator->m_websiteData.entries.appendVector(entriesToDelete); … … 1524 1530 if (!path.isEmpty() && websiteDataTypes.contains(WebsiteDataType::IndexedDBDatabases)) { 1525 1531 // FIXME: Pick the right database store based on the session ID. 1526 postStorageTask(CrossThreadTask([this, sessionID, callbackAggregator = callbackAggregator.copyRef(), path = WTFMove(path), topPrivatelyControlledDomains]() mutable {1527 RunLoop::main().dispatch([this, sessionID, topPrivatelyControlledDomains = crossThreadCopy(topPrivatelyControlledDomains), callbackAggregator = callbackAggregator.copyRef(), securityOrigins = indexedDatabaseOrigins(path)] {1532 postStorageTask(CrossThreadTask([this, sessionID, callbackAggregator = callbackAggregator.copyRef(), path = WTFMove(path), domains]() mutable { 1533 RunLoop::main().dispatch([this, sessionID, domains = crossThreadCopy(domains), callbackAggregator = callbackAggregator.copyRef(), securityOrigins = indexedDatabaseOrigins(path)] { 1528 1534 Vector<SecurityOriginData> entriesToDelete; 1529 1535 for (const auto& securityOrigin : securityOrigins) { 1530 if (! topPrivatelyControlledDomains.contains(securityOrigin.host))1536 if (!domains.contains(RegistrableDomain { securityOrigin.host })) 1531 1537 continue; 1532 1538 … … 1544 1550 path = m_swDatabasePaths.get(sessionID); 1545 1551 if (!path.isEmpty() && websiteDataTypes.contains(WebsiteDataType::ServiceWorkerRegistrations)) { 1546 swServerForSession(sessionID).getOriginsWithRegistrations([this, sessionID, topPrivatelyControlledDomains, callbackAggregator = callbackAggregator.copyRef()](const HashSet<SecurityOriginData>& securityOrigins) mutable {1552 swServerForSession(sessionID).getOriginsWithRegistrations([this, sessionID, domains, callbackAggregator = callbackAggregator.copyRef()](const HashSet<SecurityOriginData>& securityOrigins) mutable { 1547 1553 for (auto& securityOrigin : securityOrigins) { 1548 if (! topPrivatelyControlledDomains.contains(securityOrigin.host))1554 if (!domains.contains(RegistrableDomain { securityOrigin.host })) 1549 1555 continue; 1550 1556 callbackAggregator->m_websiteData.entries.append({ securityOrigin, WebsiteDataType::ServiceWorkerRegistrations, 0 }); … … 1556 1562 1557 1563 if (websiteDataTypes.contains(WebsiteDataType::DiskCache)) { 1558 fetchDiskCacheEntries(cache(), sessionID, fetchOptions, [this, topPrivatelyControlledDomains, callbackAggregator = callbackAggregator.copyRef()](auto entries) mutable {1564 fetchDiskCacheEntries(cache(), sessionID, fetchOptions, [this, domains, callbackAggregator = callbackAggregator.copyRef()](auto entries) mutable { 1559 1565 1560 1566 Vector<SecurityOriginData> entriesToDelete; 1561 1567 for (auto& entry : entries) { 1562 if (! topPrivatelyControlledDomains.contains(entry.origin.host))1568 if (!domains.contains(RegistrableDomain { entry.origin.host })) 1563 1569 continue; 1564 1570 entriesToDelete.append(entry.origin); … … 1570 1576 } 1571 1577 1572 void NetworkProcess:: topPrivatelyControlledDomainsWithWebsiteData(PAL::SessionID sessionID, OptionSet<WebsiteDataType> websiteDataTypes, bool shouldNotifyPage, CompletionHandler<void(HashSet<String>&&)>&& completionHandler)1578 void NetworkProcess::registrableDomainsWithWebsiteData(PAL::SessionID sessionID, OptionSet<WebsiteDataType> websiteDataTypes, bool shouldNotifyPage, CompletionHandler<void(HashSet<RegistrableDomain>&&)>&& completionHandler) 1573 1579 { 1574 1580 OptionSet<WebsiteDataFetchOption> fetchOptions = WebsiteDataFetchOption::DoNotCreateProcesses; 1575 1581 1576 1582 struct CallbackAggregator final : public ThreadSafeRefCounted<CallbackAggregator> { 1577 explicit CallbackAggregator(CompletionHandler<void(HashSet< String>&&)>&& completionHandler)1583 explicit CallbackAggregator(CompletionHandler<void(HashSet<RegistrableDomain>&&)>&& completionHandler) 1578 1584 : m_completionHandler(WTFMove(completionHandler)) 1579 1585 { … … 1583 1589 { 1584 1590 RunLoop::main().dispatch([completionHandler = WTFMove(m_completionHandler), websiteData = WTFMove(m_websiteData)] () mutable { 1585 HashSet< String> origins;1591 HashSet<RegistrableDomain> domains; 1586 1592 for (const auto& hostnameWithCookies : websiteData.hostNamesWithCookies) 1587 origins.add(hostnameWithCookies);1588 1593 domains.add(RegistrableDomain { hostnameWithCookies }); 1594 1589 1595 for (const auto& hostnameWithHSTS : websiteData.hostNamesWithHSTSCache) 1590 origins.add(hostnameWithHSTS);1591 1596 domains.add(RegistrableDomain { hostnameWithHSTS }); 1597 1592 1598 for (const auto& entry : websiteData.entries) 1593 origins.add(entry.origin.host);1594 1595 completionHandler(WTFMove( origins));1599 domains.add(RegistrableDomain { entry.origin.host }); 1600 1601 completionHandler(WTFMove(domains)); 1596 1602 }); 1597 1603 } 1598 1604 1599 CompletionHandler<void(HashSet< String>&&)> m_completionHandler;1605 CompletionHandler<void(HashSet<RegistrableDomain>&&)> m_completionHandler; 1600 1606 WebsiteData m_websiteData; 1601 1607 }; 1602 1608 1603 auto callbackAggregator = adoptRef(*new CallbackAggregator([this, completionHandler = WTFMove(completionHandler), shouldNotifyPage] (HashSet< String>&& originsWithData) mutable {1609 auto callbackAggregator = adoptRef(*new CallbackAggregator([this, completionHandler = WTFMove(completionHandler), shouldNotifyPage] (HashSet<RegistrableDomain>&& domainsWithData) mutable { 1604 1610 if (shouldNotifyPage) 1605 parentProcessConnection()->send(Messages::NetworkProcessProxy::NotifyWebsiteDataScanFor TopPrivatelyControlledDomainsFinished(), 0);1606 1607 RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler), originsWithData = crossThreadCopy(originsWithData)] () mutable {1608 completionHandler(WTFMove( originsWithData));1611 parentProcessConnection()->send(Messages::NetworkProcessProxy::NotifyWebsiteDataScanForRegistrableDomainsFinished(), 0); 1612 1613 RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler), domainsWithData = crossThreadCopy(domainsWithData)] () mutable { 1614 completionHandler(WTFMove(domainsWithData)); 1609 1615 }); 1610 1616 })); -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.h
r241603 r242056 38 38 #include <WebCore/IDBKeyData.h> 39 39 #include <WebCore/IDBServer.h> 40 #include <WebCore/RegistrableDomain.h> 40 41 #include <WebCore/ServiceWorkerIdentifier.h> 41 42 #include <WebCore/ServiceWorkerTypes.h> … … 111 112 WTF_MAKE_NONCOPYABLE(NetworkProcess); 112 113 public: 114 using RegistrableDomain = WebCore::RegistrableDomain; 115 using TopFrameDomain = WebCore::RegistrableDomain; 116 using SubFrameDomain = WebCore::RegistrableDomain; 117 using SubResourceDomain = WebCore::RegistrableDomain; 118 using RedirectDomain = WebCore::RegistrableDomain; 119 using RedirectedFromDomain = WebCore::RegistrableDomain; 120 using RedirectedToDomain = WebCore::RegistrableDomain; 121 using NavigatedFromDomain = WebCore::RegistrableDomain; 122 using NavigatedToDomain = WebCore::RegistrableDomain; 123 using DomainInNeedOfStorageAccess = WebCore::RegistrableDomain; 124 using OpenerDomain = WebCore::RegistrableDomain; 125 using OpenerPageID = uint64_t; 126 using PageID = uint64_t; 127 using FrameID = uint64_t; 128 113 129 NetworkProcess(AuxiliaryProcessInitializationParameters&&); 114 130 ~NetworkProcess(); … … 181 197 182 198 #if ENABLE(RESOURCE_LOAD_STATISTICS) 183 void clearPrevalentResource(PAL::SessionID, const String& resourceDomain, CompletionHandler<void()>&&);184 void clearUserInteraction(PAL::SessionID, const String& resourceDomain, CompletionHandler<void()>&&);185 void deleteWebsiteDataFor TopPrivatelyControlledDomainsInAllPersistentDataStores(PAL::SessionID, OptionSet<WebsiteDataType>, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&&);199 void clearPrevalentResource(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void()>&&); 200 void clearUserInteraction(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void()>&&); 201 void deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores(PAL::SessionID, OptionSet<WebsiteDataType>, Vector<RegistrableDomain>&&, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&&); 186 202 void dumpResourceLoadStatistics(PAL::SessionID, CompletionHandler<void(String)>&&); 187 void updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID, const Vector< String>& domainsToBlock, CompletionHandler<void()>&&);188 void isGrandfathered(PAL::SessionID, const String& targetPrimaryDomain, CompletionHandler<void(bool)>&&);189 void isPrevalentResource(PAL::SessionID, const String& resourceDomain, CompletionHandler<void(bool)>&&);190 void isVeryPrevalentResource(PAL::SessionID, const String& resourceDomain, CompletionHandler<void(bool)>&&);203 void updatePrevalentDomainsToBlockCookiesFor(PAL::SessionID, const Vector<RegistrableDomain>& domainsToBlock, CompletionHandler<void()>&&); 204 void isGrandfathered(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void(bool)>&&); 205 void isPrevalentResource(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void(bool)>&&); 206 void isVeryPrevalentResource(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void(bool)>&&); 191 207 void setAgeCapForClientSideCookies(PAL::SessionID, Optional<Seconds>, CompletionHandler<void()>&&); 192 void isRegisteredAsRedirectingTo(PAL::SessionID, const String& redirectedFrom, const String& redirectedTo, CompletionHandler<void(bool)>&&);193 void isRegisteredAsSubFrameUnder(PAL::SessionID, const S tring& subframe, const String& topFrame, CompletionHandler<void(bool)>&&);194 void isRegisteredAsSubresourceUnder(PAL::SessionID, const S tring& subresource, const String& topFrame, CompletionHandler<void(bool)>&&);195 void setGrandfathered(PAL::SessionID, const String& resourceDomain, bool isGrandfathered, CompletionHandler<void()>&&);208 void isRegisteredAsRedirectingTo(PAL::SessionID, const RedirectedFromDomain&, const RedirectedToDomain&, CompletionHandler<void(bool)>&&); 209 void isRegisteredAsSubFrameUnder(PAL::SessionID, const SubFrameDomain&, const TopFrameDomain&, CompletionHandler<void(bool)>&&); 210 void isRegisteredAsSubresourceUnder(PAL::SessionID, const SubResourceDomain&, const TopFrameDomain&, CompletionHandler<void(bool)>&&); 211 void setGrandfathered(PAL::SessionID, const RegistrableDomain&, bool isGrandfathered, CompletionHandler<void()>&&); 196 212 void setMaxStatisticsEntries(PAL::SessionID, uint64_t maximumEntryCount, CompletionHandler<void()>&&); 197 void setPrevalentResource(PAL::SessionID, const String& resourceDomain, CompletionHandler<void()>&&);198 void setPrevalentResourceForDebugMode(PAL::SessionID, String resourceDomain, CompletionHandler<void()>&&);199 void setVeryPrevalentResource(PAL::SessionID, const String& resourceDomain, CompletionHandler<void()>&&);213 void setPrevalentResource(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void()>&&); 214 void setPrevalentResourceForDebugMode(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void()>&&); 215 void setVeryPrevalentResource(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void()>&&); 200 216 void setPruneEntriesDownTo(PAL::SessionID, uint64_t pruneTargetCount, CompletionHandler<void()>&&); 201 void hadUserInteraction(PAL::SessionID, const String& resourceDomain, CompletionHandler<void(bool)>&&);202 void hasStorageAccessForFrame(PAL::SessionID, const S tring& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&&);217 void hadUserInteraction(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void(bool)>&&); 218 void hasStorageAccessForFrame(PAL::SessionID, const SubFrameDomain&, const TopFrameDomain&, FrameID, PageID, CompletionHandler<void(bool)>&&); 203 219 void getAllStorageAccessEntries(PAL::SessionID, CompletionHandler<void(Vector<String> domains)>&&); 204 void grantStorageAccess(PAL::SessionID, const S tring& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool userWasPrompted, CompletionHandler<void(bool)>&&);205 void hasStorageAccess(PAL::SessionID, const S tring& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool)>&&);206 void logFrameNavigation(PAL::SessionID, const String& targetPrimaryDomain, const String& mainFramePrimaryDomain, const String& sourcePrimaryDomain, const String& targetHost, const String& mainFrameHost, bool isRedirect, bool isMainFrame);207 void logUserInteraction(PAL::SessionID, const String& targetPrimaryDomain, CompletionHandler<void()>&&);220 void grantStorageAccess(PAL::SessionID, const SubFrameDomain&, const TopFrameDomain&, Optional<FrameID>, PageID, bool userWasPrompted, CompletionHandler<void(bool)>&&); 221 void hasStorageAccess(PAL::SessionID, const SubFrameDomain&, const TopFrameDomain&, Optional<FrameID>, PageID, CompletionHandler<void(bool)>&&); 222 void logFrameNavigation(PAL::SessionID, const NavigatedToDomain&, const TopFrameDomain&, const NavigatedFromDomain&, bool isRedirect, bool isMainFrame); 223 void logUserInteraction(PAL::SessionID, const TopFrameDomain&, CompletionHandler<void()>&&); 208 224 void removeAllStorageAccess(PAL::SessionID, CompletionHandler<void()>&&); 209 void removePrevalentDomains(PAL::SessionID, const Vector< String>& domains);210 void requestStorageAccess(PAL::SessionID, const S tring& resourceDomain, const String& firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&&);211 void requestStorageAccessGranted(PAL::SessionID, const S tring& subFrameHost, const String& topFrameHost, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(bool)>&&);225 void removePrevalentDomains(PAL::SessionID, const Vector<RegistrableDomain>&); 226 void requestStorageAccess(PAL::SessionID, const SubFrameDomain&, const TopFrameDomain&, Optional<FrameID>, PageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&&); 227 void requestStorageAccessGranted(PAL::SessionID, const SubFrameDomain&, const TopFrameDomain&, FrameID, PageID, bool promptEnabled, CompletionHandler<void(bool)>&&); 212 228 void resetCacheMaxAgeCapForPrevalentResources(PAL::SessionID, CompletionHandler<void()>&&); 213 229 void resetParametersToDefaultValues(PAL::SessionID, CompletionHandler<void()>&&); … … 218 234 void setCacheMaxAgeCapForPrevalentResources(PAL::SessionID, Seconds, CompletionHandler<void()>&&); 219 235 void setGrandfatheringTime(PAL::SessionID, Seconds, CompletionHandler<void()>&&); 220 void setLastSeen(PAL::SessionID, const String& resourceDomain, Seconds, CompletionHandler<void()>&&);236 void setLastSeen(PAL::SessionID, const RegistrableDomain&, Seconds, CompletionHandler<void()>&&); 221 237 void setMinimumTimeBetweenDataRecordsRemoval(PAL::SessionID, Seconds, CompletionHandler<void()>&&); 222 238 void setNotifyPagesWhenDataRecordsWereScanned(PAL::SessionID, bool value, CompletionHandler<void()>&&); … … 225 241 void setResourceLoadStatisticsDebugMode(PAL::SessionID, bool debugMode, CompletionHandler<void()>&&d); 226 242 void setShouldClassifyResourcesBeforeDataRecordsRemoval(PAL::SessionID, bool value, CompletionHandler<void()>&&); 227 void setSubframeUnderTopFrameOrigin(PAL::SessionID, String subframe, String topFrame, CompletionHandler<void()>&&);228 void setSubresourceUnderTopFrameOrigin(PAL::SessionID, String subresource, String topFrame, CompletionHandler<void()>&&);229 void setSubresourceUniqueRedirectTo(PAL::SessionID, String subresource, String hostNameRedirectedTo, CompletionHandler<void()>&&);230 void setSubresourceUniqueRedirectFrom(PAL::SessionID, String subresource, String hostNameRedirectedFrom, CompletionHandler<void()>&&);243 void setSubframeUnderTopFrameOrigin(PAL::SessionID, const SubFrameDomain&, const TopFrameDomain&, CompletionHandler<void()>&&); 244 void setSubresourceUnderTopFrameOrigin(PAL::SessionID, const SubResourceDomain&, const TopFrameDomain&, CompletionHandler<void()>&&); 245 void setSubresourceUniqueRedirectTo(PAL::SessionID, const SubResourceDomain&, const RedirectedToDomain&, CompletionHandler<void()>&&); 246 void setSubresourceUniqueRedirectFrom(PAL::SessionID, const SubResourceDomain&, const RedirectedFromDomain&, CompletionHandler<void()>&&); 231 247 void setTimeToLiveUserInteraction(PAL::SessionID, Seconds, CompletionHandler<void()>&&); 232 void setTopFrameUniqueRedirectTo(PAL::SessionID, String topFrameHostName, String hostNameRedirectedTo, CompletionHandler<void()>&&);233 void setTopFrameUniqueRedirectFrom(PAL::SessionID, String topFrameHostName, String hostNameRedirectedFrom, CompletionHandler<void()>&&);234 void topPrivatelyControlledDomainsWithWebsiteData(PAL::SessionID, OptionSet<WebsiteDataType>, bool shouldNotifyPage, CompletionHandler<void(HashSet<String>&&)>&&);248 void setTopFrameUniqueRedirectTo(PAL::SessionID, const TopFrameDomain&, const RedirectedToDomain&, CompletionHandler<void()>&&); 249 void setTopFrameUniqueRedirectFrom(PAL::SessionID, const TopFrameDomain&, const RedirectedFromDomain&, CompletionHandler<void()>&&); 250 void registrableDomainsWithWebsiteData(PAL::SessionID, OptionSet<WebsiteDataType>, bool shouldNotifyPage, CompletionHandler<void(HashSet<RegistrableDomain>&&)>&&); 235 251 #endif 236 252 -
trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in
r241603 r242056 84 84 85 85 #if ENABLE(RESOURCE_LOAD_STATISTICS) 86 ClearPrevalentResource(PAL::SessionID sessionID, StringresourceDomain) -> () Async87 ClearUserInteraction(PAL::SessionID sessionID, StringresourceDomain) -> () Async86 ClearPrevalentResource(PAL::SessionID sessionID, WebCore::RegistrableDomain resourceDomain) -> () Async 87 ClearUserInteraction(PAL::SessionID sessionID, WebCore::RegistrableDomain resourceDomain) -> () Async 88 88 DumpResourceLoadStatistics(PAL::SessionID sessionID) -> (String dumpedStatistics) Async 89 89 SetResourceLoadStatisticsEnabled(bool enabled) 90 UpdatePrevalentDomainsToBlockCookiesFor(PAL::SessionID sessionID, Vector< String> domainsToBlock) -> () Async91 IsGrandfathered(PAL::SessionID sessionID, String targetPrimaryDomain) -> (bool isGrandfathered) Async92 IsPrevalentResource(PAL::SessionID sessionID, String targetPrimaryDomain) -> (bool isPrevalent) Async93 IsVeryPrevalentResource(PAL::SessionID sessionID, String targetPrimaryDomain) -> (bool isVeryPrevalent) Async90 UpdatePrevalentDomainsToBlockCookiesFor(PAL::SessionID sessionID, Vector<WebCore::RegistrableDomain> domainsToBlock) -> () Async 91 IsGrandfathered(PAL::SessionID sessionID, WebCore::RegistrableDomain targetDomain) -> (bool isGrandfathered) Async 92 IsPrevalentResource(PAL::SessionID sessionID, WebCore::RegistrableDomain targetDomain) -> (bool isPrevalent) Async 93 IsVeryPrevalentResource(PAL::SessionID sessionID, WebCore::RegistrableDomain targetDomain) -> (bool isVeryPrevalent) Async 94 94 SetAgeCapForClientSideCookies(PAL::SessionID sessionID, Optional<Seconds> seconds) -> () Async 95 SetLastSeen(PAL::SessionID sessionID, StringresourceDomain, Seconds seconds) -> () Async96 SetPrevalentResource(PAL::SessionID sessionID, StringresourceDomain) -> () Async97 SetPrevalentResourceForDebugMode(PAL::SessionID sessionID, StringresourceDomain) -> () Async98 HadUserInteraction(PAL::SessionID sessionID, StringresourceDomain) -> (bool hadUserInteraction) Async99 HasStorageAccessForFrame(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, uint64_t frameID, uint64_t pageID) -> (bool hasStorageAccess) Async100 HasStorageAccess(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID) -> (bool hasStorageAccess) Async95 SetLastSeen(PAL::SessionID sessionID, WebCore::RegistrableDomain resourceDomain, Seconds seconds) -> () Async 96 SetPrevalentResource(PAL::SessionID sessionID, WebCore::RegistrableDomain resourceDomain) -> () Async 97 SetPrevalentResourceForDebugMode(PAL::SessionID sessionID, WebCore::RegistrableDomain resourceDomain) -> () Async 98 HadUserInteraction(PAL::SessionID sessionID, WebCore::RegistrableDomain resourceDomain) -> (bool hadUserInteraction) Async 99 HasStorageAccessForFrame(PAL::SessionID sessionID, WebCore::RegistrableDomain subFrameDomain, WebCore::RegistrableDomain topFrameDomain, uint64_t frameID, uint64_t pageID) -> (bool hasStorageAccess) Async 100 HasStorageAccess(PAL::SessionID sessionID, WebCore::RegistrableDomain resourceDomain, WebCore::RegistrableDomain topFrameDomain, Optional<uint64_t> frameID, uint64_t pageID) -> (bool hasStorageAccess) Async 101 101 GetAllStorageAccessEntries(PAL::SessionID sessionID) -> (Vector<String> domains) Async 102 GrantStorageAccess(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool userWasPrompted) -> (bool accessGranted) Async103 IsRegisteredAsRedirectingTo(PAL::SessionID sessionID, String redirectedFrom, String redirectedTo) -> (bool isRedirectingTo) Async104 IsRegisteredAsSubFrameUnder(PAL::SessionID sessionID, String subframe, String topFrame) -> (bool isSubframeUnder) Async105 IsRegisteredAsSubresourceUnder(PAL::SessionID sessionID, String subresource, String topFrame) -> (bool isSubresourceUnder) Async106 LogFrameNavigation(PAL::SessionID sessionID, String targetPrimaryDomain, String mainFramePrimaryDomain, String sourcePrimaryDomain, String targetHost, String mainFrameHost, bool isRedirect, bool isMainFrame)107 LogUserInteraction(PAL::SessionID sessionID, String targetPrimaryDomain) -> () Async102 GrantStorageAccess(PAL::SessionID sessionID, WebCore::RegistrableDomain subFrameDomain, WebCore::RegistrableDomain topFrameDomain, Optional<uint64_t> frameID, uint64_t pageID, bool userWasPrompted) -> (bool accessGranted) Async 103 IsRegisteredAsRedirectingTo(PAL::SessionID sessionID, WebCore::RegistrableDomain redirectedFromDomain, WebCore::RegistrableDomain redirectedToDomain) -> (bool isRedirectingTo) Async 104 IsRegisteredAsSubFrameUnder(PAL::SessionID sessionID, WebCore::RegistrableDomain subFrameDomain, WebCore::RegistrableDomain topFrameDomain) -> (bool isSubframeUnder) Async 105 IsRegisteredAsSubresourceUnder(PAL::SessionID sessionID, WebCore::RegistrableDomain subresourceDomain, WebCore::RegistrableDomain topFrameDomain) -> (bool isSubresourceUnder) Async 106 LogFrameNavigation(PAL::SessionID sessionID, WebCore::RegistrableDomain targetDomain, WebCore::RegistrableDomain topFrameDomain, WebCore::RegistrableDomain sourceDomain, bool isRedirect, bool isMainFrame) 107 LogUserInteraction(PAL::SessionID sessionID, WebCore::RegistrableDomain topFrameDomain) -> () Async 108 108 RemoveAllStorageAccess(PAL::SessionID sessionID) -> () Async 109 RemovePrevalentDomains(PAL::SessionID sessionID, Vector< String> domainsWithInteraction)110 RequestStorageAccess(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, Optional<uint64_t> frameID, uint64_t pageID, bool promptEnabled) -> (enum:uint8_t WebKit::StorageAccessStatus storageAccessStatus) Async109 RemovePrevalentDomains(PAL::SessionID sessionID, Vector<WebCore::RegistrableDomain> domainsWithInteraction) 110 RequestStorageAccess(PAL::SessionID sessionID, WebCore::RegistrableDomain resourceDomain, WebCore::RegistrableDomain topFrameDomain, Optional<uint64_t> frameID, uint64_t pageID, bool promptEnabled) -> (enum:uint8_t WebKit::StorageAccessStatus storageAccessStatus) Async 111 111 ResetParametersToDefaultValues(PAL::SessionID sessionID) -> () Async 112 112 ScheduleClearInMemoryAndPersistent(PAL::SessionID sessionID, Optional<WallTime> modifiedSince, enum:bool WebKit::ShouldGrandfatherStatistics shouldGrandfather) -> () Async … … 115 115 SubmitTelemetry(PAL::SessionID sessionID) -> () Async 116 116 SetCacheMaxAgeCapForPrevalentResources(PAL::SessionID sessionID, Seconds seconds) -> () Async 117 SetGrandfathered(PAL::SessionID sessionID, StringresourceDomain, bool isGrandfathered) -> () Async117 SetGrandfathered(PAL::SessionID sessionID, WebCore::RegistrableDomain resourceDomain, bool isGrandfathered) -> () Async 118 118 SetGrandfatheringTime(PAL::SessionID sessionID, Seconds seconds) -> () Async 119 119 SetMaxStatisticsEntries(PAL::SessionID sessionID, uint64_t maximumEntryCount) -> () Async … … 124 124 SetNotifyPagesWhenTelemetryWasCaptured(PAL::SessionID sessionID, bool value) -> () Async 125 125 SetResourceLoadStatisticsDebugMode(PAL::SessionID sessionID, bool debugMode) -> () Async 126 SetVeryPrevalentResource(PAL::SessionID sessionID, StringresourceDomain) -> () Async127 SetSubframeUnderTopFrameOrigin(PAL::SessionID sessionID, String subframe, String topFrame) -> () Async128 SetSubresourceUnderTopFrameOrigin(PAL::SessionID sessionID, String subresource, String topFrame) -> () Async129 SetSubresourceUniqueRedirectTo(PAL::SessionID sessionID, String subresource, String hostNameRedirectedTo) -> () Async130 SetSubresourceUniqueRedirectFrom(PAL::SessionID sessionID, String subresource, String hostNameRedirectedFrom) -> () Async126 SetVeryPrevalentResource(PAL::SessionID sessionID, WebCore::RegistrableDomain resourceDomain) -> () Async 127 SetSubframeUnderTopFrameOrigin(PAL::SessionID sessionID, WebCore::RegistrableDomain subFrameDomain, WebCore::RegistrableDomain topFrameDomain) -> () Async 128 SetSubresourceUnderTopFrameOrigin(PAL::SessionID sessionID, WebCore::RegistrableDomain subresourceDomain, WebCore::RegistrableDomain topFrameDomain) -> () Async 129 SetSubresourceUniqueRedirectTo(PAL::SessionID sessionID, WebCore::RegistrableDomain subresourceDomain, WebCore::RegistrableDomain redirectedToDomain) -> () Async 130 SetSubresourceUniqueRedirectFrom(PAL::SessionID sessionID, WebCore::RegistrableDomain subresourceDomain, WebCore::RegistrableDomain redirectedFromDomain) -> () Async 131 131 SetTimeToLiveUserInteraction(PAL::SessionID sessionID, Seconds seconds) -> () Async 132 SetTopFrameUniqueRedirectTo(PAL::SessionID sessionID, String topFrameHostName, String hostNameRedirectedTo) -> () Async133 SetTopFrameUniqueRedirectFrom(PAL::SessionID sessionID, String topFrameHostName, String hostNameRedirectedFrom) -> () Async132 SetTopFrameUniqueRedirectTo(PAL::SessionID sessionID, WebCore::RegistrableDomain topFrameDomain, WebCore::RegistrableDomain redirectedToDomain) -> () Async 133 SetTopFrameUniqueRedirectFrom(PAL::SessionID sessionID, WebCore::RegistrableDomain topFrameDomain, WebCore::RegistrableDomain redirectedFromDomain) -> () Async 134 134 ResetCacheMaxAgeCapForPrevalentResources(PAL::SessionID sessionID) -> () Async 135 135 #endif -
trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp
r241317 r242056 49 49 #include <WebCore/NetworkLoadMetrics.h> 50 50 #include <WebCore/NetworkStorageSession.h> 51 #include <WebCore/RegistrableDomain.h> 51 52 #include <WebCore/SameSiteInfo.h> 52 53 #include <WebCore/SecurityOrigin.h> … … 980 981 auto escapedPageID = escapeIDForJSON(pageID); 981 982 auto escapedIdentifier = escapeIDForJSON(identifier); 982 bool hasStorageAccess = (frameID && pageID) ? networkStorageSession.hasStorageAccess( url.string(), firstParty.string(), frameID.value(), pageID.value()) : false;983 bool hasStorageAccess = (frameID && pageID) ? networkStorageSession.hasStorageAccess(WebCore::RegistrableDomain { url }, WebCore::RegistrableDomain { firstParty }, frameID.value(), pageID.value()) : false; 983 984 984 985 #define LOCAL_LOG_IF_ALLOWED(fmt, ...) RELEASE_LOG_IF(networkStorageSession.sessionID().isAlwaysOnLoggingAllowed(), Network, "%p - %s::" fmt, loggedObject, label.utf8().data(), ##__VA_ARGS__) -
trunk/Source/WebKit/NetworkProcess/NetworkSession.cpp
r241451 r242056 118 118 } 119 119 120 void NetworkSession::deleteWebsiteDataFor TopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType> dataTypes, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&& completionHandler)120 void NetworkSession::deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType> dataTypes, Vector<RegistrableDomain>&& domains, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&& completionHandler) 121 121 { 122 m_networkProcess->deleteWebsiteDataFor TopPrivatelyControlledDomainsInAllPersistentDataStores(m_sessionID, dataTypes, WTFMove(topPrivatelyControlledDomains), shouldNotifyPage, WTFMove(completionHandler));122 m_networkProcess->deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores(m_sessionID, dataTypes, WTFMove(domains), shouldNotifyPage, WTFMove(completionHandler)); 123 123 } 124 124 125 void NetworkSession:: topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType> dataTypes, bool shouldNotifyPage, CompletionHandler<void(HashSet<String>&&)>&& completionHandler)125 void NetworkSession::registrableDomainsWithWebsiteData(OptionSet<WebsiteDataType> dataTypes, bool shouldNotifyPage, CompletionHandler<void(HashSet<RegistrableDomain>&&)>&& completionHandler) 126 126 { 127 m_networkProcess-> topPrivatelyControlledDomainsWithWebsiteData(m_sessionID, dataTypes, shouldNotifyPage, WTFMove(completionHandler));127 m_networkProcess->registrableDomainsWithWebsiteData(m_sessionID, dataTypes, shouldNotifyPage, WTFMove(completionHandler)); 128 128 } 129 129 #endif -
trunk/Source/WebKit/NetworkProcess/NetworkSession.h
r241451 r242056 26 26 #pragma once 27 27 28 #include <WebCore/RegistrableDomain.h> 28 29 #include <pal/SessionID.h> 29 30 #include <wtf/HashSet.h> … … 72 73 void setResourceLoadStatisticsEnabled(bool); 73 74 void notifyResourceLoadStatisticsProcessed(); 74 void deleteWebsiteDataFor TopPrivatelyControlledDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType>, Vector<String>&& topPrivatelyControlledDomains, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&&);75 void topPrivatelyControlledDomainsWithWebsiteData(OptionSet<WebsiteDataType>, bool shouldNotifyPage, CompletionHandler<void(HashSet<String>&&)>&&);75 void deleteWebsiteDataForRegistrableDomainsInAllPersistentDataStores(OptionSet<WebsiteDataType>, Vector<WebCore::RegistrableDomain>&&, bool shouldNotifyPage, CompletionHandler<void(const HashSet<String>&)>&&); 76 void registrableDomainsWithWebsiteData(OptionSet<WebsiteDataType>, bool shouldNotifyPage, CompletionHandler<void(HashSet<WebCore::RegistrableDomain>&&)>&&); 76 77 void logDiagnosticMessageWithValue(const String& message, const String& description, unsigned value, unsigned significantFigures, WebCore::ShouldSample); 77 78 void notifyPageStatisticsTelemetryFinished(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins); -
trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp
r240579 r242056 63 63 #include <WebCore/RectEdges.h> 64 64 #include <WebCore/Region.h> 65 #include <WebCore/RegistrableDomain.h> 65 66 #include <WebCore/ResourceError.h> 66 67 #include <WebCore/ResourceLoadStatistics.h> … … 2672 2673 void ArgumentCoder<ResourceLoadStatistics>::encode(Encoder& encoder, const WebCore::ResourceLoadStatistics& statistics) 2673 2674 { 2674 encoder << statistics. highLevelDomain;2675 encoder << statistics.registrableDomain; 2675 2676 2676 2677 encoder << statistics.lastSeen.secondsSinceEpoch().value(); … … 2716 2717 { 2717 2718 ResourceLoadStatistics statistics; 2718 if (!decoder.decode(statistics.highLevelDomain)) 2719 return WTF::nullopt; 2720 2719 Optional<RegistrableDomain> registrableDomain; 2720 decoder >> registrableDomain; 2721 if (!registrableDomain) 2722 return WTF::nullopt; 2723 statistics.registrableDomain = *registrableDomain; 2724 2721 2725 double lastSeenTimeAsDouble; 2722 2726 if (!decoder.decode(lastSeenTimeAsDouble)) -
trunk/Source/WebKit/UIProcess/Cocoa/ResourceLoadStatisticsMemoryStoreCocoa.mm
r240243 r242056 29 29 #if ENABLE(RESOURCE_LOAD_STATISTICS) 30 30 31 #import <WebCore/RegistrableDomain.h> 31 32 #import <wtf/text/WTFString.h> 32 33 … … 53 54 auto* debugManualPrevalentResource = [[NSUserDefaults standardUserDefaults] stringForKey:@"ResourceLoadStatisticsManualPrevalentResource"]; 54 55 if (debugManualPrevalentResource) 55 setPrevalentResourceForDebugMode( debugManualPrevalentResource);56 setPrevalentResourceForDebugMode(RegistrableDomain { debugManualPrevalentResource }); 56 57 57 58 Seconds cacheMaxAgeCapForPrevalentResources([[NSUserDefaults standardUserDefaults] doubleForKey:@"ResourceLoadStatisticsCacheMaxAgeCap"]); -
trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp
r241451 r242056 50 50 #include "WebsiteDataStoreClient.h" 51 51 #include <WebCore/ClientOrigin.h> 52 #include <WebCore/RegistrableDomain.h> 52 53 #include <wtf/CompletionHandler.h> 53 54 … … 415 416 } 416 417 417 sendWithAsyncReply(Messages::NetworkProcess::UpdatePrevalentDomainsToBlockCookiesFor(sessionID, domainsToBlock), WTFMove(completionHandler)); 418 Vector<RegistrableDomain> registrableDomainsToBlock; 419 registrableDomainsToBlock.reserveInitialCapacity(domainsToBlock.size()); 420 for (auto& domainString : domainsToBlock) 421 registrableDomainsToBlock.uncheckedAppend(RegistrableDomain { domainString }); 422 423 sendWithAsyncReply(Messages::NetworkProcess::UpdatePrevalentDomainsToBlockCookiesFor(sessionID, registrableDomainsToBlock), WTFMove(completionHandler)); 418 424 } 419 425 … … 425 431 } 426 432 427 sendWithAsyncReply(Messages::NetworkProcess::IsPrevalentResource(sessionID, resourceDomain), WTFMove(completionHandler));433 sendWithAsyncReply(Messages::NetworkProcess::IsPrevalentResource(sessionID, RegistrableDomain { resourceDomain }), WTFMove(completionHandler)); 428 434 } 429 435 … … 435 441 } 436 442 437 sendWithAsyncReply(Messages::NetworkProcess::IsVeryPrevalentResource(sessionID, resourceDomain), WTFMove(completionHandler));443 sendWithAsyncReply(Messages::NetworkProcess::IsVeryPrevalentResource(sessionID, RegistrableDomain { resourceDomain }), WTFMove(completionHandler)); 438 444 } 439 445 … … 445 451 } 446 452 447 sendWithAsyncReply(Messages::NetworkProcess::SetPrevalentResource(sessionID, resourceDomain), WTFMove(completionHandler));453 sendWithAsyncReply(Messages::NetworkProcess::SetPrevalentResource(sessionID, RegistrableDomain { resourceDomain }), WTFMove(completionHandler)); 448 454 } 449 455 … … 455 461 } 456 462 457 sendWithAsyncReply(Messages::NetworkProcess::SetPrevalentResourceForDebugMode(sessionID, resourceDomain), WTFMove(completionHandler));463 sendWithAsyncReply(Messages::NetworkProcess::SetPrevalentResourceForDebugMode(sessionID, RegistrableDomain { resourceDomain }), WTFMove(completionHandler)); 458 464 } 459 465 … … 465 471 } 466 472 467 sendWithAsyncReply(Messages::NetworkProcess::SetVeryPrevalentResource(sessionID, resourceDomain), WTFMove(completionHandler));473 sendWithAsyncReply(Messages::NetworkProcess::SetVeryPrevalentResource(sessionID, RegistrableDomain { resourceDomain }), WTFMove(completionHandler)); 468 474 } 469 475 … … 475 481 } 476 482 477 sendWithAsyncReply(Messages::NetworkProcess::SetLastSeen(sessionID, resourceDomain, lastSeen), WTFMove(completionHandler));483 sendWithAsyncReply(Messages::NetworkProcess::SetLastSeen(sessionID, RegistrableDomain { resourceDomain }, lastSeen), WTFMove(completionHandler)); 478 484 } 479 485 … … 485 491 } 486 492 487 sendWithAsyncReply(Messages::NetworkProcess::ClearPrevalentResource(sessionID, resourceDomain), WTFMove(completionHandler));493 sendWithAsyncReply(Messages::NetworkProcess::ClearPrevalentResource(sessionID, RegistrableDomain { resourceDomain }), WTFMove(completionHandler)); 488 494 } 489 495 … … 525 531 } 526 532 527 sendWithAsyncReply(Messages::NetworkProcess::LogUserInteraction(sessionID, resourceDomain), WTFMove(completionHandler));533 sendWithAsyncReply(Messages::NetworkProcess::LogUserInteraction(sessionID, RegistrableDomain { resourceDomain }), WTFMove(completionHandler)); 528 534 } 529 535 … … 535 541 } 536 542 537 sendWithAsyncReply(Messages::NetworkProcess::HadUserInteraction(sessionID, resourceDomain), WTFMove(completionHandler));543 sendWithAsyncReply(Messages::NetworkProcess::HadUserInteraction(sessionID, RegistrableDomain { resourceDomain }), WTFMove(completionHandler)); 538 544 } 539 545 … … 545 551 } 546 552 547 sendWithAsyncReply(Messages::NetworkProcess::ClearUserInteraction(sessionID, resourceDomain), WTFMove(completionHandler));553 sendWithAsyncReply(Messages::NetworkProcess::ClearUserInteraction(sessionID, RegistrableDomain { resourceDomain }), WTFMove(completionHandler)); 548 554 } 549 555 … … 595 601 } 596 602 597 sendWithAsyncReply(Messages::NetworkProcess::SetSubframeUnderTopFrameOrigin(sessionID, subframe, topFrame), WTFMove(completionHandler));603 sendWithAsyncReply(Messages::NetworkProcess::SetSubframeUnderTopFrameOrigin(sessionID, RegistrableDomain { subframe }, RegistrableDomain { topFrame }), WTFMove(completionHandler)); 598 604 } 599 605 … … 605 611 } 606 612 607 sendWithAsyncReply(Messages::NetworkProcess::IsRegisteredAsRedirectingTo(sessionID, redirectedFrom, redirectedTo), WTFMove(completionHandler));613 sendWithAsyncReply(Messages::NetworkProcess::IsRegisteredAsRedirectingTo(sessionID, RegistrableDomain { redirectedFrom }, RegistrableDomain { redirectedTo }), WTFMove(completionHandler)); 608 614 } 609 615 … … 615 621 } 616 622 617 sendWithAsyncReply(Messages::NetworkProcess::IsRegisteredAsSubFrameUnder(sessionID, subFrame, topFrame), WTFMove(completionHandler));623 sendWithAsyncReply(Messages::NetworkProcess::IsRegisteredAsSubFrameUnder(sessionID, RegistrableDomain { subFrame }, RegistrableDomain { topFrame }), WTFMove(completionHandler)); 618 624 } 619 625 … … 625 631 } 626 632 627 sendWithAsyncReply(Messages::NetworkProcess::SetSubresourceUnderTopFrameOrigin(sessionID, subresource, topFrame), WTFMove(completionHandler));633 sendWithAsyncReply(Messages::NetworkProcess::SetSubresourceUnderTopFrameOrigin(sessionID, RegistrableDomain { subresource }, RegistrableDomain { topFrame }), WTFMove(completionHandler)); 628 634 } 629 635 … … 635 641 } 636 642 637 sendWithAsyncReply(Messages::NetworkProcess::IsRegisteredAsSubresourceUnder(sessionID, subresource, topFrame), WTFMove(completionHandler));643 sendWithAsyncReply(Messages::NetworkProcess::IsRegisteredAsSubresourceUnder(sessionID, RegistrableDomain { subresource }, RegistrableDomain { topFrame }), WTFMove(completionHandler)); 638 644 } 639 645 … … 645 651 } 646 652 647 sendWithAsyncReply(Messages::NetworkProcess::SetSubresourceUniqueRedirectTo(sessionID, subresource, hostNameRedirectedTo), WTFMove(completionHandler));653 sendWithAsyncReply(Messages::NetworkProcess::SetSubresourceUniqueRedirectTo(sessionID, RegistrableDomain { subresource }, RegistrableDomain { hostNameRedirectedTo }), WTFMove(completionHandler)); 648 654 } 649 655 … … 655 661 } 656 662 657 sendWithAsyncReply(Messages::NetworkProcess::SetSubresourceUniqueRedirectFrom(sessionID, subresource, hostNameRedirectedFrom), WTFMove(completionHandler));663 sendWithAsyncReply(Messages::NetworkProcess::SetSubresourceUniqueRedirectFrom(sessionID, RegistrableDomain { subresource }, RegistrableDomain { hostNameRedirectedFrom }), WTFMove(completionHandler)); 658 664 } 659 665 … … 665 671 } 666 672 667 sendWithAsyncReply(Messages::NetworkProcess::SetTopFrameUniqueRedirectTo(sessionID, topFrameHostName, hostNameRedirectedTo), WTFMove(completionHandler));673 sendWithAsyncReply(Messages::NetworkProcess::SetTopFrameUniqueRedirectTo(sessionID, RegistrableDomain { topFrameHostName }, RegistrableDomain { hostNameRedirectedTo }), WTFMove(completionHandler)); 668 674 } 669 675 … … 675 681 } 676 682 677 sendWithAsyncReply(Messages::NetworkProcess::SetTopFrameUniqueRedirectFrom(sessionID, topFrameHostName, hostNameRedirectedFrom), WTFMove(completionHandler));683 sendWithAsyncReply(Messages::NetworkProcess::SetTopFrameUniqueRedirectFrom(sessionID, RegistrableDomain { topFrameHostName }, RegistrableDomain { hostNameRedirectedFrom }), WTFMove(completionHandler)); 678 684 } 679 685 … … 685 691 } 686 692 687 sendWithAsyncReply(Messages::NetworkProcess::IsGrandfathered(sessionID, resourceDomain), WTFMove(completionHandler));693 sendWithAsyncReply(Messages::NetworkProcess::IsGrandfathered(sessionID, RegistrableDomain { resourceDomain }), WTFMove(completionHandler)); 688 694 } 689 695 … … 695 701 } 696 702 697 sendWithAsyncReply(Messages::NetworkProcess::SetGrandfathered(sessionID, resourceDomain, isGrandfathered), WTFMove(completionHandler));703 sendWithAsyncReply(Messages::NetworkProcess::SetGrandfathered(sessionID, RegistrableDomain { resourceDomain }, isGrandfathered), WTFMove(completionHandler)); 698 704 } 699 705 … … 705 711 } 706 712 707 sendWithAsyncReply(Messages::NetworkProcess::HasStorageAccessForFrame(sessionID, resourceDomain, firstPartyDomain, frameID, pageID), WTFMove(completionHandler));713 sendWithAsyncReply(Messages::NetworkProcess::HasStorageAccessForFrame(sessionID, RegistrableDomain { resourceDomain }, RegistrableDomain { firstPartyDomain }, frameID, pageID), WTFMove(completionHandler)); 708 714 } 709 715 … … 715 721 } 716 722 717 sendWithAsyncReply(Messages::NetworkProcess::HasStorageAccess(sessionID, resourceDomain, firstPartyDomain, frameID, pageID), WTFMove(completionHandler));723 sendWithAsyncReply(Messages::NetworkProcess::HasStorageAccess(sessionID, RegistrableDomain { resourceDomain }, RegistrableDomain { firstPartyDomain }, frameID, pageID), WTFMove(completionHandler)); 718 724 } 719 725 … … 725 731 } 726 732 727 sendWithAsyncReply(Messages::NetworkProcess::RequestStorageAccess(sessionID, resourceDomain, firstPartyDomain, frameID, pageID, promptEnabled), WTFMove(completionHandler));733 sendWithAsyncReply(Messages::NetworkProcess::RequestStorageAccess(sessionID, RegistrableDomain { resourceDomain }, RegistrableDomain { firstPartyDomain }, frameID, pageID, promptEnabled), WTFMove(completionHandler)); 728 734 } 729 735 … … 746 752 } 747 753 748 sendWithAsyncReply(Messages::NetworkProcess::GrantStorageAccess(sessionID, resourceDomain, firstPartyDomain, frameID.value(), pageID, userWasPrompted), WTFMove(completionHandler)); 754 // FIXME: We should not accept an optional frame ID since we call frameID.value() unconditionally. 755 if (!frameID) { 756 completionHandler(false); 757 return; 758 } 759 760 sendWithAsyncReply(Messages::NetworkProcess::GrantStorageAccess(sessionID, RegistrableDomain { resourceDomain }, RegistrableDomain { firstPartyDomain }, frameID.value(), pageID, userWasPrompted), WTFMove(completionHandler)); 749 761 } 750 762 … … 900 912 } 901 913 902 void NetworkProcessProxy::notifyWebsiteDataDeletionFor TopPrivatelyOwnedDomainsFinished()903 { 904 WebProcessProxy::notifyWebsiteDataDeletionFor TopPrivatelyOwnedDomainsFinished();905 } 906 907 void NetworkProcessProxy::notifyWebsiteDataScanFor TopPrivatelyControlledDomainsFinished()908 { 909 WebProcessProxy::notifyWebsiteDataScanFor TopPrivatelyControlledDomainsFinished();914 void NetworkProcessProxy::notifyWebsiteDataDeletionForRegistrableDomainsFinished() 915 { 916 WebProcessProxy::notifyWebsiteDataDeletionForRegistrableDomainsFinished(); 917 } 918 919 void NetworkProcessProxy::notifyWebsiteDataScanForRegistrableDomainsFinished() 920 { 921 WebProcessProxy::notifyWebsiteDataScanForRegistrableDomainsFinished(); 910 922 } 911 923 -
trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h
r241451 r242056 190 190 void logTestingEvent(PAL::SessionID, const String& event); 191 191 void notifyResourceLoadStatisticsProcessed(); 192 void notifyWebsiteDataDeletionFor TopPrivatelyOwnedDomainsFinished();193 void notifyWebsiteDataScanFor TopPrivatelyControlledDomainsFinished();192 void notifyWebsiteDataDeletionForRegistrableDomainsFinished(); 193 void notifyWebsiteDataScanForRegistrableDomainsFinished(); 194 194 void notifyResourceLoadStatisticsTelemetryFinished(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins); 195 195 #endif -
trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in
r240676 r242056 44 44 LogTestingEvent(PAL::SessionID sessionID, String event) 45 45 NotifyResourceLoadStatisticsProcessed() 46 NotifyWebsiteDataDeletionFor TopPrivatelyOwnedDomainsFinished()47 NotifyWebsiteDataScanFor TopPrivatelyControlledDomainsFinished()46 NotifyWebsiteDataDeletionForRegistrableDomainsFinished() 47 NotifyWebsiteDataScanForRegistrableDomainsFinished() 48 48 NotifyResourceLoadStatisticsTelemetryFinished(unsigned totalPrevalentResources, unsigned totalPrevalentResourcesWithUserInteraction, unsigned top3SubframeUnderTopFrameOrigins) 49 49 RequestStorageAccessConfirm(uint64_t pageID, uint64_t frameID, String subFrameHost, String topFrameHost) -> (bool userDidGrantAccess) Async -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r242010 r242056 4620 4620 if (targetHost.isEmpty() || mainFrameHost.isEmpty() || targetHost == sourceURL.host()) 4621 4621 return; 4622 4623 auto targetPrimaryDomain = ResourceLoadStatistics::primaryDomain(targetURL); 4624 auto mainFramePrimaryDomain = ResourceLoadStatistics::primaryDomain(pageURL); 4625 auto sourcePrimaryDomain = ResourceLoadStatistics::primaryDomain(sourceURL); 4626 4627 m_process->processPool().sendToNetworkingProcess(Messages::NetworkProcess::LogFrameNavigation(m_websiteDataStore->sessionID(), targetPrimaryDomain, mainFramePrimaryDomain, sourcePrimaryDomain, targetHost.toString(), mainFrameHost.toString(), isRedirect, frame.isMainFrame())); 4622 4623 m_process->processPool().sendToNetworkingProcess(Messages::NetworkProcess::LogFrameNavigation(m_websiteDataStore->sessionID(), RegistrableDomain { targetURL }, RegistrableDomain { pageURL }, RegistrableDomain { sourceURL }, isRedirect, frame.isMainFrame())); 4628 4624 } 4629 4625 #endif … … 8359 8355 void WebPageProxy::requestStorageAccessConfirm(const String& subFrameHost, const String& topFrameHost, uint64_t frameID, CompletionHandler<void(bool)>&& completionHandler) 8360 8356 { 8361 m_uiClient->requestStorageAccessConfirm(*this, m_process->webFrame(frameID), ResourceLoadStatistics::primaryDomain(subFrameHost), ResourceLoadStatistics::primaryDomain(topFrameHost), WTFMove(completionHandler)); 8357 RegistrableDomain subFrameRegistrableDomain { subFrameHost }; 8358 RegistrableDomain topFrameRegistrableDomain { topFrameHost }; 8359 m_uiClient->requestStorageAccessConfirm(*this, m_process->webFrame(frameID), subFrameRegistrableDomain.string(), topFrameRegistrableDomain.string(), WTFMove(completionHandler)); 8362 8360 } 8363 8361 #endif -
trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp
r241868 r242056 320 320 { 321 321 for (auto& page : globalPageMap()) 322 page.value->postMessageToInjectedBundle("WebsiteDataScanFor TopPrivatelyControlledDomainsFinished", nullptr);323 } 324 325 void WebProcessProxy::notifyWebsiteDataScanFor TopPrivatelyControlledDomainsFinished()322 page.value->postMessageToInjectedBundle("WebsiteDataScanForRegistrableDomainsFinished", nullptr); 323 } 324 325 void WebProcessProxy::notifyWebsiteDataScanForRegistrableDomainsFinished() 326 326 { 327 327 for (auto& page : globalPageMap()) 328 page.value->postMessageToInjectedBundle("WebsiteDataScanFor TopPrivatelyControlledDomainsFinished", nullptr);329 } 330 331 void WebProcessProxy::notifyWebsiteDataDeletionFor TopPrivatelyOwnedDomainsFinished()328 page.value->postMessageToInjectedBundle("WebsiteDataScanForRegistrableDomainsFinished", nullptr); 329 } 330 331 void WebProcessProxy::notifyWebsiteDataDeletionForRegistrableDomainsFinished() 332 332 { 333 333 for (auto& page : globalPageMap()) 334 page.value->postMessageToInjectedBundle("WebsiteDataDeletionFor TopPrivatelyOwnedDomainsFinished", nullptr);334 page.value->postMessageToInjectedBundle("WebsiteDataDeletionForRegistrableDomainsFinished", nullptr); 335 335 } 336 336 -
trunk/Source/WebKit/UIProcess/WebProcessProxy.h
r241855 r242056 178 178 static void notifyPageStatisticsTelemetryFinished(API::Object* messageBody); 179 179 180 static void notifyWebsiteDataDeletionFor TopPrivatelyOwnedDomainsFinished();181 static void notifyWebsiteDataScanFor TopPrivatelyControlledDomainsFinished();180 static void notifyWebsiteDataDeletionForRegistrableDomainsFinished(); 181 static void notifyWebsiteDataScanForRegistrableDomainsFinished(); 182 182 #endif 183 183 -
trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.messages.in
r240243 r242056 24 24 25 25 messages -> WebResourceLoadStatisticsStore { 26 RequestStorageAccessUnderOpener( String domainReceivingUserInteraction, uint64_t openerPageID, StringopenerDomain)26 RequestStorageAccessUnderOpener(WebCore::RegistrableDomain domainReceivingUserInteraction, uint64_t openerPageID, WebCore::RegistrableDomain openerDomain) 27 27 ResourceLoadStatisticsUpdated(Vector<WebCore::ResourceLoadStatistics> origins) 28 28 } -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
r241928 r242056 49 49 #include <WebCore/HTMLMediaElement.h> 50 50 #include <WebCore/OriginLock.h> 51 #include <WebCore/RegistrableDomain.h> 51 52 #include <WebCore/SecurityOrigin.h> 52 53 #include <WebCore/SecurityOriginData.h> … … 620 621 } 621 622 622 #if ENABLE(RESOURCE_LOAD_STATISTICS)623 void WebsiteDataStore::fetchDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType> dataTypes, OptionSet<WebsiteDataFetchOption> fetchOptions, const Vector<String>& topPrivatelyControlledDomains, Function<void(Vector<WebsiteDataRecord>&&, HashSet<String>&&)>&& completionHandler)624 {625 fetchDataAndApply(dataTypes, fetchOptions, m_queue.copyRef(), [topPrivatelyControlledDomains = crossThreadCopy(topPrivatelyControlledDomains), completionHandler = WTFMove(completionHandler)] (auto&& existingDataRecords) mutable {626 ASSERT(!RunLoop::isMain());627 628 Vector<WebsiteDataRecord> matchingDataRecords;629 HashSet<String> domainsWithMatchingDataRecords;630 for (auto&& dataRecord : existingDataRecords) {631 for (auto& topPrivatelyControlledDomain : topPrivatelyControlledDomains) {632 if (dataRecord.matchesTopPrivatelyControlledDomain(topPrivatelyControlledDomain)) {633 matchingDataRecords.append(WTFMove(dataRecord));634 domainsWithMatchingDataRecords.add(topPrivatelyControlledDomain.isolatedCopy());635 break;636 }637 }638 }639 RunLoop::main().dispatch([completionHandler = WTFMove(completionHandler), matchingDataRecords = WTFMove(matchingDataRecords), domainsWithMatchingDataRecords = WTFMove(domainsWithMatchingDataRecords)] () mutable {640 completionHandler(WTFMove(matchingDataRecords), WTFMove(domainsWithMatchingDataRecords));641 });642 });643 }644 #endif645 646 623 static ProcessAccessType computeNetworkProcessAccessTypeForDataRemoval(OptionSet<WebsiteDataType> dataTypes, bool isNonPersistentStore) 647 624 { … … 1300 1277 for (auto& processPool : processPools()) { 1301 1278 if (auto* process = processPool->networkProcess()) { 1302 process->isPrevalentResource(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler));1279 process->isPrevalentResource(m_sessionID, url.host().toString(), WTFMove(completionHandler)); 1303 1280 RELEASE_ASSERT(processPools().size() == 1); 1304 1281 break; … … 1319 1296 1320 1297 for (auto& processPool : processPools()) { 1321 processPool->ensureNetworkProcess().setPrevalentResource(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), [processPool, callbackAggregator = callbackAggregator.copyRef()] { });1298 processPool->ensureNetworkProcess().setPrevalentResource(m_sessionID, url.host().toString(), [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1322 1299 } 1323 1300 } … … 1336 1313 for (auto& processPool : processPools()) { 1337 1314 if (auto* process = processPool->networkProcess()) 1338 process->setPrevalentResourceForDebugMode(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), [processPool, callbackAggregator = callbackAggregator.copyRef()] { });1315 process->setPrevalentResourceForDebugMode(m_sessionID, url.host().toString(), [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1339 1316 } 1340 1317 } … … 1351 1328 for (auto& processPool : processPools()) { 1352 1329 if (auto* process = processPool->networkProcess()) { 1353 process->isVeryPrevalentResource(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler));1330 process->isVeryPrevalentResource(m_sessionID, url.host().toString(), WTFMove(completionHandler)); 1354 1331 ASSERT(processPools().size() == 1); 1355 1332 break; … … 1371 1348 for (auto& processPool : processPools()) { 1372 1349 if (auto* process = processPool->networkProcess()) 1373 process->setVeryPrevalentResource(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), [processPool, callbackAggregator = callbackAggregator.copyRef()] { });1350 process->setVeryPrevalentResource(m_sessionID, url.host().toString(), [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1374 1351 } 1375 1352 } … … 1385 1362 } 1386 1363 1387 void WebsiteDataStore::setSubframeUnderTopFrameOrigin(const URL& sub frame, const URL& topFrame, CompletionHandler<void()>&& completionHandler)1388 { 1389 ASSERT(RunLoop::isMain()); 1390 1391 if (sub frame.protocolIsAbout() || subframe.isEmpty() || topFrame.protocolIsAbout() || topFrame.isEmpty()) {1364 void WebsiteDataStore::setSubframeUnderTopFrameOrigin(const URL& subFrameURL, const URL& topFrameURL, CompletionHandler<void()>&& completionHandler) 1365 { 1366 ASSERT(RunLoop::isMain()); 1367 1368 if (subFrameURL.protocolIsAbout() || subFrameURL.isEmpty() || topFrameURL.protocolIsAbout() || topFrameURL.isEmpty()) { 1392 1369 completionHandler(); 1393 1370 return; … … 1398 1375 for (auto& processPool : processPools()) { 1399 1376 if (auto* process = processPool->networkProcess()) 1400 process->setSubframeUnderTopFrameOrigin(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(subframe), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), [processPool, callbackAggregator = callbackAggregator.copyRef()] { });1401 } 1402 } 1403 1404 void WebsiteDataStore::isRegisteredAsSubFrameUnder(const URL& subFrame , const URL& topFrame, CompletionHandler<void(bool)>&& completionHandler)1377 process->setSubframeUnderTopFrameOrigin(m_sessionID, subFrameURL.host().toString(), topFrameURL.host().toString(), [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1378 } 1379 } 1380 1381 void WebsiteDataStore::isRegisteredAsSubFrameUnder(const URL& subFrameURL, const URL& topFrameURL, CompletionHandler<void(bool)>&& completionHandler) 1405 1382 { 1406 1383 ASSERT(RunLoop::isMain()); … … 1408 1385 for (auto& processPool : processPools()) { 1409 1386 if (auto* process = processPool->networkProcess()) { 1410 process->isRegisteredAsSubFrameUnder(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(subFrame), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), WTFMove(completionHandler));1387 process->isRegisteredAsSubFrameUnder(m_sessionID, subFrameURL.host().toString(), topFrameURL.host().toString(), WTFMove(completionHandler)); 1411 1388 ASSERT(processPools().size() == 1); 1412 1389 break; … … 1415 1392 } 1416 1393 1417 void WebsiteDataStore::setSubresourceUnderTopFrameOrigin(const URL& subresource , const URL& topFrame, CompletionHandler<void()>&& completionHandler)1418 { 1419 ASSERT(RunLoop::isMain()); 1420 1421 if (subresource .protocolIsAbout() || subresource.isEmpty() || topFrame.protocolIsAbout() || topFrame.isEmpty()) {1394 void WebsiteDataStore::setSubresourceUnderTopFrameOrigin(const URL& subresourceURL, const URL& topFrameURL, CompletionHandler<void()>&& completionHandler) 1395 { 1396 ASSERT(RunLoop::isMain()); 1397 1398 if (subresourceURL.protocolIsAbout() || subresourceURL.isEmpty() || topFrameURL.protocolIsAbout() || topFrameURL.isEmpty()) { 1422 1399 completionHandler(); 1423 1400 return; … … 1428 1405 for (auto& processPool : processPools()) { 1429 1406 if (auto* process = processPool->networkProcess()) 1430 process->setSubresourceUnderTopFrameOrigin(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), [processPool, callbackAggregator = callbackAggregator.copyRef()] { });1431 } 1432 } 1433 1434 void WebsiteDataStore::isRegisteredAsSubresourceUnder(const URL& subresource , const URL& topFrame, CompletionHandler<void(bool)>&& completionHandler)1407 process->setSubresourceUnderTopFrameOrigin(m_sessionID, subresourceURL.host().toString(), topFrameURL.host().toString(), [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1408 } 1409 } 1410 1411 void WebsiteDataStore::isRegisteredAsSubresourceUnder(const URL& subresourceURL, const URL& topFrameURL, CompletionHandler<void(bool)>&& completionHandler) 1435 1412 { 1436 1413 ASSERT(RunLoop::isMain()); … … 1438 1415 for (auto& processPool : processPools()) { 1439 1416 if (auto* process = processPool->networkProcess()) { 1440 process->isRegisteredAsSubresourceUnder(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(topFrame), WTFMove(completionHandler));1417 process->isRegisteredAsSubresourceUnder(m_sessionID, subresourceURL.host().toString(), topFrameURL.host().toString(), WTFMove(completionHandler)); 1441 1418 ASSERT(processPools().size() == 1); 1442 1419 break; … … 1445 1422 } 1446 1423 1447 void WebsiteDataStore::setSubresourceUniqueRedirectTo(const URL& subresource , const URL& hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler)1448 { 1449 ASSERT(RunLoop::isMain()); 1450 1451 if (subresource .protocolIsAbout() || subresource.isEmpty() || hostNameRedirectedTo.protocolIsAbout() || hostNameRedirectedTo.isEmpty()) {1424 void WebsiteDataStore::setSubresourceUniqueRedirectTo(const URL& subresourceURL, const URL& urlRedirectedTo, CompletionHandler<void()>&& completionHandler) 1425 { 1426 ASSERT(RunLoop::isMain()); 1427 1428 if (subresourceURL.protocolIsAbout() || subresourceURL.isEmpty() || urlRedirectedTo.protocolIsAbout() || urlRedirectedTo.isEmpty()) { 1452 1429 completionHandler(); 1453 1430 return; … … 1458 1435 for (auto& processPool : processPools()) { 1459 1436 if (auto* process = processPool->networkProcess()) 1460 process->setSubresourceUniqueRedirectTo(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedTo), [processPool, callbackAggregator = callbackAggregator.copyRef()] { });1461 } 1462 } 1463 1464 void WebsiteDataStore::setSubresourceUniqueRedirectFrom(const URL& subresource , const URL& hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler)1465 { 1466 ASSERT(RunLoop::isMain()); 1467 1468 if (subresource .protocolIsAbout() || subresource.isEmpty() || hostNameRedirectedFrom.protocolIsAbout() || hostNameRedirectedFrom.isEmpty()) {1437 process->setSubresourceUniqueRedirectTo(m_sessionID, subresourceURL.host().toString(), urlRedirectedTo.host().toString(), [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1438 } 1439 } 1440 1441 void WebsiteDataStore::setSubresourceUniqueRedirectFrom(const URL& subresourceURL, const URL& urlRedirectedFrom, CompletionHandler<void()>&& completionHandler) 1442 { 1443 ASSERT(RunLoop::isMain()); 1444 1445 if (subresourceURL.protocolIsAbout() || subresourceURL.isEmpty() || urlRedirectedFrom.protocolIsAbout() || urlRedirectedFrom.isEmpty()) { 1469 1446 completionHandler(); 1470 1447 return; … … 1475 1452 for (auto& processPool : processPools()) { 1476 1453 if (auto* process = processPool->networkProcess()) 1477 process->setSubresourceUniqueRedirectFrom(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(subresource), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedFrom), [processPool, callbackAggregator = callbackAggregator.copyRef()] { });1478 } 1479 } 1480 1481 void WebsiteDataStore::setTopFrameUniqueRedirectTo(const URL& topFrame HostName, const URL& hostNameRedirectedTo, CompletionHandler<void()>&& completionHandler)1482 { 1483 ASSERT(RunLoop::isMain()); 1484 1485 if (topFrame HostName.protocolIsAbout() || topFrameHostName.isEmpty() || hostNameRedirectedTo.protocolIsAbout() || hostNameRedirectedTo.isEmpty()) {1454 process->setSubresourceUniqueRedirectFrom(m_sessionID, subresourceURL.host().toString(), urlRedirectedFrom.host().toString(), [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1455 } 1456 } 1457 1458 void WebsiteDataStore::setTopFrameUniqueRedirectTo(const URL& topFrameURL, const URL& urlRedirectedTo, CompletionHandler<void()>&& completionHandler) 1459 { 1460 ASSERT(RunLoop::isMain()); 1461 1462 if (topFrameURL.protocolIsAbout() || topFrameURL.isEmpty() || urlRedirectedTo.protocolIsAbout() || urlRedirectedTo.isEmpty()) { 1486 1463 completionHandler(); 1487 1464 return; … … 1492 1469 for (auto& processPool : processPools()) { 1493 1470 if (auto* process = processPool->networkProcess()) 1494 process->setTopFrameUniqueRedirectTo(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(topFrameHostName), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedTo), [processPool, callbackAggregator = callbackAggregator.copyRef()] { });1495 } 1496 } 1497 1498 void WebsiteDataStore::setTopFrameUniqueRedirectFrom(const URL& topFrame HostName, const URL& hostNameRedirectedFrom, CompletionHandler<void()>&& completionHandler)1499 { 1500 ASSERT(RunLoop::isMain()); 1501 1502 if (topFrame HostName.protocolIsAbout() || topFrameHostName.isEmpty() || hostNameRedirectedFrom.protocolIsAbout() || hostNameRedirectedFrom.isEmpty()) {1471 process->setTopFrameUniqueRedirectTo(m_sessionID, topFrameURL.host().toString(), urlRedirectedTo.host().toString(), [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1472 } 1473 } 1474 1475 void WebsiteDataStore::setTopFrameUniqueRedirectFrom(const URL& topFrameURL, const URL& urlRedirectedFrom, CompletionHandler<void()>&& completionHandler) 1476 { 1477 ASSERT(RunLoop::isMain()); 1478 1479 if (topFrameURL.protocolIsAbout() || topFrameURL.isEmpty() || urlRedirectedFrom.protocolIsAbout() || urlRedirectedFrom.isEmpty()) { 1503 1480 completionHandler(); 1504 1481 return; … … 1509 1486 for (auto& processPool : processPools()) { 1510 1487 if (auto* process = processPool->networkProcess()) 1511 process->setTopFrameUniqueRedirectFrom(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(topFrameHostName), WebCore::ResourceLoadStatistics::primaryDomain(hostNameRedirectedFrom), [processPool, callbackAggregator = callbackAggregator.copyRef()] { });1512 } 1513 } 1514 1515 void WebsiteDataStore::isRegisteredAsRedirectingTo(const URL& hostRedirectedFrom, const URL& hostRedirectedTo, CompletionHandler<void(bool)>&& completionHandler)1488 process->setTopFrameUniqueRedirectFrom(m_sessionID, topFrameURL.host().toString(), urlRedirectedFrom.host().toString(), [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1489 } 1490 } 1491 1492 void WebsiteDataStore::isRegisteredAsRedirectingTo(const URL& urlRedirectedFrom, const URL& urlRedirectedTo, CompletionHandler<void(bool)>&& completionHandler) 1516 1493 { 1517 1494 ASSERT(RunLoop::isMain()); … … 1519 1496 for (auto& processPool : processPools()) { 1520 1497 if (auto* process = processPool->networkProcess()) { 1521 process->isRegisteredAsRedirectingTo(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(hostRedirectedFrom), WebCore::ResourceLoadStatistics::primaryDomain(hostRedirectedTo), WTFMove(completionHandler));1498 process->isRegisteredAsRedirectingTo(m_sessionID, urlRedirectedFrom.host().toString(), urlRedirectedTo.host().toString(), WTFMove(completionHandler)); 1522 1499 ASSERT(processPools().size() == 1); 1523 1500 break; … … 1537 1514 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 1538 1515 1539 const auto& primaryDomain = WebCore::ResourceLoadStatistics::primaryDomain(url);1540 1516 for (auto& processPool : processPools()) { 1541 1517 if (auto* process = processPool->networkProcess()) 1542 process->clearPrevalentResource(m_sessionID, primaryDomain, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });1518 process->clearPrevalentResource(m_sessionID, url.host().toString(), [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1543 1519 } 1544 1520 } … … 1621 1597 auto callbackAggregator = CallbackAggregator::create(WTFMove(completionHandler)); 1622 1598 1623 const auto& primaryDomain = WebCore::ResourceLoadStatistics::primaryDomain(url);1624 1599 for (auto& processPool : processPools()) { 1625 1600 if (auto* process = processPool->networkProcess()) 1626 process->setLastSeen(m_sessionID, primaryDomain, seconds, [processPool, callbackAggregator = callbackAggregator.copyRef()] { });1601 process->setLastSeen(m_sessionID, url.host().toString(), seconds, [processPool, callbackAggregator = callbackAggregator.copyRef()] { }); 1627 1602 } 1628 1603 } … … 1656 1631 } 1657 1632 1658 void WebsiteDataStore::hasStorageAccess( String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler)1633 void WebsiteDataStore::hasStorageAccess(const String& subFrameHost, const String& topFrameHost, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&& completionHandler) 1659 1634 { 1660 1635 if (!resourceLoadStatisticsEnabled()) { … … 1670 1645 1671 1646 if (auto networkProcess = webPage->process().processPool().networkProcess()) 1672 networkProcess->hasStorageAccess(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(subFrameHost), WebCore::ResourceLoadStatistics::primaryDomain(topFrameHost), frameID, pageID, WTFMove(completionHandler));1673 } 1674 1675 void WebsiteDataStore::requestStorageAccess( String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&& completionHandler)1647 networkProcess->hasStorageAccess(m_sessionID, subFrameHost, topFrameHost, frameID, pageID, WTFMove(completionHandler)); 1648 } 1649 1650 void WebsiteDataStore::requestStorageAccess(const String& subFrameHost, const String& topFrameHost, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&& completionHandler) 1676 1651 { 1677 1652 if (!resourceLoadStatisticsEnabled()) { … … 1687 1662 1688 1663 if (auto networkProcess = webPage->process().processPool().networkProcess()) 1689 networkProcess->requestStorageAccess(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(subFrameHost), WebCore::ResourceLoadStatistics::primaryDomain(topFrameHost), frameID, pageID, promptEnabled, WTFMove(completionHandler));1664 networkProcess->requestStorageAccess(m_sessionID, subFrameHost, topFrameHost, frameID, pageID, promptEnabled, WTFMove(completionHandler)); 1690 1665 } 1691 1666 … … 1704 1679 1705 1680 if (auto networkProcess = webPage->process().processPool().networkProcess()) 1706 networkProcess->grantStorageAccess(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(subFrameHost), WebCore::ResourceLoadStatistics::primaryDomain(topFrameHost), frameID, pageID, userWasPrompted, WTFMove(completionHandler));1681 networkProcess->grantStorageAccess(m_sessionID, subFrameHost, topFrameHost, frameID, pageID, userWasPrompted, WTFMove(completionHandler)); 1707 1682 } 1708 1683 … … 1728 1703 for (auto& processPool : processPools()) { 1729 1704 if (auto* process = processPool->networkProcess()) 1730 process->logUserInteraction(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), [callbackAggregator = callbackAggregator.copyRef()] { });1705 process->logUserInteraction(m_sessionID, url.host().toString(), [callbackAggregator = callbackAggregator.copyRef()] { }); 1731 1706 } 1732 1707 } … … 1743 1718 for (auto& processPool : processPools()) { 1744 1719 if (auto* process = processPool->networkProcess()) { 1745 process->hasHadUserInteraction(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), WTFMove(completionHandler));1720 process->hasHadUserInteraction(m_sessionID, url.host().toString(), WTFMove(completionHandler)); 1746 1721 ASSERT(processPools().size() == 1); 1747 1722 break; … … 1763 1738 for (auto& processPool : processPools()) { 1764 1739 if (auto* process = processPool->networkProcess()) 1765 process->clearUserInteraction(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), [callbackAggregator = callbackAggregator.copyRef()] { });1740 process->clearUserInteraction(m_sessionID, url.host().toString(), [callbackAggregator = callbackAggregator.copyRef()] { }); 1766 1741 } 1767 1742 } … … 1780 1755 for (auto& processPool : processPools()) { 1781 1756 if (auto* process = processPool->networkProcess()) 1782 process->setGrandfathered(m_sessionID, WebCore::ResourceLoadStatistics::primaryDomain(url), isGrandfathered, [callbackAggregator = callbackAggregator.copyRef()] { });1757 process->setGrandfathered(m_sessionID, url.host().toString(), isGrandfathered, [callbackAggregator = callbackAggregator.copyRef()] { }); 1783 1758 } 1784 1759 } -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
r241826 r242056 126 126 127 127 #if ENABLE(RESOURCE_LOAD_STATISTICS) 128 void fetchDataForTopPrivatelyControlledDomains(OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, const Vector<String>& topPrivatelyControlledDomains, Function<void(Vector<WebsiteDataRecord>&&, HashSet<String>&&)>&& completionHandler);129 130 128 void clearPrevalentResource(const URL&, CompletionHandler<void()>&&); 131 129 void clearUserInteraction(const URL&, CompletionHandler<void()>&&); … … 166 164 void setStatisticsTestingCallback(WTF::Function<void(const String&)>&& callback) { m_statisticsTestingCallback = WTFMove(callback); } 167 165 void setVeryPrevalentResource(const URL&, CompletionHandler<void()>&&); 168 void hasStorageAccess( String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&&);169 void requestStorageAccess( String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&&);166 void hasStorageAccess(const String& subFrameHost, const String& topFrameHost, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool)>&&); 167 void requestStorageAccess(const String& subFrameHost, const String& topFrameHost, uint64_t frameID, uint64_t pageID, bool promptEnabled, CompletionHandler<void(StorageAccessStatus)>&&); 170 168 void grantStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, uint64_t pageID, bool userWasPrompted, CompletionHandler<void(bool)>&&); 171 169 void setSubframeUnderTopFrameOrigin(const URL& subframe, const URL& topFrame); -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r241988 r242056 195 195 #include <WebCore/PromisedAttachmentInfo.h> 196 196 #include <WebCore/Range.h> 197 #include <WebCore/RegistrableDomain.h> 197 198 #include <WebCore/RemoteDOMWindow.h> 198 199 #include <WebCore/RemoteFrame.h> … … 6403 6404 void WebPage::hasStorageAccess(String&& subFrameHost, String&& topFrameHost, uint64_t frameID, CompletionHandler<void(bool)>&& completionHandler) 6404 6405 { 6405 WebProcess::singleton().ensureNetworkProcessConnection().connection().sendWithAsyncReply(Messages::NetworkConnectionToWebProcess::HasStorageAccess(sessionID(), WebCore::ResourceLoadStatistics::primaryDomain(subFrameHost), WebCore::ResourceLoadStatistics::primaryDomain(topFrameHost), frameID, m_pageID), WTFMove(completionHandler));6406 WebProcess::singleton().ensureNetworkProcessConnection().connection().sendWithAsyncReply(Messages::NetworkConnectionToWebProcess::HasStorageAccess(sessionID(), RegistrableDomain { subFrameHost }, RegistrableDomain { topFrameHost }, frameID, m_pageID), WTFMove(completionHandler)); 6406 6407 } 6407 6408 … … 6409 6410 { 6410 6411 bool promptEnabled = RuntimeEnabledFeatures::sharedFeatures().storageAccessPromptsEnabled(); 6411 WebProcess::singleton().ensureNetworkProcessConnection().connection().sendWithAsyncReply(Messages::NetworkConnectionToWebProcess::RequestStorageAccess(sessionID(), WebCore::ResourceLoadStatistics::primaryDomain(subFrameHost), WebCore::ResourceLoadStatistics::primaryDomain(topFrameHost), frameID, m_pageID, promptEnabled), WTFMove(completionHandler));6412 WebProcess::singleton().ensureNetworkProcessConnection().connection().sendWithAsyncReply(Messages::NetworkConnectionToWebProcess::RequestStorageAccess(sessionID(), RegistrableDomain { subFrameHost }, RegistrableDomain { topFrameHost }, frameID, m_pageID, promptEnabled), WTFMove(completionHandler)); 6412 6413 } 6413 6414 #endif -
trunk/Source/WebKit/WebProcess/WebProcess.cpp
r241556 r242056 107 107 #include <WebCore/PlatformMediaSessionManager.h> 108 108 #include <WebCore/ProcessWarming.h> 109 #include <WebCore/RegistrableDomain.h> 109 110 #include <WebCore/ResourceLoadObserver.h> 110 111 #include <WebCore/ResourceLoadStatistics.h> … … 212 213 }); 213 214 214 ResourceLoadObserver::shared().setRequestStorageAccessUnderOpenerCallback([this] (const String& domainInNeedOfStorageAccess, uint64_t openerPageID, const String& openerDomain) {215 ResourceLoadObserver::shared().setRequestStorageAccessUnderOpenerCallback([this] (const RegistrableDomain& domainInNeedOfStorageAccess, uint64_t openerPageID, const RegistrableDomain& openerDomain) { 215 216 parentProcessConnection()->send(Messages::WebResourceLoadStatisticsStore::RequestStorageAccessUnderOpener(domainInNeedOfStorageAccess, openerPageID, openerDomain), 0); 216 217 }); … … 402 403 403 404 #if ENABLE(RESOURCE_LOAD_STATISTICS) 404 ResourceLoadObserver::shared().setLogUserInteractionNotificationCallback([this] (PAL::SessionID sessionID, const String& topLevelOrigin) {405 m_networkProcessConnection->connection().send(Messages::NetworkConnectionToWebProcess::LogUserInteraction(sessionID, topLevelOrigin), 0);405 ResourceLoadObserver::shared().setLogUserInteractionNotificationCallback([this] (PAL::SessionID sessionID, const RegistrableDomain& domain) { 406 m_networkProcessConnection->connection().send(Messages::NetworkConnectionToWebProcess::LogUserInteraction(sessionID, domain), 0); 406 407 }); 407 408 408 ResourceLoadObserver::shared().setLogWebSocketLoadingNotificationCallback([this] (PAL::SessionID sessionID, const String& targetPrimaryDomain, const String& mainFramePrimaryDomain, WallTime lastSeen) {409 m_networkProcessConnection->connection().send(Messages::NetworkConnectionToWebProcess::LogWebSocketLoading(sessionID, target PrimaryDomain, mainFramePrimaryDomain, lastSeen), 0);409 ResourceLoadObserver::shared().setLogWebSocketLoadingNotificationCallback([this] (PAL::SessionID sessionID, const RegistrableDomain& targetDomain, const RegistrableDomain& topFrameDomain, WallTime lastSeen) { 410 m_networkProcessConnection->connection().send(Messages::NetworkConnectionToWebProcess::LogWebSocketLoading(sessionID, targetDomain, topFrameDomain, lastSeen), 0); 410 411 }); 411 412 412 ResourceLoadObserver::shared().setLogSubresourceLoadingNotificationCallback([this] (PAL::SessionID sessionID, const String& targetPrimaryDomain, const String& mainFramePrimaryDomain, WallTime lastSeen) {413 m_networkProcessConnection->connection().send(Messages::NetworkConnectionToWebProcess::LogSubresourceLoading(sessionID, target PrimaryDomain, mainFramePrimaryDomain, lastSeen), 0);413 ResourceLoadObserver::shared().setLogSubresourceLoadingNotificationCallback([this] (PAL::SessionID sessionID, const RegistrableDomain& targetDomain, const RegistrableDomain& topFrameDomain, WallTime lastSeen) { 414 m_networkProcessConnection->connection().send(Messages::NetworkConnectionToWebProcess::LogSubresourceLoading(sessionID, targetDomain, topFrameDomain, lastSeen), 0); 414 415 }); 415 416 416 ResourceLoadObserver::shared().setLogSubresourceRedirectNotificationCallback([this] (PAL::SessionID sessionID, const String& sourcePrimaryDomain, const String& targetPrimaryDomain) {417 m_networkProcessConnection->connection().send(Messages::NetworkConnectionToWebProcess::LogSubresourceRedirect(sessionID, source PrimaryDomain, targetPrimaryDomain), 0);417 ResourceLoadObserver::shared().setLogSubresourceRedirectNotificationCallback([this] (PAL::SessionID sessionID, const RegistrableDomain& sourceDomain, const RegistrableDomain& targetDomain) { 418 m_networkProcessConnection->connection().send(Messages::NetworkConnectionToWebProcess::LogSubresourceRedirect(sessionID, sourceDomain, targetDomain), 0); 418 419 }); 419 420 #endif -
trunk/Tools/ChangeLog
r242055 r242056 1 2019-02-25 John Wilander <wilander@apple.com> 2 3 Introduce and adopt new class RegistrableDomain for eTLD+1 4 https://bugs.webkit.org/show_bug.cgi?id=194791 5 <rdar://problem/48179240> 6 7 Reviewed by Alex Christensen, Fujii Hironori, and Brent Fulgham. 8 9 This patch adds an API test and replaces two instances of 10 "TopPrivatelyOwnedDomains" with "RegistrableDomains" in message names. 11 12 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 13 * TestWebKitAPI/Tests/WebCore/AdClickAttribution.cpp: 14 (TestWebKitAPI::TEST): 15 Changed two strings to make sure the registrable domains are still considered 16 invalid and pass the test. 17 * TestWebKitAPI/Tests/WebCore/RegistrableDomain.cpp: Added. 18 (TestWebKitAPI::TEST): 19 * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp: 20 (WTR::InjectedBundle::didReceiveMessageToPage): 21 1 22 2019-02-25 Adrian Perez de Castro <aperez@igalia.com> 2 23 -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r241899 r242056 349 349 6B0A07F721FA9C2B00D57391 /* AdClickAttribution.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B0A07F621FA9C2B00D57391 /* AdClickAttribution.cpp */; }; 350 350 6B306106218A372900F5A802 /* ClosingWebView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6B306105218A372900F5A802 /* ClosingWebView.mm */; }; 351 6B4E861C2220A5520022F389 /* RegistrableDomain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B4E861B2220A5520022F389 /* RegistrableDomain.cpp */; }; 351 352 6B9ABE122086952F00D75DE6 /* HTTPParsers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6B9ABE112086952F00D75DE6 /* HTTPParsers.cpp */; }; 352 353 6BFD294C1D5E6C1D008EC968 /* HashCountedSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A38D7E51C752D5F004F157D /* HashCountedSet.cpp */; }; … … 1741 1742 6B0A07F621FA9C2B00D57391 /* AdClickAttribution.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AdClickAttribution.cpp; sourceTree = "<group>"; }; 1742 1743 6B306105218A372900F5A802 /* ClosingWebView.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ClosingWebView.mm; sourceTree = "<group>"; }; 1744 6B4E861B2220A5520022F389 /* RegistrableDomain.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RegistrableDomain.cpp; sourceTree = "<group>"; }; 1743 1745 6B9ABE112086952F00D75DE6 /* HTTPParsers.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = HTTPParsers.cpp; sourceTree = "<group>"; }; 1744 1746 725C3EF2220584BA007C36FC /* AdditionalSupportedImageTypes.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = AdditionalSupportedImageTypes.html; sourceTree = "<group>"; }; … … 2740 2742 AA96CAB421C7DB4200FD2F97 /* ParsedContentType.cpp */, 2741 2743 041A1E33216FFDBC00789E0A /* PublicSuffix.cpp */, 2744 6B4E861B2220A5520022F389 /* RegistrableDomain.cpp */, 2742 2745 F418BE141F71B7DC001970E6 /* RoundedRectTests.cpp */, 2743 2746 CDCFA7A91E45122F00C2433D /* SampleMap.cpp */, … … 4221 4224 041A1E34216FFDBC00789E0A /* PublicSuffix.cpp in Sources */, 4222 4225 7C83E0C21D0A653500FEBCF3 /* QuickLook.mm in Sources */, 4226 6B4E861C2220A5520022F389 /* RegistrableDomain.cpp in Sources */, 4223 4227 7CCE7F0D1A411AE600447C4C /* ReloadPageAfterCrash.cpp in Sources */, 4224 4228 7C83E0C31D0A653A00FEBCF3 /* RemoteObjectRegistry.mm in Sources */, -
trunk/Tools/TestWebKitAPI/Tests/WebCore/AdClickAttribution.cpp
r240911 r242056 101 101 TEST(AdClickAttribution, InvalidSourceHost) 102 102 { 103 AdClickAttribution attribution(AdClickAttribution::Campaign(max6BitValue), AdClickAttribution::Source(" webkitorg"), AdClickAttribution::Destination("example.com"));103 AdClickAttribution attribution(AdClickAttribution::Campaign(max6BitValue), AdClickAttribution::Source(""), AdClickAttribution::Destination("example.com")); 104 104 attribution.setConversion(AdClickAttribution::Conversion(max6BitValue, AdClickAttribution::Priority(max6BitValue))); 105 105 … … 113 113 TEST(AdClickAttribution, InvalidDestinationHost) 114 114 { 115 AdClickAttribution attribution(AdClickAttribution::Campaign(max6BitValue + 1), AdClickAttribution::Source("webkit.org"), AdClickAttribution::Destination(" examplecom"));115 AdClickAttribution attribution(AdClickAttribution::Campaign(max6BitValue + 1), AdClickAttribution::Source("webkit.org"), AdClickAttribution::Destination("")); 116 116 attribution.setConversion(AdClickAttribution::Conversion(max6BitValue, AdClickAttribution::Priority(max6BitValue))); 117 117 -
trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
r239871 r242056 417 417 } 418 418 419 if (WKStringIsEqualToUTF8CString(messageName, "WebsiteDataDeletionFor TopPrivatelyOwnedDomainsFinished")) {419 if (WKStringIsEqualToUTF8CString(messageName, "WebsiteDataDeletionForRegistrableDomainsFinished")) { 420 420 m_testRunner->statisticsDidModifyDataRecordsCallback(); 421 421 return; 422 422 } 423 423 424 if (WKStringIsEqualToUTF8CString(messageName, "WebsiteDataScanFor TopPrivatelyControlledDomainsFinished")) {424 if (WKStringIsEqualToUTF8CString(messageName, "WebsiteDataScanForRegistrableDomainsFinished")) { 425 425 m_testRunner->statisticsDidScanDataRecordsCallback(); 426 426 return;
Note:
See TracChangeset
for help on using the changeset viewer.