OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_OMNIBOX_BROWSER_URL_INDEX_PRIVATE_DATA_H_ | 5 #ifndef COMPONENTS_OMNIBOX_BROWSER_URL_INDEX_PRIVATE_DATA_H_ |
6 #define COMPONENTS_OMNIBOX_BROWSER_URL_INDEX_PRIVATE_DATA_H_ | 6 #define COMPONENTS_OMNIBOX_BROWSER_URL_INDEX_PRIVATE_DATA_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <set> | 10 #include <set> |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 // marking the cache item as being |used_|. If we find a prefix for a search | 177 // marking the cache item as being |used_|. If we find a prefix for a search |
178 // term in the cache (which is very likely to occur as the user types each | 178 // term in the cache (which is very likely to occur as the user types each |
179 // term into the omnibox) then we can short-circuit the index search for those | 179 // term into the omnibox) then we can short-circuit the index search for those |
180 // characters in the prefix by returning the |word_id_set|. In that case we do | 180 // characters in the prefix by returning the |word_id_set|. In that case we do |
181 // not mark the item as being |used_|. | 181 // not mark the item as being |used_|. |
182 struct SearchTermCacheItem { | 182 struct SearchTermCacheItem { |
183 SearchTermCacheItem(const WordIDSet& word_id_set, | 183 SearchTermCacheItem(const WordIDSet& word_id_set, |
184 const HistoryIDSet& history_id_set); | 184 const HistoryIDSet& history_id_set); |
185 // Creates a cache item for a term which has no results. | 185 // Creates a cache item for a term which has no results. |
186 SearchTermCacheItem(); | 186 SearchTermCacheItem(); |
| 187 SearchTermCacheItem(const SearchTermCacheItem& other); |
187 | 188 |
188 ~SearchTermCacheItem(); | 189 ~SearchTermCacheItem(); |
189 | 190 |
190 WordIDSet word_id_set_; | 191 WordIDSet word_id_set_; |
191 HistoryIDSet history_id_set_; | 192 HistoryIDSet history_id_set_; |
192 bool used_; // True if this item has been used for the current term search. | 193 bool used_; // True if this item has been used for the current term search. |
193 }; | 194 }; |
194 typedef std::map<base::string16, SearchTermCacheItem> SearchTermCacheMap; | 195 typedef std::map<base::string16, SearchTermCacheItem> SearchTermCacheMap; |
195 | 196 |
196 // A helper class which performs the final filter on each candidate | 197 // A helper class which performs the final filter on each candidate |
197 // history URL match, inserting accepted matches into |scored_matches_|. | 198 // history URL match, inserting accepted matches into |scored_matches_|. |
198 class AddHistoryMatch : public std::unary_function<HistoryID, void> { | 199 class AddHistoryMatch : public std::unary_function<HistoryID, void> { |
199 public: | 200 public: |
200 AddHistoryMatch(bookmarks::BookmarkModel* bookmark_model, | 201 AddHistoryMatch(bookmarks::BookmarkModel* bookmark_model, |
201 const URLIndexPrivateData& private_data, | 202 const URLIndexPrivateData& private_data, |
202 const std::string& languages, | 203 const std::string& languages, |
203 const base::string16& lower_string, | 204 const base::string16& lower_string, |
204 const String16Vector& lower_terms, | 205 const String16Vector& lower_terms, |
205 const base::Time now); | 206 const base::Time now); |
| 207 AddHistoryMatch(const AddHistoryMatch& other); |
206 ~AddHistoryMatch(); | 208 ~AddHistoryMatch(); |
207 | 209 |
208 void operator()(const HistoryID history_id); | 210 void operator()(const HistoryID history_id); |
209 | 211 |
210 ScoredHistoryMatches ScoredMatches() const { return scored_matches_; } | 212 ScoredHistoryMatches ScoredMatches() const { return scored_matches_; } |
211 | 213 |
212 private: | 214 private: |
213 friend class InMemoryURLIndexTest; | 215 friend class InMemoryURLIndexTest; |
214 FRIEND_TEST_ALL_PREFIXES(InMemoryURLIndexTest, AddHistoryMatch); | 216 FRIEND_TEST_ALL_PREFIXES(InMemoryURLIndexTest, AddHistoryMatch); |
215 bookmarks::BookmarkModel* bookmark_model_; | 217 bookmarks::BookmarkModel* bookmark_model_; |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 int saved_cache_version_; | 405 int saved_cache_version_; |
404 | 406 |
405 // Used for unit testing only. Records the number of candidate history items | 407 // Used for unit testing only. Records the number of candidate history items |
406 // at three stages in the index searching process. | 408 // at three stages in the index searching process. |
407 size_t pre_filter_item_count_; // After word index is queried. | 409 size_t pre_filter_item_count_; // After word index is queried. |
408 size_t post_filter_item_count_; // After trimming large result set. | 410 size_t post_filter_item_count_; // After trimming large result set. |
409 size_t post_scoring_item_count_; // After performing final filter/scoring. | 411 size_t post_scoring_item_count_; // After performing final filter/scoring. |
410 }; | 412 }; |
411 | 413 |
412 #endif // COMPONENTS_OMNIBOX_BROWSER_URL_INDEX_PRIVATE_DATA_H_ | 414 #endif // COMPONENTS_OMNIBOX_BROWSER_URL_INDEX_PRIVATE_DATA_H_ |
OLD | NEW |