diff options
author | nick@chromium.org <nick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-16 19:16:36 +0000 |
---|---|---|
committer | nick@chromium.org <nick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-16 19:16:36 +0000 |
commit | 58b821cad0cb5351f01a701ca56c8d0747d27ae0 (patch) | |
tree | c69362eb5fd77bea3dbc431ab883357e124c566a | |
parent | bdc0814aa96d2140fdaedb52858c50ba985800bd (diff) | |
download | chromium_src-58b821cad0cb5351f01a701ca56c8d0747d27ae0.zip chromium_src-58b821cad0cb5351f01a701ca56c8d0747d27ae0.tar.gz chromium_src-58b821cad0cb5351f01a701ca56c8d0747d27ae0.tar.bz2 |
Use a multiset rather than a set to store bookmarks when running the model associator merge.
For cases where there's an exact duplicate URL and title,
this allows each BookmarkNode a chance to be associated
with a sync node. With a set, we'd forget about all
but one of the duplicates, resulting in the creation
of yet more duplicates. The result was exponential
growth with each merge and sync.
BUG=24995
TEST=
Review URL: http://codereview.chromium.org/288001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29307 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/sync/glue/model_associator.cc | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/chrome/browser/sync/glue/model_associator.cc b/chrome/browser/sync/glue/model_associator.cc index 30b4388..b8df60c 100644 --- a/chrome/browser/sync/glue/model_associator.cc +++ b/chrome/browser/sync/glue/model_associator.cc @@ -67,7 +67,7 @@ class BookmarkComparer { // matching child node for many sync nodes. class BookmarkNodeFinder { public: - // Creats an instance with the given parent bookmark node. + // Creates an instance with the given parent bookmark node. explicit BookmarkNodeFinder(const BookmarkNode* parent_node); // Finds best matching node for the given sync node. @@ -76,7 +76,7 @@ class BookmarkNodeFinder { const BookmarkNode* FindBookmarkNode(const sync_api::BaseNode& sync_node); private: - typedef std::set<const BookmarkNode*, BookmarkComparer> BookmarkNodesSet; + typedef std::multiset<const BookmarkNode*, BookmarkComparer> BookmarkNodesSet; const BookmarkNode* parent_node_; BookmarkNodesSet child_nodes_; @@ -86,8 +86,10 @@ class BookmarkNodeFinder { BookmarkNodeFinder::BookmarkNodeFinder(const BookmarkNode* parent_node) : parent_node_(parent_node) { - for (int i = 0; i < parent_node_->GetChildCount(); ++i) + for (int i = 0; i < parent_node_->GetChildCount(); ++i) { child_nodes_.insert(parent_node_->GetChild(i)); + } + DCHECK_EQ(child_nodes_.size(), parent_node_->GetChildCount()); } const BookmarkNode* BookmarkNodeFinder::FindBookmarkNode( @@ -315,7 +317,7 @@ bool ModelAssociator::BuildAssocations() { DCHECK(bookmark_bar_sync_id != sync_api::kInvalidId); int64 other_bookmarks_sync_id = GetSyncIdFromBookmarkId( model->other_node()->id()); - DCHECK(other_bookmarks_sync_id!= sync_api::kInvalidId); + DCHECK(other_bookmarks_sync_id != sync_api::kInvalidId); std::stack<int64> dfs_stack; dfs_stack.push(other_bookmarks_sync_id); |