Index: chrome/browser/sync/glue/bookmark_model_associator.cc |
diff --git a/chrome/browser/sync/glue/bookmark_model_associator.cc b/chrome/browser/sync/glue/bookmark_model_associator.cc |
index 4da7a1b5cbd6276b9c46eae0a7691d4e22154692..891d06e62cba9f0111825d683c3f9df398ee6341 100644 |
--- a/chrome/browser/sync/glue/bookmark_model_associator.cc |
+++ b/chrome/browser/sync/glue/bookmark_model_associator.cc |
@@ -364,7 +364,10 @@ bool BookmarkModelAssociator::GetSyncIdForTaggedNode(const std::string& tag, |
syncer::SyncError BookmarkModelAssociator::AssociateModels( |
syncer::SyncMergeResult* local_merge_result, |
syncer::SyncMergeResult* syncer_merge_result) { |
- CheckModelSyncState(); |
+ syncer::SyncError error; |
+ error = CheckModelSyncState(); |
+ if (error.IsSet()) |
+ return error; |
scoped_ptr<ScopedAssociationUpdater> association_updater( |
new ScopedAssociationUpdater(bookmark_model_)); |
@@ -701,22 +704,35 @@ bool BookmarkModelAssociator::CryptoReadyIfNecessary() { |
trans.GetCryptographer()->is_ready(); |
} |
-void BookmarkModelAssociator::CheckModelSyncState() const { |
+syncer::SyncError BookmarkModelAssociator::CheckModelSyncState() const { |
std::string version_str; |
if (bookmark_model_->root_node()->GetMetaInfo(kBookmarkTransactionVersionKey, |
&version_str)) { |
syncer::ReadTransaction trans(FROM_HERE, user_share_); |
- int64 native_version; |
+ int64 native_version = syncer::syncable::kInvalidTransactionVersion; |
+ int64 sync_version = trans.GetModelVersion(syncer::BOOKMARKS); |
if (base::StringToInt64(version_str, &native_version) && |
- native_version != trans.GetModelVersion(syncer::BOOKMARKS)) { |
+ native_version != sync_version) { |
UMA_HISTOGRAM_ENUMERATION("Sync.LocalModelOutOfSync", |
ModelTypeToHistogramInt(syncer::BOOKMARKS), |
syncer::MODEL_TYPE_COUNT); |
+ |
// Clear version on bookmark model so that we only report error once. |
bookmark_model_->DeleteNodeMetaInfo(bookmark_model_->root_node(), |
kBookmarkTransactionVersionKey); |
+ |
+ // If the native version is higher, there was a sync persistence failure, |
+ // and we need to delay association until after a GetUpdates. |
+ if (sync_version < native_version) { |
+ DVLOG(1) << "Native version (" << native_version << ") does not match " |
+ << "sync version (" << sync_version << ")."; |
+ return syncer::SyncError(FROM_HERE, |
+ syncer::SyncError::PERSISTENCE_ERROR, |
+ syncer::BOOKMARKS); |
+ } |
} |
} |
+ return syncer::SyncError(); |
} |
} // namespace browser_sync |