#include "components/paint_preview/browser/file_manager.h"
#include <algorithm>
#include <vector>
#include "base/files/file_enumerator.h"
#include "base/files/file_util.h"
#include "base/hash/hash.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/sequenced_task_runner.h"
#include "components/paint_preview/common/file_utils.h"
#include "components/paint_preview/common/proto_validator.h"
#include "third_party/zlib/google/zip.h"
namespace paint_preview {
namespace {
constexpr char kProtoName[] = …;
constexpr char kZipExt[] = …;
}
FileManager::FileManager(
const base::FilePath& root_directory,
scoped_refptr<base::SequencedTaskRunner> io_task_runner)
: … { … }
FileManager::~FileManager() = default;
DirectoryKey FileManager::CreateKey(const GURL& url) const { … }
DirectoryKey FileManager::CreateKey(uint64_t tab_id) const { … }
size_t FileManager::GetSizeOfArtifacts(const DirectoryKey& key) const { … }
std::optional<base::File::Info> FileManager::GetInfo(
const DirectoryKey& key) const { … }
size_t FileManager::GetTotalDiskUsage() const { … }
bool FileManager::DirectoryExists(const DirectoryKey& key) const { … }
bool FileManager::CaptureExists(const DirectoryKey& key) const { … }
std::optional<base::FilePath> FileManager::CreateOrGetDirectory(
const DirectoryKey& key,
bool clear) const { … }
bool FileManager::CompressDirectory(const DirectoryKey& key) const { … }
void FileManager::DeleteArtifactSet(const DirectoryKey& key) const { … }
void FileManager::DeleteArtifactSets(
const std::vector<DirectoryKey>& keys) const { … }
void FileManager::DeleteAll() const { … }
bool FileManager::SerializePaintPreviewProto(const DirectoryKey& key,
const PaintPreviewProto& proto,
bool compress) const { … }
std::pair<FileManager::ProtoReadStatus, std::unique_ptr<PaintPreviewProto>>
FileManager::DeserializePaintPreviewProto(const DirectoryKey& key) const { … }
base::flat_set<DirectoryKey> FileManager::ListUsedKeys() const { … }
FileManager::StorageType FileManager::GetPathForKey(
const DirectoryKey& key,
base::FilePath* path) const { … }
}