chromium/net/disk_cache/blockfile/sparse_control.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40284755): Remove this and spanify to fix the errors.
#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 {

// Stream of the sparse data index.
const int kSparseIndex =;

// Stream of the sparse data.
const int kSparseData =;

// We can have up to 64k children.
const int kMaxMapSize =;

// The maximum number of bytes that a child can store.
const int kMaxEntrySize =;

// How much we can address. 8 KiB bitmap (kMaxMapSize above) gives us offsets
// up to 64 GiB.
const int64_t kMaxEndOffset =;

// The size of each data block (tracked by the child allocation bitmap).
const int kBlockSize =;

// Returns the name of a child entry given the base_name and signature of the
// parent and the child_id.
// If the entry is called entry_name, child entries will be named something
// like Range_entry_name:XXX:YYY where XXX is the entry signature and YYY is the
// number of the particular child.
std::string GenerateChildName(const std::string& base_name,
                              int64_t signature,
                              int64_t child_id) {}

// This class deletes the children of a sparse entry.
class ChildrenDeleter
    : public base::RefCounted<ChildrenDeleter>,
      public disk_cache::FileIOCallback {};

// This is the callback of the file operation.
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() {}

// Returns the NetLog event type corresponding to a SparseOperation.
net::NetLogEventType GetSparseEventType(
    disk_cache::SparseControl::SparseOperation operation) {}

// Logs the end event for |operation| on a child entry.  Range operations log
// no events for each child they search through.
void LogChildOperationEnd(const net::NetLogWithSource& net_log,
                          disk_cache::SparseControl::SparseOperation operation,
                          int result) {}

}  // namespace.

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) {}

// Static
void SparseControl::DeleteChildren(EntryImpl* entry) {}

// We are going to start using this entry to store sparse data, so we have to
// initialize our control info.
int SparseControl::CreateSparseEntry() {}

// We are opening an entry from disk. Make sure that our control data is there.
int SparseControl::OpenSparseEntry(int data_len) {}

bool SparseControl::OpenChild() {}

void SparseControl::CloseChild() {}

std::string SparseControl::GenerateChildKey() {}

// We are deleting the child because something went wrong.
bool SparseControl::KillChildAndContinue(const std::string& key, bool fatal) {}

// We were not able to open this child; see what we can do.
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() {}

}  // namespace disk_cache