#include "chrome/browser/sync_file_system/local/local_file_change_tracker.h"
#include <stddef.h>
#include <memory>
#include <utility>
#include "base/containers/circular_deque.h"
#include "base/containers/contains.h"
#include "base/containers/queue.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/task/sequenced_task_runner.h"
#include "chrome/browser/sync_file_system/local/local_file_sync_status.h"
#include "chrome/browser/sync_file_system/syncable_file_system_util.h"
#include "storage/browser/file_system/file_system_context.h"
#include "storage/browser/file_system/file_system_file_util.h"
#include "storage/browser/file_system/file_system_operation_context.h"
#include "storage/browser/file_system/sandbox_file_system_backend_delegate.h"
#include "storage/common/file_system/file_system_util.h"
#include "third_party/leveldatabase/env_chromium.h"
#include "third_party/leveldatabase/src/include/leveldb/db.h"
#include "third_party/leveldatabase/src/include/leveldb/write_batch.h"
FileSystemContext;
FileSystemFileUtil;
FileSystemOperationContext;
FileSystemURL;
FileSystemURLSet;
namespace sync_file_system {
namespace {
const base::FilePath::CharType kDatabaseName[] = …);
const char kMark[] = …;
}
class LocalFileChangeTracker::TrackerDB { … };
LocalFileChangeTracker::ChangeInfo::ChangeInfo() : … { … }
LocalFileChangeTracker::ChangeInfo::~ChangeInfo() { … }
LocalFileChangeTracker::LocalFileChangeTracker(
const base::FilePath& base_path,
leveldb::Env* env_override,
base::SequencedTaskRunner* file_task_runner)
: … { … }
LocalFileChangeTracker::~LocalFileChangeTracker() { … }
void LocalFileChangeTracker::OnStartUpdate(const FileSystemURL& url) { … }
void LocalFileChangeTracker::OnEndUpdate(const FileSystemURL& url) { … }
void LocalFileChangeTracker::OnCreateFile(const FileSystemURL& url) { … }
void LocalFileChangeTracker::OnCreateFileFrom(const FileSystemURL& url,
const FileSystemURL& src) { … }
void LocalFileChangeTracker::OnMoveFileFrom(const FileSystemURL& url,
const FileSystemURL& src) { … }
void LocalFileChangeTracker::OnRemoveFile(const FileSystemURL& url) { … }
void LocalFileChangeTracker::OnModifyFile(const FileSystemURL& url) { … }
void LocalFileChangeTracker::OnCreateDirectory(const FileSystemURL& url) { … }
void LocalFileChangeTracker::OnRemoveDirectory(const FileSystemURL& url) { … }
void LocalFileChangeTracker::GetNextChangedURLs(
base::circular_deque<FileSystemURL>* urls,
int max_urls) { … }
void LocalFileChangeTracker::GetChangesForURL(
const FileSystemURL& url, FileChangeList* changes) { … }
void LocalFileChangeTracker::ClearChangesForURL(const FileSystemURL& url) { … }
void LocalFileChangeTracker::CreateFreshMirrorForURL(
const storage::FileSystemURL& url) { … }
void LocalFileChangeTracker::RemoveMirrorAndCommitChangesForURL(
const storage::FileSystemURL& url) { … }
void LocalFileChangeTracker::ResetToMirrorAndCommitChangesForURL(
const storage::FileSystemURL& url) { … }
void LocalFileChangeTracker::DemoteChangesForURL(
const storage::FileSystemURL& url) { … }
void LocalFileChangeTracker::PromoteDemotedChangesForURL(
const storage::FileSystemURL& url) { … }
bool LocalFileChangeTracker::PromoteDemotedChanges() { … }
SyncStatusCode LocalFileChangeTracker::Initialize(
FileSystemContext* file_system_context) { … }
void LocalFileChangeTracker::ResetForFileSystem(const GURL& origin,
storage::FileSystemType type) { … }
void LocalFileChangeTracker::UpdateNumChanges() { … }
void LocalFileChangeTracker::GetAllChangedURLs(FileSystemURLSet* urls) { … }
void LocalFileChangeTracker::DropAllChanges() { … }
SyncStatusCode LocalFileChangeTracker::MarkDirtyOnDatabase(
const FileSystemURL& url) { … }
SyncStatusCode LocalFileChangeTracker::ClearDirtyOnDatabase(
const FileSystemURL& url) { … }
SyncStatusCode LocalFileChangeTracker::CollectLastDirtyChanges(
FileSystemContext* file_system_context) { … }
void LocalFileChangeTracker::RecordChange(
const FileSystemURL& url, const FileChange& change) { … }
void LocalFileChangeTracker::RecordChangeToChangeMaps(
const FileSystemURL& url,
const FileChange& change,
int new_change_seq,
FileChangeMap* changes,
ChangeSeqMap* change_seqs) { … }
void LocalFileChangeTracker::ResetForURL(const storage::FileSystemURL& url,
int change_seq,
leveldb::WriteBatch* batch) { … }
LocalFileChangeTracker::TrackerDB::TrackerDB(const base::FilePath& base_path,
leveldb::Env* env_override)
: … { … }
SyncStatusCode LocalFileChangeTracker::TrackerDB::Init(
RecoveryOption recovery_option) { … }
SyncStatusCode LocalFileChangeTracker::TrackerDB::Repair(
const std::string& db_path) { … }
void LocalFileChangeTracker::TrackerDB::HandleError(
const base::Location& from_here,
const leveldb::Status& status) { … }
SyncStatusCode LocalFileChangeTracker::TrackerDB::MarkDirty(
const std::string& url) { … }
SyncStatusCode LocalFileChangeTracker::TrackerDB::ClearDirty(
const std::string& url) { … }
SyncStatusCode LocalFileChangeTracker::TrackerDB::GetDirtyEntries(
base::queue<FileSystemURL>* dirty_files) { … }
SyncStatusCode LocalFileChangeTracker::TrackerDB::WriteBatch(
std::unique_ptr<leveldb::WriteBatch> batch) { … }
}