#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/policy/core/common/cloud/resource_cache.h"
#include "base/base64url.h"
#include "base/files/file_enumerator.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
#include "base/task/sequenced_task_runner.h"
namespace policy {
namespace {
bool Base64UrlEncode(const std::set<std::string>& input,
std::set<std::string>* output) { … }
}
ResourceCache::ResourceCache(
const base::FilePath& cache_dir,
scoped_refptr<base::SequencedTaskRunner> task_runner,
std::optional<int64_t> max_cache_size)
: … { … }
ResourceCache::~ResourceCache() { … }
base::FilePath ResourceCache::Store(const std::string& key,
const std::string& subkey,
const std::string& data) { … }
base::FilePath ResourceCache::Load(const std::string& key,
const std::string& subkey,
std::string* data) { … }
void ResourceCache::LoadAllSubkeys(
const std::string& key,
std::map<std::string, std::string>* contents) { … }
void ResourceCache::Delete(const std::string& key, const std::string& subkey) { … }
void ResourceCache::Clear(const std::string& key) { … }
void ResourceCache::FilterSubkeys(const std::string& key,
const SubkeyFilter& test) { … }
void ResourceCache::PurgeOtherKeys(const std::set<std::string>& keys_to_keep) { … }
void ResourceCache::PurgeOtherSubkeys(
const std::string& key,
const std::set<std::string>& subkeys_to_keep) { … }
bool ResourceCache::VerifyKeyPath(const std::string& key,
bool allow_create,
base::FilePath* path) { … }
bool ResourceCache::VerifyKeyPathAndGetSubkeyPath(const std::string& key,
bool allow_create_key,
const std::string& subkey,
base::FilePath* path) { … }
void ResourceCache::InitCurrentCacheSize() { … }
bool ResourceCache::WriteCacheFile(const base::FilePath& path,
const std::string& data) { … }
bool ResourceCache::DeleteCacheFile(const base::FilePath& path,
bool recursive) { … }
int64_t ResourceCache::GetCacheDirectoryOrFileSize(
const base::FilePath& path) const { … }
}