| 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/guid.h" |
| 13 #include "base/i18n/case_conversion.h" | 13 #include "base/i18n/case_conversion.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 16 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
| 17 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
| 18 #include "chrome/browser/autocomplete/autocomplete_log.h" | 18 #include "chrome/browser/autocomplete/autocomplete_log.h" |
| 19 #include "chrome/browser/autocomplete/autocomplete_match.h" | 19 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 20 #include "chrome/browser/autocomplete/autocomplete_result.h" | 20 #include "chrome/browser/autocomplete/autocomplete_result.h" |
| 21 #include "chrome/browser/history/history_notifications.h" | 21 #include "chrome/browser/history/history_notifications.h" |
| 22 #include "chrome/browser/history/history_service.h" | 22 #include "chrome/browser/history/history_service.h" |
| 23 #include "chrome/browser/history/history_service_factory.h" | 23 #include "chrome/browser/history/history_service_factory.h" |
| 24 #include "chrome/browser/history/in_memory_database.h" | 24 #include "chrome/browser/history/in_memory_database.h" |
| 25 #include "chrome/browser/predictors/autocomplete_action_predictor_factory.h" | 25 #include "chrome/browser/predictors/autocomplete_action_predictor_factory.h" |
| 26 #include "chrome/browser/predictors/predictor_database.h" | |
| 27 #include "chrome/browser/predictors/predictor_database_factory.h" | 26 #include "chrome/browser/predictors/predictor_database_factory.h" |
| 27 #include "chrome/browser/predictors/predictor_database_service.h" |
| 28 #include "chrome/browser/prerender/prerender_field_trial.h" | 28 #include "chrome/browser/prerender/prerender_field_trial.h" |
| 29 #include "chrome/browser/prerender/prerender_handle.h" | 29 #include "chrome/browser/prerender/prerender_handle.h" |
| 30 #include "chrome/browser/prerender/prerender_manager.h" | 30 #include "chrome/browser/prerender/prerender_manager.h" |
| 31 #include "chrome/browser/prerender/prerender_manager_factory.h" | 31 #include "chrome/browser/prerender/prerender_manager_factory.h" |
| 32 #include "chrome/browser/profiles/profile.h" | 32 #include "chrome/browser/profiles/profile.h" |
| 33 #include "chrome/common/chrome_notification_types.h" | 33 #include "chrome/common/chrome_notification_types.h" |
| 34 #include "content/public/browser/browser_thread.h" | 34 #include "content/public/browser/browser_thread.h" |
| 35 #include "content/public/browser/notification_details.h" | 35 #include "content/public/browser/notification_details.h" |
| 36 #include "content/public/browser/notification_service.h" | 36 #include "content/public/browser/notification_service.h" |
| 37 #include "content/public/browser/notification_source.h" | 37 #include "content/public/browser/notification_source.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 CopyFromMainProfile(); | 78 CopyFromMainProfile(); |
| 79 } else { | 79 } else { |
| 80 // Request the in-memory database from the history to force it to load so | 80 // Request the in-memory database from the history to force it to load so |
| 81 // it's available as soon as possible. | 81 // it's available as soon as possible. |
| 82 HistoryService* history_service = HistoryServiceFactory::GetForProfile( | 82 HistoryService* history_service = HistoryServiceFactory::GetForProfile( |
| 83 profile_, Profile::EXPLICIT_ACCESS); | 83 profile_, Profile::EXPLICIT_ACCESS); |
| 84 if (history_service) | 84 if (history_service) |
| 85 history_service->InMemoryDatabase(); | 85 history_service->InMemoryDatabase(); |
| 86 | 86 |
| 87 table_ = | 87 table_ = |
| 88 PredictorDatabaseFactory::GetForProfile(profile_)->autocomplete_table(); | 88 PredictorDatabaseFactory::GetForProfile(profile_)->GetDatabase()-> |
| 89 autocomplete_table(); |
| 89 | 90 |
| 90 // Observe all main frame loads so we can wait for the first to complete | 91 // Observe all main frame loads so we can wait for the first to complete |
| 91 // before accessing DB and IO threads to build the local cache. | 92 // before accessing DB and IO threads to build the local cache. |
| 92 notification_registrar_.Add(this, | 93 notification_registrar_.Add(this, |
| 93 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 94 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 94 content::NotificationService::AllSources()); | 95 content::NotificationService::AllSources()); |
| 95 } | 96 } |
| 96 } | 97 } |
| 97 | 98 |
| 98 AutocompleteActionPredictor::~AutocompleteActionPredictor() { | 99 AutocompleteActionPredictor::~AutocompleteActionPredictor() { |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 return number_of_hits / (number_of_hits + value.number_of_misses); | 576 return number_of_hits / (number_of_hits + value.number_of_misses); |
| 576 } | 577 } |
| 577 | 578 |
| 578 AutocompleteActionPredictor::TransitionalMatch::TransitionalMatch() { | 579 AutocompleteActionPredictor::TransitionalMatch::TransitionalMatch() { |
| 579 } | 580 } |
| 580 | 581 |
| 581 AutocompleteActionPredictor::TransitionalMatch::~TransitionalMatch() { | 582 AutocompleteActionPredictor::TransitionalMatch::~TransitionalMatch() { |
| 582 } | 583 } |
| 583 | 584 |
| 584 } // namespace predictors | 585 } // namespace predictors |
| OLD | NEW |