OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_AUTOCOMPLETE_HISTORY_QUICK_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_HISTORY_QUICK_PROVIDER_H_ |
6 #define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_QUICK_PROVIDER_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_QUICK_PROVIDER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, Spans); | 45 FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, Spans); |
46 FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, Relevance); | 46 FRIEND_TEST_ALL_PREFIXES(HistoryQuickProviderTest, Relevance); |
47 | 47 |
48 // The initial maximum allowable score for a match which cannot be inlined. | 48 // The initial maximum allowable score for a match which cannot be inlined. |
49 static const int kMaxNonInliningScore; | 49 static const int kMaxNonInliningScore; |
50 | 50 |
51 // Creates an AutocompleteMatch from |history_match|. |max_match_score| gives | 51 // Creates an AutocompleteMatch from |history_match|. |max_match_score| gives |
52 // the maximum possible score for the match. | 52 // the maximum possible score for the match. |
53 AutocompleteMatch QuickMatchToACMatch( | 53 AutocompleteMatch QuickMatchToACMatch( |
54 const history::ScoredHistoryMatch& history_match, | 54 const history::ScoredHistoryMatch& history_match, |
55 const history::ScoredHistoryMatches& history_matches, | |
mrossetti
2011/08/09 23:40:43
Document what |history_matches| is.
dominich
2011/08/10 16:10:13
Done.
| |
55 bool prevent_inline_autocomplete, | 56 bool prevent_inline_autocomplete, |
56 int* max_match_score); | 57 int* max_match_score); |
57 | 58 |
58 // Determines the relevance score of |history_match|. The maximum allowed | 59 // Determines the relevance score of |history_match|. The maximum allowed |
59 // score for the match is passed in |max_match_score|. The |max_match_score| | 60 // score for the match is passed in |max_match_score|. The |max_match_score| |
60 // is always set to the resulting score minus 1 whenever the match's score | 61 // is always set to the resulting score minus 1 whenever the match's score |
61 // has to be limited or is <= to |max_match_score|. This function should be | 62 // has to be limited or is <= to |max_match_score|. This function should be |
62 // called in a loop with each match in decreasing order of raw score. | 63 // called in a loop with each match in decreasing order of raw score. |
63 static int CalculateRelevance( | 64 static int CalculateRelevance( |
64 const history::ScoredHistoryMatch& history_match, | 65 const history::ScoredHistoryMatch& history_match, |
65 int* max_match_score); | 66 int* max_match_score); |
66 | 67 |
68 // Determines the confidence of |match| by comparing the |raw_score| to the | |
69 // sum of the scores of |matches|. Returns a float in the range [0, 1]. | |
70 static float CalculateConfidence( | |
71 const history::ScoredHistoryMatch& match, | |
72 const history::ScoredHistoryMatches& matches); | |
73 | |
67 // Returns the index that should be used for history lookups. | 74 // Returns the index that should be used for history lookups. |
68 history::InMemoryURLIndex* GetIndex(); | 75 history::InMemoryURLIndex* GetIndex(); |
69 | 76 |
70 // Fill and return an ACMatchClassifications structure given the term | 77 // Fill and return an ACMatchClassifications structure given the term |
71 // matches (|matches|) to highlight where terms were found. | 78 // matches (|matches|) to highlight where terms were found. |
72 static ACMatchClassifications SpansFromTermMatch( | 79 static ACMatchClassifications SpansFromTermMatch( |
73 const history::TermMatches& matches, | 80 const history::TermMatches& matches, |
74 size_t text_length, | 81 size_t text_length, |
75 bool is_url); | 82 bool is_url); |
76 | 83 |
77 // Only for use in unittests. Takes ownership of |index|. | 84 // Only for use in unittests. Takes ownership of |index|. |
78 void SetIndexForTesting(history::InMemoryURLIndex* index); | 85 void SetIndexForTesting(history::InMemoryURLIndex* index); |
79 AutocompleteInput autocomplete_input_; | 86 AutocompleteInput autocomplete_input_; |
80 std::string languages_; | 87 std::string languages_; |
81 | 88 |
82 // Only used for testing. | 89 // Only used for testing. |
83 scoped_ptr<history::InMemoryURLIndex> index_for_testing_; | 90 scoped_ptr<history::InMemoryURLIndex> index_for_testing_; |
84 }; | 91 }; |
85 | 92 |
86 #endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_QUICK_PROVIDER_H_ | 93 #endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_QUICK_PROVIDER_H_ |
OLD | NEW |