Changeset 228416 in webkit


Ignore:
Timestamp:
Feb 12, 2018 10:08:18 PM (6 years ago)
Author:
wilander@apple.com
Message:

Resource Load Statistics: Classify resources as prevalent based on redirects to other prevalent resources
https://bugs.webkit.org/show_bug.cgi?id=182664
<rdar://problem/37372572>

Reviewed by Brent Fulgham.

Source/WebCore:

Tests: http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-redirect-collusion.html

http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-redirect-collusion.html
http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-unique-redirects-to.html

  • loader/ResourceLoadObserver.cpp:

(WebCore::ResourceLoadObserver::logFrameNavigation):

We now collect statistics on top frame navigational redirects too, both to and from.

(WebCore::ResourceLoadObserver::logSubresourceLoading):

We now collect statistics on redirects from in addition to the existing redirects to.

  • loader/ResourceLoadStatistics.cpp:

(WebCore::ResourceLoadStatistics::encode const):
(WebCore::ResourceLoadStatistics::decode):
(WebCore::ResourceLoadStatistics::toString const):
(WebCore::ResourceLoadStatistics::merge):

  • loader/ResourceLoadStatistics.h:

Three new fields:

  • topFrameUniqueRedirectsTo
  • topFrameUniqueRedirectsFrom
  • subresourceUniqueRedirectsFrom

Source/WebKit:

  • Platform/classifier/ResourceLoadStatisticsClassifier.cpp:

(WebKit::ResourceLoadStatisticsClassifier::hasPrevalentResourceCharacteristics):

Unique top frame redirects now counts toward classification as prevalent.

  • Shared/WebCoreArgumentCoders.cpp:

(IPC::ArgumentCoder<ResourceLoadStatistics>::encode):
(IPC::ArgumentCoder<ResourceLoadStatistics>::decode):

  • UIProcess/API/C/WKWebsiteDataStoreRef.cpp:

(WKWebsiteDataStoreSetStatisticsSubresourceUniqueRedirectFrom):
(WKWebsiteDataStoreSetStatisticsTopFrameUniqueRedirectTo):
(WKWebsiteDataStoreSetStatisticsTopFrameUniqueRedirectFrom):

Test infrastructure.

  • UIProcess/API/C/WKWebsiteDataStoreRef.h:
  • UIProcess/WebResourceLoadStatisticsStore.cpp:

Bumped the statistics model to 11 because of the added fields.

(WebKit::WebResourceLoadStatisticsStore::recursivelyGetAllDomainsThatHaveRedirectedToThisDomain):

This function back traces redirect chains to classify domains
that have redirected to a newly classified prevalent resource.

(WebKit::WebResourceLoadStatisticsStore::processStatisticsAndDataRecords):

Now uses the new convenience function WebResourceLoadStatisticsStore::setPrevalentResource().

(WebKit::WebResourceLoadStatisticsStore::setPrevalentResource):

New convenience function to make sure we always call
WebResourceLoadStatisticsStore::recursivelyGetAllDomainsThatHaveRedirectedToThisDomain()
and capture redirect chains backward.

(WebKit::WebResourceLoadStatisticsStore::setSubframeUnderTopFrameOrigin):
(WebKit::WebResourceLoadStatisticsStore::setSubresourceUnderTopFrameOrigin):
(WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectTo):
(WebKit::WebResourceLoadStatisticsStore::setSubresourceUniqueRedirectFrom):
(WebKit::WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectTo):
(WebKit::WebResourceLoadStatisticsStore::setTopFrameUniqueRedirectFrom):

Test infrastructure.

  • UIProcess/WebResourceLoadStatisticsStore.h:

Tools:

  • WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
  • WebKitTestRunner/InjectedBundle/TestRunner.cpp:

(WTR::TestRunner::setStatisticsSubresourceUniqueRedirectFrom):
(WTR::TestRunner::setStatisticsTopFrameUniqueRedirectTo):
(WTR::TestRunner::setStatisticsTopFrameUniqueRedirectFrom):

  • WebKitTestRunner/InjectedBundle/TestRunner.h:
  • WebKitTestRunner/TestController.cpp:

(WTR::TestController::setStatisticsSubresourceUniqueRedirectFrom):
(WTR::TestController::setStatisticsTopFrameUniqueRedirectTo):
(WTR::TestController::setStatisticsTopFrameUniqueRedirectFrom):

  • WebKitTestRunner/TestController.h:
  • WebKitTestRunner/TestInvocation.cpp:

