#include "components/commerce/core/product_specifications/product_specifications_sync_bridge.h"
#include <optional>
#include <set>
#include "base/feature_list.h"
#include "base/functional/callback_helpers.h"
#include "base/strings/stringprintf.h"
#include "base/uuid.h"
#include "components/commerce/core/commerce_feature_list.h"
#include "components/commerce/core/product_specifications/product_specifications_set.h"
#include "components/sync/base/data_type.h"
#include "components/sync/base/deletion_origin.h"
#include "components/sync/base/unique_position.h"
#include "components/sync/model/data_type_local_change_processor.h"
#include "components/sync/model/data_type_store.h"
#include "components/sync/model/in_memory_metadata_change_list.h"
#include "components/sync/model/metadata_batch.h"
#include "components/sync/model/mutable_data_batch.h"
#include "components/sync/protocol/entity_metadata.pb.h"
#include "components/sync/protocol/product_comparison_specifics.pb.h"
#include "url/gurl.h"
namespace {
syncer::EntityData MakeEntityData(
const sync_pb::ProductComparisonSpecifics& specifics) { … }
bool IsMultiSpecSetsEnabled() { … }
}
namespace commerce {
ProductSpecificationsSyncBridge::ProductSpecificationsSyncBridge(
syncer::OnceDataTypeStoreFactory create_store_callback,
std::unique_ptr<syncer::DataTypeLocalChangeProcessor> change_processor,
base::OnceCallback<void(void)> init_callback,
Delegate* delegate)
: … { … }
ProductSpecificationsSyncBridge::~ProductSpecificationsSyncBridge() = default;
std::unique_ptr<syncer::MetadataChangeList>
ProductSpecificationsSyncBridge::CreateMetadataChangeList() { … }
std::optional<syncer::ModelError>
ProductSpecificationsSyncBridge::MergeFullSyncData(
std::unique_ptr<syncer::MetadataChangeList> metadata_change_list,
syncer::EntityChangeList entity_changes) { … }
std::optional<syncer::ModelError>
ProductSpecificationsSyncBridge::ApplyIncrementalSyncChanges(
std::unique_ptr<syncer::MetadataChangeList> metadata_change_list,
syncer::EntityChangeList entity_changes) { … }
std::string ProductSpecificationsSyncBridge::GetStorageKey(
const syncer::EntityData& entity_data) { … }
std::string ProductSpecificationsSyncBridge::GetClientTag(
const syncer::EntityData& entity_data) { … }
std::unique_ptr<syncer::DataBatch>
ProductSpecificationsSyncBridge::GetDataForCommit(StorageKeyList storage_keys) { … }
std::unique_ptr<syncer::DataBatch>
ProductSpecificationsSyncBridge::GetAllDataForDebugging() { … }
sync_pb::EntitySpecifics
ProductSpecificationsSyncBridge::TrimAllSupportedFieldsFromRemoteSpecifics(
const sync_pb::EntitySpecifics& entity_specifics) const { … }
bool ProductSpecificationsSyncBridge::IsSyncEnabled() { … }
void ProductSpecificationsSyncBridge::AddSpecifics(
const std::vector<sync_pb::ProductComparisonSpecifics> specifics) { … }
void ProductSpecificationsSyncBridge::UpdateSpecifics(
const sync_pb::ProductComparisonSpecifics& new_specifics) { … }
void ProductSpecificationsSyncBridge::DeleteSpecifics(
const std::vector<sync_pb::ProductComparisonSpecifics> to_remove) { … }
void ProductSpecificationsSyncBridge::OnStoreCreated(
const std::optional<syncer::ModelError>& error,
std::unique_ptr<syncer::DataTypeStore> store) { … }
void ProductSpecificationsSyncBridge::OnReadAllDataAndMetadata(
const std::optional<syncer::ModelError>& error,
std::unique_ptr<syncer::DataTypeStore::RecordList> record_list,
std::unique_ptr<syncer::MetadataBatch> metadata_batch) { … }
void ProductSpecificationsSyncBridge::Commit(
std::unique_ptr<syncer::DataTypeStore::WriteBatch> batch) { … }
bool ProductSpecificationsSyncBridge::SyncMetadataCacheContainsSupportedFields(
const syncer::EntityMetadataMap& metadata_map) const { … }
void ProductSpecificationsSyncBridge::OnCommit(
const std::optional<syncer::ModelError>& error) { … }
const sync_pb::ProductComparisonSpecifics&
ProductSpecificationsSyncBridge::GetPossiblyTrimmedPasswordSpecificsData(
const std::string& storage_key) { … }
std::unique_ptr<syncer::EntityData>
ProductSpecificationsSyncBridge::CreateEntityData(
const sync_pb::ProductComparisonSpecifics& specifics) { … }
const sync_pb::ProductComparisonSpecifics
ProductSpecificationsSyncBridge::TrimSpecificsForCaching(
const sync_pb::ProductComparisonSpecifics& comparison_specifics) const { … }
void ProductSpecificationsSyncBridge::ApplyIncrementalSyncChangesForTesting(
const std::vector<std::pair<sync_pb::ProductComparisonSpecifics,
syncer::EntityChange::ChangeType>>&
specifics_to_change) { … }
}