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

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

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

Powered by Google App Engine
This is Rietveld 408576698