Modified: trunk/Source/WebCore/loader/ResourceLoadStatistics.cpp (233319 => 233320)
--- trunk/Source/WebCore/loader/ResourceLoadStatistics.cpp 2018-06-28 20:09:21 UTC (rev 233319)
+++ trunk/Source/WebCore/loader/ResourceLoadStatistics.cpp 2018-06-28 20:17:34 UTC (rev 233320)
@@ -40,6 +40,9 @@
static void encodeHashCountedSet(KeyedEncoder& encoder, const String& label, const HashCountedSet<String>& hashCountedSet)
{
+ if (hashCountedSet.isEmpty())
+ return;
+
encoder.encodeObjects(label, hashCountedSet.begin(), hashCountedSet.end(), [](KeyedEncoder& encoderInner, const ResourceLoadStatisticsValue& origin) {
encoderInner.encodeString("origin", origin.key);
encoderInner.encodeUInt32("count", origin.value);
@@ -48,6 +51,9 @@
static void encodeHashSet(KeyedEncoder& encoder, const String& label, const HashSet<String>& hashSet)
{
+ if (hashSet.isEmpty())
+ return;
+
encoder.encodeObjects(label, hashSet.begin(), hashSet.end(), [](KeyedEncoder& encoderInner, const String& origin) {
encoderInner.encodeString("origin", origin);
});
@@ -88,10 +94,10 @@
encoder.encodeUInt32("timesAccessedAsFirstPartyDueToStorageAccessAPI", timesAccessedAsFirstPartyDueToStorageAccessAPI);
}
-static bool decodeHashCountedSet(KeyedDecoder& decoder, const String& label, HashCountedSet<String>& hashCountedSet)
+static void decodeHashCountedSet(KeyedDecoder& decoder, const String& label, HashCountedSet<String>& hashCountedSet)
{
Vector<String> ignore;
- return decoder.decodeObjects(label, ignore, [&hashCountedSet](KeyedDecoder& decoderInner, String& origin) {
+ decoder.decodeObjects(label, ignore, [&hashCountedSet](KeyedDecoder& decoderInner, String& origin) {
if (!decoderInner.decodeString("origin", origin))
return false;
@@ -104,17 +110,16 @@
});
}
-static bool decodeHashSet(KeyedDecoder& decoder, const String& label, HashSet<String>& hashSet)
+static void decodeHashSet(KeyedDecoder& decoder, const String& label, HashSet<String>& hashSet)
{
- Vector<String> origins;
- bool success = decoder.decodeObjects(label, origins, [](KeyedDecoder& decoderInner, String& origin) {
- return decoderInner.decodeString("origin", origin);
+ Vector<String> ignore;
+ decoder.decodeObjects(label, ignore, [&hashSet](KeyedDecoder& decoderInner, String& origin) {
+ if (!decoderInner.decodeString("origin", origin))
+ return false;
+
+ hashSet.add(origin);
+ return true;
});
- if (!success)
- return false;
-
- hashSet.add(origins.begin(), origins.end());
- return true;
}
bool ResourceLoadStatistics::decode(KeyedDecoder& decoder, unsigned modelVersion)
@@ -127,34 +132,23 @@
return false;
// Storage access
- if (!decodeHashSet(decoder, "storageAccessUnderTopFrameOrigins", storageAccessUnderTopFrameOrigins))
- return false;
+ decodeHashSet(decoder, "storageAccessUnderTopFrameOrigins", storageAccessUnderTopFrameOrigins);
// Top frame stats
if (modelVersion >= 11) {
- if (!decodeHashCountedSet(decoder, "topFrameUniqueRedirectsTo", topFrameUniqueRedirectsTo))
- return false;
-
- if (!decodeHashCountedSet(decoder, "topFrameUniqueRedirectsFrom", topFrameUniqueRedirectsFrom))
- return false;
+ decodeHashCountedSet(decoder, "topFrameUniqueRedirectsTo", topFrameUniqueRedirectsTo);
+ decodeHashCountedSet(decoder, "topFrameUniqueRedirectsFrom", topFrameUniqueRedirectsFrom);
}
// Subframe stats
- if (!decodeHashCountedSet(decoder, "subframeUnderTopFrameOrigins", subframeUnderTopFrameOrigins))
- return false;
+ decodeHashCountedSet(decoder, "subframeUnderTopFrameOrigins", subframeUnderTopFrameOrigins);
// Subresource stats
- if (!decodeHashCountedSet(decoder, "subresourceUnderTopFrameOrigins", subresourceUnderTopFrameOrigins))
- return false;
+ decodeHashCountedSet(decoder, "subresourceUnderTopFrameOrigins", subresourceUnderTopFrameOrigins);
+ decodeHashCountedSet(decoder, "subresourceUniqueRedirectsTo", subresourceUniqueRedirectsTo);
+ if (modelVersion >= 11)
+ decodeHashCountedSet(decoder, "subresourceUniqueRedirectsFrom", subresourceUniqueRedirectsFrom);
- if (!decodeHashCountedSet(decoder, "subresourceUniqueRedirectsTo", subresourceUniqueRedirectsTo))
- return false;
-
- if (modelVersion >= 11) {
- if (!decodeHashCountedSet(decoder, "subresourceUniqueRedirectsFrom", subresourceUniqueRedirectsFrom))
- return false;
- }
-
// Prevalent Resource
if (!decoder.decodeBool("isPrevalentResource", isPrevalentResource))
return false;