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_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/string16.h" | 12 #include "base/string16.h" |
13 #include "chrome/browser/history/history_types.h" | 13 #include "chrome/browser/history/history_types.h" |
14 #include "chrome/browser/autocomplete/history_provider_util.h" | 14 #include "chrome/browser/autocomplete/history_provider_util.h" |
15 #include "chrome/browser/history/in_memory_url_index_types.h" | 15 #include "chrome/browser/history/in_memory_url_index_types.h" |
16 | 16 |
17 namespace history { | 17 namespace history { |
18 | 18 |
19 // An HistoryMatch that has a score as well as metrics defining where in the | 19 // An HistoryMatch that has a score as well as metrics defining where in the |
20 // history item's URL and/or page title matches have occurred. | 20 // history item's URL and/or page title matches have occurred. |
21 struct ScoredHistoryMatch : public history::HistoryMatch { | 21 struct ScoredHistoryMatch : public history::HistoryMatch { |
22 ScoredHistoryMatch(); // Required by STL. | 22 ScoredHistoryMatch(); // Required by STL. |
23 | 23 |
24 // Creates a new match with a raw score calculated for the history item given | 24 // Creates a new match with a raw score calculated for the history item given |
25 // in |row|. First determines if the row qualifies by seeing if all of the | 25 // in |row| by first determining if all of the terms in |terms_vector| occur |
26 // terms in |terms_vector| occur in |row|. If so, calculates a raw score. | 26 // in |row| and, if so, calculating a raw score based on 1) starting position |
27 // This raw score allows the results to be ordered and can be used to | 27 // of each term in the user input, 2) completeness of each term's match, |
28 // influence the final score calculated by the client of this index. | 28 // 3) ordering of the occurrence of each term (i.e. they appear in order), |
29 // If the row does not qualify the raw score will be 0. | 29 // 4) last visit time (compared to |now|), and 5) number of visits. |
| 30 // This raw score allows the results to be ordered and can be used |
| 31 // to influence the final score calculated by the client of this |
| 32 // index. |
30 ScoredHistoryMatch(const URLRow& row, | 33 ScoredHistoryMatch(const URLRow& row, |
31 const string16& lower_string, | 34 const string16& lower_string, |
32 const String16Vector& terms_vector, | 35 const String16Vector& terms_vector, |
33 const RowWordStarts& word_starts, | 36 const RowWordStarts& word_starts, |
34 const base::Time now); | 37 const base::Time now); |
35 ~ScoredHistoryMatch(); | 38 ~ScoredHistoryMatch(); |
36 | 39 |
37 // Calculates a component score based on position, ordering and total | 40 // Calculates a component score based on position, ordering and total |
38 // substring match size using metrics recorded in |matches|. |max_length| | 41 // substring match size using metrics recorded in |matches|. |max_length| |
39 // is the length of the string against which the terms are being searched. | 42 // is the length of the string against which the terms are being searched. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 134 |
132 // Whether to use new-score or old-scoring. Set in the constructor | 135 // Whether to use new-score or old-scoring. Set in the constructor |
133 // by examining command line flags. | 136 // by examining command line flags. |
134 static bool use_new_scoring; | 137 static bool use_new_scoring; |
135 }; | 138 }; |
136 typedef std::vector<ScoredHistoryMatch> ScoredHistoryMatches; | 139 typedef std::vector<ScoredHistoryMatch> ScoredHistoryMatches; |
137 | 140 |
138 } // namespace history | 141 } // namespace history |
139 | 142 |
140 #endif // CHROME_BROWSER_HISTORY_SCORED_HISTORY_MATCH_H_ | 143 #endif // CHROME_BROWSER_HISTORY_SCORED_HISTORY_MATCH_H_ |
OLD | NEW |