(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

LayoutTests:

  • http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-redirect-collusion-expected.txt: Added.
  • http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-redirect-collusion.html: Added.
  • http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-redirect-collusion-expected.txt: Added.
  • http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-redirect-collusion.html: Added.
  • http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-unique-redirects-to-expected.txt: Added.
  • http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-unique-redirects-to.html: Added.
  • platform/wk2/TestExpectations:

New tests added as [ Pass ].

Location:
trunk
Files:
6 added
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r228403 r228416  
     12018-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
    1182018-02-12  Matt Lewis  <jlewis3@apple.com>
    219
  • trunk/LayoutTests/platform/wk2/TestExpectations

    r228329 r228416  
    690690http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-under-top-frame-origins.html [ Pass ]
    691691http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-unique-redirects-to.html [ Pass ]
     692http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-subresource-redirect-collusion.html [ Pass ]
     693http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-redirect-collusion.html [ Pass ]
     694http/tests/resourceLoadStatistics/classify-as-prevalent-based-on-top-frame-unique-redirects-to.html [ Pass ]
    692695webkit.org/b/181223 http/tests/resourceLoadStatistics/clear-in-memory-and-persistent-store.html [ Skip ]
    693696http/tests/resourceLoadStatistics/grandfathering.html [ Pass ]
  • trunk/Source/WebCore/ChangeLog

    r228414 r228416  
     12018-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
    1292018-02-12  Zalan Bujtas  <zalan@apple.com>
    230
  • trunk/Source/WebCore/loader/ResourceLoadObserver.cpp

    r227790 r228416  
    139139    ASSERT(topFrame.page());
    140140
    141     if (frame.isMainFrame())
    142         return;
    143    
    144141    auto* page = topFrame.page();
    145142    if (!shouldLog(page))
     
    178175    if (isRedirect
    179176        && !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)
    182192            shouldCallNotificationCallback = true;
    183193    }
     
    235245    if (isRedirect) {
    236246        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)
    238252            shouldCallNotificationCallback = true;
    239253    }
  • trunk/Source/WebCore/loader/ResourceLoadStatistics.cpp

    r227755 r228416  
    7171    encodeHashSet(encoder, "storageAccessUnderTopFrameOrigins", storageAccessUnderTopFrameOrigins);
    7272
     73    // Top frame stats
     74    encodeHashCountedSet(encoder, "topFrameUniqueRedirectsTo", topFrameUniqueRedirectsTo);
     75    encodeHashCountedSet(encoder, "topFrameUniqueRedirectsFrom", topFrameUniqueRedirectsFrom);
     76
    7377    // Subframe stats
    7478    encodeHashCountedSet(encoder, "subframeUnderTopFrameOrigins", subframeUnderTopFrameOrigins);
     
    7781    encodeHashCountedSet(encoder, "subresourceUnderTopFrameOrigins", subresourceUnderTopFrameOrigins);
    7882    encodeHashCountedSet(encoder, "subresourceUniqueRedirectsTo", subresourceUniqueRedirectsTo);
    79    
     83    encodeHashCountedSet(encoder, "subresourceUniqueRedirectsFrom", subresourceUniqueRedirectsFrom);
     84
    8085    // Prevalent Resource
    8186    encoder.encodeBool("isPrevalentResource", isPrevalentResource);
     
    126131    decodeHashSet(decoder, "storageAccessUnderTopFrameOrigins", storageAccessUnderTopFrameOrigins);
    127132
     133    // Top frame stats
     134    decodeHashCountedSet(decoder, "topFrameUniqueRedirectsTo", topFrameUniqueRedirectsTo);
     135    decodeHashCountedSet(decoder, "topFrameUniqueRedirectsFrom", topFrameUniqueRedirectsFrom);
     136
    128137    // Subframe stats
    129138    decodeHashCountedSet(decoder, "subframeUnderTopFrameOrigins", subframeUnderTopFrameOrigins);
     
    132141    decodeHashCountedSet(decoder, "subresourceUnderTopFrameOrigins", subresourceUnderTopFrameOrigins);
    133142    decodeHashCountedSet(decoder, "subresourceUniqueRedirectsTo", subresourceUniqueRedirectsTo);
    134    
     143    decodeHashCountedSet(decoder, "subresourceUniqueRedirectsFrom", subresourceUniqueRedirectsFrom);
     144
    135145    // Prevalent Resource
    136146    if (!decoder.decodeBool("isPrevalentResource", isPrevalentResource))
     
    223233    appendHashSet(builder, "storageAccessUnderTopFrameOrigins", storageAccessUnderTopFrameOrigins);
    224234
     235    // Top frame stats
     236    appendHashCountedSet(builder, "topFrameUniqueRedirectsTo", topFrameUniqueRedirectsTo);
     237    appendHashCountedSet(builder, "topFrameUniqueRedirectsFrom", topFrameUniqueRedirectsFrom);
     238
    225239    // Subframe stats
    226240    appendHashCountedSet(builder, "subframeUnderTopFrameOrigins", subframeUnderTopFrameOrigins);
     
    229243    appendHashCountedSet(builder, "subresourceUnderTopFrameOrigins", subresourceUnderTopFrameOrigins);
    230244    appendHashCountedSet(builder, "subresourceUniqueRedirectsTo", subresourceUniqueRedirectsTo);
    231    
     245    appendHashCountedSet(builder, "subresourceUniqueRedirectsFrom", subresourceUniqueRedirectsFrom);
     246
    232247    // Prevalent Resource
    233248    appendBoolean(builder, "isPrevalentResource", isPrevalentResource);
     
    284299    mergeHashSet(storageAccessUnderTopFrameOrigins, other.storageAccessUnderTopFrameOrigins);
    285300
     301    // Top frame stats
     302    mergeHashCountedSet(topFrameUniqueRedirectsTo, other.topFrameUniqueRedirectsTo);
     303    mergeHashCountedSet(topFrameUniqueRedirectsFrom, other.topFrameUniqueRedirectsFrom);
     304
    286305    // Subframe stats
    287306    mergeHashCountedSet(subframeUnderTopFrameOrigins, other.subframeUnderTopFrameOrigins);
     
    290309    mergeHashCountedSet(subresourceUnderTopFrameOrigins, other.subresourceUnderTopFrameOrigins);
    291310    mergeHashCountedSet(subresourceUniqueRedirectsTo, other.subresourceUniqueRedirectsTo);
    292    
     311    mergeHashCountedSet(subresourceUniqueRedirectsFrom, other.subresourceUniqueRedirectsFrom);
     312
    293313    // Prevalent resource stats
    294314    isPrevalentResource |= other.isPrevalentResource;
  • trunk/Source/WebCore/loader/ResourceLoadStatistics.h

    r227755 r228416  
    7474    HashSet<String> storageAccessUnderTopFrameOrigins;
    7575
     76    // Top frame stats
     77    HashCountedSet<String> topFrameUniqueRedirectsTo;
     78    HashCountedSet<String> topFrameUniqueRedirectsFrom;
     79
    7680    // Subframe stats
    7781    HashCountedSet<String> subframeUnderTopFrameOrigins;
     
    8084    HashCountedSet<String> subresourceUnderTopFrameOrigins;
    8185    HashCountedSet<String> subresourceUniqueRedirectsTo;
    82    
     86    HashCountedSet<String> subresourceUniqueRedirectsFrom;
     87
    8388    // Prevalent resource stats
    8489    bool isPrevalentResource { false };
  • trunk/Source/WebKit/ChangeLog

    r228415 r228416  
     12018-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
    1412018-02-12  Antti Koivisto  <antti@apple.com>
    242
  • trunk/Source/WebKit/Platform/classifier/ResourceLoadStatisticsClassifier.cpp

    r228373 r228416  
    3939    auto subresourceUniqueRedirectsToCount = resourceStatistic.subresourceUniqueRedirectsTo.size();
    4040    auto subframeUnderTopFrameOriginsCount = resourceStatistic.subframeUnderTopFrameOrigins.size();
     41    auto topFrameUniqueRedirectsToCount = resourceStatistic.topFrameUniqueRedirectsTo.size();
    4142   
    4243    if (!subresourceUnderTopFrameOriginsCount
    4344        && !subresourceUniqueRedirectsToCount
    44         && !subframeUnderTopFrameOriginsCount)
     45        && !subframeUnderTopFrameOriginsCount
     46        && !topFrameUniqueRedirectsToCount)
    4547        return false;
    4648   
    4749    if (subresourceUnderTopFrameOriginsCount > featureVectorLengthThreshold
    4850        || subresourceUniqueRedirectsToCount > featureVectorLengthThreshold
    49         || subframeUnderTopFrameOriginsCount > featureVectorLengthThreshold)
     51        || subframeUnderTopFrameOriginsCount > featureVectorLengthThreshold
     52        || topFrameUniqueRedirectsToCount > featureVectorLengthThreshold)
    5053        return true;
    5154
  • trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp

    r226886 r228416  
    25392539    encoder << statistics.storageAccessUnderTopFrameOrigins;
    25402540
     2541    // Top frame stats
     2542    encoder << statistics.topFrameUniqueRedirectsTo;
     2543    encoder << statistics.topFrameUniqueRedirectsFrom;
     2544
    25412545    // Subframe stats
    25422546    encoder << statistics.subframeUnderTopFrameOrigins;
     
    25452549    encoder << statistics.subresourceUnderTopFrameOrigins;
    25462550    encoder << statistics.subresourceUniqueRedirectsTo;
    2547    
     2551    encoder << statistics.subresourceUniqueRedirectsFrom;
     2552
    25482553    // Prevalent Resource
    25492554    encoder << statistics.isPrevalentResource;
     
    25782583        return std::nullopt;
    25792584
     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
    25802592    // Subframe stats
    25812593    if (!decoder.decode(statistics.subframeUnderTopFrameOrigins))
     
    25872599
    25882600    if (!decoder.decode(statistics.subresourceUniqueRedirectsTo))
     2601        return std::nullopt;
     2602   
     2603    if (!decoder.decode(statistics.subresourceUniqueRedirectsFrom))
    25892604        return std::nullopt;
    25902605   
  • trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp

    r228304 r228416  
    212212}
    213213
     214void 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
     223void 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
     232void 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
    214241void WKWebsiteDataStoreSetStatisticsTimeToLiveUserInteraction(WKWebsiteDataStoreRef dataStoreRef, double seconds)
    215242{
  • trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h

    r228304 r228416  
    5959WK_EXPORT void WKWebsiteDataStoreSetStatisticsSubresourceUnderTopFrameOrigin(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef topFrameHost);
    6060WK_EXPORT void WKWebsiteDataStoreSetStatisticsSubresourceUniqueRedirectTo(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef hostRedirectedTo);
     61WK_EXPORT void WKWebsiteDataStoreSetStatisticsSubresourceUniqueRedirectFrom(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef hostRedirectedFrom);
     62WK_EXPORT void WKWebsiteDataStoreSetStatisticsTopFrameUniqueRedirectTo(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef hostRedirectedTo);
     63WK_EXPORT void WKWebsiteDataStoreSetStatisticsTopFrameUniqueRedirectFrom(WKWebsiteDataStoreRef dataStoreRef, WKStringRef host, WKStringRef hostRedirectedFrom);
    6164WK_EXPORT void WKWebsiteDataStoreSetStatisticsTimeToLiveUserInteraction(WKWebsiteDataStoreRef dataStoreRef, double seconds);
    6265WK_EXPORT void WKWebsiteDataStoreSetStatisticsTimeToLiveCookiePartitionFree(WKWebsiteDataStoreRef dataStoreRef, double seconds);
  • trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp

    r228373 r228416  
    4747
    4848constexpr unsigned operatingDatesWindow { 30 };
    49 constexpr unsigned statisticsModelVersion { 10 };
     49constexpr unsigned statisticsModelVersion { 11 };
    5050constexpr unsigned maxImportance { 3 };
     51constexpr unsigned maxNumberOfRecursiveCallsInRedirectTraceBack { 50 };
    5152
    5253template<typename T> static inline String isolatedPrimaryDomain(const T& value)
     
    225226}
    226227
     228
     229unsigned 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
    227257void WebResourceLoadStatisticsStore::processStatisticsAndDataRecords()
    228258{
     
    232262        for (auto& resourceStatistic : m_resourceStatisticsMap.values()) {
    233263            if (!resourceStatistic.isPrevalentResource && m_resourceLoadStatisticsClassifier.hasPrevalentResourceCharacteristics(resourceStatistic))
    234                 resourceStatistic.isPrevalentResource = true;
     264                setPrevalentResource(resourceStatistic);
    235265        }
    236266    }
     
    449479
    450480    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
     486void 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    }
    454499}
    455500
     
    538583        auto& statistics = ensureResourceStatisticsForPrimaryDomain(primarySubFrameDomain);
    539584        statistics.subframeUnderTopFrameOrigins.add(primaryTopFrameDomain);
     585        // For consistency, make sure we also have a statistics entry for the top frame domain.
     586        ensureResourceStatisticsForPrimaryDomain(primaryTopFrameDomain);
    540587    });
    541588}
     
    549596        auto& statistics = ensureResourceStatisticsForPrimaryDomain(primarySubresourceDomain);
    550597        statistics.subresourceUnderTopFrameOrigins.add(primaryTopFrameDomain);
     598        // For consistency, make sure we also have a statistics entry for the top frame domain.
     599        ensureResourceStatisticsForPrimaryDomain(primaryTopFrameDomain);
    551600    });
    552601}
     
    560609        auto& statistics = ensureResourceStatisticsForPrimaryDomain(primarySubresourceDomain);
    561610        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
     616void 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
     629void 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
     642void 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);
    562652    });
    563653}
  • trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.h

    r227943 r228416  
    107107    void setSubresourceUnderTopFrameOrigin(const WebCore::URL& subresource, const WebCore::URL& topFrame);
    108108    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);
    109112    void scheduleCookiePartitioningUpdate(CompletionHandler<void()>&&);
    110113    void scheduleCookiePartitioningUpdateForDomains(const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, ShouldClearFirst, CompletionHandler<void()>&&);
     
    168171    void mergeStatistics(Vector<WebCore::ResourceLoadStatistics>&&);
    169172    WebCore::ResourceLoadStatistics& ensureResourceStatisticsForPrimaryDomain(const String&);
     173    unsigned recursivelyGetAllDomainsThatHaveRedirectedToThisDomain(const WebCore::ResourceLoadStatistics&, HashSet<String>& domainsThatHaveRedirectedTo, unsigned numberOfRecursiveCalls);
     174    void setPrevalentResource(WebCore::ResourceLoadStatistics&);
    170175    void processStatisticsAndDataRecords();
    171176
  • trunk/Tools/ChangeLog

    r228396 r228416  
     12018-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
    1232018-02-12  Ross Kirsling  <ross.kirsling@sony.com>
    224
  • trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl

    r228109 r228416  
    279279    void setStatisticsSubresourceUnderTopFrameOrigin(DOMString hostName, DOMString topFrameHostName);
    280280    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);
    281284    void setStatisticsTimeToLiveUserInteraction(double seconds);
    282285    void setStatisticsTimeToLiveCookiePartitionFree(double seconds);
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp

    r228109 r228416  
    14781478}
    14791479
     1480
     1481void 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
     1505void 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
     1529void 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
    14801554void TestRunner::setStatisticsTimeToLiveUserInteraction(double seconds)
    14811555{
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h

    r228109 r228416  
    384384    void setStatisticsSubresourceUnderTopFrameOrigin(JSStringRef hostName, JSStringRef topFrameHostName);
    385385    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);
    386389    void setStatisticsTimeToLiveUserInteraction(double seconds);
    387390    void setStatisticsTimeToLiveCookiePartitionFree(double seconds);
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r228304 r228416  
    25972597}
    25982598
     2599void TestController::setStatisticsSubresourceUniqueRedirectFrom(WKStringRef host, WKStringRef hostRedirectedFrom)
     2600{
     2601    auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
     2602    WKWebsiteDataStoreSetStatisticsSubresourceUniqueRedirectFrom(dataStore, host, hostRedirectedFrom);
     2603}
     2604
     2605void TestController::setStatisticsTopFrameUniqueRedirectTo(WKStringRef host, WKStringRef hostRedirectedTo)
     2606{
     2607    auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
     2608    WKWebsiteDataStoreSetStatisticsTopFrameUniqueRedirectTo(dataStore, host, hostRedirectedTo);
     2609}
     2610
     2611void TestController::setStatisticsTopFrameUniqueRedirectFrom(WKStringRef host, WKStringRef hostRedirectedFrom)
     2612{
     2613    auto* dataStore = WKContextGetWebsiteDataStore(platformContext());
     2614    WKWebsiteDataStoreSetStatisticsTopFrameUniqueRedirectFrom(dataStore, host, hostRedirectedFrom);
     2615}
     2616
    25992617void TestController::setStatisticsTimeToLiveUserInteraction(double seconds)
    26002618{
  • trunk/Tools/WebKitTestRunner/TestController.h

    r228304 r228416  
    167167    void setStatisticsSubresourceUnderTopFrameOrigin(WKStringRef hostName, WKStringRef topFrameHostName);
    168168    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);
    169172    void setStatisticsTimeToLiveUserInteraction(double seconds);
    170173    void setStatisticsTimeToLiveCookiePartitionFree(double seconds);
  • trunk/Tools/WebKitTestRunner/TestInvocation.cpp

    r228109 r228416  
    11081108    }
    11091109
     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   
    11101152    if (WKStringIsEqualToUTF8CString(messageName, "SetStatisticsTimeToLiveUserInteraction")) {
    11111153        ASSERT(WKGetTypeID(messageBody) == WKDoubleGetTypeID());
Note: See TracChangeset for help on using the changeset viewer.