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

Unified Diff: chrome/browser/predictors/autocomplete_action_predictor.cc

Issue 2538763002: Data from the autocomplete predictor wasn't deleted immediately when deleting browsing history. (Closed)
Patch Set: assume history_service always exist to ensure we definitly delete data when requested Created 4 years 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 side-by-side diff with in-line comments
Download patch
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..cf6a900922a70d2bc72dd1c8f9904d4ca256b725 100644
--- a/chrome/browser/predictors/autocomplete_action_predictor.cc
+++ b/chrome/browser/predictors/autocomplete_action_predictor.cc
@@ -85,8 +85,8 @@ AutocompleteActionPredictor::AutocompleteActionPredictor(Profile* profile)
history::HistoryService* history_service =
HistoryServiceFactory::GetForProfile(
profile_, ServiceAccessType::EXPLICIT_ACCESS);
- if (history_service)
- history_service->InMemoryDatabase();
+ DCHECK(history_service);
+ history_service->InMemoryDatabase();
table_ =
PredictorDatabaseFactory::GetForProfile(profile_)->autocomplete_table();
@@ -442,29 +442,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);
+ DCHECK(history_service);
+ 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 +565,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 +575,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() {

Powered by Google App Engine
This is Rietveld 408576698