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

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: Fix unit test 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..5b954282ad1f818baf5b7e6652628875d0130c1c 100644
--- a/chrome/browser/prefs/pref_model_associator.cc
+++ b/chrome/browser/prefs/pref_model_associator.cc
@@ -119,7 +119,8 @@ void PrefModelAssociator::InitPrefAndAssociate(
bool PrefModelAssociator::MergeDataAndStartSyncing(
syncable::ModelType type,
const SyncDataList& initial_sync_data,
- SyncChangeProcessor* sync_processor) {
+ SyncChangeProcessor* sync_processor,
+ SyncError* error) {
DCHECK_EQ(type, PREFERENCES);
DCHECK(CalledOnValidThread());
DCHECK(!sync_processor_);
@@ -158,9 +159,12 @@ bool PrefModelAssociator::MergeDataAndStartSyncing(
}
// Push updates to sync.
- sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes);
- models_associated_ = true;
- return true;
+ if (!sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes, error)) {
+ return false;
+ } else {
+ models_associated_ = true;
+ return true;
+ }
}
void PrefModelAssociator::StopSyncing(syncable::ModelType type) {
@@ -306,11 +310,16 @@ SyncDataList PrefModelAssociator::GetAllSyncData(syncable::ModelType type)
return current_data;
}
-void PrefModelAssociator::ProcessSyncChanges(
+bool PrefModelAssociator::ProcessSyncChanges(
const tracked_objects::Location& from_here,
- const SyncChangeList& change_list) {
- if (!models_associated_)
- return;
+ const SyncChangeList& change_list,
+ SyncError* error) {
+ if (!models_associated_) {
+ error->reset(FROM_HERE,
+ "Models not yet associated.",
+ PREFERENCES);
+ return false;
+ }
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 true;
}
Value* PrefModelAssociator::ReadPreferenceSpecifics(
@@ -432,5 +442,8 @@ void PrefModelAssociator::ProcessPrefChange(const std::string& name) {
}
changes.push_back(SyncChange(SyncChange::ACTION_UPDATE, sync_data));
}
- sync_processor_->ProcessSyncChanges(FROM_HERE, changes);
+
+ SyncError error;
+ if (!sync_processor_->ProcessSyncChanges(FROM_HERE, changes, &error))
+ StopSyncing(PREFERENCES);
}

Powered by Google App Engine
This is Rietveld 408576698