#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "net/disk_cache/blockfile/block_files.h"
#include <atomic>
#include <limits>
#include <memory>
#include <optional>
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/threading/thread_checker.h"
#include "base/time/time.h"
#include "net/disk_cache/blockfile/file_lock.h"
#include "net/disk_cache/blockfile/stress_support.h"
#include "net/disk_cache/cache_util.h"
TimeTicks;
namespace {
const char kBlockName[] = …;
const char s_types[16] = …;
inline int GetMapBlockType(uint32_t value) { … }
}
namespace disk_cache {
BlockHeader::BlockHeader() : … { … }
BlockHeader::BlockHeader(BlockFileHeader* header) : … { … }
BlockHeader::BlockHeader(MappedFile* file)
: … { … }
BlockHeader::BlockHeader(const BlockHeader& other) = default;
BlockHeader::~BlockHeader() = default;
bool BlockHeader::CreateMapBlock(int size, int* index) { … }
void BlockHeader::DeleteMapBlock(int index, int size) { … }
bool BlockHeader::UsedMapBlock(int index, int size) { … }
void BlockHeader::FixAllocationCounters() { … }
bool BlockHeader::NeedToGrowBlockFile(int block_count) const { … }
bool BlockHeader::CanAllocate(int block_count) const { … }
int BlockHeader::EmptyBlocks() const { … }
int BlockHeader::MinimumAllocations() const { … }
int BlockHeader::Capacity() const { … }
bool BlockHeader::ValidateCounters() const { … }
int BlockHeader::FileId() const { … }
int BlockHeader::NextFileId() const { … }
int BlockHeader::Size() const { … }
BlockFileHeader* BlockHeader::Header() { … }
BlockFiles::BlockFiles(const base::FilePath& path) : … { … }
BlockFiles::~BlockFiles() { … }
bool BlockFiles::Init(bool create_files) { … }
MappedFile* BlockFiles::GetFile(Addr address) { … }
bool BlockFiles::CreateBlock(FileType block_type, int block_count,
Addr* block_address) { … }
void BlockFiles::DeleteBlock(Addr address, bool deep) { … }
void BlockFiles::CloseFiles() { … }
bool BlockFiles::IsValid(Addr address) { … }
bool BlockFiles::CreateBlockFile(int index, FileType file_type, bool force) { … }
bool BlockFiles::OpenBlockFile(int index) { … }
bool BlockFiles::GrowBlockFile(MappedFile* file, BlockFileHeader* header) { … }
MappedFile* BlockFiles::FileForNewBlock(FileType block_type, int block_count) { … }
MappedFile* BlockFiles::NextFile(MappedFile* file) { … }
int16_t BlockFiles::CreateNextBlockFile(FileType block_type) { … }
bool BlockFiles::RemoveEmptyFile(FileType block_type) { … }
bool BlockFiles::FixBlockFileHeader(MappedFile* file) { … }
base::FilePath BlockFiles::Name(int index) { … }
}