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

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: Add operator= 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..f92eaaa3f01036b0d9191ff1fcf8c5b20b653ceb 100644
--- a/chrome/browser/prefs/pref_model_associator.cc
+++ b/chrome/browser/prefs/pref_model_associator.cc
@@ -11,6 +11,7 @@
#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/sync/api/sync_change.h"
+#include "chrome/browser/sync/api/sync_error.h"
#include "chrome/browser/sync/protocol/preference_specifics.pb.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/pref_names.h"
@@ -119,7 +120,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 +160,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 +311,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 +369,7 @@ void PrefModelAssociator::ProcessSyncChanges(
SendUpdateNotificationsIfNecessary(name);
}
+ return true;
}
Value* PrefModelAssociator::ReadPreferenceSpecifics(
@@ -432,5 +443,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