#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "net/disk_cache/blockfile/sparse_control.h"
#include <stdint.h>
#include "base/format_macros.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/numerics/checked_math.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/time.h"
#include "net/base/interval.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/entry_impl.h"
#include "net/disk_cache/blockfile/file.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_with_source.h"
Time;
namespace {
const int kSparseIndex = …;
const int kSparseData = …;
const int kMaxMapSize = …;
const int kMaxEntrySize = …;
const int64_t kMaxEndOffset = …;
const int kBlockSize = …;
std::string GenerateChildName(const std::string& base_name,
int64_t signature,
int64_t child_id) { … }
class ChildrenDeleter
: public base::RefCounted<ChildrenDeleter>,
public disk_cache::FileIOCallback { … };
void ChildrenDeleter::OnFileIOComplete(int bytes_copied) { … }
void ChildrenDeleter::Start(std::unique_ptr<char[]> buffer, int len) { … }
void ChildrenDeleter::ReadData(disk_cache::Addr address, int len) { … }
void ChildrenDeleter::DeleteChildren() { … }
net::NetLogEventType GetSparseEventType(
disk_cache::SparseControl::SparseOperation operation) { … }
void LogChildOperationEnd(const net::NetLogWithSource& net_log,
disk_cache::SparseControl::SparseOperation operation,
int result) { … }
}
namespace disk_cache {
SparseControl::SparseControl(EntryImpl* entry)
: … { … }
SparseControl::~SparseControl() { … }
int SparseControl::Init() { … }
bool SparseControl::CouldBeSparse() const { … }
int SparseControl::StartIO(SparseOperation op,
int64_t offset,
net::IOBuffer* buf,
int buf_len,
CompletionOnceCallback callback) { … }
RangeResult SparseControl::GetAvailableRange(int64_t offset, int len) { … }
void SparseControl::CancelIO() { … }
int SparseControl::ReadyToUse(CompletionOnceCallback callback) { … }
void SparseControl::DeleteChildren(EntryImpl* entry) { … }
int SparseControl::CreateSparseEntry() { … }
int SparseControl::OpenSparseEntry(int data_len) { … }
bool SparseControl::OpenChild() { … }
void SparseControl::CloseChild() { … }
std::string SparseControl::GenerateChildKey() { … }
bool SparseControl::KillChildAndContinue(const std::string& key, bool fatal) { … }
bool SparseControl::ContinueWithoutChild(const std::string& key) { … }
bool SparseControl::ChildPresent() { … }
void SparseControl::SetChildBit(bool value) { … }
void SparseControl::WriteSparseData() { … }
bool SparseControl::VerifyRange() { … }
void SparseControl::UpdateRange(int result) { … }
int SparseControl::PartialBlockLength(int block_index) const { … }
void SparseControl::InitChildData() { … }
void SparseControl::DoChildrenIO() { … }
bool SparseControl::DoChildIO() { … }
int SparseControl::DoGetAvailableRange() { … }
void SparseControl::DoChildIOCompleted(int result) { … }
void SparseControl::OnChildIOCompleted(int result) { … }
void SparseControl::DoUserCallback() { … }
void SparseControl::DoAbortCallbacks() { … }
}