#include "storage/browser/file_system/sandbox_directory_database.h"
#include <math.h>
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include <set>
#include "base/containers/contains.h"
#include "base/containers/span.h"
#include "base/containers/stack.h"
#include "base/files/file_enumerator.h"
#include "base/files/file_util.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_macros.h"
#include "base/pickle.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "storage/browser/file_system/file_system_usage_cache.h"
#include "storage/common/file_system/file_system_util.h"
#include "third_party/leveldatabase/env_chromium.h"
#include "third_party/leveldatabase/leveldb_chrome.h"
#include "third_party/leveldatabase/src/include/leveldb/db.h"
#include "third_party/leveldatabase/src/include/leveldb/write_batch.h"
namespace storage {
void PickleFromFileInfo(const SandboxDirectoryDatabase::FileInfo& info,
base::Pickle* pickle) { … }
bool FileInfoFromPickle(const base::Pickle& pickle,
SandboxDirectoryDatabase::FileInfo* info) { … }
const base::FilePath::CharType kDirectoryDatabaseName[] = …);
const char kChildLookupPrefix[] = …;
const char kChildLookupSeparator[] = …;
const char kSandboxDirectoryLastFileIdKey[] = …;
const char kSandboxDirectoryLastIntegerKey[] = …;
const int64_t kSandboxDirectoryMinimumReportIntervalHours = …;
const char kSandboxDirectoryInitStatusHistogramLabel[] = …;
enum class SandboxDirectoryInitStatus { … };
std::string GetChildLookupKey(SandboxDirectoryDatabase::FileId parent_id,
const base::FilePath::StringType& child_name) { … }
std::string GetChildListingKeyPrefix(
SandboxDirectoryDatabase::FileId parent_id) { … }
const char* LastFileIdKey() { … }
const char* LastIntegerKey() { … }
std::string GetFileLookupKey(SandboxDirectoryDatabase::FileId file_id) { … }
class DatabaseCheckHelper { … };
DatabaseCheckHelper::DatabaseCheckHelper(SandboxDirectoryDatabase* dir_db,
leveldb::DB* db,
const base::FilePath& path)
: … { … }
bool DatabaseCheckHelper::IsDatabaseEmpty() { … }
bool DatabaseCheckHelper::ScanDatabase() { … }
bool DatabaseCheckHelper::ScanDirectory() { … }
bool DatabaseCheckHelper::ScanHierarchy() { … }
bool VerifyDataPath(const base::FilePath& data_path) { … }
SandboxDirectoryDatabase::FileInfo::FileInfo() : … { … }
SandboxDirectoryDatabase::FileInfo::~FileInfo() = default;
SandboxDirectoryDatabase::SandboxDirectoryDatabase(
const base::FilePath& filesystem_data_directory,
leveldb::Env* env_override)
: … { … }
SandboxDirectoryDatabase::~SandboxDirectoryDatabase() = default;
bool SandboxDirectoryDatabase::GetChildWithName(
FileId parent_id,
const base::FilePath::StringType& name,
FileId* child_id) { … }
bool SandboxDirectoryDatabase::GetFileWithPath(const base::FilePath& path,
FileId* file_id) { … }
bool SandboxDirectoryDatabase::ListChildren(FileId parent_id,
std::vector<FileId>* children) { … }
bool SandboxDirectoryDatabase::GetFileInfo(FileId file_id, FileInfo* info) { … }
base::File::Error SandboxDirectoryDatabase::AddFileInfo(const FileInfo& info,
FileId* file_id) { … }
bool SandboxDirectoryDatabase::RemoveFileInfo(FileId file_id) { … }
bool SandboxDirectoryDatabase::UpdateFileInfo(FileId file_id,
const FileInfo& new_info) { … }
bool SandboxDirectoryDatabase::UpdateModificationTime(
FileId file_id,
const base::Time& modification_time) { … }
bool SandboxDirectoryDatabase::OverwritingMoveFile(FileId src_file_id,
FileId dest_file_id) { … }
bool SandboxDirectoryDatabase::GetNextInteger(int64_t* next) { … }
bool SandboxDirectoryDatabase::DestroyDatabase() { … }
bool SandboxDirectoryDatabase::Init(RecoveryOption recovery_option) { … }
bool SandboxDirectoryDatabase::RepairDatabase(const std::string& db_path) { … }
bool SandboxDirectoryDatabase::IsDirectory(FileId file_id) { … }
bool SandboxDirectoryDatabase::IsFileSystemConsistent() { … }
void SandboxDirectoryDatabase::ReportInitStatus(const leveldb::Status& status) { … }
bool SandboxDirectoryDatabase::StoreDefaultValues() { … }
bool SandboxDirectoryDatabase::GetLastFileId(FileId* file_id) { … }
bool SandboxDirectoryDatabase::AddFileInfoHelper(const FileInfo& info,
FileId file_id,
leveldb::WriteBatch* batch) { … }
bool SandboxDirectoryDatabase::RemoveFileInfoHelper(
FileId file_id,
leveldb::WriteBatch* batch) { … }
void SandboxDirectoryDatabase::HandleError(const base::Location& from_here,
const leveldb::Status& status) { … }
}