#include "chrome/browser/sync_file_system/sync_file_system_service.h"
#include <stddef.h>
#include <stdint.h>
#include <string>
#include <utility>
#include "base/barrier_closure.h"
#include "base/check_deref.h"
#include "base/format_macros.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/observer_list.h"
#include "base/task/single_thread_task_runner.h"
#include "chrome/browser/apps/platform_apps/api/sync_file_system/extension_sync_event_observer.h"
#include "chrome/browser/apps/platform_apps/api/sync_file_system/sync_file_system_api_helpers.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/sync_service_factory.h"
#include "chrome/browser/sync_file_system/local/local_file_sync_service.h"
#include "chrome/browser/sync_file_system/logger.h"
#include "chrome/browser/sync_file_system/sync_direction.h"
#include "chrome/browser/sync_file_system/sync_event_observer.h"
#include "chrome/browser/sync_file_system/sync_file_metadata.h"
#include "chrome/browser/sync_file_system/sync_file_status.h"
#include "chrome/browser/sync_file_system/sync_process_runner.h"
#include "chrome/browser/sync_file_system/sync_status_code.h"
#include "chrome/browser/sync_file_system/syncable_file_system_util.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/sync/service/sync_service.h"
#include "components/sync/service/sync_user_settings.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/unloaded_extension_reason.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest_constants.h"
#include "storage/browser/file_system/file_system_context.h"
#include "url/gurl.h"
BrowserThread;
Extension;
ExtensionPrefs;
ExtensionRegistry;
FileSystemURL;
FileSystemURLSet;
namespace sync_file_system {
namespace {
const char kLocalSyncName[] = …;
const char kRemoteSyncName[] = …;
SyncServiceState RemoteStateToSyncServiceState(
RemoteServiceState state) { … }
void DidHandleUninstalledEvent(const GURL& origin, SyncStatusCode code) { … }
void DidHandleUnloadedEvent(const GURL& origin, SyncStatusCode code) { … }
void DidHandleLoadEvent(
const GURL& origin,
SyncStatusCode code) { … }
std::string SyncFileStatusToString(SyncFileStatus sync_file_status) { … }
LocalChangeProcessor* GetLocalChangeProcessorAdapter(
base::WeakPtr<SyncFileSystemService> service,
const GURL& origin) { … }
void SetFileStatusFromSyncStatus(base::Value::Dict* file,
SyncStatusCode,
SyncFileStatus status) { … }
}
class LocalSyncRunner : public SyncProcessRunner,
public LocalFileSyncService::Observer { … };
class RemoteSyncRunner : public SyncProcessRunner,
public RemoteFileSyncService::Observer { … };
void SyncFileSystemService::Shutdown() { … }
SyncFileSystemService::~SyncFileSystemService() { … }
void SyncFileSystemService::InitializeForApp(
storage::FileSystemContext* file_system_context,
const GURL& app_origin,
SyncStatusCallback callback) { … }
void SyncFileSystemService::GetExtensionStatusMap(
ExtensionStatusMapCallback callback) { … }
void SyncFileSystemService::DumpFiles(
content::StoragePartition* storage_partition,
const GURL& origin,
DumpFilesCallback callback) { … }
void SyncFileSystemService::DumpDatabase(DumpFilesCallback callback) { … }
void SyncFileSystemService::GetFileSyncStatus(const FileSystemURL& url,
SyncFileStatusCallback callback) { … }
void SyncFileSystemService::AddSyncEventObserver(SyncEventObserver* observer) { … }
void SyncFileSystemService::RemoveSyncEventObserver(
SyncEventObserver* observer) { … }
LocalChangeProcessor* SyncFileSystemService::GetLocalChangeProcessor(
const GURL& origin) { … }
void SyncFileSystemService::OnSyncIdle() { … }
void SyncFileSystemService::OnPromotionCompleted(int* count) { … }
void SyncFileSystemService::CheckIfIdle() { … }
SyncServiceState SyncFileSystemService::GetSyncServiceState() { … }
SyncFileSystemService* SyncFileSystemService::GetSyncService() { … }
void SyncFileSystemService::CallOnIdleForTesting(base::OnceClosure callback) { … }
SyncFileSystemService::SyncFileSystemService(Profile* profile)
: … { … }
void SyncFileSystemService::Initialize(
std::unique_ptr<LocalFileSyncService> local_service,
std::unique_ptr<RemoteFileSyncService> remote_service) { … }
void SyncFileSystemService::DidInitializeFileSystem(const GURL& app_origin,
SyncStatusCallback callback,
SyncStatusCode status) { … }
void SyncFileSystemService::DidRegisterOrigin(const GURL& app_origin,
SyncStatusCallback callback,
SyncStatusCode status) { … }
void SyncFileSystemService::DidInitializeFileSystemForDump(
const GURL& origin,
DumpFilesCallback callback,
SyncStatusCode status) { … }
void SyncFileSystemService::DidDumpFiles(const GURL& origin,
DumpFilesCallback callback,
base::Value::List dump_files) { … }
void SyncFileSystemService::DidDumpDatabase(DumpFilesCallback callback,
base::Value::List list) { … }
void SyncFileSystemService::DidGetExtensionStatusMap(
ExtensionStatusMapCallback callback,
std::unique_ptr<RemoteFileSyncService::OriginStatusMap> status_map) { … }
void SyncFileSystemService::SetSyncEnabledForTesting(bool enabled) { … }
void SyncFileSystemService::DidGetLocalChangeStatus(
SyncFileStatusCallback callback,
SyncStatusCode status,
bool has_pending_local_changes) { … }
void SyncFileSystemService::OnRemoteServiceStateUpdated(
RemoteServiceState state,
const std::string& description) { … }
void SyncFileSystemService::OnExtensionInstalled(
content::BrowserContext* browser_context,
const Extension* extension,
bool is_update) { … }
void SyncFileSystemService::OnExtensionUnloaded(
content::BrowserContext* browser_context,
const Extension* extension,
extensions::UnloadedExtensionReason reason) { … }
void SyncFileSystemService::OnExtensionUninstalled(
content::BrowserContext* browser_context,
const Extension* extension,
extensions::UninstallReason reason) { … }
void SyncFileSystemService::OnExtensionLoaded(
content::BrowserContext* browser_context,
const Extension* extension) { … }
void SyncFileSystemService::OnStateChanged(syncer::SyncService* sync) { … }
void SyncFileSystemService::OnFileStatusChanged(
const FileSystemURL& url,
SyncFileType file_type,
SyncFileStatus sync_status,
SyncAction action_taken,
SyncDirection direction) { … }
void SyncFileSystemService::UpdateSyncEnabledStatus(
syncer::SyncService* sync_service) { … }
void SyncFileSystemService::RunForEachSyncRunners(
void(SyncProcessRunner::*method)()) { … }
}