OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_INDEX_H_ | 5 #ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_INDEX_H_ |
6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_INDEX_H_ | 6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_INDEX_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 typedef std::map<string16, NodeSet> Index; | 55 typedef std::map<string16, NodeSet> Index; |
56 | 56 |
57 struct Match; | 57 struct Match; |
58 typedef std::vector<Match> Matches; | 58 typedef std::vector<Match> Matches; |
59 | 59 |
60 // Pairs BookmarkNodes and the number of times the nodes' URLs were typed. | 60 // Pairs BookmarkNodes and the number of times the nodes' URLs were typed. |
61 // Used to sort Matches in decreasing order of typed count. | 61 // Used to sort Matches in decreasing order of typed count. |
62 typedef std::pair<const BookmarkNode*, int> NodeTypedCountPair; | 62 typedef std::pair<const BookmarkNode*, int> NodeTypedCountPair; |
63 typedef std::vector<NodeTypedCountPair> NodeTypedCountPairs; | 63 typedef std::vector<NodeTypedCountPair> NodeTypedCountPairs; |
64 | 64 |
65 // Extracts |matches.nodes| into NodeTypedCountPairs and sorts the pairs in | 65 // Extracts |matches.nodes| into NodeTypedCountPairs, sorts the pairs in |
66 // decreasing order of typed count. | 66 // decreasing order of typed count, and then de-dupes the matches. |
67 void SortMatches(const Matches& matches, | 67 void SortMatches(const Matches& matches, |
68 NodeTypedCountPairs* node_typed_counts) const; | 68 NodeTypedCountPairs* node_typed_counts) const; |
69 | 69 |
70 // Extracts BookmarkNodes from |match| and retrieves typed counts for each | 70 // Extracts BookmarkNodes from |match| and retrieves typed counts for each |
71 // node from the in-memory database. Inserts pairs containing the node and | 71 // node from the in-memory database. Inserts pairs containing the node and |
72 // typed count into the vector |node_typed_counts|. |node_typed_counts| is | 72 // typed count into the vector |node_typed_counts|. |node_typed_counts| is |
73 // sorted in decreasing order of typed count. | 73 // sorted in decreasing order of typed count. |
74 void ExtractBookmarkNodePairs(history::URLDatabase* url_db, | 74 void ExtractBookmarkNodePairs(history::URLDatabase* url_db, |
75 const Match& match, | 75 const Match& match, |
76 NodeTypedCountPairs* node_typed_counts) const; | 76 NodeTypedCountPairs* node_typed_counts) const; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 void UnregisterNode(const string16& term, const BookmarkNode* node); | 126 void UnregisterNode(const string16& term, const BookmarkNode* node); |
127 | 127 |
128 Index index_; | 128 Index index_; |
129 | 129 |
130 Profile* profile_; | 130 Profile* profile_; |
131 | 131 |
132 DISALLOW_COPY_AND_ASSIGN(BookmarkIndex); | 132 DISALLOW_COPY_AND_ASSIGN(BookmarkIndex); |
133 }; | 133 }; |
134 | 134 |
135 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_INDEX_H_ | 135 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_INDEX_H_ |
OLD | NEW |