#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "net/disk_cache/memory/mem_entry_impl.h"
#include <algorithm>
#include <memory>
#include <utility>
#include "base/check_op.h"
#include "base/format_macros.h"
#include "base/functional/bind.h"
#include "base/metrics/histogram_macros.h"
#include "base/numerics/safe_math.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "net/base/interval.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
#include "net/disk_cache/memory/mem_backend_impl.h"
#include "net/disk_cache/net_log_parameters.h"
#include "net/log/net_log_event_type.h"
#include "net/log/net_log_source_type.h"
Time;
namespace disk_cache {
namespace {
const int kSparseData = …;
const int kMaxChildEntryBits = …;
const int kMaxChildEntrySize = …;
int64_t ToChildIndex(int64_t offset) { … }
int ToChildOffset(int64_t offset) { … }
std::string GenerateChildName(const std::string& base_name, int64_t child_id) { … }
base::Value::Dict NetLogEntryCreationParams(const MemEntryImpl* entry) { … }
}
MemEntryImpl::MemEntryImpl(base::WeakPtr<MemBackendImpl> backend,
const std::string& key,
net::NetLog* net_log)
: … { … }
MemEntryImpl::MemEntryImpl(base::WeakPtr<MemBackendImpl> backend,
int64_t child_id,
MemEntryImpl* parent,
net::NetLog* net_log)
: … { … }
void MemEntryImpl::Open() { … }
bool MemEntryImpl::InUse() const { … }
int MemEntryImpl::GetStorageSize() const { … }
void MemEntryImpl::UpdateStateOnUse(EntryModified modified_enum) { … }
void MemEntryImpl::Doom() { … }
void MemEntryImpl::Close() { … }
std::string MemEntryImpl::GetKey() const { … }
Time MemEntryImpl::GetLastUsed() const { … }
Time MemEntryImpl::GetLastModified() const { … }
int32_t MemEntryImpl::GetDataSize(int index) const { … }
int MemEntryImpl::ReadData(int index,
int offset,
IOBuffer* buf,
int buf_len,
CompletionOnceCallback callback) { … }
int MemEntryImpl::WriteData(int index,
int offset,
IOBuffer* buf,
int buf_len,
CompletionOnceCallback callback,
bool truncate) { … }
int MemEntryImpl::ReadSparseData(int64_t offset,
IOBuffer* buf,
int buf_len,
CompletionOnceCallback callback) { … }
int MemEntryImpl::WriteSparseData(int64_t offset,
IOBuffer* buf,
int buf_len,
CompletionOnceCallback callback) { … }
RangeResult MemEntryImpl::GetAvailableRange(int64_t offset,
int len,
RangeResultCallback callback) { … }
bool MemEntryImpl::CouldBeSparse() const { … }
net::Error MemEntryImpl::ReadyForSparseIO(CompletionOnceCallback callback) { … }
void MemEntryImpl::SetLastUsedTimeForTest(base::Time time) { … }
MemEntryImpl::MemEntryImpl(base::WeakPtr<MemBackendImpl> backend,
const ::std::string& key,
int64_t child_id,
MemEntryImpl* parent,
net::NetLog* net_log)
: … { … }
MemEntryImpl::~MemEntryImpl() { … }
int MemEntryImpl::InternalReadData(int index, int offset, IOBuffer* buf,
int buf_len) { … }
int MemEntryImpl::InternalWriteData(int index, int offset, IOBuffer* buf,
int buf_len, bool truncate) { … }
int MemEntryImpl::InternalReadSparseData(int64_t offset,
IOBuffer* buf,
int buf_len) { … }
int MemEntryImpl::InternalWriteSparseData(int64_t offset,
IOBuffer* buf,
int buf_len) { … }
RangeResult MemEntryImpl::InternalGetAvailableRange(int64_t offset, int len) { … }
bool MemEntryImpl::InitSparseInfo() { … }
MemEntryImpl* MemEntryImpl::GetChild(int64_t offset, bool create) { … }
net::Interval<int64_t> MemEntryImpl::ChildInterval(
MemEntryImpl::EntryMap::const_iterator i) { … }
void MemEntryImpl::Compact() { … }
}