Changeset 228495 in webkit


Ignore:
Timestamp:
Feb 14, 2018 4:52:29 PM (6 years ago)
Author:
wilander@apple.com
Message:

Resource Load Statistics: Make sure WebResourceLoadStatisticsStore::mergeWithDataFromDecoder() can ingest older plist versions and not reset the database
https://bugs.webkit.org/show_bug.cgi?id=182812
<rdar://problem/37511406>

Reviewed by Brent Fulgham.

Source/WebCore:

No new tests. Tested manually between versions of Safari.

  • loader/ResourceLoadStatistics.cpp:

(WebCore::ResourceLoadStatistics::decode):

Now only expects these fields for model version 11 or higher:

  • topFrameUniqueRedirectsTo
  • topFrameUniqueRedirectsFrom
  • subresourceUniqueRedirectsFrom
  • timesAccessedAsFirstPartyDueToUserInteraction
  • timesAccessedAsFirstPartyDueToStorageAccessAPI
  • loader/ResourceLoadStatistics.h:

Source/WebKit:

  • UIProcess/WebResourceLoadStatisticsStore.cpp:

(WebKit::WebResourceLoadStatisticsStore::mergeWithDataFromDecoder):

Now does the following:

  • Logs when there is a model version mismatch.
  • Does not ingest statistics if the version on disk is newer than the supported one.
  • Does ingest statistics if the version on disk is older than the supported one.
  • Passes on the version found on disk to WebCore::ResourceLoadStatistics::decode().
Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r228494 r228495  
     12018-02-14  John Wilander  <wilander@apple.com>
     2
     3        Resource Load Statistics: Make sure WebResourceLoadStatisticsStore::mergeWithDataFromDecoder() can ingest older plist versions and not reset the database
     4        https://bugs.webkit.org/show_bug.cgi?id=182812
     5        <rdar://problem/37511406>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        No new tests. Tested manually between versions of Safari.
     10
     11        * loader/ResourceLoadStatistics.cpp:
     12        (WebCore::ResourceLoadStatistics::decode):
     13            Now only expects these fields for model version 11 or higher:
     14            - topFrameUniqueRedirectsTo
     15            - topFrameUniqueRedirectsFrom
     16            - subresourceUniqueRedirectsFrom
     17            - timesAccessedAsFirstPartyDueToUserInteraction
     18            - timesAccessedAsFirstPartyDueToStorageAccessAPI
     19        * loader/ResourceLoadStatistics.h:
     20
    1212018-02-14  Basuke Suzuki  <Basuke.Suzuki@sony.com>
    222
  • trunk/Source/WebCore/loader/ResourceLoadStatistics.cpp

    r228416 r228495  
    119119}
    120120
    121 bool ResourceLoadStatistics::decode(KeyedDecoder& decoder)
     121bool ResourceLoadStatistics::decode(KeyedDecoder& decoder, unsigned modelVersion)
    122122{
    123123    if (!decoder.decodeString("PrevalentResourceOrigin", highLevelDomain))
     
    132132
    133133    // Top frame stats
    134     decodeHashCountedSet(decoder, "topFrameUniqueRedirectsTo", topFrameUniqueRedirectsTo);
    135     decodeHashCountedSet(decoder, "topFrameUniqueRedirectsFrom", topFrameUniqueRedirectsFrom);
     134    if (modelVersion >= 11) {
     135        decodeHashCountedSet(decoder, "topFrameUniqueRedirectsTo", topFrameUniqueRedirectsTo);
     136        decodeHashCountedSet(decoder, "topFrameUniqueRedirectsFrom", topFrameUniqueRedirectsFrom);
     137    }
    136138
    137139    // Subframe stats
     
    141143    decodeHashCountedSet(decoder, "subresourceUnderTopFrameOrigins", subresourceUnderTopFrameOrigins);
    142144    decodeHashCountedSet(decoder, "subresourceUniqueRedirectsTo", subresourceUniqueRedirectsTo);
    143     decodeHashCountedSet(decoder, "subresourceUniqueRedirectsFrom", subresourceUniqueRedirectsFrom);
     145    if (modelVersion >= 11)
     146        decodeHashCountedSet(decoder, "subresourceUniqueRedirectsFrom", subresourceUniqueRedirectsFrom);
    144147
    145148    // Prevalent Resource
     
    163166    lastSeen = WallTime::fromRawSeconds(lastSeenTimeAsDouble);
    164167
    165     if (!decoder.decodeUInt32("timesAccessedAsFirstPartyDueToUserInteraction", timesAccessedAsFirstPartyDueToUserInteraction))
    166         timesAccessedAsFirstPartyDueToUserInteraction = 0;
    167     if (!decoder.decodeUInt32("timesAccessedAsFirstPartyDueToStorageAccessAPI", timesAccessedAsFirstPartyDueToStorageAccessAPI))
    168         timesAccessedAsFirstPartyDueToStorageAccessAPI = 0;
    169 
     168    if (modelVersion >= 11) {
     169        if (!decoder.decodeUInt32("timesAccessedAsFirstPartyDueToUserInteraction", timesAccessedAsFirstPartyDueToUserInteraction))
     170            timesAccessedAsFirstPartyDueToUserInteraction = 0;
     171        if (!decoder.decodeUInt32("timesAccessedAsFirstPartyDueToStorageAccessAPI", timesAccessedAsFirstPartyDueToStorageAccessAPI))
     172            timesAccessedAsFirstPartyDueToStorageAccessAPI = 0;
     173    }
    170174    return true;
    171175}
  • trunk/Source/WebCore/loader/ResourceLoadStatistics.h

    r228416 r228495  
    5555
    5656    WEBCORE_EXPORT void encode(KeyedEncoder&) const;
    57     WEBCORE_EXPORT bool decode(KeyedDecoder&);
     57    WEBCORE_EXPORT bool decode(KeyedDecoder&, unsigned modelVersion);
    5858
    5959    String toString() const;
  • trunk/Source/WebKit/ChangeLog

    r228486 r228495  
     12018-02-14  John Wilander  <wilander@apple.com>
     2
     3        Resource Load Statistics: Make sure WebResourceLoadStatisticsStore::mergeWithDataFromDecoder() can ingest older plist versions and not reset the database
     4        https://bugs.webkit.org/show_bug.cgi?id=182812
     5        <rdar://problem/37511406>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        * UIProcess/WebResourceLoadStatisticsStore.cpp:
     10        (WebKit::WebResourceLoadStatisticsStore::mergeWithDataFromDecoder):
     11            Now does the following:
     12            - Logs when there is a model version mismatch.
     13            - Does not ingest statistics if the version on disk is newer than the supported one.
     14            - Does ingest statistics if the version on disk is older than the supported one.
     15            - Passes on the version found on disk to WebCore::ResourceLoadStatistics::decode().
     16
    1172018-02-14  Daniel Bates  <dabates@apple.com>
    218
  • trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp

    r228416 r228495  
    804804        return;
    805805
    806     if (versionOnDisk != statisticsModelVersion)
    807         return;
     806    if (versionOnDisk > statisticsModelVersion) {
     807        WTFLogAlways("Found resource load statistics on disk with model version %u whereas the highest supported version is %u. Resetting.", versionOnDisk, statisticsModelVersion);
     808        return;
     809    }
     810
     811    if (versionOnDisk < statisticsModelVersion)
     812        WTFLogAlways("Found resource load statistics on disk with model version %u and the current version is %u. Ingesting old statistics.", versionOnDisk, statisticsModelVersion);
    808813
    809814    double endOfGrandfatheringTimestamp;
     
    814819
    815820    Vector<ResourceLoadStatistics> loadedStatistics;
    816     bool succeeded = decoder.decodeObjects("browsingStatistics", loadedStatistics, [](KeyedDecoder& decoderInner, ResourceLoadStatistics& statistics) {
    817         return statistics.decode(decoderInner);
     821    bool succeeded = decoder.decodeObjects("browsingStatistics", loadedStatistics, [versionOnDisk](KeyedDecoder& decoderInner, ResourceLoadStatistics& statistics) {
     822        return statistics.decode(decoderInner, versionOnDisk);
    818823    });
    819824
Note: See TracChangeset for help on using the changeset viewer.