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

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: 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.
129 const HUPScoringParams::ScoreBuckets::CountMaxRelevance* score_bucket = NULL; 131 const HUPScoringParams::ScoreBuckets::CountMaxRelevance* score_bucket = NULL;
130 for (size_t i = 0; i < score_buckets.buckets().size(); ++i) { 132 for (size_t i = 0; i < score_buckets.buckets().size(); ++i) {
131 score_bucket = &score_buckets.buckets()[i]; 133 score_bucket = &score_buckets.buckets()[i];
132 if (decayed_count >= score_bucket->first) 134 if (score_buckets.use_decay_factor()) {
Bart N. 2015/08/26 23:01:25 This is invariant, so I suggest taking it out of t
Ashok vardhan 2015/08/27 00:30:46 Done.
133 break; // Buckets are in descending order, so we can ignore the rest. 135 if (decay_factor >= score_bucket->first) {
136 break;
137 }
138 } else {
139 if (decayed_count >= score_bucket->first) {
140 break;
141 }
142 }
134 } 143 }
135 144
136 return (score_bucket && (undecayed_relevance > score_bucket->second)) ? 145 return (score_bucket && (undecayed_relevance > score_bucket->second)) ?
137 score_bucket->second : undecayed_relevance; 146 score_bucket->second : undecayed_relevance;
138 } 147 }
139 148
140 // Returns a new relevance score for the given |match| based on the 149 // Returns a new relevance score for the given |match| based on the
141 // |old_relevance| score and |scoring_params|. The new relevance score is 150 // |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 151 // 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 152 // function can only demote a score, never boost it. Returns |old_relevance| if
144 // experimental scoring is disabled. 153 // experimental scoring is disabled.
145 int CalculateRelevanceScoreUsingScoringParams( 154 int CalculateRelevanceScoreUsingScoringParams(
146 const history::HistoryMatch& match, 155 const history::HistoryMatch& match,
147 int old_relevance, 156 int old_relevance,
148 const HUPScoringParams& scoring_params) { 157 const HUPScoringParams& scoring_params) {
149 if (!scoring_params.experimental_scoring_enabled) 158 if (!scoring_params.experimental_scoring_enabled &&
159 !scoring_params.default_scoring_enabled) {
Bart N. 2015/08/26 23:01:25 I don't understand why we need default_scoring_ena
Ashok vardhan 2015/08/27 00:30:46 Done.
150 return old_relevance; 160 return old_relevance;
161 }
151 162
152 const base::TimeDelta time_since_last_visit = 163 const base::TimeDelta time_since_last_visit =
153 base::Time::Now() - match.url_info.last_visit(); 164 base::Time::Now() - match.url_info.last_visit();
154 165
155 int relevance = CalculateRelevanceUsingScoreBuckets( 166 int relevance = CalculateRelevanceUsingScoreBuckets(
156 scoring_params.typed_count_buckets, time_since_last_visit, old_relevance, 167 scoring_params.typed_count_buckets, time_since_last_visit, old_relevance,
157 match.url_info.typed_count()); 168 match.url_info.typed_count());
158 169
159 // Additional demotion (on top of typed_count demotion) of URLs that were 170 // Additional demotion (on top of typed_count demotion) of URLs that were
160 // never typed. 171 // never typed.
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 } 467 }
457 468
458 HistoryURLProviderParams::~HistoryURLProviderParams() { 469 HistoryURLProviderParams::~HistoryURLProviderParams() {
459 } 470 }
460 471
461 HistoryURLProvider::HistoryURLProvider(AutocompleteProviderClient* client, 472 HistoryURLProvider::HistoryURLProvider(AutocompleteProviderClient* client,
462 AutocompleteProviderListener* listener) 473 AutocompleteProviderListener* listener)
463 : HistoryProvider(AutocompleteProvider::TYPE_HISTORY_URL, client), 474 : HistoryProvider(AutocompleteProvider::TYPE_HISTORY_URL, client),
464 listener_(listener), 475 listener_(listener),
465 params_(NULL) { 476 params_(NULL) {
477 // Initialize the default HUP scoring params.
478 OmniboxFieldTrial::GetDefaultHUPScoringParams(&scoring_params_);
466 // Initialize HUP scoring params based on the current experiment. 479 // Initialize HUP scoring params based on the current experiment.
467 OmniboxFieldTrial::GetExperimentalHUPScoringParams(&scoring_params_); 480 OmniboxFieldTrial::GetExperimentalHUPScoringParams(&scoring_params_);
468 } 481 }
469 482
470 void HistoryURLProvider::Start(const AutocompleteInput& input, 483 void HistoryURLProvider::Start(const AutocompleteInput& input,
471 bool minimal_changes) { 484 bool minimal_changes) {
472 // NOTE: We could try hard to do less work in the |minimal_changes| case 485 // 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 486 // 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 487 // 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 488 // 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, 1212 AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0,
1200 match.contents.length(), ACMatchClassification::URL, 1213 match.contents.length(), ACMatchClassification::URL,
1201 &match.contents_class); 1214 &match.contents_class);
1202 } 1215 }
1203 match.description = info.title(); 1216 match.description = info.title();
1204 match.description_class = 1217 match.description_class =
1205 ClassifyDescription(params.input.text(), match.description); 1218 ClassifyDescription(params.input.text(), match.description);
1206 RecordAdditionalInfoFromUrlRow(info, &match); 1219 RecordAdditionalInfoFromUrlRow(info, &match);
1207 return match; 1220 return match;
1208 } 1221 }
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