summaryrefslogtreecommitdiffstats
path: root/chrome/browser/prefs
diff options
context:
space:
mode:
authorzea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-26 23:41:50 +0000
committerzea@chromium.org <zea@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-26 23:41:50 +0000
commitde7d78c74cb823da110e828610be3b83f4229c00 (patch)
tree2b26c2a59804f68d76c93b308deab48cdb15ea37 /chrome/browser/prefs
parenta3bcff633580fa9afd4653817f497d8a49235994 (diff)
downloadchromium_src-de7d78c74cb823da110e828610be3b83f4229c00.zip
chromium_src-de7d78c74cb823da110e828610be3b83f4229c00.tar.gz
chromium_src-de7d78c74cb823da110e828610be3b83f4229c00.tar.bz2
Reland 87645 with clang fixes.
[Sync] Refactor sync datatype error handling. This introduces SyncError's, which are a convenient way of passing around an error location, type, and message. All datatypes have been refactored to use this, including in the AssociateModels code. A future change will use this to add support for continuing sync even when a datatype fails to start. In addition, eventually a future change will convert the UnrecoverableError handler to use SyncError's as well as have the datatype controller's and datatype manager surface SyncError's to the PSS. Original Review URL: http://codereview.chromium.org/7453014 TBR=akalin@chromium.org BUG=87645 TEST= Review URL: http://codereview.chromium.org/7461098 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94204 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/prefs')
-rw-r--r--chrome/browser/prefs/pref_model_associator.cc28
-rw-r--r--chrome/browser/prefs/pref_model_associator.h7
2 files changed, 25 insertions, 10 deletions
diff --git a/chrome/browser/prefs/pref_model_associator.cc b/chrome/browser/prefs/pref_model_associator.cc
index 5c004a7b..88c9640 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);
+ SyncError error =
+ sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes);
+ if (error.IsSet()) {
+ return error;
+ }
+
models_associated_ = true;
- return 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);
}
diff --git a/chrome/browser/prefs/pref_model_associator.h b/chrome/browser/prefs/pref_model_associator.h
index 1503153..a185a78 100644
--- a/chrome/browser/prefs/pref_model_associator.h
+++ b/chrome/browser/prefs/pref_model_associator.h
@@ -37,9 +37,10 @@ class PrefModelAssociator
// SyncableService implementation.
virtual SyncDataList GetAllSyncData(syncable::ModelType type) const OVERRIDE;
- virtual void ProcessSyncChanges(const tracked_objects::Location& from_here,
- const SyncChangeList& change_list) OVERRIDE;
- virtual bool MergeDataAndStartSyncing(
+ virtual SyncError ProcessSyncChanges(
+ const tracked_objects::Location& from_here,
+ const SyncChangeList& change_list) OVERRIDE;
+ virtual SyncError MergeDataAndStartSyncing(
syncable::ModelType type,
const SyncDataList& initial_sync_data,
SyncChangeProcessor* sync_processor) OVERRIDE;