ResourceLoadStatisticsPersistentStorage.h [plain text]
#pragma once
#include <wtf/Forward.h>
#include <wtf/MonotonicTime.h>
#include <wtf/RunLoop.h>
#include <wtf/WallTime.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
class FileMonitor;
}
namespace WebKit {
class WebResourceLoadStatisticsStore;
class ResourceLoadStatisticsPersistentStorage {
public:
ResourceLoadStatisticsPersistentStorage(WebResourceLoadStatisticsStore&, const String& storageDirectoryPath);
~ResourceLoadStatisticsPersistentStorage();
void initialize();
void clear();
void finishAllPendingWorkSynchronously();
void ref();
void deref();
enum class ForceImmediateWrite {
No,
Yes,
};
void scheduleOrWriteMemoryStore(ForceImmediateWrite);
private:
String storageDirectoryPath() const;
String resourceLogFilePath() const;
void startMonitoringDisk();
void stopMonitoringDisk();
void monitorDirectoryForNewStatistics();
void writeMemoryStoreToDisk();
void populateMemoryStoreFromDisk();
void excludeFromBackup() const;
void refreshMemoryStoreFromDisk();
void asyncWriteTimerFired();
WebResourceLoadStatisticsStore& m_memoryStore;
const String m_storageDirectoryPath;
RunLoop::Timer<ResourceLoadStatisticsPersistentStorage> m_asyncWriteTimer;
std::unique_ptr<WebCore::FileMonitor> m_fileMonitor;
WallTime m_lastStatisticsFileSyncTime;
MonotonicTime m_lastStatisticsWriteTime;
bool m_hasPendingWrite { false };
};
}