#include "components/sync_preferences/pref_model_associator.h"
#include <algorithm>
#include <memory>
#include <string>
#include <string_view>
#include <utility>
#include "base/auto_reset.h"
#include "base/check_op.h"
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/json/json_reader.h"
#include "base/json/json_string_value_serializer.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/observer_list.h"
#include "base/types/expected_macros.h"
#include "base/values.h"
#include "build/chromeos_buildflags.h"
#include "components/sync/base/data_type.h"
#include "components/sync/base/features.h"
#include "components/sync/model/sync_change.h"
#include "components/sync/model/sync_change_processor.h"
#include "components/sync/protocol/entity_specifics.pb.h"
#include "components/sync/protocol/preference_specifics.pb.h"
#include "components/sync_preferences/dual_layer_user_pref_store.h"
#include "components/sync_preferences/preferences_merge_helper.h"
#include "components/sync_preferences/syncable_prefs_database.h"
namespace sync_preferences {
namespace {
const sync_pb::PreferenceSpecifics& GetSpecifics(const syncer::SyncData& pref) { … }
std::optional<base::Value> ReadPreferenceSpecifics(
const sync_pb::PreferenceSpecifics& preference) { … }
}
PrefModelAssociator::PrefModelAssociator(
scoped_refptr<PrefModelAssociatorClient> client,
scoped_refptr<WriteablePrefStore> user_prefs,
syncer::DataType type)
: … { … }
PrefModelAssociator::PrefModelAssociator(
scoped_refptr<PrefModelAssociatorClient> client,
scoped_refptr<DualLayerUserPrefStore> dual_layer_user_prefs,
syncer::DataType type)
: … { … }
PrefModelAssociator::~PrefModelAssociator() { … }
void PrefModelAssociator::SetPrefService(
PrefServiceForAssociator* pref_service) { … }
sync_pb::PreferenceSpecifics* PrefModelAssociator::GetMutableSpecifics(
syncer::DataType type,
sync_pb::EntitySpecifics* specifics) { … }
void PrefModelAssociator::InitPrefAndAssociate(
const syncer::SyncData& sync_pref,
std::string_view pref_name,
syncer::SyncChangeList* sync_changes) { … }
void PrefModelAssociator::WaitUntilReadyToSync(base::OnceClosure done) { … }
std::optional<syncer::ModelError> PrefModelAssociator::MergeDataAndStartSyncing(
syncer::DataType type,
const syncer::SyncDataList& initial_sync_data,
std::unique_ptr<syncer::SyncChangeProcessor> sync_processor) { … }
void PrefModelAssociator::StopSyncing(syncer::DataType type) { … }
void PrefModelAssociator::OnBrowserShutdown(syncer::DataType type) { … }
void PrefModelAssociator::Stop(bool is_browser_shutdown) { … }
bool PrefModelAssociator::CreatePrefSyncData(
std::string_view name,
const base::Value& value,
syncer::SyncData* sync_data) const { … }
std::optional<syncer::ModelError> PrefModelAssociator::ProcessSyncChanges(
const base::Location& from_here,
const syncer::SyncChangeList& change_list) { … }
base::WeakPtr<syncer::SyncableService> PrefModelAssociator::AsWeakPtr() { … }
void PrefModelAssociator::AddSyncedPrefObserver(const std::string& name,
SyncedPrefObserver* observer) { … }
void PrefModelAssociator::RemoveSyncedPrefObserver(
const std::string& name,
SyncedPrefObserver* observer) { … }
bool PrefModelAssociator::IsPrefSyncedForTesting(
const std::string& name) const { … }
void PrefModelAssociator::RegisterPref(std::string_view name) { … }
bool PrefModelAssociator::IsPrefRegistered(std::string_view name) const { … }
void PrefModelAssociator::OnPrefValueChanged(std::string_view name) { … }
void PrefModelAssociator::OnInitializationCompleted(bool succeeded) { … }
void PrefModelAssociator::NotifySyncedPrefObservers(std::string_view path,
bool from_sync) const { … }
bool PrefModelAssociator::SetPrefWithTypeCheck(std::string_view pref_name,
const base::Value& new_value) { … }
void PrefModelAssociator::NotifyStartedSyncing(const std::string& path) const { … }
bool PrefModelAssociator::IsUsingDualLayerUserPrefStoreForTesting() const { … }
}