OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_INDEX_H_ | 5 #ifndef COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_INDEX_H_ |
6 #define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_INDEX_H_ | 6 #define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_INDEX_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 typedef std::vector<const BookmarkNode*> Nodes; | 51 typedef std::vector<const BookmarkNode*> Nodes; |
52 typedef std::set<const BookmarkNode*> NodeSet; | 52 typedef std::set<const BookmarkNode*> NodeSet; |
53 typedef std::map<base::string16, NodeSet> Index; | 53 typedef std::map<base::string16, NodeSet> Index; |
54 | 54 |
55 // Constructs |sorted_nodes| by taking the matches in |matches| and sorting | 55 // Constructs |sorted_nodes| by taking the matches in |matches| and sorting |
56 // them in decreasing order of typed count (if supported by the client) and | 56 // them in decreasing order of typed count (if supported by the client) and |
57 // deduping them. | 57 // deduping them. |
58 void SortMatches(const NodeSet& matches, Nodes* sorted_nodes) const; | 58 void SortMatches(const NodeSet& matches, Nodes* sorted_nodes) const; |
59 | 59 |
60 // Add |node| to |results| if the node matches the query. | 60 // Add |node| to |results| if the node matches the query. |
61 void AddMatchToResults( | 61 void AddMatchToResults(const BookmarkNode* node, |
62 const BookmarkNode* node, | 62 query_parser::QueryParser* parser, |
63 query_parser::QueryParser* parser, | 63 const query_parser::QueryNodeVector& query_nodes, |
64 const query_parser::QueryNodeStarVector& query_nodes, | 64 std::vector<BookmarkMatch>* results); |
65 std::vector<BookmarkMatch>* results); | |
66 | 65 |
67 // Populates |matches| for the specified term. If |first_term| is true, this | 66 // Populates |matches| for the specified term. If |first_term| is true, this |
68 // is the first term in the query. Returns true if there is at least one node | 67 // is the first term in the query. Returns true if there is at least one node |
69 // matching the term. | 68 // matching the term. |
70 bool GetBookmarksMatchingTerm( | 69 bool GetBookmarksMatchingTerm( |
71 const base::string16& term, | 70 const base::string16& term, |
72 bool first_term, | 71 bool first_term, |
73 query_parser::MatchingAlgorithm matching_algorithm, | 72 query_parser::MatchingAlgorithm matching_algorithm, |
74 NodeSet* matches); | 73 NodeSet* matches); |
75 | 74 |
76 // Returns the set of query words from |query|. | 75 // Returns the set of query words from |query|. |
77 std::vector<base::string16> ExtractQueryWords(const base::string16& query); | 76 std::vector<base::string16> ExtractQueryWords(const base::string16& query); |
78 | 77 |
79 // Adds |node| to |index_|. | 78 // Adds |node| to |index_|. |
80 void RegisterNode(const base::string16& term, const BookmarkNode* node); | 79 void RegisterNode(const base::string16& term, const BookmarkNode* node); |
81 | 80 |
82 // Removes |node| from |index_|. | 81 // Removes |node| from |index_|. |
83 void UnregisterNode(const base::string16& term, const BookmarkNode* node); | 82 void UnregisterNode(const base::string16& term, const BookmarkNode* node); |
84 | 83 |
85 Index index_; | 84 Index index_; |
86 | 85 |
87 BookmarkClient* const client_; | 86 BookmarkClient* const client_; |
88 | 87 |
89 DISALLOW_COPY_AND_ASSIGN(BookmarkIndex); | 88 DISALLOW_COPY_AND_ASSIGN(BookmarkIndex); |
90 }; | 89 }; |
91 | 90 |
92 } // namespace bookmarks | 91 } // namespace bookmarks |
93 | 92 |
94 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_INDEX_H_ | 93 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_INDEX_H_ |
OLD | NEW |