#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "storage/browser/file_system/obfuscated_file_util_memory_delegate.h"
#include <algorithm>
#include <utility>
#include "base/files/file_util.h"
#include "base/memory/raw_ptr.h"
#include "base/numerics/checked_math.h"
#include "base/numerics/safe_conversions.h"
#include "base/ranges/algorithm.h"
#include "base/system/sys_info.h"
#include "build/build_config.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
#include "partition_alloc/partition_alloc_constants.h"
namespace {
bool IsMemoryAvailable(size_t required_memory) { … }
}
namespace storage {
struct ObfuscatedFileUtilMemoryDelegate::Entry { … };
struct ObfuscatedFileUtilMemoryDelegate::DecomposedPath { … };
ObfuscatedFileUtilMemoryDelegate::ObfuscatedFileUtilMemoryDelegate(
const base::FilePath& file_system_directory)
: … { … }
ObfuscatedFileUtilMemoryDelegate::~ObfuscatedFileUtilMemoryDelegate() { … }
std::optional<ObfuscatedFileUtilMemoryDelegate::DecomposedPath>
ObfuscatedFileUtilMemoryDelegate::ParsePath(const base::FilePath& path) { … }
bool ObfuscatedFileUtilMemoryDelegate::DirectoryExists(
const base::FilePath& path) { … }
base::File::Error ObfuscatedFileUtilMemoryDelegate::CreateDirectory(
const base::FilePath& path,
bool exclusive,
bool recursive) { … }
bool ObfuscatedFileUtilMemoryDelegate::DeleteFileOrDirectory(
const base::FilePath& path,
bool recursive) { … }
bool ObfuscatedFileUtilMemoryDelegate::IsLink(const base::FilePath& file_path) { … }
bool ObfuscatedFileUtilMemoryDelegate::PathExists(const base::FilePath& path) { … }
base::File ObfuscatedFileUtilMemoryDelegate::CreateOrOpen(
const base::FilePath& path,
uint32_t file_flags) { … }
void ObfuscatedFileUtilMemoryDelegate::CreateOrOpenInternal(
const DecomposedPath& dp,
uint32_t file_flags) { … }
base::File::Error ObfuscatedFileUtilMemoryDelegate::DeleteFile(
const base::FilePath& path) { … }
base::File::Error ObfuscatedFileUtilMemoryDelegate::EnsureFileExists(
const base::FilePath& path,
bool* created) { … }
base::File::Error ObfuscatedFileUtilMemoryDelegate::GetFileInfo(
const base::FilePath& path,
base::File::Info* file_info) { … }
base::File::Error ObfuscatedFileUtilMemoryDelegate::Touch(
const base::FilePath& path,
const base::Time& last_access_time,
const base::Time& last_modified_time) { … }
base::File::Error ObfuscatedFileUtilMemoryDelegate::Truncate(
const base::FilePath& path,
int64_t length) { … }
NativeFileUtil::CopyOrMoveMode
ObfuscatedFileUtilMemoryDelegate::CopyOrMoveModeForDestination(
const FileSystemURL& ,
bool copy) { … }
base::File::Error ObfuscatedFileUtilMemoryDelegate::CopyOrMoveFile(
const base::FilePath& src_path,
const base::FilePath& dest_path,
FileSystemOperation::CopyOrMoveOptionSet options,
NativeFileUtil::CopyOrMoveMode mode) { … }
bool ObfuscatedFileUtilMemoryDelegate::MoveDirectoryInternal(
const DecomposedPath& src_dp,
const DecomposedPath& dest_dp) { … }
bool ObfuscatedFileUtilMemoryDelegate::CopyOrMoveFileInternal(
const DecomposedPath& src_dp,
const DecomposedPath& dest_dp,
bool move) { … }
size_t ObfuscatedFileUtilMemoryDelegate::ComputeDirectorySize(
const base::FilePath& path) { … }
int ObfuscatedFileUtilMemoryDelegate::ReadFile(const base::FilePath& path,
int64_t offset,
scoped_refptr<net::IOBuffer> buf,
int buf_len) { … }
int ObfuscatedFileUtilMemoryDelegate::WriteFile(
const base::FilePath& path,
int64_t offset,
scoped_refptr<net::IOBuffer> buf,
int buf_len) { … }
base::File::Error ObfuscatedFileUtilMemoryDelegate::CreateFileForTesting(
const base::FilePath& path,
base::span<const char> content) { … }
base::File::Error ObfuscatedFileUtilMemoryDelegate::CopyInForeignFile(
const base::FilePath& src_path,
const base::FilePath& dest_path,
FileSystemOperation::CopyOrMoveOptionSet ,
NativeFileUtil::CopyOrMoveMode ) { … }
}