#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "net/disk_cache/simple/simple_file_tracker.h"
#include <algorithm>
#include <limits>
#include <memory>
#include <utility>
#include "base/files/file.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/not_fatal_until.h"
#include "base/synchronization/lock.h"
#include "net/disk_cache/disk_cache.h"
#include "net/disk_cache/simple/simple_histogram_enums.h"
#include "net/disk_cache/simple/simple_synchronous_entry.h"
namespace disk_cache {
namespace {
void RecordFileDescripterLimiterOp(FileDescriptorLimiterOp op) { … }
}
SimpleFileTracker::SimpleFileTracker(int file_limit)
: … { … }
SimpleFileTracker::~SimpleFileTracker() { … }
void SimpleFileTracker::Register(const SimpleSynchronousEntry* owner,
SubFile subfile,
std::unique_ptr<base::File> file) { … }
SimpleFileTracker::FileHandle SimpleFileTracker::Acquire(
BackendFileOperations* file_operations,
const SimpleSynchronousEntry* owner,
SubFile subfile) { … }
SimpleFileTracker::TrackedFiles::TrackedFiles() { … }
SimpleFileTracker::TrackedFiles::~TrackedFiles() = default;
bool SimpleFileTracker::TrackedFiles::Empty() const { … }
bool SimpleFileTracker::TrackedFiles::HasOpenFiles() const { … }
void SimpleFileTracker::Release(const SimpleSynchronousEntry* owner,
SubFile subfile) { … }
void SimpleFileTracker::Close(const SimpleSynchronousEntry* owner,
SubFile subfile) { … }
void SimpleFileTracker::Doom(const SimpleSynchronousEntry* owner,
EntryFileKey* key) { … }
bool SimpleFileTracker::IsEmptyForTesting() { … }
SimpleFileTracker::TrackedFiles* SimpleFileTracker::Find(
const SimpleSynchronousEntry* owner) { … }
std::unique_ptr<base::File> SimpleFileTracker::PrepareClose(
TrackedFiles* owners_files,
int file_index) { … }
void SimpleFileTracker::CloseFilesIfTooManyOpen(
std::vector<std::unique_ptr<base::File>>* files_to_close) { … }
void SimpleFileTracker::ReopenFile(BackendFileOperations* file_operations,
TrackedFiles* owners_files,
SubFile subfile) { … }
void SimpleFileTracker::EnsureInFrontOfLRU(TrackedFiles* owners_files) { … }
SimpleFileTracker::FileHandle::FileHandle() = default;
SimpleFileTracker::FileHandle::FileHandle(SimpleFileTracker* file_tracker,
const SimpleSynchronousEntry* entry,
SimpleFileTracker::SubFile subfile,
base::File* file)
: … { … }
SimpleFileTracker::FileHandle::FileHandle(FileHandle&& other) { … }
SimpleFileTracker::FileHandle::~FileHandle() { … }
SimpleFileTracker::FileHandle& SimpleFileTracker::FileHandle::operator=(
FileHandle&& other) { … }
base::File* SimpleFileTracker::FileHandle::operator->() const { … }
base::File* SimpleFileTracker::FileHandle::get() const { … }
bool SimpleFileTracker::FileHandle::IsOK() const { … }
}