#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "net/disk_cache/blockfile/entry_impl.h"
#include <limits>
#include <memory>
#include "base/files/file_util.h"
#include "base/hash/hash.h"
#include "base/numerics/safe_math.h"
#include "base/strings/string_util.h"
#include "base/time/time.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
#include "net/disk_cache/blockfile/backend_impl.h"
#include "net/disk_cache/blockfile/bitmap.h"
#include "net/disk_cache/blockfile/disk_format.h"
#include "net/disk_cache/blockfile/sparse_control.h"
#include "net/disk_cache/cache_util.h"
#include "net/disk_cache/net_log_parameters.h"
#include "net/log/net_log.h"
#include "net/log/net_log_event_type.h"
#include "net/log/net_log_source_type.h"
Time;
TimeTicks;
namespace {
const int kKeyFileIndex = …;
class SyncCallback: public disk_cache::FileIOCallback { … };
void SyncCallback::OnFileIOComplete(int bytes_copied) { … }
void SyncCallback::Discard() { … }
const int kMaxBufferSize = …;
}
namespace disk_cache {
class EntryImpl::UserBuffer { … };
bool EntryImpl::UserBuffer::PreWrite(int offset, int len) { … }
void EntryImpl::UserBuffer::Truncate(int offset) { … }
void EntryImpl::UserBuffer::Write(int offset, IOBuffer* buf, int len) { … }
bool EntryImpl::UserBuffer::PreRead(int eof, int offset, int* len) { … }
int EntryImpl::UserBuffer::Read(int offset, IOBuffer* buf, int len) { … }
void EntryImpl::UserBuffer::Reset() { … }
bool EntryImpl::UserBuffer::GrowBuffer(int required, int limit) { … }
EntryImpl::EntryImpl(BackendImpl* backend, Addr address, bool read_only)
: … { … }
void EntryImpl::DoomImpl() { … }
int EntryImpl::ReadDataImpl(int index,
int offset,
IOBuffer* buf,
int buf_len,
CompletionOnceCallback callback) { … }
int EntryImpl::WriteDataImpl(int index,
int offset,
IOBuffer* buf,
int buf_len,
CompletionOnceCallback callback,
bool truncate) { … }
int EntryImpl::ReadSparseDataImpl(int64_t offset,
IOBuffer* buf,
int buf_len,
CompletionOnceCallback callback) { … }
int EntryImpl::WriteSparseDataImpl(int64_t offset,
IOBuffer* buf,
int buf_len,
CompletionOnceCallback callback) { … }
RangeResult EntryImpl::GetAvailableRangeImpl(int64_t offset, int len) { … }
void EntryImpl::CancelSparseIOImpl() { … }
int EntryImpl::ReadyForSparseIOImpl(CompletionOnceCallback callback) { … }
uint32_t EntryImpl::GetHash() { … }
bool EntryImpl::CreateEntry(Addr node_address,
const std::string& key,
uint32_t hash) { … }
bool EntryImpl::IsSameEntry(const std::string& key, uint32_t hash) { … }
void EntryImpl::InternalDoom() { … }
void EntryImpl::DeleteEntryData(bool everything) { … }
CacheAddr EntryImpl::GetNextAddress() { … }
void EntryImpl::SetNextAddress(Addr address) { … }
bool EntryImpl::LoadNodeAddress() { … }
bool EntryImpl::Update() { … }
void EntryImpl::SetDirtyFlag(int32_t current_id) { … }
void EntryImpl::SetPointerForInvalidEntry(int32_t new_id) { … }
bool EntryImpl::LeaveRankingsBehind() { … }
bool EntryImpl::SanityCheck() { … }
bool EntryImpl::DataSanityCheck() { … }
void EntryImpl::FixForDelete() { … }
void EntryImpl::IncrementIoCount() { … }
void EntryImpl::DecrementIoCount() { … }
void EntryImpl::OnEntryCreated(BackendImpl* backend) { … }
void EntryImpl::SetTimes(base::Time last_used, base::Time last_modified) { … }
void EntryImpl::BeginLogging(net::NetLog* net_log, bool created) { … }
const net::NetLogWithSource& EntryImpl::net_log() const { … }
int EntryImpl::NumBlocksForEntry(int key_size) { … }
void EntryImpl::Doom() { … }
void EntryImpl::Close() { … }
std::string EntryImpl::GetKey() const { … }
Time EntryImpl::GetLastUsed() const { … }
Time EntryImpl::GetLastModified() const { … }
int32_t EntryImpl::GetDataSize(int index) const { … }
int EntryImpl::ReadData(int index,
int offset,
IOBuffer* buf,
int buf_len,
CompletionOnceCallback callback) { … }
int EntryImpl::WriteData(int index,
int offset,
IOBuffer* buf,
int buf_len,
CompletionOnceCallback callback,
bool truncate) { … }
int EntryImpl::ReadSparseData(int64_t offset,
IOBuffer* buf,
int buf_len,
CompletionOnceCallback callback) { … }
int EntryImpl::WriteSparseData(int64_t offset,
IOBuffer* buf,
int buf_len,
CompletionOnceCallback callback) { … }
RangeResult EntryImpl::GetAvailableRange(int64_t offset,
int len,
RangeResultCallback callback) { … }
bool EntryImpl::CouldBeSparse() const { … }
void EntryImpl::CancelSparseIO() { … }
net::Error EntryImpl::ReadyForSparseIO(CompletionOnceCallback callback) { … }
void EntryImpl::SetLastUsedTimeForTest(base::Time time) { … }
EntryImpl::~EntryImpl() { … }
int EntryImpl::InternalReadData(int index,
int offset,
IOBuffer* buf,
int buf_len,
CompletionOnceCallback callback) { … }
int EntryImpl::InternalWriteData(int index,
int offset,
IOBuffer* buf,
int buf_len,
CompletionOnceCallback callback,
bool truncate) { … }
bool EntryImpl::CreateDataBlock(int index, int size) { … }
bool EntryImpl::CreateBlock(int size, Addr* address) { … }
void EntryImpl::DeleteData(Addr address, int index) { … }
void EntryImpl::UpdateRank(bool modified) { … }
File* EntryImpl::GetBackingFile(Addr address, int index) { … }
File* EntryImpl::GetExternalFile(Addr address, int index) { … }
bool EntryImpl::PrepareTarget(int index, int offset, int buf_len,
bool truncate) { … }
bool EntryImpl::HandleTruncation(int index, int offset, int buf_len) { … }
bool EntryImpl::CopyToLocalBuffer(int index) { … }
bool EntryImpl::MoveToLocalBuffer(int index) { … }
bool EntryImpl::ImportSeparateFile(int index, int new_size) { … }
bool EntryImpl::PrepareBuffer(int index, int offset, int buf_len) { … }
bool EntryImpl::Flush(int index, int min_len) { … }
void EntryImpl::UpdateSize(int index, int old_size, int new_size) { … }
int EntryImpl::InitSparseData() { … }
void EntryImpl::SetEntryFlags(uint32_t flags) { … }
uint32_t EntryImpl::GetEntryFlags() { … }
void EntryImpl::GetData(int index,
std::unique_ptr<char[]>* buffer,
Addr* address) { … }
}