Changeset 228416 in webkit
- Timestamp:
- Feb 12, 2018 10:08:18 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r228403 r228416 1 2018-02-12 John Wilander <wilander@apple.com> 2 3 Resource Load Statistics: Classify resources as prevalent based on redirects to other prevalent resources 4 https://bugs.webkit.org/show_bug.cgi?id=182664 5 <rdar://problem/37372572> 6 7 Reviewed by Brent Fulgham. 8 9 * http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-redirect-collusion-expected.txt: Added. 10 * http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-redirect-collusion.html: Added. 11 * http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-redirect-collusion-expected.txt: Added. 12 * http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-redirect-collusion.html: Added. 13 * http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-unique-redirects-to-expected.txt: Added. 14 * http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-unique-redirects-to.html: Added. 15 * platform/wk2/TestExpectations: 16 New tests added as [ Pass ]. 17 1 18 2018-02-12 Matt Lewis <jlewis3@apple.com> 2 19 -
trunk/LayoutTests/platform/wk2/TestExpectations
r228329 r228416 690 690 http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html [ Pass ] 691 691 http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html [ Pass ] 692 http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-redirect-collusion.html [ Pass ] 693 http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-redirect-collusion.html [ Pass ] 694 http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-unique-redirects-to.html [ Pass ] 692 695 webkit.org/b/181223 http/tests/resourceLoadStatistics/clear-in-memory-and-persistent-store.html [ Skip ] 693 696 http/tests/resourceLoadStatistics/grandfathering.html [ Pass ] -
trunk/Source/WebCore/ChangeLog
r228414 r228416 1 2018-02-12 John Wilander <wilander@apple.com> 2 3 Resource Load Statistics: Classify resources as prevalent based on redirects to other prevalent resources 4 https://bugs.webkit.org/show_bug.cgi?id=182664 5 <rdar://problem/37372572> 6 7 Reviewed by Brent Fulgham. 8 9 Tests: http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-redirect-collusion.html 10 http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-redirect-collusion.html 11 http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-unique-redirects-to.html 12 13 * loader/ResourceLoadObserver.cpp: 14 (WebCore::ResourceLoadObserver::logFrameNavigation): 15 We now collect statistics on top frame navigational redirects too, both to and from. 16 (WebCore::ResourceLoadObserver::logSubresourceLoading): 17 We now collect statistics on redirects from in addition to the existing redirects to. 18 * loader/ResourceLoadStatistics.cpp: 19 (WebCore::ResourceLoadStatistics::encode const): 20 (WebCore::ResourceLoadStatistics::decode): 21 (WebCore::ResourceLoadStatistics::toString const): 22 (WebCore::ResourceLoadStatistics::merge): 23 * loader/ResourceLoadStatistics.h: 24 Three new fields: 25 - topFrameUniqueRedirectsTo 26 - topFrameUniqueRedirectsFrom 27 - subresourceUniqueRedirectsFrom 28 1 29 2018-02-12 Zalan Bujtas <zalan@apple.com> 2 30 -
trunk/Source/WebCore/loader/ResourceLoadObserver.cpp
r227790 r228416 139 139 ASSERT(topFrame.page()); 140 140 141 if (frame.isMainFrame())142 return;143 144 141 auto* page = topFrame.page(); 145 142 if (!shouldLog(page)) … … 178 175 if (isRedirect 179 176 && !areDomainsAssociated(page, sourcePrimaryDomain, targetPrimaryDomain)) { 180 auto& redirectingOriginStatistics = ensureResourceStatisticsForPrimaryDomain(sourcePrimaryDomain); 181 if (redirectingOriginStatistics.subresourceUniqueRedirectsTo.add(targetPrimaryDomain).isNewEntry) 177 bool isNewRedirectToEntry = false; 178 bool isNewRedirectFromEntry = false; 179 if (frame.isMainFrame()) { 180 auto& redirectingOriginStatistics = ensureResourceStatisticsForPrimaryDomain(sourcePrimaryDomain); 181 isNewRedirectToEntry = redirectingOriginStatistics.topFrameUniqueRedirectsTo.add(targetPrimaryDomain).isNewEntry; 182 auto& targetStatistics = ensureResourceStatisticsForPrimaryDomain(targetPrimaryDomain); 183 isNewRedirectFromEntry = targetStatistics.topFrameUniqueRedirectsFrom.add(sourcePrimaryDomain).isNewEntry; 184 } else { 185 auto& redirectingOriginStatistics = ensureResourceStatisticsForPrimaryDomain(sourcePrimaryDomain); 186 isNewRedirectToEntry = redirectingOriginStatistics.subresourceUniqueRedirectsTo.add(targetPrimaryDomain).isNewEntry; 187 auto& targetStatistics = ensureResourceStatisticsForPrimaryDomain(targetPrimaryDomain); 188 isNewRedirectFromEntry = targetStatistics.subresourceUniqueRedirectsFrom.add(sourcePrimaryDomain).isNewEntry; 189 } 190 191 if (isNewRedirectToEntry || isNewRedirectFromEntry) 182 192 shouldCallNotificationCallback = true; 183 193 } … … 235 245 if (isRedirect) { 236 246 auto& redirectingOriginStatistics = ensureResourceStatisticsForPrimaryDomain(sourcePrimaryDomain); 237 if (redirectingOriginStatistics.subresourceUniqueRedirectsTo.add(targetPrimaryDomain).isNewEntry) 247 bool isNewRedirectToEntry = redirectingOriginStatistics.subresourceUniqueRedirectsTo.add(targetPrimaryDomain).isNewEntry; 248 auto& targetStatistics = ensureResourceStatisticsForPrimaryDomain(targetPrimaryDomain); 249 bool isNewRedirectFromEntry = targetStatistics.subresourceUniqueRedirectsFrom.add(sourcePrimaryDomain).isNewEntry; 250 251 if (isNewRedirectToEntry || isNewRedirectFromEntry) 238 252 shouldCallNotificationCallback = true; 239 253 } -
trunk/Source/WebCore/loader/ResourceLoadStatistics.cpp
r227755 r228416 71 71 encodeHashSet(encoder, "storageAccessUnderTopFrameOrigins", storageAccessUnderTopFrameOrigins); 72 72 73 // Top frame stats 74 encodeHashCountedSet(encoder, "topFrameUniqueRedirectsTo", topFrameUniqueRedirectsTo); 75 encodeHashCountedSet(encoder, "topFrameUniqueRedirectsFrom", topFrameUniqueRedirectsFrom); 76 73 77 // Subframe stats 74 78 encodeHashCountedSet(encoder, "subframeUnderTopFrameOrigins", subframeUnderTopFrameOrigins); … … 77 81 encodeHashCountedSet(encoder, "subresourceUnderTopFrameOrigins", subresourceUnderTopFrameOrigins); 78 82 encodeHashCountedSet(encoder, "subresourceUniqueRedirectsTo", subresourceUniqueRedirectsTo); 79 83 encodeHashCountedSet(encoder, "subresourceUniqueRedirectsFrom", subresourceUniqueRedirectsFrom); 84 80 85 // Prevalent Resource 81 86 encoder.encodeBool("isPrevalentResource", isPrevalentResource); … … 126 131 decodeHashSet(decoder, "storageAccessUnderTopFrameOrigins", storageAccessUnderTopFrameOrigins); 127 132 133 // Top frame stats 134 decodeHashCountedSet(decoder, "topFrameUniqueRedirectsTo", topFrameUniqueRedirectsTo); 135 decodeHashCountedSet(decoder, "topFrameUniqueRedirectsFrom", topFrameUniqueRedirectsFrom); 136 128 137 // Subframe stats 129 138 decodeHashCountedSet(decoder, "subframeUnderTopFrameOrigins", subframeUnderTopFrameOrigins); … … 132 141 decodeHashCountedSet(decoder, "subresourceUnderTopFrameOrigins", subresourceUnderTopFrameOrigins); 133 142 decodeHashCountedSet(decoder, "subresourceUniqueRedirectsTo", subresourceUniqueRedirectsTo); 134 143 decodeHashCountedSet(decoder, "subresourceUniqueRedirectsFrom", subresourceUniqueRedirectsFrom); 144 135 145 // Prevalent Resource 136 146 if (!decoder.decodeBool("isPrevalentResource", isPrevalentResource)) … … 223 233 appendHashSet(builder, "storageAccessUnderTopFrameOrigins", storageAccessUnderTopFrameOrigins); 224 234 235 // Top frame stats 236 appendHashCountedSet(builder, "topFrameUniqueRedirectsTo", topFrameUniqueRedirectsTo); 237 appendHashCountedSet(builder, "topFrameUniqueRedirectsFrom", topFrameUniqueRedirectsFrom); 238 225 239 // Subframe stats 226 240 appendHashCountedSet(builder, "subframeUnderTopFrameOrigins", subframeUnderTopFrameOrigins); … … 229 243 appendHashCountedSet(builder, "subresourceUnderTopFrameOrigins", subresourceUnderTopFrameOrigins); 230 244 appendHashCountedSet(builder, "subresourceUniqueRedirectsTo", subresourceUniqueRedirectsTo); 231 245 appendHashCountedSet(builder, "subresourceUniqueRedirectsFrom", subresourceUniqueRedirectsFrom); 246 232 247 // Prevalent Resource 233 248 appendBoolean(builder, "isPrevalentResource", isPrevalentResource); … … 284 299 mergeHashSet(storageAccessUnderTopFrameOrigins, other.storageAccessUnderTopFrameOrigins); 285 300 301 // Top frame stats 302 mergeHashCountedSet(topFrameUniqueRedirectsTo, other.topFrameUniqueRedirectsTo); 303 mergeHashCountedSet(topFrameUniqueRedirectsFrom, other.topFrameUniqueRedirectsFrom); 304 286 305 // Subframe stats 287 306 mergeHashCountedSet(subframeUnderTopFrameOrigins, other.subframeUnderTopFrameOrigins); … … 290 309 mergeHashCountedSet(subresourceUnderTopFrameOrigins, other.subresourceUnderTopFrameOrigins); 291 310 mergeHashCountedSet(subresourceUniqueRedirectsTo, other.subresourceUniqueRedirectsTo); 292 311 mergeHashCountedSet(subresourceUniqueRedirectsFrom, other.subresourceUniqueRedirectsFrom); 312 293 313 // Prevalent resource stats 294 314 isPrevalentResource |= other.isPrevalentResource; -
trunk/Source/WebCore/loader/ResourceLoadStatistics.h
r227755 r228416 74 74 HashSet<String> storageAccessUnderTopFrameOrigins; 75 75 76 // Top frame stats 77 HashCountedSet<String> topFrameUniqueRedirectsTo; 78 HashCountedSet<String> topFrameUniqueRedirectsFrom; 79 76 80 // Subframe stats 77 81 HashCountedSet<String> subframeUnderTopFrameOrigins; … … 80 84 HashCountedSet<String> subresourceUnderTopFrameOrigins; 81 85 HashCountedSet<String> subresourceUniqueRedirectsTo; 82 86 HashCountedSet<String> subresourceUniqueRedirectsFrom; 87 83 88 // Prevalent resource stats 84 89 bool isPrevalentResource { false }; -
trunk/Source/WebKit/ChangeLog
r228415 r228416 1 2018-02-12 John Wilander <wilander@apple.com> 2 3 Resource Load Statistics: Classify resources as prevalent based on redirects to other prevalent resources 4 https://bugs.webkit.org/show_bug.cgi?id=182664 5 <rdar://problem/37372572> 6 7 Reviewed by Brent Fulgham. 8 9 * Platform/classifier/ResourceLoadStatisticsClassifier.cpp: 10 (WebKit::ResourceLoadStatisticsClassifier::hasPrevalentResourceCharacteristics): 11 Unique top frame redirects now counts toward classification as prevalent. 12 * Shared/WebCoreArgumentCoders.cpp: 13 (IPC::ArgumentCoder<ResourceLoadStatistics>::encode): 14 (IPC::ArgumentCoder<ResourceLoadStatistics>::decode): 15 * UIProcess/API/C/WKWebsiteDataStoreRef.cpp: 16 (WKWebsiteDataStoreSetStatisticsSubresourceUniqueRedirectFrom): 17 (WKWebsiteDataStoreSetStatisticsTopFrameUniqueRedirectTo): 18 (WKWebsiteDataStoreSetStatisticsTopFrameUniqueRedirectFrom): 19 Test infrastructure. 20 * UIProcess/API/C/WKWebsiteDataStoreRef.h: 21 * UIProcess/WebResourceLoadStatisticsStore.cpp: 22 Bumped the statistics model to 11 because of the added fields. 23 (WebKit::WebResourceLoadStatisticsStore::recursivelyGetAllDomainsThatHaveRedirectedToThisDomain): 24 This function back traces redirect chains to classify domains 25 that have redirected to a newly classified prevalent resource. 26 (WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords): 27 Now uses the new convenience function WebResourceLoadStatisticsStore::setPrevalentResource(). 28 (WebKit::WebResourceLoadStatisticsStore::setPrevalentResource): 29 New convenience function to make sure we always call 30 WebResourceLoadStatisticsStore::recursivelyGetAllDomainsThatHaveRedirectedToThisDomain() 31 and capture redirect chains backward. 32 (WebKit::WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin): 33 (WebKit::WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin): 34 (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo): 35 (WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectFrom): 36 (WebKit::WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectTo): 37 (WebKit::WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectFrom): 38 Test infrastructure. 39 * UIProcess/WebResourceLoadStatisticsStore.h: 40 1 41 2018-02-12 Antti Koivisto <antti@apple.com> 2 42 -
trunk/Source/WebKit/Platform/classifier/ResourceLoadStatisticsClassifier.cpp
r228373 r228416 39 39 auto subresourceUniqueRedirectsToCount = resourceStatistic.subresourceUniqueRedirectsTo.size(); 40 40 auto subframeUnderTopFrameOriginsCount = resourceStatistic.subframeUnderTopFrameOrigins.size(); 41 auto topFrameUniqueRedirectsToCount = resourceStatistic.topFrameUniqueRedirectsTo.size(); 41 42 42 43 if (!subresourceUnderTopFrameOriginsCount 43 44 && !subresourceUniqueRedirectsToCount 44 && !subframeUnderTopFrameOriginsCount) 45 && !subframeUnderTopFrameOriginsCount 46 && !topFrameUniqueRedirectsToCount) 45 47 return false; 46 48 47 49 if (subresourceUnderTopFrameOriginsCount > featureVectorLengthThreshold 48 50 || subresourceUniqueRedirectsToCount > featureVectorLengthThreshold 49 || subframeUnderTopFrameOriginsCount > featureVectorLengthThreshold) 51 || subframeUnderTopFrameOriginsCount > featureVectorLengthThreshold 52 || topFrameUniqueRedirectsToCount > featureVectorLengthThreshold) 50 53 return true; 51 54 -
trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp
r226886 r228416 2539 2539 encoder << statistics.storageAccessUnderTopFrameOrigins; 2540 2540 2541 // Top frame stats 2542 encoder << statistics.topFrameUniqueRedirectsTo; 2543 encoder << statistics.topFrameUniqueRedirectsFrom; 2544 2541 2545 // Subframe stats 2542 2546 encoder << statistics.subframeUnderTopFrameOrigins; … … 2545 2549 encoder << statistics.subresourceUnderTopFrameOrigins; 2546 2550 encoder << statistics.subresourceUniqueRedirectsTo; 2547 2551 encoder << statistics.subresourceUniqueRedirectsFrom; 2552 2548 2553 // Prevalent Resource 2549 2554 encoder << statistics.isPrevalentResource; … … 2578 2583 return std::nullopt; 2579 2584 2585 // Top frame stats 2586 if (!decoder.decode(statistics.topFrameUniqueRedirectsTo)) 2587 return std::nullopt; 2588 2589 if (!decoder.decode(statistics.topFrameUniqueRedirectsFrom)) 2590 return std::nullopt; 2591 2580 2592 // Subframe stats 2581 2593 if (!decoder.decode(statistics.subframeUnderTopFrameOrigins)) … … 2587 2599 2588 2600 if (!decoder.decode(statistics.subresourceUniqueRedirectsTo)) 2601 return std::nullopt; 2602 2603 if (!decoder.decode(statistics.subresourceUniqueRedirectsFrom)) 2589 2604 return std::nullopt; 2590 2605 -
trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp
r228304 r228416 212 212 } 213 213 214 void WKWebsiteDataStoreSetStatisticsSubresourceUniqueRedirectFrom(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef hostRedirectedFrom) 215 { 216 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 217 if (!store) 218 return; 219 220 store->setSubresourceUniqueRedirectFrom(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()), WebCore::URL(WebCore::URL(), WebKit::toImpl(hostRedirectedFrom)->string())); 221 } 222 223 void WKWebsiteDataStoreSetStatisticsTopFrameUniqueRedirectTo(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef hostRedirectedTo) 224 { 225 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 226 if (!store) 227 return; 228 229 store->setTopFrameUniqueRedirectTo(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()), WebCore::URL(WebCore::URL(), WebKit::toImpl(hostRedirectedTo)->string())); 230 } 231 232 void WKWebsiteDataStoreSetStatisticsTopFrameUniqueRedirectFrom(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef hostRedirectedFrom) 233 { 234 auto* store = WebKit::toImpl(dataStoreRef)->websiteDataStore().resourceLoadStatistics(); 235 if (!store) 236 return; 237 238 store->setTopFrameUniqueRedirectFrom(WebCore::URL(WebCore::URL(), WebKit::toImpl(host)->string()), WebCore::URL(WebCore::URL(), WebKit::toImpl(hostRedirectedFrom)->string())); 239 } 240 214 241 void WKWebsiteDataStoreSetStatisticsTimeToLiveUserInteraction(WKWebsiteDataStoreRef dataStoreRef, double seconds) 215 242 { -
trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h
r228304 r228416 59 59 WK_EXPORT void WKWebsiteDataStoreSetStatisticsSubresourceUnderTopFrameOrigin(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef topFrameHost); 60 60 WK_EXPORT void WKWebsiteDataStoreSetStatisticsSubresourceUniqueRedirectTo(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef hostRedirectedTo); 61 WK_EXPORT void WKWebsiteDataStoreSetStatisticsSubresourceUniqueRedirectFrom(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef hostRedirectedFrom); 62 WK_EXPORT void WKWebsiteDataStoreSetStatisticsTopFrameUniqueRedirectTo(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef hostRedirectedTo); 63 WK_EXPORT void WKWebsiteDataStoreSetStatisticsTopFrameUniqueRedirectFrom(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef hostRedirectedFrom); 61 64 WK_EXPORT void WKWebsiteDataStoreSetStatisticsTimeToLiveUserInteraction(WKWebsiteDataStoreRef dataStoreRef, double seconds); 62 65 WK_EXPORT void WKWebsiteDataStoreSetStatisticsTimeToLiveCookiePartitionFree(WKWebsiteDataStoreRef dataStoreRef, double seconds); -
trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp
r228373 r228416 47 47 48 48 constexpr unsigned operatingDatesWindow { 30 }; 49 constexpr unsigned statisticsModelVersion { 1 0};49 constexpr unsigned statisticsModelVersion { 11 }; 50 50 constexpr unsigned maxImportance { 3 }; 51 constexpr unsigned maxNumberOfRecursiveCallsInRedirectTraceBack { 50 }; 51 52 52 53 template<typename T> static inline String isolatedPrimaryDomain(const T& value) … … 225 226 } 226 227 228 229 unsigned WebResourceLoadStatisticsStore::recursivelyGetAllDomainsThatHaveRedirectedToThisDomain(const WebCore::ResourceLoadStatistics& resourceStatistic, HashSet<String>& domainsThatHaveRedirectedTo, unsigned numberOfRecursiveCalls) 230 { 231 if (numberOfRecursiveCalls >= maxNumberOfRecursiveCallsInRedirectTraceBack) { 232 ASSERT_NOT_REACHED(); 233 WTFLogAlways("Hit %u recursive calls in redirect backtrace. Returning early.", maxNumberOfRecursiveCallsInRedirectTraceBack); 234 return numberOfRecursiveCalls; 235 } 236 237 numberOfRecursiveCalls++; 238 239 for (auto& subresourceUniqueRedirectFromDomain : resourceStatistic.subresourceUniqueRedirectsFrom.values()) { 240 auto mapEntry = m_resourceStatisticsMap.find(subresourceUniqueRedirectFromDomain); 241 if (mapEntry == m_resourceStatisticsMap.end() || mapEntry->value.isPrevalentResource) 242 continue; 243 if (domainsThatHaveRedirectedTo.add(mapEntry->value.highLevelDomain).isNewEntry) 244 numberOfRecursiveCalls = recursivelyGetAllDomainsThatHaveRedirectedToThisDomain(mapEntry->value, domainsThatHaveRedirectedTo, numberOfRecursiveCalls); 245 } 246 for (auto& topFrameUniqueRedirectFromDomain : resourceStatistic.topFrameUniqueRedirectsFrom.values()) { 247 auto mapEntry = m_resourceStatisticsMap.find(topFrameUniqueRedirectFromDomain); 248 if (mapEntry == m_resourceStatisticsMap.end() || mapEntry->value.isPrevalentResource) 249 continue; 250 if (domainsThatHaveRedirectedTo.add(mapEntry->value.highLevelDomain).isNewEntry) 251 numberOfRecursiveCalls = recursivelyGetAllDomainsThatHaveRedirectedToThisDomain(mapEntry->value, domainsThatHaveRedirectedTo, numberOfRecursiveCalls); 252 } 253 254 return numberOfRecursiveCalls; 255 } 256 227 257 void WebResourceLoadStatisticsStore::processStatisticsAndDataRecords() 228 258 { … … 232 262 for (auto& resourceStatistic : m_resourceStatisticsMap.values()) { 233 263 if (!resourceStatistic.isPrevalentResource && m_resourceLoadStatisticsClassifier.hasPrevalentResourceCharacteristics(resourceStatistic)) 234 resourceStatistic.isPrevalentResource = true;264 setPrevalentResource(resourceStatistic); 235 265 } 236 266 } … … 449 479 450 480 m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), primaryDomain = isolatedPrimaryDomain(url)] { 451 auto& statistics = ensureResourceStatisticsForPrimaryDomain(primaryDomain); 452 statistics.isPrevalentResource = true; 453 }); 481 auto& resourceStatistic = ensureResourceStatisticsForPrimaryDomain(primaryDomain); 482 setPrevalentResource(resourceStatistic); 483 }); 484 } 485 486 void WebResourceLoadStatisticsStore::setPrevalentResource(WebCore::ResourceLoadStatistics& resourceStatistic) 487 { 488 ASSERT(!RunLoop::isMain()); 489 resourceStatistic.isPrevalentResource = true; 490 HashSet<String> domainsThatHaveRedirectedTo; 491 recursivelyGetAllDomainsThatHaveRedirectedToThisDomain(resourceStatistic, domainsThatHaveRedirectedTo, 0); 492 for (auto& domain : domainsThatHaveRedirectedTo) { 493 auto mapEntry = m_resourceStatisticsMap.find(domain); 494 if (mapEntry == m_resourceStatisticsMap.end()) 495 continue; 496 ASSERT(!mapEntry->value.isPrevalentResource); 497 mapEntry->value.isPrevalentResource = true; 498 } 454 499 } 455 500 … … 538 583 auto& statistics = ensureResourceStatisticsForPrimaryDomain(primarySubFrameDomain); 539 584 statistics.subframeUnderTopFrameOrigins.add(primaryTopFrameDomain); 585 // For consistency, make sure we also have a statistics entry for the top frame domain. 586 ensureResourceStatisticsForPrimaryDomain(primaryTopFrameDomain); 540 587 }); 541 588 } … … 549 596 auto& statistics = ensureResourceStatisticsForPrimaryDomain(primarySubresourceDomain); 550 597 statistics.subresourceUnderTopFrameOrigins.add(primaryTopFrameDomain); 598 // For consistency, make sure we also have a statistics entry for the top frame domain. 599 ensureResourceStatisticsForPrimaryDomain(primaryTopFrameDomain); 551 600 }); 552 601 } … … 560 609 auto& statistics = ensureResourceStatisticsForPrimaryDomain(primarySubresourceDomain); 561 610 statistics.subresourceUniqueRedirectsTo.add(primaryRedirectDomain); 611 // For consistency, make sure we also have a statistics entry for the redirect domain. 612 ensureResourceStatisticsForPrimaryDomain(primaryRedirectDomain); 613 }); 614 } 615 616 void WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectFrom(const URL& subresource, const URL& hostNameRedirectedFrom) 617 { 618 if (subresource.isBlankURL() || subresource.isEmpty() || hostNameRedirectedFrom.isBlankURL() || hostNameRedirectedFrom.isEmpty()) 619 return; 620 621 m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), primaryRedirectDomain = isolatedPrimaryDomain(hostNameRedirectedFrom), primarySubresourceDomain = isolatedPrimaryDomain(subresource)] { 622 auto& statistics = ensureResourceStatisticsForPrimaryDomain(primarySubresourceDomain); 623 statistics.subresourceUniqueRedirectsFrom.add(primaryRedirectDomain); 624 // For consistency, make sure we also have a statistics entry for the redirect domain. 625 ensureResourceStatisticsForPrimaryDomain(primaryRedirectDomain); 626 }); 627 } 628 629 void WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectTo(const URL& topFrameHostName, const URL& hostNameRedirectedTo) 630 { 631 if (topFrameHostName.isBlankURL() || topFrameHostName.isEmpty() || hostNameRedirectedTo.isBlankURL() || hostNameRedirectedTo.isEmpty()) 632 return; 633 634 m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), primaryRedirectDomain = isolatedPrimaryDomain(hostNameRedirectedTo), topFramePrimaryDomain = isolatedPrimaryDomain(topFrameHostName)] { 635 auto& statistics = ensureResourceStatisticsForPrimaryDomain(topFramePrimaryDomain); 636 statistics.topFrameUniqueRedirectsTo.add(primaryRedirectDomain); 637 // For consistency, make sure we also have a statistics entry for the redirect domain. 638 ensureResourceStatisticsForPrimaryDomain(primaryRedirectDomain); 639 }); 640 } 641 642 void WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectFrom(const URL& topFrameHostName, const URL& hostNameRedirectedFrom) 643 { 644 if (topFrameHostName.isBlankURL() || topFrameHostName.isEmpty() || hostNameRedirectedFrom.isBlankURL() || hostNameRedirectedFrom.isEmpty()) 645 return; 646 647 m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this), primaryRedirectDomain = isolatedPrimaryDomain(hostNameRedirectedFrom), topFramePrimaryDomain = isolatedPrimaryDomain(topFrameHostName)] { 648 auto& statistics = ensureResourceStatisticsForPrimaryDomain(topFramePrimaryDomain); 649 statistics.topFrameUniqueRedirectsFrom.add(primaryRedirectDomain); 650 // For consistency, make sure we also have a statistics entry for the redirect domain. 651 ensureResourceStatisticsForPrimaryDomain(primaryRedirectDomain); 562 652 }); 563 653 } -
trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h
r227943 r228416 107 107 void setSubresourceUnderTopFrameOrigin(const WebCore::URL& subresource, const WebCore::URL& topFrame); 108 108 void setSubresourceUniqueRedirectTo(const WebCore::URL& subresource, const WebCore::URL& hostNameRedirectedTo); 109 void setSubresourceUniqueRedirectFrom(const WebCore::URL& subresource, const WebCore::URL& hostNameRedirectedFrom); 110 void setTopFrameUniqueRedirectTo(const WebCore::URL& topFrameHostName, const WebCore::URL& hostNameRedirectedTo); 111 void setTopFrameUniqueRedirectFrom(const WebCore::URL& topFrameHostName, const WebCore::URL& hostNameRedirectedFrom); 109 112 void scheduleCookiePartitioningUpdate(CompletionHandler<void()>&&); 110 113 void scheduleCookiePartitioningUpdateForDomains(const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, ShouldClearFirst, CompletionHandler<void()>&&); … … 168 171 void mergeStatistics(Vector<WebCore::ResourceLoadStatistics>&&); 169 172 WebCore::ResourceLoadStatistics& ensureResourceStatisticsForPrimaryDomain(const String&); 173 unsigned recursivelyGetAllDomainsThatHaveRedirectedToThisDomain(const WebCore::ResourceLoadStatistics&, HashSet<String>& domainsThatHaveRedirectedTo, unsigned numberOfRecursiveCalls); 174 void setPrevalentResource(WebCore::ResourceLoadStatistics&); 170 175 void processStatisticsAndDataRecords(); 171 176 -
trunk/Tools/ChangeLog
r228396 r228416 1 2018-02-12 John Wilander <wilander@apple.com> 2 3 Resource Load Statistics: Classify resources as prevalent based on redirects to other prevalent resources 4 https://bugs.webkit.org/show_bug.cgi?id=182664 5 <rdar://problem/37372572> 6 7 Reviewed by Brent Fulgham. 8 9 * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: 10 * WebKitTestRunner/InjectedBundle/TestRunner.cpp: 11 (WTR::TestRunner::setStatisticsSubresourceUniqueRedirectFrom): 12 (WTR::TestRunner::setStatisticsTopFrameUniqueRedirectTo): 13 (WTR::TestRunner::setStatisticsTopFrameUniqueRedirectFrom): 14 * WebKitTestRunner/InjectedBundle/TestRunner.h: 15 * WebKitTestRunner/TestController.cpp: 16 (WTR::TestController::setStatisticsSubresourceUniqueRedirectFrom): 17 (WTR::TestController::setStatisticsTopFrameUniqueRedirectTo): 18 (WTR::TestController::setStatisticsTopFrameUniqueRedirectFrom): 19 * WebKitTestRunner/TestController.h: 20 * WebKitTestRunner/TestInvocation.cpp: 21 (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle): 22 1 23 2018-02-12 Ross Kirsling <ross.kirsling@sony.com> 2 24 -
trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
r228109 r228416 279 279 void setStatisticsSubresourceUnderTopFrameOrigin(DOMString hostName, DOMString topFrameHostName); 280 280 void setStatisticsSubresourceUniqueRedirectTo(DOMString hostName, DOMString hostNameRedirectedTo); 281 void setStatisticsSubresourceUniqueRedirectFrom(DOMString hostName, DOMString hostNameRedirectedTo); 282 void setStatisticsTopFrameUniqueRedirectTo(DOMString hostName, DOMString hostNameRedirectedTo); 283 void setStatisticsTopFrameUniqueRedirectFrom(DOMString hostName, DOMString hostNameRedirectedTo); 281 284 void setStatisticsTimeToLiveUserInteraction(double seconds); 282 285 void setStatisticsTimeToLiveCookiePartitionFree(double seconds); -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
r228109 r228416 1478 1478 } 1479 1479 1480 1481 void TestRunner::setStatisticsSubresourceUniqueRedirectFrom(JSStringRef hostName, JSStringRef hostNameRedirectedFrom) 1482 { 1483 Vector<WKRetainPtr<WKStringRef>> keys; 1484 Vector<WKRetainPtr<WKTypeRef>> values; 1485 1486 keys.append({ AdoptWK, WKStringCreateWithUTF8CString("HostName") }); 1487 values.append({ AdoptWK, WKStringCreateWithJSString(hostName) }); 1488 1489 keys.append({ AdoptWK, WKStringCreateWithUTF8CString("HostNameRedirectedFrom") }); 1490 values.append({ AdoptWK, WKStringCreateWithJSString(hostNameRedirectedFrom) }); 1491 1492 Vector<WKStringRef> rawKeys(keys.size()); 1493 Vector<WKTypeRef> rawValues(values.size()); 1494 1495 for (size_t i = 0; i < keys.size(); ++i) { 1496 rawKeys[i] = keys[i].get(); 1497 rawValues[i] = values[i].get(); 1498 } 1499 1500 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStatisticsSubresourceUniqueRedirectFrom")); 1501 WKRetainPtr<WKDictionaryRef> messageBody(AdoptWK, WKDictionaryCreate(rawKeys.data(), rawValues.data(), rawKeys.size())); 1502 WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr); 1503 } 1504 1505 void TestRunner::setStatisticsTopFrameUniqueRedirectTo(JSStringRef hostName, JSStringRef hostNameRedirectedTo) 1506 { 1507 Vector<WKRetainPtr<WKStringRef>> keys; 1508 Vector<WKRetainPtr<WKTypeRef>> values; 1509 1510 keys.append({ AdoptWK, WKStringCreateWithUTF8CString("HostName") }); 1511 values.append({ AdoptWK, WKStringCreateWithJSString(hostName) }); 1512 1513 keys.append({ AdoptWK, WKStringCreateWithUTF8CString("HostNameRedirectedTo") }); 1514 values.append({ AdoptWK, WKStringCreateWithJSString(hostNameRedirectedTo) }); 1515 1516 Vector<WKStringRef> rawKeys(keys.size()); 1517 Vector<WKTypeRef> rawValues(values.size()); 1518 1519 for (size_t i = 0; i < keys.size(); ++i) { 1520 rawKeys[i] = keys[i].get(); 1521 rawValues[i] = values[i].get(); 1522 } 1523 1524 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStatisticsTopFrameUniqueRedirectTo")); 1525 WKRetainPtr<WKDictionaryRef> messageBody(AdoptWK, WKDictionaryCreate(rawKeys.data(), rawValues.data(), rawKeys.size())); 1526 WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr); 1527 } 1528 1529 void TestRunner::setStatisticsTopFrameUniqueRedirectFrom(JSStringRef hostName, JSStringRef hostNameRedirectedFrom) 1530 { 1531 Vector<WKRetainPtr<WKStringRef>> keys; 1532 Vector<WKRetainPtr<WKTypeRef>> values; 1533 1534 keys.append({ AdoptWK, WKStringCreateWithUTF8CString("HostName") }); 1535 values.append({ AdoptWK, WKStringCreateWithJSString(hostName) }); 1536 1537 keys.append({ AdoptWK, WKStringCreateWithUTF8CString("HostNameRedirectedFrom") }); 1538 values.append({ AdoptWK, WKStringCreateWithJSString(hostNameRedirectedFrom) }); 1539 1540 Vector<WKStringRef> rawKeys(keys.size()); 1541 Vector<WKTypeRef> rawValues(values.size()); 1542 1543 for (size_t i = 0; i < keys.size(); ++i) { 1544 rawKeys[i] = keys[i].get(); 1545 rawValues[i] = values[i].get(); 1546 } 1547 1548 WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetStatisticsTopFrameUniqueRedirectFrom")); 1549 WKRetainPtr<WKDictionaryRef> messageBody(AdoptWK, WKDictionaryCreate(rawKeys.data(), rawValues.data(), rawKeys.size())); 1550 WKBundlePostSynchronousMessage(InjectedBundle::singleton().bundle(), messageName.get(), messageBody.get(), nullptr); 1551 } 1552 1553 1480 1554 void TestRunner::setStatisticsTimeToLiveUserInteraction(double seconds) 1481 1555 { -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
r228109 r228416 384 384 void setStatisticsSubresourceUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName); 385 385 void setStatisticsSubresourceUniqueRedirectTo(JSStringRef hostName, JSStringRef hostNameRedirectedTo); 386 void setStatisticsSubresourceUniqueRedirectFrom(JSStringRef hostName, JSStringRef hostNameRedirectedFrom); 387 void setStatisticsTopFrameUniqueRedirectTo(JSStringRef hostName, JSStringRef hostNameRedirectedTo); 388 void setStatisticsTopFrameUniqueRedirectFrom(JSStringRef hostName, JSStringRef hostNameRedirectedFrom); 386 389 void setStatisticsTimeToLiveUserInteraction(double seconds); 387 390 void setStatisticsTimeToLiveCookiePartitionFree(double seconds); -
trunk/Tools/WebKitTestRunner/TestController.cpp
r228304 r228416 2597 2597 } 2598 2598 2599 void TestController::setStatisticsSubresourceUniqueRedirectFrom(WKStringRef host, WKStringRef hostRedirectedFrom) 2600 { 2601 auto* dataStore = WKContextGetWebsiteDataStore(platformContext()); 2602 WKWebsiteDataStoreSetStatisticsSubresourceUniqueRedirectFrom(dataStore, host, hostRedirectedFrom); 2603 } 2604 2605 void TestController::setStatisticsTopFrameUniqueRedirectTo(WKStringRef host, WKStringRef hostRedirectedTo) 2606 { 2607 auto* dataStore = WKContextGetWebsiteDataStore(platformContext()); 2608 WKWebsiteDataStoreSetStatisticsTopFrameUniqueRedirectTo(dataStore, host, hostRedirectedTo); 2609 } 2610 2611 void TestController::setStatisticsTopFrameUniqueRedirectFrom(WKStringRef host, WKStringRef hostRedirectedFrom) 2612 { 2613 auto* dataStore = WKContextGetWebsiteDataStore(platformContext()); 2614 WKWebsiteDataStoreSetStatisticsTopFrameUniqueRedirectFrom(dataStore, host, hostRedirectedFrom); 2615 } 2616 2599 2617 void TestController::setStatisticsTimeToLiveUserInteraction(double seconds) 2600 2618 { -
trunk/Tools/WebKitTestRunner/TestController.h
r228304 r228416 167 167 void setStatisticsSubresourceUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName); 168 168 void setStatisticsSubresourceUniqueRedirectTo(WKStringRef hostName, WKStringRef hostNameRedirectedTo); 169 void setStatisticsSubresourceUniqueRedirectFrom(WKStringRef host, WKStringRef hostRedirectedFrom); 170 void setStatisticsTopFrameUniqueRedirectTo(WKStringRef host, WKStringRef hostRedirectedTo); 171 void setStatisticsTopFrameUniqueRedirectFrom(WKStringRef host, WKStringRef hostRedirectedFrom); 169 172 void setStatisticsTimeToLiveUserInteraction(double seconds); 170 173 void setStatisticsTimeToLiveCookiePartitionFree(double seconds); -
trunk/Tools/WebKitTestRunner/TestInvocation.cpp
r228109 r228416 1108 1108 } 1109 1109 1110 if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsSubresourceUniqueRedirectFrom")) { 1111 ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID()); 1112 1113 WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody); 1114 WKRetainPtr<WKStringRef> hostNameKey(AdoptWK, WKStringCreateWithUTF8CString("HostName")); 1115 WKRetainPtr<WKStringRef> hostNameRedirectedFromKey(AdoptWK, WKStringCreateWithUTF8CString("HostNameRedirectedFrom")); 1116 1117 WKStringRef hostName = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, hostNameKey.get())); 1118 WKStringRef hostNameRedirectedFrom = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, hostNameRedirectedFromKey.get())); 1119 1120 TestController::singleton().setStatisticsSubresourceUniqueRedirectFrom(hostName, hostNameRedirectedFrom); 1121 return nullptr; 1122 } 1123 1124 if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsTopFrameUniqueRedirectTo")) { 1125 ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID()); 1126 1127 WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody); 1128 WKRetainPtr<WKStringRef> hostNameKey(AdoptWK, WKStringCreateWithUTF8CString("HostName")); 1129 WKRetainPtr<WKStringRef> hostNameRedirectedToKey(AdoptWK, WKStringCreateWithUTF8CString("HostNameRedirectedTo")); 1130 1131 WKStringRef hostName = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, hostNameKey.get())); 1132 WKStringRef hostNameRedirectedTo = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, hostNameRedirectedToKey.get())); 1133 1134 TestController::singleton().setStatisticsTopFrameUniqueRedirectTo(hostName, hostNameRedirectedTo); 1135 return nullptr; 1136 } 1137 1138 if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsTopFrameUniqueRedirectFrom")) { 1139 ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID()); 1140 1141 WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody); 1142 WKRetainPtr<WKStringRef> hostNameKey(AdoptWK, WKStringCreateWithUTF8CString("HostName")); 1143 WKRetainPtr<WKStringRef> hostNameRedirectedFromKey(AdoptWK, WKStringCreateWithUTF8CString("HostNameRedirectedFrom")); 1144 1145 WKStringRef hostName = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, hostNameKey.get())); 1146 WKStringRef hostNameRedirectedFrom = static_cast<WKStringRef>(WKDictionaryGetItemForKey(messageBodyDictionary, hostNameRedirectedFromKey.get())); 1147 1148 TestController::singleton().setStatisticsTopFrameUniqueRedirectFrom(hostName, hostNameRedirectedFrom); 1149 return nullptr; 1150 } 1151 1110 1152 if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsTimeToLiveUserInteraction")) { 1111 1153 ASSERT(WKGetTypeID(messageBody) == WKDoubleGetTypeID());
Note: See TracChangeset
for help on using the changeset viewer.