#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "net/tools/dump_cache/dump_files.h"
#include <stdio.h>
#include <memory>
#include <set>
#include <string>
#include "base/command_line.h"
#include "base/files/file.h"
#include "base/files/file_enumerator.h"
#include "base/files/file_util.h"
#include "base/format_macros.h"
#include "base/i18n/time_formatting.h"
#include "base/message_loop/message_pump_type.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/task/single_thread_task_executor.h"
#include "base/time/time.h"
#include "net/disk_cache/blockfile/block_files.h"
#include "net/disk_cache/blockfile/disk_format.h"
#include "net/disk_cache/blockfile/mapped_file.h"
#include "net/disk_cache/blockfile/stats.h"
#include "net/disk_cache/blockfile/storage_block-inl.h"
#include "net/disk_cache/blockfile/storage_block.h"
#include "net/url_request/view_cache_helper.h"
namespace {
const base::FilePath::CharType kIndexName[] = …);
bool ReadHeader(const base::FilePath& name, char* header, int header_size) { … }
int GetMajorVersionFromIndexFile(const base::FilePath& name) { … }
int GetMajorVersionFromBlockFile(const base::FilePath& name) { … }
void DumpStats(const base::FilePath& path, disk_cache::CacheAddr addr) { … }
void DumpIndexHeader(const base::FilePath& name,
disk_cache::CacheAddr* stats_addr) { … }
void DumpBlockHeader(const base::FilePath& name) { … }
class CacheDumper { … };
bool CacheDumper::Init() { … }
bool CacheDumper::GetEntry(disk_cache::EntryStore* entry,
disk_cache::CacheAddr* addr) { … }
bool CacheDumper::LoadEntry(disk_cache::CacheAddr addr,
disk_cache::EntryStore* entry) { … }
bool CacheDumper::LoadRankings(disk_cache::CacheAddr addr,
disk_cache::RankingsNode* rankings) { … }
bool CacheDumper::HexDump(disk_cache::CacheAddr addr, std::string* out) { … }
std::string ToLocalTime(int64_t time_us) { … }
void DumpEntry(disk_cache::CacheAddr addr,
const disk_cache::EntryStore& entry,
bool verbose) { … }
void DumpRankings(disk_cache::CacheAddr addr,
const disk_cache::RankingsNode& rankings,
bool verbose) { … }
void PrintCSVHeader() { … }
void DumpCSV(disk_cache::CacheAddr addr,
const disk_cache::EntryStore& entry,
const disk_cache::RankingsNode& rankings) { … }
bool CanDump(disk_cache::CacheAddr addr) { … }
}
bool CheckFileVersion(const base::FilePath& input_path) { … }
int DumpHeaders(const base::FilePath& input_path) { … }
int DumpContents(const base::FilePath& input_path) { … }
int DumpLists(const base::FilePath& input_path) { … }
int DumpEntryAt(const base::FilePath& input_path, const std::string& at) { … }
int DumpAllocation(const base::FilePath& file) { … }