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() { |