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> |
| 11 #include <stack> |
11 #include <string> | 12 #include <string> |
12 | 13 |
13 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
14 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
15 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
16 #include "components/history/core/browser/history_service.h" | 17 #include "components/history/core/browser/history_service.h" |
17 #include "components/omnibox/browser/in_memory_url_index_cache.pb.h" | 18 #include "components/omnibox/browser/in_memory_url_index_cache.pb.h" |
18 #include "components/omnibox/browser/in_memory_url_index_types.h" | 19 #include "components/omnibox/browser/in_memory_url_index_types.h" |
19 #include "components/omnibox/browser/scored_history_match.h" | 20 #include "components/omnibox/browser/scored_history_match.h" |
20 | 21 |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 | 247 |
247 // Parses and indexes the words in the URL and page title of |row| and | 248 // Parses and indexes the words in the URL and page title of |row| and |
248 // calculate the word starts in each, saving the starts in |word_starts|. | 249 // calculate the word starts in each, saving the starts in |word_starts|. |
249 void AddRowWordsToIndex(const history::URLRow& row, | 250 void AddRowWordsToIndex(const history::URLRow& row, |
250 RowWordStarts* word_starts); | 251 RowWordStarts* word_starts); |
251 | 252 |
252 // Given a single word in |uni_word|, adds a reference for the containing | 253 // Given a single word in |uni_word|, adds a reference for the containing |
253 // history item identified by |history_id| to the index. | 254 // history item identified by |history_id| to the index. |
254 void AddWordToIndex(const base::string16& uni_word, HistoryID history_id); | 255 void AddWordToIndex(const base::string16& uni_word, HistoryID history_id); |
255 | 256 |
256 // Creates a new entry in the word/history map for |word_id| and add | 257 // Adds a new entry to word_list. Uses previously freed positions if |
257 // |history_id| as the initial element of the word's set. | 258 // available. |
258 void AddWordHistory(const base::string16& uni_word, HistoryID history_id); | 259 WordID AddNewWordToWordList(const base::string16& term); |
259 | |
260 // Updates an existing entry in the word/history index by adding the | |
261 // |history_id| to set for |word_id| in the word_id_history_map_. | |
262 void UpdateWordHistory(WordID word_id, HistoryID history_id); | |
263 | |
264 // Adds |word_id| to |history_id|'s entry in the history/word map, | |
265 // creating a new entry if one does not already exist. | |
266 void AddToHistoryIDWordMap(HistoryID history_id, WordID word_id); | |
267 | 260 |
268 // Removes |row| and all associated words and characters from the index. | 261 // Removes |row| and all associated words and characters from the index. |
269 void RemoveRowFromIndex(const history::URLRow& row); | 262 void RemoveRowFromIndex(const history::URLRow& row); |
270 | 263 |
271 // Removes all words and characters associated with |row| from the index. | 264 // Removes all words and characters associated with |row| from the index. |
272 void RemoveRowWordsFromIndex(const history::URLRow& row); | 265 void RemoveRowWordsFromIndex(const history::URLRow& row); |
273 | 266 |
274 // Clears |used_| for each item in the search term cache. | 267 // Clears |used_| for each item in the search term cache. |
275 void ResetSearchTermCache(); | 268 void ResetSearchTermCache(); |
276 | 269 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 String16Vector word_list_; | 332 String16Vector word_list_; |
340 | 333 |
341 // A list of available words slots in |word_list_|. An available word slot | 334 // A list of available words slots in |word_list_|. An available word slot |
342 // is the index of a unused word in word_list_ vector, also referred to as | 335 // is the index of a unused word in word_list_ vector, also referred to as |
343 // a WordID. As URL visits are added or modified new words may be added to | 336 // a WordID. As URL visits are added or modified new words may be added to |
344 // the index, in which case any available words are used, if any, and then | 337 // the index, in which case any available words are used, if any, and then |
345 // words are added to the end of the word_list_. When URL visits are | 338 // words are added to the end of the word_list_. When URL visits are |
346 // modified or deleted old words may be removed from the index, in which | 339 // modified or deleted old words may be removed from the index, in which |
347 // case the slots for those words are added to available_words_ for resuse | 340 // case the slots for those words are added to available_words_ for resuse |
348 // by future URL updates. | 341 // by future URL updates. |
349 WordIDSet available_words_; | 342 std::stack<WordID> available_words_; |
350 | 343 |
351 // A one-to-one mapping from the a word string to its slot number (i.e. | 344 // A one-to-one mapping from the a word string to its slot number (i.e. |
352 // WordID) in the |word_list_|. | 345 // WordID) in the |word_list_|. |
353 WordMap word_map_; | 346 WordMap word_map_; |
354 | 347 |
355 // A one-to-many mapping from a single character to all WordIDs of words | 348 // A one-to-many mapping from a single character to all WordIDs of words |
356 // containing that character. | 349 // containing that character. |
357 CharWordIDMap char_word_map_; | 350 CharWordIDMap char_word_map_; |
358 | 351 |
359 // A one-to-many mapping from a WordID to all HistoryIDs (the row_id as | 352 // A one-to-many mapping from a WordID to all HistoryIDs (the row_id as |
(...skipping 21 matching lines...) Expand all Loading... |
381 int saved_cache_version_; | 374 int saved_cache_version_; |
382 | 375 |
383 // Used for unit testing only. Records the number of candidate history items | 376 // Used for unit testing only. Records the number of candidate history items |
384 // at three stages in the index searching process. | 377 // at three stages in the index searching process. |
385 size_t pre_filter_item_count_; // After word index is queried. | 378 size_t pre_filter_item_count_; // After word index is queried. |
386 size_t post_filter_item_count_; // After trimming large result set. | 379 size_t post_filter_item_count_; // After trimming large result set. |
387 size_t post_scoring_item_count_; // After performing final filter/scoring. | 380 size_t post_scoring_item_count_; // After performing final filter/scoring. |
388 }; | 381 }; |
389 | 382 |
390 #endif // COMPONENTS_OMNIBOX_BROWSER_URL_INDEX_PRIVATE_DATA_H_ | 383 #endif // COMPONENTS_OMNIBOX_BROWSER_URL_INDEX_PRIVATE_DATA_H_ |
OLD | NEW |