Chromium Code Reviews| Index: chrome/browser/predictors/autocomplete_action_predictor.cc |
| diff --git a/chrome/browser/predictors/autocomplete_action_predictor.cc b/chrome/browser/predictors/autocomplete_action_predictor.cc |
| index 90fd37d1c6711e49854d7c5977724d415fdc1517..9165cb803e3eb500caa5eaa2aa54d4be8f3d6b66 100644 |
| --- a/chrome/browser/predictors/autocomplete_action_predictor.cc |
| +++ b/chrome/browser/predictors/autocomplete_action_predictor.cc |
| @@ -335,8 +335,7 @@ void AutocompleteActionPredictor::CreateLocalCachesFromDatabase() { |
| } |
| void AutocompleteActionPredictor::DeleteAllRows() { |
| - if (!initialized_) |
| - return; |
| + DCHECK(initialized_); |
| db_cache_.clear(); |
| db_id_cache_.clear(); |
| @@ -353,8 +352,7 @@ void AutocompleteActionPredictor::DeleteAllRows() { |
| void AutocompleteActionPredictor::DeleteRowsWithURLs( |
| const history::URLRows& rows) { |
| - if (!initialized_) |
| - return; |
| + DCHECK(initialized_); |
| std::vector<AutocompleteActionPredictorTable::Row::Id> id_list; |
| @@ -442,29 +440,25 @@ void AutocompleteActionPredictor::CreateCaches( |
| history::HistoryService* history_service = |
| HistoryServiceFactory::GetForProfile(profile_, |
| ServiceAccessType::EXPLICIT_ACCESS); |
| - if (!TryDeleteOldEntries(history_service)) { |
| - // Wait for the notification that the history service is ready and the URL |
| - // DB is loaded. |
| - if (history_service) |
| - history_service_observer_.Add(history_service); |
| - } |
| + TryDeleteOldEntries(history_service); |
| + if (history_service) |
|
pasko
2016/12/15 15:29:48
nit: extra check for the pointer in TryDeleteOldEn
|
| + history_service_observer_.Add(history_service); |
| } |
| -bool AutocompleteActionPredictor::TryDeleteOldEntries( |
| +void AutocompleteActionPredictor::TryDeleteOldEntries( |
| history::HistoryService* service) { |
| CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| DCHECK(!profile_->IsOffTheRecord()); |
| DCHECK(!initialized_); |
| if (!service) |
| - return false; |
| + return; |
| history::URLDatabase* url_db = service->InMemoryDatabase(); |
| if (!url_db) |
| - return false; |
| + return; |
| DeleteOldEntries(url_db); |
| - return true; |
| } |
| void AutocompleteActionPredictor::DeleteOldEntries( |
| @@ -569,8 +563,7 @@ void AutocompleteActionPredictor::OnURLsDeleted( |
| bool expired, |
| const history::URLRows& deleted_rows, |
| const std::set<GURL>& favicon_urls) { |
| - if (!initialized_) |
| - return; |
| + DCHECK(initialized_); |
| if (all_history) |
| DeleteAllRows(); |
| @@ -580,8 +573,8 @@ void AutocompleteActionPredictor::OnURLsDeleted( |
| void AutocompleteActionPredictor::OnHistoryServiceLoaded( |
| history::HistoryService* history_service) { |
| - TryDeleteOldEntries(history_service); |
| - history_service_observer_.Remove(history_service); |
| + if (!initialized_) |
| + TryDeleteOldEntries(history_service); |
| } |
| AutocompleteActionPredictor::TransitionalMatch::TransitionalMatch() { |