chromium/net/disk_cache/simple/simple_index_file.cc

// Copyright 2013 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/341324165): Fix and remove.
#pragma allow_unsafe_buffers
#endif

#include "net/disk_cache/simple/simple_index_file.h"

#include <utility>
#include <vector>

#include "base/files/file.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
#include "base/pickle.h"
#include "base/strings/string_util.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "net/disk_cache/simple/simple_backend_impl.h"
#include "net/disk_cache/simple/simple_entry_format.h"
#include "net/disk_cache/simple/simple_file_enumerator.h"
#include "net/disk_cache/simple/simple_histogram_macros.h"
#include "net/disk_cache/simple/simple_index.h"
#include "net/disk_cache/simple/simple_synchronous_entry.h"
#include "net/disk_cache/simple/simple_util.h"

namespace disk_cache {
namespace {

const int kEntryFilesHashLength =;
const int kEntryFilesSuffixLength =;

// Limit on how big a file we are willing to work with, to avoid crashes
// when its corrupt.
const int kMaxEntriesInIndex =;

// Here 8 comes from the key size.
const int64_t kMaxIndexFileSizeBytes =;

uint32_t CalculatePickleCRC(const base::Pickle& pickle) {}

// Used in histograms. Please only add new values at the end.
enum IndexFileState {};

enum StaleIndexQuality {};

void UmaRecordIndexFileState(IndexFileState state, net::CacheType cache_type) {}

void UmaRecordIndexInitMethod(SimpleIndex::IndexInitMethod method,
                              net::CacheType cache_type) {}

void UmaRecordStaleIndexQuality(int missed_entry_count,
                                int extra_entry_count,
                                net::CacheType cache_type) {}

struct PickleHeader : public base::Pickle::Header {};

class SimpleIndexPickle : public base::Pickle {};

bool WritePickleFile(BackendFileOperations* file_operations,
                     base::Pickle* pickle,
                     const base::FilePath& file_name) {}

// Called for each cache directory traversal iteration.
void ProcessEntryFile(BackendFileOperations* file_operations,
                      net::CacheType cache_type,
                      SimpleIndex::EntrySet* entries,
                      const base::FilePath& file_path,
                      base::Time last_accessed,
                      base::Time last_modified,
                      int64_t size) {}

}  // namespace

SimpleIndexLoadResult::SimpleIndexLoadResult() = default;

SimpleIndexLoadResult::~SimpleIndexLoadResult() = default;

void SimpleIndexLoadResult::Reset() {}

// static
const char SimpleIndexFile::kIndexFileName[] =;
// static
const char SimpleIndexFile::kIndexDirectory[] =;
// static
const char SimpleIndexFile::kTempIndexFileName[] =;

SimpleIndexFile::IndexMetadata::IndexMetadata()
    :{}

SimpleIndexFile::IndexMetadata::IndexMetadata(
    SimpleIndex::IndexWriteToDiskReason reason,
    uint64_t entry_count,
    uint64_t cache_size)
    :{}

void SimpleIndexFile::IndexMetadata::Serialize(base::Pickle* pickle) const {}

// static
void SimpleIndexFile::SerializeFinalData(base::Time cache_modified,
                                         base::Pickle* pickle) {}

bool SimpleIndexFile::IndexMetadata::Deserialize(base::PickleIterator* it) {}

void SimpleIndexFile::SyncWriteToDisk(
    std::unique_ptr<BackendFileOperations> file_operations,
    net::CacheType cache_type,
    const base::FilePath& cache_directory,
    const base::FilePath& index_filename,
    const base::FilePath& temp_index_filename,
    std::unique_ptr<base::Pickle> pickle) {}

bool SimpleIndexFile::IndexMetadata::CheckIndexMetadata() {}

SimpleIndexFile::SimpleIndexFile(
    scoped_refptr<base::SequencedTaskRunner> cache_runner,
    scoped_refptr<BackendFileOperationsFactory> file_operations_factory,
    net::CacheType cache_type,
    const base::FilePath& cache_directory)
    :{}

SimpleIndexFile::~SimpleIndexFile() = default;

void SimpleIndexFile::LoadIndexEntries(base::Time cache_last_modified,
                                       base::OnceClosure callback,
                                       SimpleIndexLoadResult* out_result) {}

void SimpleIndexFile::WriteToDisk(net::CacheType cache_type,
                                  SimpleIndex::IndexWriteToDiskReason reason,
                                  const SimpleIndex::EntrySet& entry_set,
                                  uint64_t cache_size,
                                  base::OnceClosure callback) {}

// static
void SimpleIndexFile::SyncLoadIndexEntries(
    std::unique_ptr<BackendFileOperations> file_operations,
    net::CacheType cache_type,
    base::Time cache_last_modified,
    const base::FilePath& cache_directory,
    const base::FilePath& index_file_path,
    SimpleIndexLoadResult* out_result) {}

// static
void SimpleIndexFile::SyncLoadFromDisk(BackendFileOperations* file_operations,
                                       net::CacheType cache_type,
                                       const base::FilePath& index_filename,
                                       base::Time* out_last_cache_seen_by_index,
                                       SimpleIndexLoadResult* out_result) {}

// static
std::unique_ptr<base::Pickle> SimpleIndexFile::Serialize(
    net::CacheType cache_type,
    const SimpleIndexFile::IndexMetadata& index_metadata,
    const SimpleIndex::EntrySet& entries) {}

// static
void SimpleIndexFile::Deserialize(net::CacheType cache_type,
                                  const char* data,
                                  int data_len,
                                  base::Time* out_cache_last_modified,
                                  SimpleIndexLoadResult* out_result) {}

// static
void SimpleIndexFile::SyncRestoreFromDisk(
    BackendFileOperations* file_operations,
    net::CacheType cache_type,
    const base::FilePath& cache_directory,
    const base::FilePath& index_file_path,
    SimpleIndexLoadResult* out_result) {}

// static
bool SimpleIndexFile::LegacyIsIndexFileStale(
    BackendFileOperations* file_operations,
    base::Time cache_last_modified,
    const base::FilePath& index_file_path) {}

}  // namespace disk_cache