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

Side by Side 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: Response to pkasting 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_CONTENTS_PROVIDER_H_ 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_HISTORY_CONTENTS_PROVIDER_H_
6 #define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_CONTENTS_PROVIDER_H_ 6 #define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_CONTENTS_PROVIDER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "chrome/browser/autocomplete/history_provider.h" 9 #include "chrome/browser/autocomplete/history_provider.h"
10 #include "chrome/browser/history/history.h" 10 #include "chrome/browser/history/history.h"
(...skipping 17 matching lines...) Expand all
28 Profile* profile, 28 Profile* profile,
29 bool body_only); 29 bool body_only);
30 30
31 // As necessary asks the history service for the relevant results. When 31 // As necessary asks the history service for the relevant results. When
32 // done SetResults is invoked. 32 // done SetResults is invoked.
33 virtual void Start(const AutocompleteInput& input, 33 virtual void Start(const AutocompleteInput& input,
34 bool minimal_changes) OVERRIDE; 34 bool minimal_changes) OVERRIDE;
35 virtual void Stop() OVERRIDE; 35 virtual void Stop() OVERRIDE;
36 36
37 private: 37 private:
38 // When processing the results from the history query, this structure points
39 // to a single result. It allows the results to be sorted and processed
40 // without modifying the larger and slower results structure.
41 struct MatchReference {
42 MatchReference(const history::URLResult* result,
43 int relevance,
44 float confidence);
45
46 static bool CompareRelevance(const MatchReference& lhs,
47 const MatchReference& rhs);
48
49 const history::URLResult* result;
50 int relevance; // Score of relevance computed by CalculateRelevance.
51 float confidence; // Confidence computed by CalculateConfidence.
52 };
53
38 virtual ~HistoryContentsProvider(); 54 virtual ~HistoryContentsProvider();
39 55
40 void QueryComplete(HistoryService::Handle handle, 56 void QueryComplete(HistoryService::Handle handle,
41 history::QueryResults* results); 57 history::QueryResults* results);
42 58
43 // Converts each MatchingPageResult in results_ to an AutocompleteMatch and 59 // Converts each MatchingPageResult in results_ to an AutocompleteMatch and
44 // adds it to matches_. 60 // adds it to matches_.
45 void ConvertResults(); 61 void ConvertResults();
46 62
47 // Creates and returns an AutocompleteMatch from a MatchingPageResult. 63 // Creates and returns an AutocompleteMatch from a MatchingPageResult.
48 AutocompleteMatch ResultToMatch(const history::URLResult& result, 64 AutocompleteMatch ResultToMatch(const MatchReference& match_reference);
49 int score);
50 65
51 // Adds ACMatchClassifications to match from the offset positions in 66 // Adds ACMatchClassifications to match from the offset positions in
52 // page_result. 67 // page_result.
53 void ClassifyDescription(const history::URLResult& result, 68 void ClassifyDescription(const history::URLResult& result,
54 AutocompleteMatch* match) const; 69 AutocompleteMatch* match) const;
55 70
56 // Calculates and returns the relevance of a particular result. See the 71 // Calculates and returns the relevance of a particular result. See the
57 // chart in autocomplete.h for the list of values this returns. 72 // chart in autocomplete.h for the list of values this returns.
58 int CalculateRelevance(const history::URLResult& result); 73 int CalculateRelevance(const history::URLResult& result);
59 74
75 // Calculates and returns the confidence for a particular result. This is
76 // calculated by comparing the result's |visit_count| to that of all the
77 // results.
78 float CalculateConfidence(const history::URLResult& result,
79 const history::QueryResults& results) const;
mrossetti 2011/08/09 23:40:43 Same suggestion as for the HistoryQuickProvider: c
dominich 2011/08/10 16:10:13 There's a very good chance the details of the calc
80
60 // Queries the bookmarks for any bookmarks whose title matches input. All 81 // Queries the bookmarks for any bookmarks whose title matches input. All
61 // matches are added directly to results_. 82 // matches are added directly to results_.
62 void QueryBookmarks(const AutocompleteInput& input); 83 void QueryBookmarks(const AutocompleteInput& input);
63 84
64 // Converts a BookmarkModel::TitleMatch to a QueryResult and adds it to 85 // Converts a BookmarkModel::TitleMatch to a QueryResult and adds it to
65 // results_. 86 // results_.
66 void AddBookmarkTitleMatchToResults(const bookmark_utils::TitleMatch& match); 87 void AddBookmarkTitleMatchToResults(const bookmark_utils::TitleMatch& match);
67 88
68 // Return true if the search term can be found in the title of |result|. 89 // Return true if the search term can be found in the title of |result|.
69 bool MatchInTitle(const history::URLResult& result); 90 bool MatchInTitle(const history::URLResult& result);
(...skipping 26 matching lines...) Expand all
96 // Whether results_ is valid (so we can tell invalid apart from empty). 117 // Whether results_ is valid (so we can tell invalid apart from empty).
97 bool have_results_; 118 bool have_results_;
98 119
99 // Current query string. 120 // Current query string.
100 string16 query_; 121 string16 query_;
101 122
102 DISALLOW_COPY_AND_ASSIGN(HistoryContentsProvider); 123 DISALLOW_COPY_AND_ASSIGN(HistoryContentsProvider);
103 }; 124 };
104 125
105 #endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_CONTENTS_PROVIDER_H_ 126 #endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_CONTENTS_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698