Commit e4a5c1d8 authored by pnoland's avatar pnoland Committed by Commit bot

[sync] use std::multimap for BookmarkNodeMap

When associating bookmarks, sync nodes are matched to BookmarkNodes.
To match a BookmarkNode with a sync node, a BookmarkNodeFinder is
created and asked to find the child node with the matching title. When searching
for the title, BookmarkNodeFinder returns the first matching child in
its child_nodes_ map. This map is an unordered_map with undefined
iteration order. If sync node siblings share a title, the
BookmarkNodeFinder can erroneously swap their respective
BookmarkNodes.
To fix this, this CL makes the iteration order defined with
std::multimap, which stores pairs in insertion order.
This is safe since sync nodes are processed in the same
order as BookmarkNodes are stored.

R=skym@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2743713005
Cr-Commit-Position: refs/heads/master@{#456234}
parent 1a8b3d0a
......@@ -94,7 +94,7 @@ class BookmarkNodeFinder {
// Maps bookmark node titles to instances, duplicates allowed.
// Titles are converted to the sync internal format before
// being used as keys for the map.
using BookmarkNodeMap = base::hash_multimap<std::string, const BookmarkNode*>;
using BookmarkNodeMap = std::multimap<std::string, const BookmarkNode*>;
using BookmarkNodeRange =
std::pair<BookmarkNodeMap::iterator, BookmarkNodeMap::iterator>;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment