ResourceLoadStatistics.h [plain text]
#pragma once
#include "CanvasActivityRecord.h"
#include "RegistrableDomain.h"
#include <wtf/HashCountedSet.h>
#include <wtf/HashSet.h>
#include <wtf/OptionSet.h>
#include <wtf/URL.h>
#include <wtf/WallTime.h>
#include <wtf/text/StringHash.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class KeyedDecoder;
class KeyedEncoder;
struct ResourceLoadStatistics {
explicit ResourceLoadStatistics(const RegistrableDomain& domain)
: registrableDomain { domain }
{
}
ResourceLoadStatistics() = default;
ResourceLoadStatistics(const ResourceLoadStatistics&) = delete;
ResourceLoadStatistics& operator=(const ResourceLoadStatistics&) = delete;
ResourceLoadStatistics(ResourceLoadStatistics&&) = default;
ResourceLoadStatistics& operator=(ResourceLoadStatistics&&) = default;
static constexpr Seconds NoExistingTimestamp { -1 };
WEBCORE_EXPORT static WallTime reduceTimeResolution(WallTime);
WEBCORE_EXPORT void encode(KeyedEncoder&) const;
WEBCORE_EXPORT bool decode(KeyedDecoder&, unsigned modelVersion);
WEBCORE_EXPORT String toString() const;
WEBCORE_EXPORT void merge(const ResourceLoadStatistics&);
RegistrableDomain registrableDomain;
WallTime lastSeen;
bool hadUserInteraction { false };
WallTime mostRecentUserInteractionTime { WallTime::fromRawSeconds(-1) };
bool grandfathered { false };
HashSet<RegistrableDomain> storageAccessUnderTopFrameDomains;
HashSet<RegistrableDomain> topFrameUniqueRedirectsTo;
HashSet<RegistrableDomain> topFrameUniqueRedirectsToSinceSameSiteStrictEnforcement;
HashSet<RegistrableDomain> topFrameUniqueRedirectsFrom;
HashSet<RegistrableDomain> topFrameLinkDecorationsFrom;
bool gotLinkDecorationFromPrevalentResource { false };
HashSet<RegistrableDomain> topFrameLoadedThirdPartyScripts;
HashSet<RegistrableDomain> subframeUnderTopFrameDomains;
HashSet<RegistrableDomain> subresourceUnderTopFrameDomains;
HashSet<RegistrableDomain> subresourceUniqueRedirectsTo;
HashSet<RegistrableDomain> subresourceUniqueRedirectsFrom;
bool isPrevalentResource { false };
bool isVeryPrevalentResource { false };
unsigned dataRecordsRemoved { 0 };
unsigned timesAccessedAsFirstPartyDueToUserInteraction { 0 };
unsigned timesAccessedAsFirstPartyDueToStorageAccessAPI { 0 };
enum class IsEphemeral : bool { No, Yes };
enum class NavigatorAPI : uint64_t {
AppVersion = 1 << 0,
UserAgent = 1 << 1,
Plugins = 1 << 2,
MimeTypes = 1 << 3,
CookieEnabled = 1 << 4,
JavaEnabled = 1 << 5,
};
enum class ScreenAPI : uint64_t {
Height = 1 << 0,
Width = 1 << 1,
ColorDepth = 1 << 2,
PixelDepth = 1 << 3,
AvailLeft = 1 << 4,
AvailTop = 1 << 5,
AvailHeight = 1 << 6,
AvailWidth = 1 << 7,
};
#if ENABLE(WEB_API_STATISTICS)
HashSet<RegistrableDomain> topFrameRegistrableDomainsWhichAccessedWebAPIs;
HashSet<String> fontsFailedToLoad;
HashSet<String> fontsSuccessfullyLoaded;
CanvasActivityRecord canvasActivityRecord;
OptionSet<NavigatorAPI> navigatorFunctionsAccessed;
OptionSet<ScreenAPI> screenFunctionsAccessed;
#endif
};
}
namespace WTF {
template<> struct EnumTraits<WebCore::ResourceLoadStatistics::NavigatorAPI> {
using values = EnumValues<
WebCore::ResourceLoadStatistics::NavigatorAPI,
WebCore::ResourceLoadStatistics::NavigatorAPI::AppVersion,
WebCore::ResourceLoadStatistics::NavigatorAPI::UserAgent,
WebCore::ResourceLoadStatistics::NavigatorAPI::Plugins,
WebCore::ResourceLoadStatistics::NavigatorAPI::MimeTypes,
WebCore::ResourceLoadStatistics::NavigatorAPI::CookieEnabled,
WebCore::ResourceLoadStatistics::NavigatorAPI::JavaEnabled
>;
};
template<> struct EnumTraits<WebCore::ResourceLoadStatistics::ScreenAPI> {
using values = EnumValues<
WebCore::ResourceLoadStatistics::ScreenAPI,
WebCore::ResourceLoadStatistics::ScreenAPI::Height,
WebCore::ResourceLoadStatistics::ScreenAPI::Width,
WebCore::ResourceLoadStatistics::ScreenAPI::ColorDepth,
WebCore::ResourceLoadStatistics::ScreenAPI::PixelDepth,
WebCore::ResourceLoadStatistics::ScreenAPI::AvailLeft,
WebCore::ResourceLoadStatistics::ScreenAPI::AvailTop,
WebCore::ResourceLoadStatistics::ScreenAPI::AvailHeight,
WebCore::ResourceLoadStatistics::ScreenAPI::AvailWidth
>;
};
}