#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "net/disk_cache/blockfile/rankings.h"
#include <stdint.h>
#include <limits>
#include <memory>
#include "base/memory/raw_ptr.h"
#include "base/process/process.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "net/base/net_export.h"
#include "net/disk_cache/blockfile/backend_impl.h"
#include "net/disk_cache/blockfile/disk_format.h"
#include "net/disk_cache/blockfile/entry_impl.h"
#include "net/disk_cache/blockfile/errors.h"
#include "net/disk_cache/blockfile/stress_support.h"
#if BUILDFLAG(IS_WIN)
#include <windows.h>
#endif
Time;
TimeTicks;
namespace disk_cache {
NET_EXPORT_PRIVATE RankCrashes g_rankings_crash = …;
}
namespace {
enum Operation { … };
class Transaction { … };
Transaction::Transaction(volatile disk_cache::LruData* data,
disk_cache::Addr addr, Operation op, int list)
: … { … }
Transaction::~Transaction() { … }
enum CrashLocation { … };
void GenerateCrash(CrashLocation location) { … }
void UpdateTimes(disk_cache::CacheRankingsBlock* node, bool modified) { … }
}
namespace disk_cache {
Rankings::ScopedRankingsBlock::ScopedRankingsBlock() : … { … }
Rankings::ScopedRankingsBlock::ScopedRankingsBlock(Rankings* rankings)
: … { … }
Rankings::ScopedRankingsBlock::ScopedRankingsBlock(Rankings* rankings,
CacheRankingsBlock* node)
: … { … }
Rankings::Iterator::Iterator() = default;
void Rankings::Iterator::Reset() { … }
Rankings::Rankings() = default;
Rankings::~Rankings() = default;
bool Rankings::Init(BackendImpl* backend, bool count_lists) { … }
void Rankings::Reset() { … }
void Rankings::Insert(CacheRankingsBlock* node, bool modified, List list) { … }
void Rankings::Remove(CacheRankingsBlock* node, List list, bool strict) { … }
void Rankings::UpdateRank(CacheRankingsBlock* node, bool modified, List list) { … }
CacheRankingsBlock* Rankings::GetNext(CacheRankingsBlock* node, List list) { … }
CacheRankingsBlock* Rankings::GetPrev(CacheRankingsBlock* node, List list) { … }
void Rankings::FreeRankingsBlock(CacheRankingsBlock* node) { … }
void Rankings::TrackRankingsBlock(CacheRankingsBlock* node,
bool start_tracking) { … }
int Rankings::SelfCheck() { … }
bool Rankings::SanityCheck(CacheRankingsBlock* node, bool from_list) const { … }
bool Rankings::DataSanityCheck(CacheRankingsBlock* node, bool from_list) const { … }
void Rankings::SetContents(CacheRankingsBlock* node, CacheAddr address) { … }
void Rankings::ReadHeads() { … }
void Rankings::ReadTails() { … }
void Rankings::WriteHead(List list) { … }
void Rankings::WriteTail(List list) { … }
bool Rankings::GetRanking(CacheRankingsBlock* rankings) { … }
void Rankings::ConvertToLongLived(CacheRankingsBlock* rankings) { … }
void Rankings::CompleteTransaction() { … }
void Rankings::FinishInsert(CacheRankingsBlock* node) { … }
void Rankings::RevertRemove(CacheRankingsBlock* node) { … }
bool Rankings::CheckLinks(CacheRankingsBlock* node, CacheRankingsBlock* prev,
CacheRankingsBlock* next, List* list) { … }
bool Rankings::CheckSingleLink(CacheRankingsBlock* prev,
CacheRankingsBlock* next) { … }
int Rankings::CheckList(List list) { … }
int Rankings::CheckListSection(List list, Addr end1, Addr end2, bool forward,
Addr* last, Addr* second_last, int* num_items) { … }
bool Rankings::IsHead(CacheAddr addr, List* list) const { … }
bool Rankings::IsTail(CacheAddr addr, List* list) const { … }
void Rankings::UpdateIterators(CacheRankingsBlock* node) { … }
void Rankings::UpdateIteratorsForRemoved(CacheAddr address,
CacheRankingsBlock* next) { … }
void Rankings::IncrementCounter(List list) { … }
void Rankings::DecrementCounter(List list) { … }
}