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

Side by Side Diff: chrome/browser/predictors/autocomplete_action_predictor.cc

Issue 10453013: Remove hit weight experiment (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: integer math for the win Created 8 years, 7 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) 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 "chrome/browser/predictors/autocomplete_action_predictor.h" 5 #include "chrome/browser/predictors/autocomplete_action_predictor.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 return false; 68 return false;
69 } 69 }
70 } 70 }
71 71
72 } // namespace 72 } // namespace
73 73
74 namespace predictors { 74 namespace predictors {
75 75
76 const int AutocompleteActionPredictor::kMaximumDaysToKeepEntry = 14; 76 const int AutocompleteActionPredictor::kMaximumDaysToKeepEntry = 14;
77 77
78 double AutocompleteActionPredictor::hit_weight_ = 1.0;
79
80 AutocompleteActionPredictor::AutocompleteActionPredictor(Profile* profile) 78 AutocompleteActionPredictor::AutocompleteActionPredictor(Profile* profile)
81 : profile_(profile), 79 : profile_(profile),
82 table_(PredictorDatabaseFactory::GetForProfile( 80 table_(PredictorDatabaseFactory::GetForProfile(
83 profile)->autocomplete_table()), 81 profile)->autocomplete_table()),
84 initialized_(false) { 82 initialized_(false) {
85 // Request the in-memory database from the history to force it to load so it's 83 // Request the in-memory database from the history to force it to load so it's
86 // available as soon as possible. 84 // available as soon as possible.
87 HistoryService* history_service = 85 HistoryService* history_service =
88 profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); 86 profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
89 if (history_service) 87 if (history_service)
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 } 233 }
236 234
237 void AutocompleteActionPredictor::OnOmniboxOpenedUrl( 235 void AutocompleteActionPredictor::OnOmniboxOpenedUrl(
238 const AutocompleteLog& log) { 236 const AutocompleteLog& log) {
239 if (log.text.length() < kMinimumUserTextLength) 237 if (log.text.length() < kMinimumUserTextLength)
240 return; 238 return;
241 239
242 const AutocompleteMatch& match = log.result.match_at(log.selected_index); 240 const AutocompleteMatch& match = log.result.match_at(log.selected_index);
243 241
244 UMA_HISTOGRAM_BOOLEAN( 242 UMA_HISTOGRAM_BOOLEAN(
245 StringPrintf("Prerender.OmniboxNavigationsCouldPrerender_%.1f%s", 243 StringPrintf("Prerender.OmniboxNavigationsCouldPrerender_%s",
cbentzel 2012/05/25 16:34:34 Do you plan to obsolete these in histograms.xml?
dominich 2012/05/25 16:54:57 Actually I'll remove them if they're even there. T
246 get_hit_weight(),
247 prerender::PrerenderManager::GetModeString()).c_str(), 244 prerender::PrerenderManager::GetModeString()).c_str(),
248 prerender::IsOmniboxEnabled(profile_)); 245 prerender::IsOmniboxEnabled(profile_));
249 246
250 const GURL& opened_url = match.destination_url; 247 const GURL& opened_url = match.destination_url;
251 248
252 // If the Omnibox triggered a prerender but the URL doesn't match the one the 249 // If the Omnibox triggered a prerender but the URL doesn't match the one the
253 // user is navigating to, cancel the prerender. 250 // user is navigating to, cancel the prerender.
254 prerender::PrerenderManager* prerender_manager = 251 prerender::PrerenderManager* prerender_manager =
255 prerender::PrerenderManagerFactory::GetForProfile(profile_); 252 prerender::PrerenderManagerFactory::GetForProfile(profile_);
256 // |prerender_manager| can be NULL in incognito mode or if prerendering is 253 // |prerender_manager| can be NULL in incognito mode or if prerendering is
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 *is_in_db = true; 414 *is_in_db = true;
418 return CalculateConfidenceForDbEntry(iter); 415 return CalculateConfidenceForDbEntry(iter);
419 } 416 }
420 417
421 double AutocompleteActionPredictor::CalculateConfidenceForDbEntry( 418 double AutocompleteActionPredictor::CalculateConfidenceForDbEntry(
422 DBCacheMap::const_iterator iter) const { 419 DBCacheMap::const_iterator iter) const {
423 const DBCacheValue& value = iter->second; 420 const DBCacheValue& value = iter->second;
424 if (value.number_of_hits < kMinimumNumberOfHits) 421 if (value.number_of_hits < kMinimumNumberOfHits)
425 return 0.0; 422 return 0.0;
426 423
427 const double number_of_hits = value.number_of_hits * hit_weight_; 424 const double number_of_hits = static_cast<double>(value.number_of_hits);
cbentzel 2012/05/25 16:34:34 Do you actually need the explicit cast here? Manti
dominich 2012/05/25 16:54:57 A preference to be explicit. const double a = som
428 return number_of_hits / (number_of_hits + value.number_of_misses); 425 return number_of_hits / (number_of_hits + value.number_of_misses);
429 } 426 }
430 427
431 void AutocompleteActionPredictor::AddAndUpdateRows( 428 void AutocompleteActionPredictor::AddAndUpdateRows(
432 const AutocompleteActionPredictorTable::Rows& rows_to_add, 429 const AutocompleteActionPredictorTable::Rows& rows_to_add,
433 const AutocompleteActionPredictorTable::Rows& rows_to_update) { 430 const AutocompleteActionPredictorTable::Rows& rows_to_update) {
434 if (!initialized_) 431 if (!initialized_)
435 return; 432 return;
436 433
437 for (AutocompleteActionPredictorTable::Rows::const_iterator it = 434 for (AutocompleteActionPredictorTable::Rows::const_iterator it =
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 DATABASE_ACTION_DELETE_SOME, DATABASE_ACTION_COUNT); 504 DATABASE_ACTION_DELETE_SOME, DATABASE_ACTION_COUNT);
508 } 505 }
509 506
510 AutocompleteActionPredictor::TransitionalMatch::TransitionalMatch() { 507 AutocompleteActionPredictor::TransitionalMatch::TransitionalMatch() {
511 } 508 }
512 509
513 AutocompleteActionPredictor::TransitionalMatch::~TransitionalMatch() { 510 AutocompleteActionPredictor::TransitionalMatch::~TransitionalMatch() {
514 } 511 }
515 512
516 } // namespace predictors 513 } // namespace predictors
OLDNEW
« no previous file with comments | « chrome/browser/predictors/autocomplete_action_predictor.h ('k') | chrome/browser/prerender/prerender_field_trial.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698