Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2884)

Unified Diff: chrome/browser/prefs/pref_model_associator.cc

Issue 7453014: [Sync] Refactor sync datatype error handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 5c004a7becc9ae4fea2ad292af6736f21b4720b7..3298d658a3bad952df9754a95a6a807d5d077206 100644
--- a/chrome/browser/prefs/pref_model_associator.cc
+++ b/chrome/browser/prefs/pref_model_associator.cc
@@ -116,7 +116,7 @@ void PrefModelAssociator::InitPrefAndAssociate(
return;
}
-bool PrefModelAssociator::MergeDataAndStartSyncing(
+SyncError PrefModelAssociator::MergeDataAndStartSyncing(
syncable::ModelType type,
const SyncDataList& initial_sync_data,
SyncChangeProcessor* sync_processor) {
@@ -158,9 +158,14 @@ bool PrefModelAssociator::MergeDataAndStartSyncing(
}
// Push updates to sync.
- sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes);
- models_associated_ = true;
- return true;
+ SyncError error =
+ sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes);
+ if (error.IsSet()) {
+ return error;
+ } else {
akalin 2011/07/25 22:43:13 i think it's cleaner to leave off the else (since
Nicolas Zea 2011/07/25 23:08:19 Done.
+ models_associated_ = true;
+ return SyncError();
+ }
}
void PrefModelAssociator::StopSyncing(syncable::ModelType type) {
@@ -306,11 +311,15 @@ SyncDataList PrefModelAssociator::GetAllSyncData(syncable::ModelType type)
return current_data;
}
-void PrefModelAssociator::ProcessSyncChanges(
+SyncError PrefModelAssociator::ProcessSyncChanges(
const tracked_objects::Location& from_here,
const SyncChangeList& change_list) {
- if (!models_associated_)
- return;
+ if (!models_associated_) {
+ SyncError error(FROM_HERE,
+ "Models not yet associated.",
+ PREFERENCES);
+ return error;
+ }
AutoReset<bool> processing_changes(&processing_syncer_changes_, true);
SyncChangeList::const_iterator iter;
for (iter = change_list.begin(); iter != change_list.end(); ++iter) {
@@ -359,6 +368,7 @@ void PrefModelAssociator::ProcessSyncChanges(
SendUpdateNotificationsIfNecessary(name);
}
+ return SyncError();
}
Value* PrefModelAssociator::ReadPreferenceSpecifics(
@@ -432,5 +442,9 @@ void PrefModelAssociator::ProcessPrefChange(const std::string& name) {
}
changes.push_back(SyncChange(SyncChange::ACTION_UPDATE, sync_data));
}
- sync_processor_->ProcessSyncChanges(FROM_HERE, changes);
+
+ SyncError error =
+ sync_processor_->ProcessSyncChanges(FROM_HERE, changes);
+ if (error.IsSet())
+ StopSyncing(PREFERENCES);
}

Powered by Google App Engine
This is Rietveld 408576698