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

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

Issue 903493002: Componentize ScoredHistoryMatch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 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
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
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "chrome/browser/history/history_service.h" 14 #include "chrome/browser/history/history_service.h"
15 #include "chrome/browser/history/scored_history_match.h"
16 #include "components/history/core/browser/in_memory_url_index_cache.pb.h" 15 #include "components/history/core/browser/in_memory_url_index_cache.pb.h"
17 #include "components/history/core/browser/in_memory_url_index_types.h" 16 #include "components/history/core/browser/in_memory_url_index_types.h"
17 #include "components/history/core/browser/scored_history_match.h"
18 18
19 class HistoryQuickProviderTest; 19 class HistoryQuickProviderTest;
20 20
21 namespace in_memory_url_index { 21 namespace in_memory_url_index {
22 class InMemoryURLIndexCacheItem; 22 class InMemoryURLIndexCacheItem;
23 } 23 }
24 24
25 namespace history { 25 namespace history {
26 26
27 namespace imui = in_memory_url_index; 27 namespace imui = in_memory_url_index;
28 28
29 class HistoryClient;
30 class HistoryDatabase; 29 class HistoryDatabase;
31 class InMemoryURLIndex; 30 class InMemoryURLIndex;
32 class RefCountedBool; 31 class RefCountedBool;
32 class ScoredHistoryMatchClient;
33 33
34 // Current version of the cache file. 34 // Current version of the cache file.
35 static const int kCurrentCacheFileVersion = 5; 35 static const int kCurrentCacheFileVersion = 5;
36 36
37 // A structure private to InMemoryURLIndex describing its internal data and 37 // A structure private to InMemoryURLIndex describing its internal data and
38 // providing for restoring, rebuilding and updating that internal data. As 38 // providing for restoring, rebuilding and updating that internal data. As
39 // this class is for exclusive use by the InMemoryURLIndex class there should 39 // this class is for exclusive use by the InMemoryURLIndex class there should
40 // be no calls from any other class. 40 // be no calls from any other class.
41 // 41 //
42 // All public member functions are called on the main thread unless otherwise 42 // All public member functions are called on the main thread unless otherwise
(...skipping 17 matching lines...) Expand all
60 // cause perceptible typing response delays in the omnibox. This is 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 61 // likely to occur for short omnibox terms such as 'h' and 'w' which
62 // 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
63 // descending score. The full results set (i.e. beyond the 63 // descending score. The full results set (i.e. beyond the
64 // |kItemsToScoreLimit| limit) will be retained and used for subsequent calls 64 // |kItemsToScoreLimit| limit) will be retained and used for subsequent calls
65 // to this function. |history_client| is used to boost a result's score if 65 // to this function. |history_client| is used to boost a result's score if
66 // its URL is referenced by one or more of the user's bookmarks. |languages| 66 // its URL is referenced by one or more of the user's bookmarks. |languages|
67 // is used to help parse/format the URLs in the history index. In total, 67 // is used to help parse/format the URLs in the history index. In total,
68 // |max_matches| of items will be returned in the |ScoredHistoryMatches| 68 // |max_matches| of items will be returned in the |ScoredHistoryMatches|
69 // vector. 69 // vector.
70 ScoredHistoryMatches HistoryItemsForTerms(base::string16 term_string, 70 ScoredHistoryMatches HistoryItemsForTerms(
71 size_t cursor_position, 71 base::string16 term_string,
72 size_t max_matches, 72 size_t cursor_position,
73 const std::string& languages, 73 size_t max_matches,
74 HistoryClient* history_client); 74 const std::string& languages,
75 const ScoredHistoryMatchClient* scored_history_match_client);
75 76
76 // Adds the history item in |row| to the index if it does not already already 77 // Adds the history item in |row| to the index if it does not already already
77 // exist and it meets the minimum 'quick' criteria. If the row already exists 78 // exist and it meets the minimum 'quick' criteria. If the row already exists
78 // in the index then the index will be updated if the row still meets the 79 // in the index then the index will be updated if the row still meets the
79 // criteria, otherwise the row will be removed from the index. Returns true 80 // criteria, otherwise the row will be removed from the index. Returns true
80 // if the index was actually updated. |languages| gives a list of language 81 // if the index was actually updated. |languages| gives a list of language
81 // encodings by which the URLs and page titles are broken down into words and 82 // encodings by which the URLs and page titles are broken down into words and
82 // characters. |scheme_whitelist| is used to filter non-qualifying schemes. 83 // characters. |scheme_whitelist| is used to filter non-qualifying schemes.
83 // |history_service| is used to schedule an update to the recent visits 84 // |history_service| is used to schedule an update to the recent visits
84 // component of this URL's entry in the index. 85 // component of this URL's entry in the index.
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 bool used_; // True if this item has been used for the current term search. 190 bool used_; // True if this item has been used for the current term search.
190 }; 191 };
191 typedef std::map<base::string16, SearchTermCacheItem> SearchTermCacheMap; 192 typedef std::map<base::string16, SearchTermCacheItem> SearchTermCacheMap;
192 193
193 // A helper class which performs the final filter on each candidate 194 // A helper class which performs the final filter on each candidate
194 // history URL match, inserting accepted matches into |scored_matches_|. 195 // history URL match, inserting accepted matches into |scored_matches_|.
195 class AddHistoryMatch : public std::unary_function<HistoryID, void> { 196 class AddHistoryMatch : public std::unary_function<HistoryID, void> {
196 public: 197 public:
197 AddHistoryMatch(const URLIndexPrivateData& private_data, 198 AddHistoryMatch(const URLIndexPrivateData& private_data,
198 const std::string& languages, 199 const std::string& languages,
199 HistoryClient* history_client, 200 const ScoredHistoryMatchClient* scored_history_match_client,
200 const base::string16& lower_string, 201 const base::string16& lower_string,
201 const String16Vector& lower_terms, 202 const String16Vector& lower_terms,
202 const base::Time now); 203 const base::Time now);
203 ~AddHistoryMatch(); 204 ~AddHistoryMatch();
204 205
205 void operator()(const HistoryID history_id); 206 void operator()(const HistoryID history_id);
206 207
207 ScoredHistoryMatches ScoredMatches() const { return scored_matches_; } 208 ScoredHistoryMatches ScoredMatches() const { return scored_matches_; }
208 209
209 private: 210 private:
210 const URLIndexPrivateData& private_data_; 211 const URLIndexPrivateData& private_data_;
211 const std::string& languages_; 212 const std::string& languages_;
212 HistoryClient* history_client_; 213 const ScoredHistoryMatchClient* scored_history_match_client_;
213 ScoredHistoryMatches scored_matches_; 214 ScoredHistoryMatches scored_matches_;
214 const base::string16& lower_string_; 215 const base::string16& lower_string_;
215 const String16Vector& lower_terms_; 216 const String16Vector& lower_terms_;
216 WordStarts lower_terms_to_word_starts_offsets_; 217 WordStarts lower_terms_to_word_starts_offsets_;
217 const base::Time now_; 218 const base::Time now_;
218 }; 219 };
219 220
220 // A helper predicate class used to filter excess history items when the 221 // A helper predicate class used to filter excess history items when the
221 // candidate results set is too large. 222 // candidate results set is too large.
222 class HistoryItemFactorGreater 223 class HistoryItemFactorGreater
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 // 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
388 // at three stages in the index searching process. 389 // at three stages in the index searching process.
389 size_t pre_filter_item_count_; // After word index is queried. 390 size_t pre_filter_item_count_; // After word index is queried.
390 size_t post_filter_item_count_; // After trimming large result set. 391 size_t post_filter_item_count_; // After trimming large result set.
391 size_t post_scoring_item_count_; // After performing final filter/scoring. 392 size_t post_scoring_item_count_; // After performing final filter/scoring.
392 }; 393 };
393 394
394 } // namespace history 395 } // namespace history
395 396
396 #endif // CHROME_BROWSER_HISTORY_URL_INDEX_PRIVATE_DATA_H_ 397 #endif // CHROME_BROWSER_HISTORY_URL_INDEX_PRIVATE_DATA_H_
OLDNEW
« no previous file with comments | « chrome/browser/history/scored_history_match_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