ResourceLoadStatisticsStore.h [plain text]
#pragma once
#include "ResourceLoadStatistics.h"
namespace WebCore {
class KeyedDecoder;
class KeyedEncoder;
class URL;
struct ResourceLoadStatistics;
class ResourceLoadStatisticsStore : public RefCounted<ResourceLoadStatisticsStore> {
public:
WEBCORE_EXPORT static Ref<ResourceLoadStatisticsStore> create();
WEBCORE_EXPORT std::unique_ptr<KeyedEncoder> createEncoderFromData();
WEBCORE_EXPORT void readDataFromDecoder(KeyedDecoder&);
WEBCORE_EXPORT String statisticsForOrigin(const String&);
bool isEmpty() const { return m_resourceStatisticsMap.isEmpty(); }
size_t size() const { return m_resourceStatisticsMap.size(); }
void clear() { m_resourceStatisticsMap.clear(); }
ResourceLoadStatistics& ensureResourceStatisticsForPrimaryDomain(const String&);
void setResourceStatisticsForPrimaryDomain(const String&, ResourceLoadStatistics&&);
bool isPrevalentResource(const String&) const;
WEBCORE_EXPORT void mergeStatistics(const Vector<ResourceLoadStatistics>&);
WEBCORE_EXPORT Vector<ResourceLoadStatistics> takeStatistics();
WEBCORE_EXPORT void setNotificationCallback(std::function<void()> handler);
void fireDataModificationHandler();
WEBCORE_EXPORT void processStatistics(std::function<void(ResourceLoadStatistics&)>&&);
WEBCORE_EXPORT Vector<String> prevalentResourceDomainsWithoutUserInteraction();
WEBCORE_EXPORT void updateStatisticsForRemovedDataRecords(const Vector<String>& prevalentResourceDomains);
private:
ResourceLoadStatisticsStore() = default;
HashMap<String, ResourceLoadStatistics> m_resourceStatisticsMap;
std::function<void()> m_dataAddedHandler;
};
}