diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-12 17:38:33 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-12 17:38:33 +0000 |
commit | ffaf78a76172755b47a12c408656818d05232b85 (patch) | |
tree | 40a385fee1c04574e34ae66e89a817761982d527 /chrome/browser/autocomplete | |
parent | c1602a9988ef421b9773dc03da40c6bf184d22a1 (diff) | |
download | chromium_src-ffaf78a76172755b47a12c408656818d05232b85.zip chromium_src-ffaf78a76172755b47a12c408656818d05232b85.tar.gz chromium_src-ffaf78a76172755b47a12c408656818d05232b85.tar.bz2 |
Omnibox metrics logging patch splitout, part 1: Random miscellaneous small style and similar changes. In one or two cases the motivation is not obvious without looking at the original patch.
Review URL: http://codereview.chromium.org/10822
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5261 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autocomplete')
-rw-r--r-- | chrome/browser/autocomplete/history_contents_provider.cc | 33 | ||||
-rw-r--r-- | chrome/browser/autocomplete/keyword_provider.cc | 2 | ||||
-rw-r--r-- | chrome/browser/autocomplete/search_provider.cc | 4 |
3 files changed, 21 insertions, 18 deletions
diff --git a/chrome/browser/autocomplete/history_contents_provider.cc b/chrome/browser/autocomplete/history_contents_provider.cc index 9c50bd3..1d3ed28 100644 --- a/chrome/browser/autocomplete/history_contents_provider.cc +++ b/chrome/browser/autocomplete/history_contents_provider.cc @@ -22,6 +22,11 @@ const int kDaysToSearch = 30; // 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) + : result(result), + relevance(relevance) { + } + const history::URLResult* result; int relevance; // Score of relevance computed by CalculateRelevance. }; @@ -144,9 +149,7 @@ void HistoryContentsProvider::ConvertResults() { std::vector<MatchReference> result_refs; result_refs.reserve(results_.size()); for (size_t i = 0; i < results_.size(); i++) { - MatchReference ref; - ref.result = &results_[i]; - ref.relevance = CalculateRelevance(*ref.result); + MatchReference ref(&results_[i], CalculateRelevance(results_[i])); result_refs.push_back(ref); } @@ -180,6 +183,10 @@ void HistoryContentsProvider::ConvertResults() { matches_[i].relevance = -matches_[i].relevance; } +static bool MatchInTitle(const history::URLResult& result) { + return !result.title_match_positions().empty(); +} + AutocompleteMatch HistoryContentsProvider::ResultToMatch( const history::URLResult& result, int score) { @@ -227,8 +234,8 @@ void HistoryContentsProvider::ClassifyDescription( int HistoryContentsProvider::CalculateRelevance( const history::URLResult& result) { - bool in_title = !!result.title_match_positions().size(); - bool is_starred = + const bool in_title = MatchInTitle(result); + const bool is_starred = (profile_->GetBookmarkModel() && profile_->GetBookmarkModel()->IsBookmarked(result.url())); @@ -236,22 +243,18 @@ int HistoryContentsProvider::CalculateRelevance( case AutocompleteInput::UNKNOWN: case AutocompleteInput::REQUESTED_URL: if (is_starred) { - return in_title ? 1000 + star_title_count_++ : - 550 + star_contents_count_++; - } else { - return in_title ? 700 + title_count_++ : - 500 + contents_count_++; + return in_title ? + (1000 + star_title_count_++) : (550 + star_contents_count_++); } + return in_title ? (700 + title_count_++) : (500 + contents_count_++); case AutocompleteInput::QUERY: case AutocompleteInput::FORCED_QUERY: if (is_starred) { - return in_title ? 1200 + star_title_count_++ : - 750 + star_contents_count_++; - } else { - return in_title ? 900 + title_count_++ : - 700 + contents_count_++; + return in_title ? + (1200 + star_title_count_++) : (750 + star_contents_count_++); } + return in_title ? (900 + title_count_++) : (700 + contents_count_++); default: NOTREACHED(); diff --git a/chrome/browser/autocomplete/keyword_provider.cc b/chrome/browser/autocomplete/keyword_provider.cc index 4674d85..7c9f55b 100644 --- a/chrome/browser/autocomplete/keyword_provider.cc +++ b/chrome/browser/autocomplete/keyword_provider.cc @@ -227,7 +227,7 @@ int KeywordProvider::CalculateRelevance(AutocompleteInput::Type type, } AutocompleteMatch KeywordProvider::CreateAutocompleteMatch( - TemplateURLModel *model, + TemplateURLModel* model, const std::wstring keyword, const AutocompleteInput& input, size_t prefix_length, diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc index b7b260e..96fd52f 100644 --- a/chrome/browser/autocomplete/search_provider.cc +++ b/chrome/browser/autocomplete/search_provider.cc @@ -360,11 +360,11 @@ void SearchProvider::ConvertResultsToAutocompleteMatches() { for (MatchMap::const_iterator i(map.begin()); i != map.end(); ++i) matches_.push_back(i->second); - if (navigation_results_.size()) { + if (!navigation_results_.empty()) { // TODO(kochi): http://b/1170574 We add only one results for navigational // suggestions. If we can get more useful information about the score, // consider adding more results. - matches_.push_back(NavigationToMatch(navigation_results_[0], + matches_.push_back(NavigationToMatch(navigation_results_.front(), CalculateRelevanceForNavigation(0))); } |