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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 // this class is for exclusive use by the InMemoryURLIndex class there should | 43 // this class is for exclusive use by the InMemoryURLIndex class there should |
44 // be no calls from any other class. | 44 // be no calls from any other class. |
45 // | 45 // |
46 // All public member functions are called on the main thread unless otherwise | 46 // All public member functions are called on the main thread unless otherwise |
47 // annotated. | 47 // annotated. |
48 class URLIndexPrivateData | 48 class URLIndexPrivateData |
49 : public base::RefCountedThreadSafe<URLIndexPrivateData> { | 49 : public base::RefCountedThreadSafe<URLIndexPrivateData> { |
50 public: | 50 public: |
51 URLIndexPrivateData(); | 51 URLIndexPrivateData(); |
52 | 52 |
53 // Given a base::string16 in |term_string|, scans the history index and | 53 // Given a |term_string|, scans the history index and returns a vector with |
54 // returns a vector with all scored, matching history items. The | 54 // all scored, matching history items. The |term_string| is broken down into |
55 // |term_string| is broken down into individual terms (words), each of which | 55 // individual terms (words), each of which must occur in the candidate |
56 // must occur in the candidate history item's URL or page title for the item | 56 // history item's URL or page title for the item to qualify; however, the |
57 // to qualify; however, the terms do not necessarily have to be adjacent. We | 57 // terms do not necessarily have to be adjacent. We also allow breaking |
58 // also allow breaking |term_string| at |cursor_position| (if | 58 // |term_string| at |cursor_position| (if set). Once we have a set of |
59 // set). Once we have a set of candidates, they are filtered to ensure | 59 // candidates, they are filtered to ensure that all |term_string| terms, as |
60 // that all |term_string| terms, as separated by whitespace and the | 60 // separated by whitespace and the cursor (if set), occur within the |
61 // cursor (if set), occur within the candidate's URL or page title. | 61 // candidate's URL or page title. Scores are then calculated on no more than |
62 // Scores are then calculated on no more than |kItemsToScoreLimit| | 62 // |kItemsToScoreLimit| candidates, as the scoring of such a large number of |
63 // candidates, as the scoring of such a large number of candidates may | 63 // candidates may cause perceptible typing response delays in the omnibox. |
64 // cause perceptible typing response delays in the omnibox. This is | 64 // This is likely to occur for short omnibox terms such as 'h' and 'w' which |
65 // likely to occur for short omnibox terms such as 'h' and 'w' which | |
66 // will be found in nearly all history candidates. Results are sorted by | 65 // will be found in nearly all history candidates. Results are sorted by |
67 // descending score. The full results set (i.e. beyond the | 66 // descending score. The full results set (i.e. beyond the |
68 // |kItemsToScoreLimit| limit) will be retained and used for subsequent calls | 67 // |kItemsToScoreLimit| limit) will be retained and used for subsequent calls |
69 // to this function. In total, |max_matches| of items will be returned in the | 68 // to this function. In total, |max_matches| of items will be returned in the |
70 // |ScoredHistoryMatches| vector. | 69 // |ScoredHistoryMatches| vector. |
71 ScoredHistoryMatches HistoryItemsForTerms( | 70 ScoredHistoryMatches HistoryItemsForTerms( |
72 base::string16 term_string, | 71 base::string16 term_string, |
73 size_t cursor_position, | 72 size_t cursor_position, |
74 size_t max_matches, | 73 size_t max_matches, |
75 bookmarks::BookmarkModel* bookmark_model, | 74 bookmarks::BookmarkModel* bookmark_model, |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 int saved_cache_version_; | 386 int saved_cache_version_; |
388 | 387 |
389 // Used for unit testing only. Records the number of candidate history items | 388 // Used for unit testing only. Records the number of candidate history items |
390 // at three stages in the index searching process. | 389 // at three stages in the index searching process. |
391 size_t pre_filter_item_count_; // After word index is queried. | 390 size_t pre_filter_item_count_; // After word index is queried. |
392 size_t post_filter_item_count_; // After trimming large result set. | 391 size_t post_filter_item_count_; // After trimming large result set. |
393 size_t post_scoring_item_count_; // After performing final filter/scoring. | 392 size_t post_scoring_item_count_; // After performing final filter/scoring. |
394 }; | 393 }; |
395 | 394 |
396 #endif // COMPONENTS_OMNIBOX_BROWSER_URL_INDEX_PRIVATE_DATA_H_ | 395 #endif // COMPONENTS_OMNIBOX_BROWSER_URL_INDEX_PRIVATE_DATA_H_ |
OLD | NEW |