#include "chrome/browser/sync_file_system/drive_backend/local_to_remote_syncer.h"
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/check_op.h"
#include "base/format_macros.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/location.h"
#include "base/notreached.h"
#include "base/strings/stringprintf.h"
#include "base/task/sequenced_task_runner.h"
#include "chrome/browser/sync_file_system/drive_backend/callback_helper.h"
#include "chrome/browser/sync_file_system/drive_backend/drive_backend_constants.h"
#include "chrome/browser/sync_file_system/drive_backend/drive_backend_util.h"
#include "chrome/browser/sync_file_system/drive_backend/folder_creator.h"
#include "chrome/browser/sync_file_system/drive_backend/metadata_database.h"
#include "chrome/browser/sync_file_system/drive_backend/metadata_database.pb.h"
#include "chrome/browser/sync_file_system/drive_backend/sync_engine_context.h"
#include "chrome/browser/sync_file_system/drive_backend/sync_task_manager.h"
#include "chrome/browser/sync_file_system/drive_backend/sync_task_token.h"
#include "chrome/browser/sync_file_system/logger.h"
#include "components/drive/drive_api_util.h"
#include "components/drive/drive_uploader.h"
#include "components/drive/service/drive_service_interface.h"
#include "google_apis/drive/drive_api_parser.h"
#include "net/base/mime_util.h"
#include "storage/common/file_system/file_system_util.h"
namespace sync_file_system {
namespace drive_backend {
namespace {
std::unique_ptr<FileTracker> FindTrackerByID(
MetadataDatabase* metadata_database,
int64_t tracker_id) { … }
bool GetKnownChangeID(MetadataDatabase* metadata_database,
const std::string& file_id,
int64_t* change_id) { … }
bool IsLocalFileMissing(const SyncFileMetadata& local_metadata,
const FileChange& local_change) { … }
std::string GetMimeTypeFromTitle(const base::FilePath& title) { … }
}
LocalToRemoteSyncer::LocalToRemoteSyncer(SyncEngineContext* sync_context,
const SyncFileMetadata& local_metadata,
const FileChange& local_change,
const base::FilePath& local_path,
const storage::FileSystemURL& url)
: … { … }
LocalToRemoteSyncer::~LocalToRemoteSyncer() = default;
void LocalToRemoteSyncer::RunPreflight(std::unique_ptr<SyncTaskToken> token) { … }
void LocalToRemoteSyncer::MoveToBackground(
Continuation continuation,
std::unique_ptr<SyncTaskToken> token) { … }
void LocalToRemoteSyncer::ContinueAsBackgroundTask(
Continuation continuation,
std::unique_ptr<SyncTaskToken> token) { … }
void LocalToRemoteSyncer::SyncCompleted(std::unique_ptr<SyncTaskToken> token,
SyncStatusCode status) { … }
void LocalToRemoteSyncer::HandleConflict(std::unique_ptr<SyncTaskToken> token) { … }
void LocalToRemoteSyncer::UpdateTrackerForReusedFolder(
const FileDetails& details,
std::unique_ptr<SyncTaskToken> token) { … }
void LocalToRemoteSyncer::HandleExistingRemoteFile(
std::unique_ptr<SyncTaskToken> token) { … }
void LocalToRemoteSyncer::DeleteRemoteFile(
std::unique_ptr<SyncTaskToken> token) { … }
void LocalToRemoteSyncer::DidDeleteRemoteFile(
std::unique_ptr<SyncTaskToken> token,
google_apis::ApiErrorCode error) { … }
void LocalToRemoteSyncer::UploadExistingFile(
std::unique_ptr<SyncTaskToken> token) { … }
void LocalToRemoteSyncer::DidUploadExistingFile(
std::unique_ptr<SyncTaskToken> token,
google_apis::ApiErrorCode error,
const GURL&,
std::unique_ptr<google_apis::FileResource> entry) { … }
void LocalToRemoteSyncer::UpdateRemoteMetadata(
const std::string& file_id,
std::unique_ptr<SyncTaskToken> token) { … }
void LocalToRemoteSyncer::DidGetRemoteMetadata(
const std::string& file_id,
std::unique_ptr<SyncTaskToken> token,
google_apis::ApiErrorCode error,
std::unique_ptr<google_apis::FileResource> entry) { … }
void LocalToRemoteSyncer::UploadNewFile(std::unique_ptr<SyncTaskToken> token) { … }
void LocalToRemoteSyncer::DidUploadNewFile(
std::unique_ptr<SyncTaskToken> token,
google_apis::ApiErrorCode error,
const GURL& upload_location,
std::unique_ptr<google_apis::FileResource> entry) { … }
void LocalToRemoteSyncer::CreateRemoteFolder(
std::unique_ptr<SyncTaskToken> token) { … }
void LocalToRemoteSyncer::DidCreateRemoteFolder(
std::unique_ptr<SyncTaskToken> token,
const std::string& file_id,
SyncStatusCode status) { … }
void LocalToRemoteSyncer::DidDetachResourceForCreationConflict(
std::unique_ptr<SyncTaskToken> token,
google_apis::ApiErrorCode error) { … }
bool LocalToRemoteSyncer::IsContextReady() { … }
drive::DriveServiceInterface* LocalToRemoteSyncer::drive_service() { … }
drive::DriveUploaderInterface* LocalToRemoteSyncer::drive_uploader() { … }
MetadataDatabase* LocalToRemoteSyncer::metadata_database() { … }
}
}