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

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

Issue 11341048: Populate versions on individual nodes in sync model and native bookmark model. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 165a4766808f1af01cb085bb924691386e035678..f8755cdad3bfbb483c8a04374b85669f8df7be70 100644
--- a/chrome/browser/sync/glue/bookmark_model_associator.cc
+++ b/chrome/browser/sync/glue/bookmark_model_associator.cc
@@ -527,26 +527,41 @@ void BookmarkModelAssociator::PersistAssociations() {
return;
}
- syncer::WriteTransaction trans(FROM_HERE, user_share_);
- DirtyAssociationsSyncIds::iterator iter;
- for (iter = dirty_associations_sync_ids_.begin();
- iter != dirty_associations_sync_ids_.end();
- ++iter) {
- int64 sync_id = *iter;
- syncer::WriteNode sync_node(&trans);
- if (sync_node.InitByIdLookup(sync_id) != syncer::BaseNode::INIT_OK) {
- unrecoverable_error_handler_->OnSingleDatatypeUnrecoverableError(
- FROM_HERE,
- "Could not lookup bookmark node for ID persistence.");
- return;
+ int64 new_version = -1;
+ std::vector<const BookmarkNode*> bnodes;
+ {
+ syncer::WriteTransaction trans(FROM_HERE, user_share_, &new_version);
+ DirtyAssociationsSyncIds::iterator iter;
+ for (iter = dirty_associations_sync_ids_.begin();
+ iter != dirty_associations_sync_ids_.end();
+ ++iter) {
+ int64 sync_id = *iter;
+ syncer::WriteNode sync_node(&trans);
+ if (sync_node.InitByIdLookup(sync_id) != syncer::BaseNode::INIT_OK) {
+ unrecoverable_error_handler_->OnSingleDatatypeUnrecoverableError(
+ FROM_HERE,
+ "Could not lookup bookmark node for ID persistence.");
+ return;
+ }
+ const BookmarkNode* node = GetChromeNodeFromSyncId(sync_id);
+ if (node && sync_node.GetExternalId() != node->id()) {
+ sync_node.SetExternalId(node->id());
+ bnodes.push_back(node);
+ }
+ }
+ dirty_associations_sync_ids_.clear();
+ }
+
+ if (new_version > 0) {
+ bookmark_model_->SetNodeMetaInfo(bookmark_model_->root_node(),
+ kBookmarkTransactionVersionKey,
+ base::Int64ToString(new_version));
+ for (uint32 i = 0; i < bnodes.size(); ++i) {
tim (not reviewing) 2012/11/08 17:38:49 Prefer size_t, although I think this could all be
haitaol1 2012/11/08 19:06:53 Done.
+ bookmark_model_->SetNodeMetaInfo(bnodes[i],
+ kBookmarkTransactionVersionKey,
+ base::Int64ToString(new_version));
}
- const BookmarkNode* node = GetChromeNodeFromSyncId(sync_id);
- if (node)
- sync_node.SetExternalId(node->id());
- else
- NOTREACHED();
}
- dirty_associations_sync_ids_.clear();
}
bool BookmarkModelAssociator::CryptoReadyIfNecessary() {

Powered by Google App Engine
This is Rietveld 408576698