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

Side by Side Diff: components/omnibox/browser/history_url_provider.cc

Issue 1286093006: Launch HQP & HUP score changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing Barts comments Created 5 years, 3 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
OLDNEW
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 #include "components/omnibox/browser/history_url_provider.h" 5 #include "components/omnibox/browser/history_url_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 } 107 }
108 108
109 // Calculates a new relevance score applying half-life time decaying to |count| 109 // Calculates a new relevance score applying half-life time decaying to |count|
110 // using |time_since_last_visit| and |score_buckets|. This function will never 110 // using |time_since_last_visit| and |score_buckets|. This function will never
111 // return a score higher than |undecayed_relevance|; in other words, it can only 111 // return a score higher than |undecayed_relevance|; in other words, it can only
112 // demote the old score. 112 // demote the old score.
113 double CalculateRelevanceUsingScoreBuckets( 113 double CalculateRelevanceUsingScoreBuckets(
114 const HUPScoringParams::ScoreBuckets& score_buckets, 114 const HUPScoringParams::ScoreBuckets& score_buckets,
115 const base::TimeDelta& time_since_last_visit, 115 const base::TimeDelta& time_since_last_visit,
116 int undecayed_relevance, 116 int undecayed_relevance,
117 int count) { 117 int undecayed_count) {
118 // Back off if above relevance cap. 118 // Back off if above relevance cap.
119 if ((score_buckets.relevance_cap() != -1) && 119 if ((score_buckets.relevance_cap() != -1) &&
120 (undecayed_relevance >= score_buckets.relevance_cap())) 120 (undecayed_relevance >= score_buckets.relevance_cap()))
121 return undecayed_relevance; 121 return undecayed_relevance;
122 122
123 // Time based decay using half-life time. 123 // Time based decay using half-life time.
124 double decayed_count = count; 124 double decayed_count = undecayed_count;
125 double decay_factor = score_buckets.HalfLifeTimeDecay(time_since_last_visit);
125 if (decayed_count > 0) 126 if (decayed_count > 0)
126 decayed_count *= score_buckets.HalfLifeTimeDecay(time_since_last_visit); 127 decayed_count *= decay_factor;
127 128
128 // Find a threshold where decayed_count >= bucket. 129 // Find a threshold where decayed_count >= bucket. If buckets are based on
130 // decay factor, then use it correspondingly.
Peter Kasting 2015/08/27 00:50:44 Nit: After updating the comments in the .h file (s
Ashok vardhan 2015/08/27 19:09:27 Done.
129 const HUPScoringParams::ScoreBuckets::CountMaxRelevance* score_bucket = NULL; 131 const HUPScoringParams::ScoreBuckets::CountMaxRelevance* score_bucket = NULL;
132 const double factor = (score_buckets.use_decay_factor() ? decay_factor :
133 decayed_count);
130 for (size_t i = 0; i < score_buckets.buckets().size(); ++i) { 134 for (size_t i = 0; i < score_buckets.buckets().size(); ++i) {
131 score_bucket = &score_buckets.buckets()[i]; 135 score_bucket = &score_buckets.buckets()[i];
132 if (decayed_count >= score_bucket->first) 136 if (factor >= score_bucket->first)
133 break; // Buckets are in descending order, so we can ignore the rest. 137 break;
134 } 138 }
135 139
136 return (score_bucket && (undecayed_relevance > score_bucket->second)) ? 140 return (score_bucket && (undecayed_relevance > score_bucket->second)) ?
137 score_bucket->second : undecayed_relevance; 141 score_bucket->second : undecayed_relevance;
138 } 142 }
139 143
140 // Returns a new relevance score for the given |match| based on the 144 // Returns a new relevance score for the given |match| based on the
141 // |old_relevance| score and |scoring_params|. The new relevance score is 145 // |old_relevance| score and |scoring_params|. The new relevance score is
142 // guaranteed to be less than or equal to |old_relevance|. In other words, this 146 // guaranteed to be less than or equal to |old_relevance|. In other words, this
143 // function can only demote a score, never boost it. Returns |old_relevance| if 147 // function can only demote a score, never boost it. Returns |old_relevance| if
144 // experimental scoring is disabled. 148 // experimental scoring is disabled.
145 int CalculateRelevanceScoreUsingScoringParams( 149 int CalculateRelevanceScoreUsingScoringParams(
146 const history::HistoryMatch& match, 150 const history::HistoryMatch& match,
147 int old_relevance, 151 int old_relevance,
148 const HUPScoringParams& scoring_params) { 152 const HUPScoringParams& scoring_params) {
149 if (!scoring_params.experimental_scoring_enabled)
150 return old_relevance;
151
152 const base::TimeDelta time_since_last_visit = 153 const base::TimeDelta time_since_last_visit =
153 base::Time::Now() - match.url_info.last_visit(); 154 base::Time::Now() - match.url_info.last_visit();
154 155
155 int relevance = CalculateRelevanceUsingScoreBuckets( 156 int relevance = CalculateRelevanceUsingScoreBuckets(
156 scoring_params.typed_count_buckets, time_since_last_visit, old_relevance, 157 scoring_params.typed_count_buckets, time_since_last_visit, old_relevance,
157 match.url_info.typed_count()); 158 match.url_info.typed_count());
158 159
159 // Additional demotion (on top of typed_count demotion) of URLs that were 160 // Additional demotion (on top of typed_count demotion) of URLs that were
160 // never typed. 161 // never typed.
161 if (match.url_info.typed_count() == 0) { 162 if (match.url_info.typed_count() == 0) {
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 } 457 }
457 458
458 HistoryURLProviderParams::~HistoryURLProviderParams() { 459 HistoryURLProviderParams::~HistoryURLProviderParams() {
459 } 460 }
460 461
461 HistoryURLProvider::HistoryURLProvider(AutocompleteProviderClient* client, 462 HistoryURLProvider::HistoryURLProvider(AutocompleteProviderClient* client,
462 AutocompleteProviderListener* listener) 463 AutocompleteProviderListener* listener)
463 : HistoryProvider(AutocompleteProvider::TYPE_HISTORY_URL, client), 464 : HistoryProvider(AutocompleteProvider::TYPE_HISTORY_URL, client),
464 listener_(listener), 465 listener_(listener),
465 params_(NULL) { 466 params_(NULL) {
467 // Initialize the default HUP scoring params.
468 OmniboxFieldTrial::GetDefaultHUPScoringParams(&scoring_params_);
466 // Initialize HUP scoring params based on the current experiment. 469 // Initialize HUP scoring params based on the current experiment.
467 OmniboxFieldTrial::GetExperimentalHUPScoringParams(&scoring_params_); 470 OmniboxFieldTrial::GetExperimentalHUPScoringParams(&scoring_params_);
468 } 471 }
469 472
470 void HistoryURLProvider::Start(const AutocompleteInput& input, 473 void HistoryURLProvider::Start(const AutocompleteInput& input,
471 bool minimal_changes) { 474 bool minimal_changes) {
472 // NOTE: We could try hard to do less work in the |minimal_changes| case 475 // NOTE: We could try hard to do less work in the |minimal_changes| case
473 // here; some clever caching would let us reuse the raw matches from the 476 // here; some clever caching would let us reuse the raw matches from the
474 // history DB without re-querying. However, we'd still have to go back to 477 // history DB without re-querying. However, we'd still have to go back to
475 // the history thread to mark these up properly, and if pass 2 is currently 478 // the history thread to mark these up properly, and if pass 2 is currently
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
1199 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0, 1202 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0,
1200 match.contents.length(), ACMatchClassification::URL, 1203 match.contents.length(), ACMatchClassification::URL,
1201 &match.contents_class); 1204 &match.contents_class);
1202 } 1205 }
1203 match.description = info.title(); 1206 match.description = info.title();
1204 match.description_class = 1207 match.description_class =
1205 ClassifyDescription(params.input.text(), match.description); 1208 ClassifyDescription(params.input.text(), match.description);
1206 RecordAdditionalInfoFromUrlRow(info, &match); 1209 RecordAdditionalInfoFromUrlRow(info, &match);
1207 return match; 1210 return match;
1208 } 1211 }
OLDNEW
« no previous file with comments | « no previous file | components/omnibox/browser/omnibox_field_trial.h » ('j') | components/omnibox/browser/omnibox_field_trial.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698