| 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 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/file_path.h" | 11 #include "base/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/in_memory_url_index_types.h" | 14 #include "chrome/browser/history/in_memory_url_index_types.h" |
| 15 #include "chrome/browser/history/in_memory_url_index_cache.pb.h" | 15 #include "chrome/browser/history/in_memory_url_index_cache.pb.h" |
| 16 #include "chrome/browser/history/scored_history_match.h" | 16 #include "chrome/browser/history/scored_history_match.h" |
| 17 #include "content/public/browser/notification_details.h" | 17 #include "content/public/browser/notification_details.h" |
| 18 | 18 |
| 19 class HistoryQuickProviderTest; | 19 class HistoryQuickProviderTest; |
| 20 class BookmarkService; |
| 20 | 21 |
| 21 namespace in_memory_url_index { | 22 namespace in_memory_url_index { |
| 22 class InMemoryURLIndexCacheItem; | 23 class InMemoryURLIndexCacheItem; |
| 23 } | 24 } |
| 24 | 25 |
| 25 namespace history { | 26 namespace history { |
| 26 | 27 |
| 27 namespace imui = in_memory_url_index; | 28 namespace imui = in_memory_url_index; |
| 28 | 29 |
| 29 class HistoryDatabase; | 30 class HistoryDatabase; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 52 // however, the terms do not necessarily have to be adjacent. Once we have | 53 // however, the terms do not necessarily have to be adjacent. Once we have |
| 53 // a set of candidates, they are filtered to insure that all |term_string| | 54 // a set of candidates, they are filtered to insure that all |term_string| |
| 54 // terms, as separated by whitespace, occur within the candidate's URL | 55 // terms, as separated by whitespace, occur within the candidate's URL |
| 55 // or page title. Scores are then calculated on no more than | 56 // or page title. Scores are then calculated on no more than |
| 56 // |kItemsToScoreLimit| candidates, as the scoring of such a large number of | 57 // |kItemsToScoreLimit| candidates, as the scoring of such a large number of |
| 57 // candidates may cause perceptible typing response delays in the omnibox. | 58 // candidates may cause perceptible typing response delays in the omnibox. |
| 58 // This is likely to occur for short omnibox terms such as 'h' and 'w' which | 59 // This is likely to occur for short omnibox terms such as 'h' and 'w' which |
| 59 // will be found in nearly all history candidates. Results are sorted by | 60 // will be found in nearly all history candidates. Results are sorted by |
| 60 // descending score. The full results set (i.e. beyond the | 61 // descending score. The full results set (i.e. beyond the |
| 61 // |kItemsToScoreLimit| limit) will be retained and used for subsequent calls | 62 // |kItemsToScoreLimit| limit) will be retained and used for subsequent calls |
| 62 // to this function. | 63 // to this function. |bookmark_service| is used to boost a result's score if |
| 63 ScoredHistoryMatches HistoryItemsForTerms(const string16& term_string); | 64 // its URL is referenced by one or more of the user's bookmarks. |
| 65 ScoredHistoryMatches HistoryItemsForTerms(const string16& term_string, |
| 66 BookmarkService* bookmark_service); |
| 64 | 67 |
| 65 // Adds the history item in |row| to the index if it does not already already | 68 // Adds the history item in |row| to the index if it does not already already |
| 66 // exist and it meets the minimum 'quick' criteria. If the row already exists | 69 // exist and it meets the minimum 'quick' criteria. If the row already exists |
| 67 // in the index then the index will be updated if the row still meets the | 70 // in the index then the index will be updated if the row still meets the |
| 68 // criteria, otherwise the row will be removed from the index. Returns true | 71 // criteria, otherwise the row will be removed from the index. Returns true |
| 69 // if the index was actually updated. |languages| gives a list of language | 72 // if the index was actually updated. |languages| gives a list of language |
| 70 // encodings by which the URLs and page titles are broken down into words and | 73 // encodings by which the URLs and page titles are broken down into words and |
| 71 // characters. |scheme_whitelist| is used to filter non-qualifying schemes. | 74 // characters. |scheme_whitelist| is used to filter non-qualifying schemes. |
| 72 bool UpdateURL(const URLRow& row, | 75 bool UpdateURL(const URLRow& row, |
| 73 const std::string& languages, | 76 const std::string& languages, |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 HistoryIDSet history_id_set_; | 161 HistoryIDSet history_id_set_; |
| 159 bool used_; // True if this item has been used for the current term search. | 162 bool used_; // True if this item has been used for the current term search. |
| 160 }; | 163 }; |
| 161 typedef std::map<string16, SearchTermCacheItem> SearchTermCacheMap; | 164 typedef std::map<string16, SearchTermCacheItem> SearchTermCacheMap; |
| 162 | 165 |
| 163 // A helper class which performs the final filter on each candidate | 166 // A helper class which performs the final filter on each candidate |
| 164 // history URL match, inserting accepted matches into |scored_matches_|. | 167 // history URL match, inserting accepted matches into |scored_matches_|. |
| 165 class AddHistoryMatch : public std::unary_function<HistoryID, void> { | 168 class AddHistoryMatch : public std::unary_function<HistoryID, void> { |
| 166 public: | 169 public: |
| 167 AddHistoryMatch(const URLIndexPrivateData& private_data, | 170 AddHistoryMatch(const URLIndexPrivateData& private_data, |
| 171 BookmarkService* bookmark_service, |
| 168 const string16& lower_string, | 172 const string16& lower_string, |
| 169 const String16Vector& lower_terms, | 173 const String16Vector& lower_terms, |
| 170 const base::Time now); | 174 const base::Time now); |
| 171 ~AddHistoryMatch(); | 175 ~AddHistoryMatch(); |
| 172 | 176 |
| 173 void operator()(const HistoryID history_id); | 177 void operator()(const HistoryID history_id); |
| 174 | 178 |
| 175 ScoredHistoryMatches ScoredMatches() const { return scored_matches_; } | 179 ScoredHistoryMatches ScoredMatches() const { return scored_matches_; } |
| 176 | 180 |
| 177 private: | 181 private: |
| 178 const URLIndexPrivateData& private_data_; | 182 const URLIndexPrivateData& private_data_; |
| 183 BookmarkService* bookmark_service_; |
| 179 ScoredHistoryMatches scored_matches_; | 184 ScoredHistoryMatches scored_matches_; |
| 180 const string16& lower_string_; | 185 const string16& lower_string_; |
| 181 const String16Vector& lower_terms_; | 186 const String16Vector& lower_terms_; |
| 182 const base::Time now_; | 187 const base::Time now_; |
| 183 }; | 188 }; |
| 184 | 189 |
| 185 // A helper predicate class used to filter excess history items when the | 190 // A helper predicate class used to filter excess history items when the |
| 186 // candidate results set is too large. | 191 // candidate results set is too large. |
| 187 class HistoryItemFactorGreater | 192 class HistoryItemFactorGreater |
| 188 : public std::binary_function<HistoryID, HistoryID, void> { | 193 : public std::binary_function<HistoryID, HistoryID, void> { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 // Used for unit testing only. Records the number of candidate history items | 353 // Used for unit testing only. Records the number of candidate history items |
| 349 // at three stages in the index searching process. | 354 // at three stages in the index searching process. |
| 350 size_t pre_filter_item_count_; // After word index is queried. | 355 size_t pre_filter_item_count_; // After word index is queried. |
| 351 size_t post_filter_item_count_; // After trimming large result set. | 356 size_t post_filter_item_count_; // After trimming large result set. |
| 352 size_t post_scoring_item_count_; // After performing final filter/scoring. | 357 size_t post_scoring_item_count_; // After performing final filter/scoring. |
| 353 }; | 358 }; |
| 354 | 359 |
| 355 } // namespace history | 360 } // namespace history |
| 356 | 361 |
| 357 #endif // CHROME_BROWSER_HISTORY_URL_INDEX_PRIVATE_DATA_H_ | 362 #endif // CHROME_BROWSER_HISTORY_URL_INDEX_PRIVATE_DATA_H_ |
| OLD | NEW |