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

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

Issue 285233012: Abstract history dependencies on bookmarks through HistoryClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix android unit tests Created 6 years, 6 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_SCORED_HISTORY_MATCH_H_ 5 #ifndef CHROME_BROWSER_HISTORY_SCORED_HISTORY_MATCH_H_
6 #define CHROME_BROWSER_HISTORY_SCORED_HISTORY_MATCH_H_ 6 #define CHROME_BROWSER_HISTORY_SCORED_HISTORY_MATCH_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
13 #include "chrome/browser/autocomplete/history_provider_util.h" 13 #include "chrome/browser/autocomplete/history_provider_util.h"
14 #include "chrome/browser/history/history_types.h" 14 #include "chrome/browser/history/history_types.h"
15 #include "chrome/browser/history/in_memory_url_index_types.h" 15 #include "chrome/browser/history/in_memory_url_index_types.h"
16 #include "testing/gtest/include/gtest/gtest_prod.h" 16 #include "testing/gtest/include/gtest/gtest_prod.h"
17 17
18 class BookmarkService;
19
20 namespace history { 18 namespace history {
21 19
20 class HistoryClient;
22 class ScoredHistoryMatchTest; 21 class ScoredHistoryMatchTest;
23 22
24 // An HistoryMatch that has a score as well as metrics defining where in the 23 // An HistoryMatch that has a score as well as metrics defining where in the
25 // history item's URL and/or page title matches have occurred. 24 // history item's URL and/or page title matches have occurred.
26 class ScoredHistoryMatch : public history::HistoryMatch { 25 class ScoredHistoryMatch : public history::HistoryMatch {
27 public: 26 public:
28 // The maximum number of recent visits to examine in GetFrequency(). 27 // The maximum number of recent visits to examine in GetFrequency().
29 // Public so url_index_private_data.cc knows how many visits it is 28 // Public so url_index_private_data.cc knows how many visits it is
30 // expected to deliver (at minimum) to this class. 29 // expected to deliver (at minimum) to this class.
31 static const size_t kMaxVisitsToScore; 30 static const size_t kMaxVisitsToScore;
32 31
33 ScoredHistoryMatch(); // Required by STL. 32 ScoredHistoryMatch(); // Required by STL.
34 33
35 // Creates a new match with a raw score calculated for the history item 34 // Creates a new match with a raw score calculated for the history item
36 // given in |row| with recent visits as indicated in |visits|. First 35 // given in |row| with recent visits as indicated in |visits|. First
37 // determines if the row qualifies by seeing if all of the terms in 36 // determines if the row qualifies by seeing if all of the terms in
38 // |terms_vector| occur in |row|. If so, calculates a raw score. This raw 37 // |terms_vector| occur in |row|. If so, calculates a raw score. This raw
39 // score is in part determined by whether the matches occur at word 38 // score is in part determined by whether the matches occur at word
40 // boundaries, the locations of which are stored in |word_starts|. For some 39 // boundaries, the locations of which are stored in |word_starts|. For some
41 // terms, it's appropriate to look for the word boundary within the term. 40 // terms, it's appropriate to look for the word boundary within the term.
42 // For instance, the term ".net" should look for a word boundary at the "n". 41 // For instance, the term ".net" should look for a word boundary at the "n".
43 // These offsets (".net" should have an offset of 1) come from 42 // These offsets (".net" should have an offset of 1) come from
44 // |terms_to_word_starts_offsets|. |bookmark_service| is used to determine 43 // |terms_to_word_starts_offsets|. |history_client| is used to determine
45 // if the match's URL is referenced by any bookmarks, which can also affect 44 // if the match's URL is referenced by any bookmarks, which can also affect
46 // the raw score. The raw score allows the matches to be ordered and can be 45 // the raw score. The raw score allows the matches to be ordered and can be
47 // used to influence the final score calculated by the client of this index. 46 // used to influence the final score calculated by the client of this index.
48 // If the row does not qualify the raw score will be 0. |languages| is used 47 // If the row does not qualify the raw score will be 0. |languages| is used
49 // to help parse/format the URL before looking for the terms. 48 // to help parse/format the URL before looking for the terms.
50 ScoredHistoryMatch(const URLRow& row, 49 ScoredHistoryMatch(const URLRow& row,
51 const VisitInfoVector& visits, 50 const VisitInfoVector& visits,
52 const std::string& languages, 51 const std::string& languages,
53 const base::string16& lower_string, 52 const base::string16& lower_string,
54 const String16Vector& terms_vector, 53 const String16Vector& terms_vector,
55 const WordStarts& terms_to_word_starts_offsets, 54 const WordStarts& terms_to_word_starts_offsets,
56 const RowWordStarts& word_starts, 55 const RowWordStarts& word_starts,
57 const base::Time now, 56 const base::Time now,
58 BookmarkService* bookmark_service); 57 HistoryClient* history_client);
59 ~ScoredHistoryMatch(); 58 ~ScoredHistoryMatch();
60 59
61 // Compares two matches by score. Functor supporting URLIndexPrivateData's 60 // Compares two matches by score. Functor supporting URLIndexPrivateData's
62 // HistoryItemsForTerms function. Looks at particular fields within 61 // HistoryItemsForTerms function. Looks at particular fields within
63 // with url_info to make tie-breaking a bit smarter. 62 // with url_info to make tie-breaking a bit smarter.
64 static bool MatchScoreGreater(const ScoredHistoryMatch& m1, 63 static bool MatchScoreGreater(const ScoredHistoryMatch& m1,
65 const ScoredHistoryMatch& m2); 64 const ScoredHistoryMatch& m2);
66 65
67 // Accessors: 66 // Accessors:
68 int raw_score() const { return raw_score_; } 67 int raw_score() const { return raw_score_; }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 // matches) because if a non-inlineable match comes first than all matches 199 // matches) because if a non-inlineable match comes first than all matches
201 // will get demoted later in HistoryQuickProvider to non-inlineable scores. 200 // will get demoted later in HistoryQuickProvider to non-inlineable scores.
202 // Set to -1 to indicate no maximum score. 201 // Set to -1 to indicate no maximum score.
203 static int max_assigned_score_for_non_inlineable_matches_; 202 static int max_assigned_score_for_non_inlineable_matches_;
204 }; 203 };
205 typedef std::vector<ScoredHistoryMatch> ScoredHistoryMatches; 204 typedef std::vector<ScoredHistoryMatch> ScoredHistoryMatches;
206 205
207 } // namespace history 206 } // namespace history
208 207
209 #endif // CHROME_BROWSER_HISTORY_SCORED_HISTORY_MATCH_H_ 208 #endif // CHROME_BROWSER_HISTORY_SCORED_HISTORY_MATCH_H_
OLDNEW
« no previous file with comments | « chrome/browser/history/in_memory_url_index_unittest.cc ('k') | chrome/browser/history/scored_history_match.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698