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

Unified Diff: chrome/browser/sync/glue/bookmark_model_associator.cc

Issue 15701022: [Sync] Add support for sync Persistence Errors (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move bookmark change into separate patch Created 7 years, 6 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/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 846d3e2955ca37e85cb2b923c07d96db00f32f92..2782ec22efe671c04c7f527c74d10e1970024d19 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(local_merge_result, syncer_merge_result);
+ syncer::SyncError error = CheckModelSyncState(local_merge_result,
+ syncer_merge_result);
+ if (error.IsSet())
+ return error;
scoped_ptr<ScopedAssociationUpdater> association_updater(
new ScopedAssociationUpdater(bookmark_model_));
@@ -702,16 +705,16 @@ bool BookmarkModelAssociator::CryptoReadyIfNecessary() {
trans.GetCryptographer()->is_ready();
}
-void BookmarkModelAssociator::CheckModelSyncState(
+syncer::SyncError BookmarkModelAssociator::CheckModelSyncState(
syncer::SyncMergeResult* local_merge_result,
syncer::SyncMergeResult* syncer_merge_result) 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;
if (!base::StringToInt64(version_str, &native_version))
- return;
+ return syncer::SyncError();
local_merge_result->set_pre_association_version(native_version);
int64 sync_version = trans.GetModelVersion(syncer::BOOKMARKS);
@@ -721,11 +724,21 @@ void BookmarkModelAssociator::CheckModelSyncState(
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 << ").";
+ // TODO(zea): return a persistence error here.
+ }
}
}
+ return syncer::SyncError();
}
} // namespace browser_sync
« no previous file with comments | « chrome/browser/sync/glue/bookmark_model_associator.h ('k') | chrome/browser/sync/glue/data_type_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698