#include "components/sync/model/syncable_service_based_bridge.h"
#include <stdint.h>
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/stringprintf.h"
#include "base/trace_event/memory_usage_estimator.h"
#include "base/trace_event/trace_event.h"
#include "components/sync/base/client_tag_hash.h"
#include "components/sync/base/deletion_origin.h"
#include "components/sync/model/conflict_resolution.h"
#include "components/sync/model/metadata_batch.h"
#include "components/sync/model/mutable_data_batch.h"
#include "components/sync/model/sync_change.h"
#include "components/sync/model/syncable_service.h"
#include "components/sync/protocol/data_type_state_helper.h"
#include "components/sync/protocol/entity_specifics.pb.h"
#include "components/sync/protocol/persisted_entity_data.pb.h"
#include "components/sync/protocol/proto_memory_estimations.h"
namespace syncer {
namespace {
std::unique_ptr<EntityData> ConvertPersistedToEntityData(
const ClientTagHash& client_tag_hash,
sync_pb::PersistedEntityData data) { … }
sync_pb::PersistedEntityData CreatePersistedFromRemoteData(
const EntityData& entity_data) { … }
sync_pb::PersistedEntityData CreatePersistedFromLocalData(
const SyncData& sync_data) { … }
SyncChange::SyncChangeType ConvertToSyncChangeType(
EntityChange::ChangeType type) { … }
std::optional<ModelError> ParseInMemoryStoreOnBackendSequence(
SyncableServiceBasedBridge::InMemoryStore* in_memory_store,
std::unique_ptr<DataTypeStore::RecordList> record_list) { … }
class LocalChangeProcessor : public SyncChangeProcessor { … };
}
SyncableServiceBasedBridge::SyncableServiceBasedBridge(
DataType type,
OnceDataTypeStoreFactory store_factory,
std::unique_ptr<DataTypeLocalChangeProcessor> change_processor,
SyncableService* syncable_service)
: … { … }
SyncableServiceBasedBridge::~SyncableServiceBasedBridge() { … }
std::unique_ptr<MetadataChangeList>
SyncableServiceBasedBridge::CreateMetadataChangeList() { … }
std::optional<ModelError> SyncableServiceBasedBridge::MergeFullSyncData(
std::unique_ptr<MetadataChangeList> metadata_change_list,
EntityChangeList entity_change_list) { … }
std::optional<ModelError>
SyncableServiceBasedBridge::ApplyIncrementalSyncChanges(
std::unique_ptr<MetadataChangeList> metadata_change_list,
EntityChangeList entity_change_list) { … }
std::unique_ptr<DataBatch> SyncableServiceBasedBridge::GetDataForCommit(
StorageKeyList storage_keys) { … }
std::unique_ptr<DataBatch>
SyncableServiceBasedBridge::GetAllDataForDebugging() { … }
std::string SyncableServiceBasedBridge::GetClientTag(
const EntityData& entity_data) { … }
std::string SyncableServiceBasedBridge::GetStorageKey(
const EntityData& entity_data) { … }
bool SyncableServiceBasedBridge::SupportsGetClientTag() const { … }
bool SyncableServiceBasedBridge::SupportsGetStorageKey() const { … }
ConflictResolution SyncableServiceBasedBridge::ResolveConflict(
const std::string& storage_key,
const EntityData& remote_data) const { … }
void SyncableServiceBasedBridge::ApplyDisableSyncChanges(
std::unique_ptr<MetadataChangeList> delete_metadata_change_list) { … }
size_t SyncableServiceBasedBridge::EstimateSyncOverheadMemoryUsage() const { … }
std::unique_ptr<SyncChangeProcessor>
SyncableServiceBasedBridge::CreateLocalChangeProcessorForTesting(
DataType type,
DataTypeStore* store,
InMemoryStore* in_memory_store,
DataTypeLocalChangeProcessor* other) { … }
void SyncableServiceBasedBridge::OnStoreCreated(
const std::optional<ModelError>& error,
std::unique_ptr<DataTypeStore> store) { … }
void SyncableServiceBasedBridge::OnReadAllDataForInit(
std::unique_ptr<InMemoryStore> in_memory_store,
const std::optional<ModelError>& error) { … }
void SyncableServiceBasedBridge::OnReadAllMetadataForInit(
const std::optional<ModelError>& error,
std::unique_ptr<MetadataBatch> metadata_batch) { … }
void SyncableServiceBasedBridge::OnSyncableServiceReady(
std::unique_ptr<MetadataBatch> metadata_batch) { … }
std::optional<ModelError> SyncableServiceBasedBridge::StartSyncableService() { … }
SyncChangeList SyncableServiceBasedBridge::StoreAndConvertRemoteChanges(
std::unique_ptr<MetadataChangeList> initial_metadata_change_list,
EntityChangeList input_entity_change_list) { … }
void SyncableServiceBasedBridge::ReportErrorIfSet(
const std::optional<ModelError>& error) { … }
}