- Revision
- 228532
- Author
- [email protected]
- Date
- 2018-02-15 13:50:14 -0800 (Thu, 15 Feb 2018)
Log 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().
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (228531 => 228532)
--- trunk/Source/WebCore/ChangeLog 2018-02-15 21:08:45 UTC (rev 228531)
+++ trunk/Source/WebCore/ChangeLog 2018-02-15 21:50:14 UTC (rev 228532)
@@ -1,3 +1,23 @@
+2018-02-15 John Wilander <[email protected]>
+
+ 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.
+
+ 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:
+
2018-02-15 Tim Horton <[email protected]>
Stop using EXCLUDED_SOURCE_FILE_NAMES for actual source files in WebCore
Modified: trunk/Source/WebCore/loader/ResourceLoadStatistics.cpp (228531 => 228532)
--- trunk/Source/WebCore/loader/ResourceLoadStatistics.cpp 2018-02-15 21:08:45 UTC (rev 228531)
+++ trunk/Source/WebCore/loader/ResourceLoadStatistics.cpp 2018-02-15 21:50:14 UTC (rev 228532)
@@ -118,7 +118,7 @@
});
}
-bool ResourceLoadStatistics::decode(KeyedDecoder& decoder)
+bool ResourceLoadStatistics::decode(KeyedDecoder& decoder, unsigned modelVersion)
{
if (!decoder.decodeString("PrevalentResourceOrigin", highLevelDomain))
return false;
@@ -131,8 +131,10 @@
decodeHashSet(decoder, "storageAccessUnderTopFrameOrigins", storageAccessUnderTopFrameOrigins);
// Top frame stats
- decodeHashCountedSet(decoder, "topFrameUniqueRedirectsTo", topFrameUniqueRedirectsTo);
- decodeHashCountedSet(decoder, "topFrameUniqueRedirectsFrom", topFrameUniqueRedirectsFrom);
+ if (modelVersion >= 11) {
+ decodeHashCountedSet(decoder, "topFrameUniqueRedirectsTo", topFrameUniqueRedirectsTo);
+ decodeHashCountedSet(decoder, "topFrameUniqueRedirectsFrom", topFrameUniqueRedirectsFrom);
+ }
// Subframe stats
decodeHashCountedSet(decoder, "subframeUnderTopFrameOrigins", subframeUnderTopFrameOrigins);
@@ -140,7 +142,8 @@
// Subresource stats
decodeHashCountedSet(decoder, "subresourceUnderTopFrameOrigins", subresourceUnderTopFrameOrigins);
decodeHashCountedSet(decoder, "subresourceUniqueRedirectsTo", subresourceUniqueRedirectsTo);
- decodeHashCountedSet(decoder, "subresourceUniqueRedirectsFrom", subresourceUniqueRedirectsFrom);
+ if (modelVersion >= 11)
+ decodeHashCountedSet(decoder, "subresourceUniqueRedirectsFrom", subresourceUniqueRedirectsFrom);
// Prevalent Resource
if (!decoder.decodeBool("isPrevalentResource", isPrevalentResource))
@@ -162,11 +165,12 @@
return false;
lastSeen = WallTime::fromRawSeconds(lastSeenTimeAsDouble);
- if (!decoder.decodeUInt32("timesAccessedAsFirstPartyDueToUserInteraction", timesAccessedAsFirstPartyDueToUserInteraction))
- timesAccessedAsFirstPartyDueToUserInteraction = 0;
- if (!decoder.decodeUInt32("timesAccessedAsFirstPartyDueToStorageAccessAPI", timesAccessedAsFirstPartyDueToStorageAccessAPI))
- timesAccessedAsFirstPartyDueToStorageAccessAPI = 0;
-
+ if (modelVersion >= 11) {
+ if (!decoder.decodeUInt32("timesAccessedAsFirstPartyDueToUserInteraction", timesAccessedAsFirstPartyDueToUserInteraction))
+ timesAccessedAsFirstPartyDueToUserInteraction = 0;
+ if (!decoder.decodeUInt32("timesAccessedAsFirstPartyDueToStorageAccessAPI", timesAccessedAsFirstPartyDueToStorageAccessAPI))
+ timesAccessedAsFirstPartyDueToStorageAccessAPI = 0;
+ }
return true;
}
Modified: trunk/Source/WebCore/loader/ResourceLoadStatistics.h (228531 => 228532)
--- trunk/Source/WebCore/loader/ResourceLoadStatistics.h 2018-02-15 21:08:45 UTC (rev 228531)
+++ trunk/Source/WebCore/loader/ResourceLoadStatistics.h 2018-02-15 21:50:14 UTC (rev 228532)
@@ -54,7 +54,7 @@
WEBCORE_EXPORT static String primaryDomain(const String& host);
WEBCORE_EXPORT void encode(KeyedEncoder&) const;
- WEBCORE_EXPORT bool decode(KeyedDecoder&);
+ WEBCORE_EXPORT bool decode(KeyedDecoder&, unsigned modelVersion);
String toString() const;
Modified: trunk/Source/WebKit/ChangeLog (228531 => 228532)
--- trunk/Source/WebKit/ChangeLog 2018-02-15 21:08:45 UTC (rev 228531)
+++ trunk/Source/WebKit/ChangeLog 2018-02-15 21:50:14 UTC (rev 228532)
@@ -1,3 +1,19 @@
+2018-02-15 John Wilander <[email protected]>
+
+ 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.
+
+ * 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().
+
2018-02-15 Jiewen Tan <[email protected]>
[WebAuthN] Revisit the whole async model of task dispatching, timeout and aborting
Modified: trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp (228531 => 228532)
--- trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp 2018-02-15 21:08:45 UTC (rev 228531)
+++ trunk/Source/WebKit/UIProcess/WebResourceLoadStatisticsStore.cpp 2018-02-15 21:50:14 UTC (rev 228532)
@@ -803,8 +803,10 @@
if (!decoder.decodeUInt32("version", versionOnDisk))
return;
- if (versionOnDisk != statisticsModelVersion)
+ if (versionOnDisk > statisticsModelVersion) {
+ WTFLogAlways("Found resource load statistics on disk with model version %u whereas the highest supported version is %u. Resetting.", versionOnDisk, statisticsModelVersion);
return;
+ }
double endOfGrandfatheringTimestamp;
if (decoder.decodeDouble("endOfGrandfatheringTimestamp", endOfGrandfatheringTimestamp))
@@ -813,8 +815,8 @@
m_endOfGrandfatheringTimestamp = { };
Vector<ResourceLoadStatistics> loadedStatistics;
- bool succeeded = decoder.decodeObjects("browsingStatistics", loadedStatistics, [](KeyedDecoder& decoderInner, ResourceLoadStatistics& statistics) {
- return statistics.decode(decoderInner);
+ bool succeeded = decoder.decodeObjects("browsingStatistics", loadedStatistics, [versionOnDisk](KeyedDecoder& decoderInner, ResourceLoadStatistics& statistics) {
+ return statistics.decode(decoderInner, versionOnDisk);
});
if (!succeeded)