| Index: chrome/browser/prefs/pref_model_associator.cc
|
| diff --git a/chrome/browser/prefs/pref_model_associator.cc b/chrome/browser/prefs/pref_model_associator.cc
|
| index 4a9a7e7d35cbe8cc52461b00536d7219fee215b0..acef08af7acf81c0f409d59425ca75dfea81d777 100644
|
| --- a/chrome/browser/prefs/pref_model_associator.cc
|
| +++ b/chrome/browser/prefs/pref_model_associator.cc
|
| @@ -33,9 +33,9 @@ PrefModelAssociator::~PrefModelAssociator() {
|
| }
|
|
|
| void PrefModelAssociator::InitPrefAndAssociate(
|
| - const SyncData& sync_pref,
|
| + const csync::SyncData& sync_pref,
|
| const std::string& pref_name,
|
| - SyncChangeList* sync_changes) {
|
| + csync::SyncChangeList* sync_changes) {
|
| const PrefService::Preference* pref =
|
| pref_service_->FindPreference(pref_name.c_str());
|
| DCHECK(pref);
|
| @@ -74,22 +74,24 @@ void PrefModelAssociator::InitPrefAndAssociate(
|
|
|
| // If the merge resulted in an updated value, inform the syncer.
|
| if (!value->Equals(new_value.get())) {
|
| - SyncData sync_data;
|
| + csync::SyncData sync_data;
|
| if (!CreatePrefSyncData(pref->name(), *new_value, &sync_data)) {
|
| LOG(ERROR) << "Failed to update preference.";
|
| return;
|
| }
|
| - sync_changes->push_back(SyncChange(SyncChange::ACTION_UPDATE, sync_data));
|
| + sync_changes->push_back(
|
| + csync::SyncChange(csync::SyncChange::ACTION_UPDATE, sync_data));
|
| }
|
| } else if (pref->IsUserControlled()) {
|
| // The server does not know about this preference and should be added
|
| // to the syncer's database.
|
| - SyncData sync_data;
|
| + csync::SyncData sync_data;
|
| if (!CreatePrefSyncData(pref->name(), *pref->GetValue(), &sync_data)) {
|
| LOG(ERROR) << "Failed to update preference.";
|
| return;
|
| }
|
| - sync_changes->push_back(SyncChange(SyncChange::ACTION_ADD, sync_data));
|
| + sync_changes->push_back(
|
| + csync::SyncChange(csync::SyncChange::ACTION_ADD, sync_data));
|
| } else {
|
| // This pref does not have a sync value but also does not have a user
|
| // controlled value (either it's a default value or it's policy controlled,
|
| @@ -104,11 +106,11 @@ void PrefModelAssociator::InitPrefAndAssociate(
|
| return;
|
| }
|
|
|
| -SyncError PrefModelAssociator::MergeDataAndStartSyncing(
|
| +csync::SyncError PrefModelAssociator::MergeDataAndStartSyncing(
|
| syncable::ModelType type,
|
| - const SyncDataList& initial_sync_data,
|
| - scoped_ptr<SyncChangeProcessor> sync_processor,
|
| - scoped_ptr<SyncErrorFactory> sync_error_factory) {
|
| + const csync::SyncDataList& initial_sync_data,
|
| + scoped_ptr<csync::SyncChangeProcessor> sync_processor,
|
| + scoped_ptr<csync::SyncErrorFactory> sync_error_factory) {
|
| DCHECK_EQ(type, PREFERENCES);
|
| DCHECK(CalledOnValidThread());
|
| DCHECK(pref_service_);
|
| @@ -118,12 +120,13 @@ SyncError PrefModelAssociator::MergeDataAndStartSyncing(
|
| sync_processor_ = sync_processor.Pass();
|
| sync_error_factory_ = sync_error_factory.Pass();
|
|
|
| - SyncChangeList new_changes;
|
| + csync::SyncChangeList new_changes;
|
| std::set<std::string> remaining_preferences = registered_preferences_;
|
|
|
| // Go through and check for all preferences we care about that sync already
|
| // knows about.
|
| - for (SyncDataList::const_iterator sync_iter = initial_sync_data.begin();
|
| + for (csync::SyncDataList::const_iterator sync_iter =
|
| + initial_sync_data.begin();
|
| sync_iter != initial_sync_data.end();
|
| ++sync_iter) {
|
| DCHECK_EQ(PREFERENCES, sync_iter->GetDataType());
|
| @@ -146,18 +149,18 @@ SyncError PrefModelAssociator::MergeDataAndStartSyncing(
|
| remaining_preferences.begin();
|
| pref_name_iter != remaining_preferences.end();
|
| ++pref_name_iter) {
|
| - InitPrefAndAssociate(SyncData(), *pref_name_iter, &new_changes);
|
| + InitPrefAndAssociate(csync::SyncData(), *pref_name_iter, &new_changes);
|
| }
|
|
|
| // Push updates to sync.
|
| - SyncError error =
|
| + csync::SyncError error =
|
| sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes);
|
| if (error.IsSet()) {
|
| return error;
|
| }
|
|
|
| models_associated_ = true;
|
| - return SyncError();
|
| + return csync::SyncError();
|
| }
|
|
|
| void PrefModelAssociator::StopSyncing(syncable::ModelType type) {
|
| @@ -190,7 +193,7 @@ Value* PrefModelAssociator::MergePreference(
|
| bool PrefModelAssociator::CreatePrefSyncData(
|
| const std::string& name,
|
| const Value& value,
|
| - SyncData* sync_data) {
|
| + csync::SyncData* sync_data) {
|
| std::string serialized;
|
| // TODO(zea): consider JSONWriter::Write since you don't have to check
|
| // failures to deserialize.
|
| @@ -204,7 +207,7 @@ bool PrefModelAssociator::CreatePrefSyncData(
|
| sync_pb::PreferenceSpecifics* pref_specifics = specifics.mutable_preference();
|
| pref_specifics->set_name(name);
|
| pref_specifics->set_value(serialized);
|
| - *sync_data = SyncData::CreateLocalData(name, name, specifics);
|
| + *sync_data = csync::SyncData::CreateLocalData(name, name, specifics);
|
| return true;
|
| }
|
|
|
| @@ -270,10 +273,11 @@ Value* PrefModelAssociator::MergeDictionaryValues(
|
| // with user controlled data. We do not track any information for preferences
|
| // not registered locally as syncable and do not inform the syncer of
|
| // non-user controlled preferences.
|
| -SyncDataList PrefModelAssociator::GetAllSyncData(syncable::ModelType type)
|
| +csync::SyncDataList PrefModelAssociator::GetAllSyncData(
|
| + syncable::ModelType type)
|
| const {
|
| DCHECK_EQ(PREFERENCES, type);
|
| - SyncDataList current_data;
|
| + csync::SyncDataList current_data;
|
| for (PreferenceSet::const_iterator iter = synced_preferences_.begin();
|
| iter != synced_preferences_.end();
|
| ++iter) {
|
| @@ -284,7 +288,7 @@ SyncDataList PrefModelAssociator::GetAllSyncData(syncable::ModelType type)
|
| if (!pref->IsUserControlled() || pref->IsDefaultValue())
|
| continue; // This is not data we care about.
|
| // TODO(zea): plumb a way to read the user controlled value.
|
| - SyncData sync_data;
|
| + csync::SyncData sync_data;
|
| if (!CreatePrefSyncData(name, *pref->GetValue(), &sync_data))
|
| continue;
|
| current_data.push_back(sync_data);
|
| @@ -292,17 +296,17 @@ SyncDataList PrefModelAssociator::GetAllSyncData(syncable::ModelType type)
|
| return current_data;
|
| }
|
|
|
| -SyncError PrefModelAssociator::ProcessSyncChanges(
|
| +csync::SyncError PrefModelAssociator::ProcessSyncChanges(
|
| const tracked_objects::Location& from_here,
|
| - const SyncChangeList& change_list) {
|
| + const csync::SyncChangeList& change_list) {
|
| if (!models_associated_) {
|
| - SyncError error(FROM_HERE,
|
| + csync::SyncError error(FROM_HERE,
|
| "Models not yet associated.",
|
| PREFERENCES);
|
| return error;
|
| }
|
| AutoReset<bool> processing_changes(&processing_syncer_changes_, true);
|
| - SyncChangeList::const_iterator iter;
|
| + csync::SyncChangeList::const_iterator iter;
|
| for (iter = change_list.begin(); iter != change_list.end(); ++iter) {
|
| DCHECK_EQ(PREFERENCES, iter->sync_data().GetDataType());
|
|
|
| @@ -312,7 +316,7 @@ SyncError PrefModelAssociator::ProcessSyncChanges(
|
| scoped_ptr<Value> value(ReadPreferenceSpecifics(pref_specifics,
|
| &name));
|
|
|
| - if (iter->change_type() == SyncChange::ACTION_DELETE) {
|
| + if (iter->change_type() == csync::SyncChange::ACTION_DELETE) {
|
| // We never delete preferences.
|
| NOTREACHED() << "Attempted to process sync delete change for " << name
|
| << ". Skipping.";
|
| @@ -343,11 +347,11 @@ SyncError PrefModelAssociator::ProcessSyncChanges(
|
| pref_service_->Set(pref_name, *value);
|
|
|
| // Keep track of any newly synced preferences.
|
| - if (iter->change_type() == SyncChange::ACTION_ADD) {
|
| + if (iter->change_type() == csync::SyncChange::ACTION_ADD) {
|
| synced_preferences_.insert(name);
|
| }
|
| }
|
| - return SyncError();
|
| + return csync::SyncError();
|
| }
|
|
|
| Value* PrefModelAssociator::ReadPreferenceSpecifics(
|
| @@ -399,7 +403,7 @@ void PrefModelAssociator::ProcessPrefChange(const std::string& name) {
|
| if (!IsPrefRegistered(name.c_str()))
|
| return; // We are not syncing this preference.
|
|
|
| - SyncChangeList changes;
|
| + csync::SyncChangeList changes;
|
|
|
| if (!preference->IsUserModifiable()) {
|
| // If the preference is no longer user modifiable, it must now be controlled
|
| @@ -415,18 +419,19 @@ void PrefModelAssociator::ProcessPrefChange(const std::string& name) {
|
| // Not in synced_preferences_ means no synced data. InitPrefAndAssociate(..)
|
| // will determine if we care about its data (e.g. if it has a default value
|
| // and hasn't been changed yet we don't) and take care syncing any new data.
|
| - InitPrefAndAssociate(SyncData(), name, &changes);
|
| + InitPrefAndAssociate(csync::SyncData(), name, &changes);
|
| } else {
|
| // We are already syncing this preference, just update it's sync node.
|
| - SyncData sync_data;
|
| + csync::SyncData sync_data;
|
| if (!CreatePrefSyncData(name, *preference->GetValue(), &sync_data)) {
|
| LOG(ERROR) << "Failed to update preference.";
|
| return;
|
| }
|
| - changes.push_back(SyncChange(SyncChange::ACTION_UPDATE, sync_data));
|
| + changes.push_back(
|
| + csync::SyncChange(csync::SyncChange::ACTION_UPDATE, sync_data));
|
| }
|
|
|
| - SyncError error =
|
| + csync::SyncError error =
|
| sync_processor_->ProcessSyncChanges(FROM_HERE, changes);
|
| }
|
|
|
|
|