OLD | NEW |
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 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/guid.h" |
12 #include "base/i18n/case_conversion.h" | 13 #include "base/i18n/case_conversion.h" |
13 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
14 #include "base/string_util.h" | 15 #include "base/string_util.h" |
15 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
16 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
17 #include "chrome/browser/autocomplete/autocomplete.h" | 18 #include "chrome/browser/autocomplete/autocomplete.h" |
18 #include "chrome/browser/autocomplete/autocomplete_match.h" | 19 #include "chrome/browser/autocomplete/autocomplete_match.h" |
19 #include "chrome/browser/history/history.h" | 20 #include "chrome/browser/history/history.h" |
20 #include "chrome/browser/history/history_notifications.h" | 21 #include "chrome/browser/history/history_notifications.h" |
21 #include "chrome/browser/history/in_memory_database.h" | 22 #include "chrome/browser/history/in_memory_database.h" |
22 #include "chrome/browser/predictors/autocomplete_action_predictor_factory.h" | 23 #include "chrome/browser/predictors/autocomplete_action_predictor_factory.h" |
23 #include "chrome/browser/predictors/predictor_database.h" | 24 #include "chrome/browser/predictors/predictor_database.h" |
24 #include "chrome/browser/predictors/predictor_database_factory.h" | 25 #include "chrome/browser/predictors/predictor_database_factory.h" |
25 #include "chrome/browser/prerender/prerender_field_trial.h" | 26 #include "chrome/browser/prerender/prerender_field_trial.h" |
26 #include "chrome/browser/prerender/prerender_manager.h" | 27 #include "chrome/browser/prerender/prerender_manager.h" |
27 #include "chrome/browser/prerender/prerender_manager_factory.h" | 28 #include "chrome/browser/prerender/prerender_manager_factory.h" |
28 #include "chrome/browser/profiles/profile.h" | 29 #include "chrome/browser/profiles/profile.h" |
29 #include "chrome/common/chrome_notification_types.h" | 30 #include "chrome/common/chrome_notification_types.h" |
30 #include "chrome/common/guid.h" | |
31 #include "content/public/browser/browser_thread.h" | 31 #include "content/public/browser/browser_thread.h" |
32 #include "content/public/browser/notification_details.h" | 32 #include "content/public/browser/notification_details.h" |
33 #include "content/public/browser/notification_service.h" | 33 #include "content/public/browser/notification_service.h" |
34 #include "content/public/browser/notification_source.h" | 34 #include "content/public/browser/notification_source.h" |
35 | 35 |
36 namespace { | 36 namespace { |
37 | 37 |
38 const float kConfidenceCutoff[] = { | 38 const float kConfidenceCutoff[] = { |
39 0.8f, | 39 0.8f, |
40 0.5f | 40 0.5f |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 DCHECK(it->user_text.length() >= kMinimumUserTextLength); | 335 DCHECK(it->user_text.length() >= kMinimumUserTextLength); |
336 const DBCacheKey key = { it->user_text, *url_it }; | 336 const DBCacheKey key = { it->user_text, *url_it }; |
337 const bool is_hit = (*url_it == opened_url); | 337 const bool is_hit = (*url_it == opened_url); |
338 | 338 |
339 AutocompleteActionPredictorTable::Row row; | 339 AutocompleteActionPredictorTable::Row row; |
340 row.user_text = key.user_text; | 340 row.user_text = key.user_text; |
341 row.url = key.url; | 341 row.url = key.url; |
342 | 342 |
343 DBCacheMap::iterator it = db_cache_.find(key); | 343 DBCacheMap::iterator it = db_cache_.find(key); |
344 if (it == db_cache_.end()) { | 344 if (it == db_cache_.end()) { |
345 row.id = guid::GenerateGUID(); | 345 row.id = base::GenerateGUID(); |
346 row.number_of_hits = is_hit ? 1 : 0; | 346 row.number_of_hits = is_hit ? 1 : 0; |
347 row.number_of_misses = is_hit ? 0 : 1; | 347 row.number_of_misses = is_hit ? 0 : 1; |
348 | 348 |
349 rows_to_add.push_back(row); | 349 rows_to_add.push_back(row); |
350 } else { | 350 } else { |
351 DCHECK(db_id_cache_.find(key) != db_id_cache_.end()); | 351 DCHECK(db_id_cache_.find(key) != db_id_cache_.end()); |
352 row.id = db_id_cache_.find(key)->second; | 352 row.id = db_id_cache_.find(key)->second; |
353 row.number_of_hits = it->second.number_of_hits + (is_hit ? 1 : 0); | 353 row.number_of_hits = it->second.number_of_hits + (is_hit ? 1 : 0); |
354 row.number_of_misses = it->second.number_of_misses + (is_hit ? 0 : 1); | 354 row.number_of_misses = it->second.number_of_misses + (is_hit ? 0 : 1); |
355 | 355 |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 return number_of_hits / (number_of_hits + value.number_of_misses); | 558 return number_of_hits / (number_of_hits + value.number_of_misses); |
559 } | 559 } |
560 | 560 |
561 AutocompleteActionPredictor::TransitionalMatch::TransitionalMatch() { | 561 AutocompleteActionPredictor::TransitionalMatch::TransitionalMatch() { |
562 } | 562 } |
563 | 563 |
564 AutocompleteActionPredictor::TransitionalMatch::~TransitionalMatch() { | 564 AutocompleteActionPredictor::TransitionalMatch::~TransitionalMatch() { |
565 } | 565 } |
566 | 566 |
567 } // namespace predictors | 567 } // namespace predictors |
OLD | NEW |