| Index: chrome/browser/autocomplete/network_action_predictor.cc
|
| diff --git a/chrome/browser/autocomplete/network_action_predictor.cc b/chrome/browser/autocomplete/network_action_predictor.cc
|
| index 444da0711db1d4d0dfe96386ab1e43d91b56dfff..bd601103f6282eeefaaa53940dc9cce04798ebe7 100644
|
| --- a/chrome/browser/autocomplete/network_action_predictor.cc
|
| +++ b/chrome/browser/autocomplete/network_action_predictor.cc
|
| @@ -35,7 +35,7 @@ const float kConfidenceCutoff[] = {
|
| 0.5f
|
| };
|
|
|
| -const size_t kMinimumUserTextLength = 2;
|
| +const size_t kMinimumUserTextLength = 1;
|
| const int kMinimumNumberOfHits = 3;
|
|
|
| COMPILE_ASSERT(arraysize(kConfidenceCutoff) ==
|
| @@ -131,23 +131,20 @@ void NetworkActionPredictor::ClearTransitionalMatches() {
|
| NetworkActionPredictor::Action NetworkActionPredictor::RecommendAction(
|
| const string16& user_text,
|
| const AutocompleteMatch& match) const {
|
| - double confidence = 0.0;
|
| -
|
| - switch (prerender::GetOmniboxHeuristicToUse()) {
|
| - case prerender::OMNIBOX_HEURISTIC_EXACT:
|
| - case prerender::OMNIBOX_HEURISTIC_EXACT_FULL:
|
| - confidence = ExactAlgorithm(user_text, match);
|
| - break;
|
| - default:
|
| - NOTREACHED();
|
| - break;
|
| - };
|
| + DCHECK(prerender::GetOmniboxHeuristicToUse() ==
|
| + prerender::OMNIBOX_HEURISTIC_EXACT ||
|
| + prerender::GetOmniboxHeuristicToUse() ==
|
| + prerender::OMNIBOX_HEURISTIC_EXACT_FULL);
|
|
|
| + bool is_in_db = false;
|
| + const double confidence = CalculateConfidence(user_text, match, &is_in_db);
|
| DCHECK(confidence >= 0.0 && confidence <= 1.0);
|
|
|
| - UMA_HISTOGRAM_COUNTS_100("NetworkActionPredictor.Confidence_" +
|
| - prerender::GetOmniboxHistogramSuffix(),
|
| - confidence * 100);
|
| + if (is_in_db) {
|
| + UMA_HISTOGRAM_COUNTS_100("NetworkActionPredictor.Confidence_" +
|
| + prerender::GetOmniboxHistogramSuffix(),
|
| + confidence * 100);
|
| + }
|
|
|
| // Map the confidence to an action.
|
| Action action = ACTION_NONE;
|
| @@ -380,11 +377,13 @@ bool NetworkActionPredictor::TryDeleteOldEntries(HistoryService* service) {
|
| return true;
|
| }
|
|
|
| -double NetworkActionPredictor::ExactAlgorithm(
|
| +double NetworkActionPredictor::CalculateConfidence(
|
| const string16& user_text,
|
| - const AutocompleteMatch& match) const {
|
| + const AutocompleteMatch& match,
|
| + bool* is_in_db) const {
|
| const DBCacheKey key = { user_text, match.destination_url };
|
|
|
| + *is_in_db = false;
|
| if (user_text.length() < kMinimumUserTextLength)
|
| return 0.0;
|
|
|
| @@ -392,6 +391,7 @@ double NetworkActionPredictor::ExactAlgorithm(
|
| if (iter == db_cache_.end())
|
| return 0.0;
|
|
|
| + *is_in_db = true;
|
| const DBCacheValue& value = iter->second;
|
| if (value.number_of_hits < kMinimumNumberOfHits)
|
| return 0.0;
|
|
|