Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: chrome/browser/history/url_index_private_data.h

Issue 11757004: Omnibox: Add Mid-Input Matching to HistoryQuick Provider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix typo in comment Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 CHROME_BROWSER_HISTORY_URL_INDEX_PRIVATE_DATA_H_ 5 #ifndef CHROME_BROWSER_HISTORY_URL_INDEX_PRIVATE_DATA_H_
6 #define CHROME_BROWSER_HISTORY_URL_INDEX_PRIVATE_DATA_H_ 6 #define CHROME_BROWSER_HISTORY_URL_INDEX_PRIVATE_DATA_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // annotated. 43 // annotated.
44 class URLIndexPrivateData 44 class URLIndexPrivateData
45 : public base::RefCountedThreadSafe<URLIndexPrivateData> { 45 : public base::RefCountedThreadSafe<URLIndexPrivateData> {
46 public: 46 public:
47 URLIndexPrivateData(); 47 URLIndexPrivateData();
48 48
49 // Given a string16 in |term_string|, scans the history index and returns a 49 // Given a string16 in |term_string|, scans the history index and returns a
50 // vector with all scored, matching history items. The |term_string| is 50 // vector with all scored, matching history items. The |term_string| is
51 // broken down into individual terms (words), each of which must occur in the 51 // broken down into individual terms (words), each of which must occur in the
52 // candidate history item's URL or page title for the item to qualify; 52 // candidate history item's URL or page title for the item to qualify;
53 // however, the terms do not necessarily have to be adjacent. Once we have 53 // however, the terms do not necessarily have to be adjacent. We
54 // a set of candidates, they are filtered to insure that all |term_string| 54 // also allow breaking |term_string| at |cursor_position| (if
55 // terms, as separated by whitespace, occur within the candidate's URL 55 // set). Once we have a set of candidates, they are filtered to ensure
56 // or page title. Scores are then calculated on no more than 56 // that all |term_string| terms, as separated by whitespace and the
57 // |kItemsToScoreLimit| candidates, as the scoring of such a large number of 57 // cursor (if set), occur within the candidate's URL or page title.
58 // candidates may cause perceptible typing response delays in the omnibox. 58 // Scores are then calculated on no more than |kItemsToScoreLimit|
59 // This is likely to occur for short omnibox terms such as 'h' and 'w' which 59 // candidates, as the scoring of such a large number of candidates may
60 // cause perceptible typing response delays in the omnibox. This is
61 // likely to occur for short omnibox terms such as 'h' and 'w' which
60 // will be found in nearly all history candidates. Results are sorted by 62 // will be found in nearly all history candidates. Results are sorted by
61 // descending score. The full results set (i.e. beyond the 63 // descending score. The full results set (i.e. beyond the
62 // |kItemsToScoreLimit| limit) will be retained and used for subsequent calls 64 // |kItemsToScoreLimit| limit) will be retained and used for subsequent calls
63 // to this function. |bookmark_service| is used to boost a result's score if 65 // to this function. |bookmark_service| is used to boost a result's score if
64 // its URL is referenced by one or more of the user's bookmarks. 66 // its URL is referenced by one or more of the user's bookmarks.
65 ScoredHistoryMatches HistoryItemsForTerms(const string16& term_string, 67 ScoredHistoryMatches HistoryItemsForTerms(string16 term_string,
68 size_t cursor_position,
66 BookmarkService* bookmark_service); 69 BookmarkService* bookmark_service);
67 70
68 // Adds the history item in |row| to the index if it does not already already 71 // Adds the history item in |row| to the index if it does not already already
69 // exist and it meets the minimum 'quick' criteria. If the row already exists 72 // exist and it meets the minimum 'quick' criteria. If the row already exists
70 // in the index then the index will be updated if the row still meets the 73 // in the index then the index will be updated if the row still meets the
71 // criteria, otherwise the row will be removed from the index. Returns true 74 // criteria, otherwise the row will be removed from the index. Returns true
72 // if the index was actually updated. |languages| gives a list of language 75 // if the index was actually updated. |languages| gives a list of language
73 // encodings by which the URLs and page titles are broken down into words and 76 // encodings by which the URLs and page titles are broken down into words and
74 // characters. |scheme_whitelist| is used to filter non-qualifying schemes. 77 // characters. |scheme_whitelist| is used to filter non-qualifying schemes.
75 bool UpdateURL(const URLRow& row, 78 bool UpdateURL(const URLRow& row,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 void Clear(); 119 void Clear();
117 120
118 private: 121 private:
119 friend class base::RefCountedThreadSafe<URLIndexPrivateData>; 122 friend class base::RefCountedThreadSafe<URLIndexPrivateData>;
120 ~URLIndexPrivateData(); 123 ~URLIndexPrivateData();
121 124
122 friend class AddHistoryMatch; 125 friend class AddHistoryMatch;
123 friend class ::HistoryQuickProviderTest; 126 friend class ::HistoryQuickProviderTest;
124 friend class InMemoryURLIndexTest; 127 friend class InMemoryURLIndexTest;
125 FRIEND_TEST_ALL_PREFIXES(InMemoryURLIndexTest, CacheSaveRestore); 128 FRIEND_TEST_ALL_PREFIXES(InMemoryURLIndexTest, CacheSaveRestore);
129 FRIEND_TEST_ALL_PREFIXES(InMemoryURLIndexTest, CursorPositionRetrieval);
126 FRIEND_TEST_ALL_PREFIXES(InMemoryURLIndexTest, HugeResultSet); 130 FRIEND_TEST_ALL_PREFIXES(InMemoryURLIndexTest, HugeResultSet);
127 FRIEND_TEST_ALL_PREFIXES(InMemoryURLIndexTest, Scoring); 131 FRIEND_TEST_ALL_PREFIXES(InMemoryURLIndexTest, Scoring);
128 FRIEND_TEST_ALL_PREFIXES(InMemoryURLIndexTest, TitleSearch); 132 FRIEND_TEST_ALL_PREFIXES(InMemoryURLIndexTest, TitleSearch);
129 FRIEND_TEST_ALL_PREFIXES(InMemoryURLIndexTest, TypedCharacterCaching); 133 FRIEND_TEST_ALL_PREFIXES(InMemoryURLIndexTest, TypedCharacterCaching);
130 FRIEND_TEST_ALL_PREFIXES(InMemoryURLIndexTest, WhitelistedURLs); 134 FRIEND_TEST_ALL_PREFIXES(InMemoryURLIndexTest, WhitelistedURLs);
131 FRIEND_TEST_ALL_PREFIXES(LimitedInMemoryURLIndexTest, Initialization); 135 FRIEND_TEST_ALL_PREFIXES(LimitedInMemoryURLIndexTest, Initialization);
132 136
133 // Support caching of term results so that we can optimize searches which 137 // Support caching of term results so that we can optimize searches which
134 // build upon a previous search. Each entry in this map represents one 138 // build upon a previous search. Each entry in this map represents one
135 // search term from the most recent search. For example, if the user had 139 // search term from the most recent search. For example, if the user had
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 bool RestoreWordStartsMap(const imui::InMemoryURLIndexCacheItem& cache, 291 bool RestoreWordStartsMap(const imui::InMemoryURLIndexCacheItem& cache,
288 const std::string& languages); 292 const std::string& languages);
289 293
290 // Determines if |gurl| has a whitelisted scheme and returns true if so. 294 // Determines if |gurl| has a whitelisted scheme and returns true if so.
291 static bool URLSchemeIsWhitelisted(const GURL& gurl, 295 static bool URLSchemeIsWhitelisted(const GURL& gurl,
292 const std::set<std::string>& whitelist); 296 const std::set<std::string>& whitelist);
293 297
294 // Cache of search terms. 298 // Cache of search terms.
295 SearchTermCacheMap search_term_cache_; 299 SearchTermCacheMap search_term_cache_;
296 300
301 // Whether to allow breaking the input at the cursor position. Set based
302 // on whether the user is in the OmniboxHQPUseCursorPosition field trial
303 // experiment group.
304 bool use_cursor_position_;
305
297 // Start of data members that are cached ------------------------------------- 306 // Start of data members that are cached -------------------------------------
298 307
299 // The version of the cache file most recently used to restore this instance 308 // The version of the cache file most recently used to restore this instance
300 // of the private data. If the private data was rebuilt from the history 309 // of the private data. If the private data was rebuilt from the history
301 // database this will be 0. 310 // database this will be 0.
302 int restored_cache_version_; 311 int restored_cache_version_;
303 312
304 // A list of all of indexed words. The index of a word in this list is the 313 // A list of all of indexed words. The index of a word in this list is the
305 // ID of the word in the word_map_. It reduces the memory overhead by 314 // ID of the word in the word_map_. It reduces the memory overhead by
306 // replacing a potentially long and repeated string with a simple index. 315 // replacing a potentially long and repeated string with a simple index.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 // Used for unit testing only. Records the number of candidate history items 360 // Used for unit testing only. Records the number of candidate history items
352 // at three stages in the index searching process. 361 // at three stages in the index searching process.
353 size_t pre_filter_item_count_; // After word index is queried. 362 size_t pre_filter_item_count_; // After word index is queried.
354 size_t post_filter_item_count_; // After trimming large result set. 363 size_t post_filter_item_count_; // After trimming large result set.
355 size_t post_scoring_item_count_; // After performing final filter/scoring. 364 size_t post_scoring_item_count_; // After performing final filter/scoring.
356 }; 365 };
357 366
358 } // namespace history 367 } // namespace history
359 368
360 #endif // CHROME_BROWSER_HISTORY_URL_INDEX_PRIVATE_DATA_H_ 369 #endif // CHROME_BROWSER_HISTORY_URL_INDEX_PRIVATE_DATA_H_
OLDNEW
« no previous file with comments | « chrome/browser/history/in_memory_url_index_unittest.cc ('k') | chrome/browser/history/url_index_private_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698