#include "chrome/browser/sync_file_system/local/local_file_sync_service.h"
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/memory/ptr_util.h"
#include "base/observer_list.h"
#include "base/task/single_thread_task_runner.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync_file_system/file_change.h"
#include "chrome/browser/sync_file_system/local/local_file_change_tracker.h"
#include "chrome/browser/sync_file_system/local/local_file_sync_context.h"
#include "chrome/browser/sync_file_system/local/sync_file_system_backend.h"
#include "chrome/browser/sync_file_system/local_change_processor.h"
#include "chrome/browser/sync_file_system/logger.h"
#include "chrome/browser/sync_file_system/sync_file_metadata.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/site_instance.h"
#include "content/public/browser/storage_partition.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_util.h"
#include "extensions/common/extension_set.h"
#include "storage/browser/blob/scoped_file.h"
#include "storage/browser/file_system/file_system_context.h"
#include "storage/browser/file_system/file_system_url.h"
#include "url/gurl.h"
BrowserThread;
FileSystemURL;
namespace sync_file_system {
namespace {
void PrepareForProcessRemoteChangeCallbackAdapter(
RemoteChangeProcessor::PrepareChangeCallback callback,
SyncStatusCode status,
const LocalFileSyncInfo& sync_file_info,
storage::ScopedFile snapshot) { … }
void InvokeCallbackOnNthInvocation(int* count,
base::RepeatingClosure callback) { … }
}
LocalFileSyncService::OriginChangeMap::OriginChangeMap()
: … { … }
LocalFileSyncService::OriginChangeMap::~OriginChangeMap() { … }
bool LocalFileSyncService::OriginChangeMap::NextOriginToProcess(GURL* origin) { … }
int64_t LocalFileSyncService::OriginChangeMap::GetTotalChangeCount() const { … }
void LocalFileSyncService::OriginChangeMap::SetOriginChangeCount(
const GURL& origin,
int64_t changes) { … }
void LocalFileSyncService::OriginChangeMap::SetOriginEnabled(
const GURL& origin, bool enabled) { … }
std::unique_ptr<LocalFileSyncService> LocalFileSyncService::Create(
Profile* profile) { … }
std::unique_ptr<LocalFileSyncService> LocalFileSyncService::CreateForTesting(
Profile* profile,
leveldb::Env* env) { … }
LocalFileSyncService::~LocalFileSyncService() { … }
void LocalFileSyncService::Shutdown() { … }
void LocalFileSyncService::MaybeInitializeFileSystemContext(
const GURL& app_origin,
storage::FileSystemContext* file_system_context,
SyncStatusCallback callback) { … }
void LocalFileSyncService::AddChangeObserver(Observer* observer) { … }
void LocalFileSyncService::RegisterURLForWaitingSync(
const FileSystemURL& url,
base::OnceClosure on_syncable_callback) { … }
void LocalFileSyncService::ProcessLocalChange(SyncFileCallback callback) { … }
void LocalFileSyncService::SetLocalChangeProcessor(
LocalChangeProcessor* local_change_processor) { … }
void LocalFileSyncService::SetLocalChangeProcessorCallback(
GetLocalChangeProcessorCallback get_local_change_processor) { … }
void LocalFileSyncService::HasPendingLocalChanges(
const FileSystemURL& url,
HasPendingLocalChangeCallback callback) { … }
void LocalFileSyncService::PromoteDemotedChanges(
base::RepeatingClosure callback) { … }
void LocalFileSyncService::GetLocalFileMetadata(
const FileSystemURL& url,
SyncFileMetadataCallback callback) { … }
void LocalFileSyncService::PrepareForProcessRemoteChange(
const FileSystemURL& url,
PrepareChangeCallback callback) { … }
void LocalFileSyncService::ApplyRemoteChange(const FileChange& change,
const base::FilePath& local_path,
const FileSystemURL& url,
SyncStatusCallback callback) { … }
void LocalFileSyncService::FinalizeRemoteSync(
const FileSystemURL& url,
bool clear_local_changes,
base::OnceClosure completion_callback) { … }
void LocalFileSyncService::RecordFakeLocalChange(const FileSystemURL& url,
const FileChange& change,
SyncStatusCallback callback) { … }
void LocalFileSyncService::OnChangesAvailableInOrigins(
const std::set<GURL>& origins) { … }
void LocalFileSyncService::SetOriginEnabled(const GURL& origin, bool enabled) { … }
LocalFileSyncService::LocalFileSyncService(Profile* profile,
leveldb::Env* env_override)
: … { … }
void LocalFileSyncService::DidInitializeFileSystemContext(
const GURL& app_origin,
storage::FileSystemContext* file_system_context,
SyncStatusCallback callback,
SyncStatusCode status) { … }
void LocalFileSyncService::DidInitializeForRemoteSync(
const FileSystemURL& url,
storage::FileSystemContext* file_system_context,
PrepareChangeCallback callback,
SyncStatusCode status) { … }
void LocalFileSyncService::DidApplyRemoteChange(SyncStatusCallback callback,
SyncStatusCode status) { … }
void LocalFileSyncService::DidGetFileForLocalSync(
SyncFileCallback callback,
SyncStatusCode status,
const LocalFileSyncInfo& sync_file_info,
storage::ScopedFile snapshot) { … }
void LocalFileSyncService::ProcessNextChangeForURL(
SyncFileCallback callback,
storage::ScopedFile snapshot,
const LocalFileSyncInfo& sync_file_info,
const FileChange& processed_change,
const FileChangeList& changes,
SyncStatusCode status) { … }
LocalChangeProcessor* LocalFileSyncService::GetLocalChangeProcessor(
const FileSystemURL& url) { … }
}