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

Unified Diff: chrome/browser/autocomplete/history_contents_provider.h

Issue 7607007: Add confidence to AutocompleteMatch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/autocomplete/history_contents_provider.h
diff --git a/chrome/browser/autocomplete/history_contents_provider.h b/chrome/browser/autocomplete/history_contents_provider.h
index 7ceb0b90639758ce5eff2c5d683d37af39068001..f4fd334afd17bcadce9fea75f681a328fe9f9d10 100644
--- a/chrome/browser/autocomplete/history_contents_provider.h
+++ b/chrome/browser/autocomplete/history_contents_provider.h
@@ -35,6 +35,22 @@ class HistoryContentsProvider : public HistoryProvider {
virtual void Stop() OVERRIDE;
private:
+ // When processing the results from the history query, this structure points
+ // to a single result. It allows the results to be sorted and processed
+ // without modifying the larger and slower results structure.
+ struct MatchReference {
+ MatchReference(const history::URLResult* result,
+ int relevance,
+ float confidence);
+
+ static bool CompareRelevance(const MatchReference& lhs,
+ const MatchReference& rhs);
+
+ const history::URLResult* result;
+ int relevance; // Score of relevance computed by CalculateRelevance.
+ float confidence; // Confidence computed by CalculateConfidence.
+ };
+
virtual ~HistoryContentsProvider();
void QueryComplete(HistoryService::Handle handle,
@@ -45,8 +61,7 @@ class HistoryContentsProvider : public HistoryProvider {
void ConvertResults();
// Creates and returns an AutocompleteMatch from a MatchingPageResult.
- AutocompleteMatch ResultToMatch(const history::URLResult& result,
- int score);
+ AutocompleteMatch ResultToMatch(const MatchReference& match_reference);
// Adds ACMatchClassifications to match from the offset positions in
// page_result.
@@ -57,6 +72,12 @@ class HistoryContentsProvider : public HistoryProvider {
// chart in autocomplete.h for the list of values this returns.
int CalculateRelevance(const history::URLResult& result);
+ // Calculates and returns the confidence for a particular result. This is
+ // calculated by comparing the result's |visit_count| to that of all the
+ // results.
+ float CalculateConfidence(const history::URLResult& result,
+ const history::QueryResults& results) const;
+
// Queries the bookmarks for any bookmarks whose title matches input. All
// matches are added directly to results_.
void QueryBookmarks(const AutocompleteInput& input);
« no previous file with comments | « chrome/browser/autocomplete/extension_app_provider.cc ('k') | chrome/browser/autocomplete/history_contents_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698