#include "chrome/browser/sync_file_system/drive_backend/sync_engine.h"
#include <utility>
#include <vector>
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "base/observer_list.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/time/time.h"
#include "base/values.h"
#include "chrome/browser/drive/drive_notification_manager_factory.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/sync_file_system/drive_backend/callback_helper.h"
#include "chrome/browser/sync_file_system/drive_backend/conflict_resolver.h"
#include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.h"
#include "chrome/browser/sync_file_system/drive_backend/drive_service_on_worker.h"
#include "chrome/browser/sync_file_system/drive_backend/drive_service_wrapper.h"
#include "chrome/browser/sync_file_system/drive_backend/drive_uploader_on_worker.h"
#include "chrome/browser/sync_file_system/drive_backend/drive_uploader_wrapper.h"
#include "chrome/browser/sync_file_system/drive_backend/list_changes_task.h"
#include "chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.h"
#include "chrome/browser/sync_file_system/drive_backend/metadata_database.h"
#include "chrome/browser/sync_file_system/drive_backend/register_app_task.h"
#include "chrome/browser/sync_file_system/drive_backend/remote_change_processor_on_worker.h"
#include "chrome/browser/sync_file_system/drive_backend/remote_change_processor_wrapper.h"
#include "chrome/browser/sync_file_system/drive_backend/remote_to_local_syncer.h"
#include "chrome/browser/sync_file_system/drive_backend/sync_engine_context.h"
#include "chrome/browser/sync_file_system/drive_backend/sync_engine_initializer.h"
#include "chrome/browser/sync_file_system/drive_backend/sync_task.h"
#include "chrome/browser/sync_file_system/drive_backend/sync_worker.h"
#include "chrome/browser/sync_file_system/drive_backend/sync_worker_interface.h"
#include "chrome/browser/sync_file_system/drive_backend/uninstall_app_task.h"
#include "chrome/browser/sync_file_system/file_status_observer.h"
#include "chrome/browser/sync_file_system/logger.h"
#include "chrome/browser/sync_file_system/syncable_file_system_util.h"
#include "components/drive/drive_notification_manager.h"
#include "components/drive/drive_uploader.h"
#include "components/drive/service/drive_api_service.h"
#include "components/drive/service/drive_service_interface.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/device_service.h"
#include "content/public/browser/network_service_instance.h"
#include "content/public/browser/storage_partition.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/extension_system_provider.h"
#include "extensions/browser/extensions_browser_client.h"
#include "extensions/common/extension.h"
#include "google_apis/drive/drive_api_url_generator.h"
#include "google_apis/gaia/gaia_urls.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "services/device/public/mojom/wake_lock_provider.mojom.h"
#include "storage/browser/blob/scoped_file.h"
#include "storage/common/file_system/file_system_util.h"
namespace sync_file_system {
class RemoteChangeProcessor;
namespace drive_backend {
constexpr net::NetworkTrafficAnnotationTag kSyncFileSystemTrafficAnnotation = …;
std::unique_ptr<drive::DriveServiceInterface>
SyncEngine::DriveServiceFactory::CreateDriveService(
signin::IdentityManager* identity_manager,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
base::SequencedTaskRunner* blocking_task_runner) { … }
class SyncEngine::WorkerObserver : public SyncWorkerInterface::Observer { … };
std::unique_ptr<SyncEngine> SyncEngine::CreateForBrowserContext(
content::BrowserContext* context,
TaskLogger* task_logger) { … }
void SyncEngine::AppendDependsOnFactories(
std::set<BrowserContextKeyedServiceFactory*>* factories) { … }
SyncEngine::~SyncEngine() { … }
void SyncEngine::Reset() { … }
void SyncEngine::Initialize() { … }
void SyncEngine::InitializeForTesting(
std::unique_ptr<drive::DriveServiceInterface> drive_service,
std::unique_ptr<drive::DriveUploaderInterface> drive_uploader,
std::unique_ptr<SyncWorkerInterface> sync_worker) { … }
void SyncEngine::InitializeInternal(
std::unique_ptr<drive::DriveServiceInterface> drive_service,
std::unique_ptr<drive::DriveUploaderInterface> drive_uploader,
std::unique_ptr<SyncWorkerInterface> sync_worker) { … }
void SyncEngine::AddServiceObserver(SyncServiceObserver* observer) { … }
void SyncEngine::AddFileStatusObserver(FileStatusObserver* observer) { … }
void SyncEngine::RegisterOrigin(const GURL& origin,
SyncStatusCallback callback) { … }
void SyncEngine::EnableOrigin(const GURL& origin, SyncStatusCallback callback) { … }
void SyncEngine::DisableOrigin(const GURL& origin,
SyncStatusCallback callback) { … }
void SyncEngine::UninstallOrigin(const GURL& origin,
UninstallFlag flag,
SyncStatusCallback callback) { … }
void SyncEngine::ProcessRemoteChange(SyncFileCallback callback) { … }
void SyncEngine::SetRemoteChangeProcessor(RemoteChangeProcessor* processor) { … }
LocalChangeProcessor* SyncEngine::GetLocalChangeProcessor() { … }
RemoteServiceState SyncEngine::GetCurrentState() const { … }
void SyncEngine::GetOriginStatusMap(StatusMapCallback callback) { … }
void SyncEngine::DumpFiles(const GURL& origin, ListCallback callback) { … }
void SyncEngine::DumpDatabase(ListCallback callback) { … }
void SyncEngine::SetSyncEnabled(bool sync_enabled) { … }
void SyncEngine::PromoteDemotedChanges(base::OnceClosure callback) { … }
void SyncEngine::ApplyLocalChange(const FileChange& local_change,
const base::FilePath& local_path,
const SyncFileMetadata& local_metadata,
const storage::FileSystemURL& url,
SyncStatusCallback callback) { … }
void SyncEngine::OnNotificationReceived(
const std::map<std::string, int64_t>& invalidations) { … }
void SyncEngine::OnNotificationTimerFired() { … }
void SyncEngine::OnPushNotificationEnabled(bool ) { … }
void SyncEngine::OnReadyToSendRequests() { … }
void SyncEngine::OnRefreshTokenInvalid() { … }
void SyncEngine::OnConnectionChanged(network::mojom::ConnectionType type) { … }
void SyncEngine::OnPrimaryAccountChanged(
const signin::PrimaryAccountChangeEvent& event_details) { … }
SyncEngine::SyncEngine(
const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner,
const scoped_refptr<base::SequencedTaskRunner>& worker_task_runner,
const scoped_refptr<base::SequencedTaskRunner>& drive_task_runner,
const base::FilePath& sync_file_system_dir,
TaskLogger* task_logger,
drive::DriveNotificationManager* notification_manager,
extensions::ExtensionServiceInterface* extension_service,
extensions::ExtensionRegistry* extension_registry,
signin::IdentityManager* identity_manager,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
std::unique_ptr<DriveServiceFactory> drive_service_factory,
leveldb::Env* env_override)
: … { … }
void SyncEngine::OnPendingFileListUpdated(int item_count) { … }
void SyncEngine::OnFileStatusChanged(const storage::FileSystemURL& url,
SyncFileType file_type,
SyncFileStatus file_status,
SyncAction sync_action,
SyncDirection direction) { … }
void SyncEngine::UpdateServiceState(RemoteServiceState state,
const std::string& description) { … }
SyncStatusCallback SyncEngine::TrackCallback(SyncStatusCallback callback) { … }
}
}