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

Side by Side Diff: chrome/browser/predictors/resource_prefetch_predictor.cc

Issue 2538763002: Data from the autocomplete predictor wasn't deleted immediately when deleting browsing history. (Closed)
Patch Set: fix destruction order 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/predictors/autocomplete_action_predictor_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/resource_prefetch_predictor.h" 5 #include "chrome/browser/predictors/resource_prefetch_predictor.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 } 1118 }
1119 } 1119 }
1120 1120
1121 void ResourcePrefetchPredictor::OnURLsDeleted( 1121 void ResourcePrefetchPredictor::OnURLsDeleted(
1122 history::HistoryService* history_service, 1122 history::HistoryService* history_service,
1123 bool all_history, 1123 bool all_history,
1124 bool expired, 1124 bool expired,
1125 const history::URLRows& deleted_rows, 1125 const history::URLRows& deleted_rows,
1126 const std::set<GURL>& favicon_urls) { 1126 const std::set<GURL>& favicon_urls) {
1127 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1127 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1128 if (INITIALIZED != initialization_state_) 1128 DCHECK(initialization_state_ == INITIALIZED);
1129 return;
1130 1129
1131 if (all_history) { 1130 if (all_history) {
1132 DeleteAllUrls(); 1131 DeleteAllUrls();
1133 UMA_HISTOGRAM_ENUMERATION("ResourcePrefetchPredictor.ReportingEvent", 1132 UMA_HISTOGRAM_ENUMERATION("ResourcePrefetchPredictor.ReportingEvent",
1134 REPORTING_EVENT_ALL_HISTORY_CLEARED, 1133 REPORTING_EVENT_ALL_HISTORY_CLEARED,
1135 REPORTING_EVENT_COUNT); 1134 REPORTING_EVENT_COUNT);
1136 } else { 1135 } else {
1137 DeleteUrls(deleted_rows); 1136 DeleteUrls(deleted_rows);
1138 UMA_HISTOGRAM_ENUMERATION("ResourcePrefetchPredictor.ReportingEvent", 1137 UMA_HISTOGRAM_ENUMERATION("ResourcePrefetchPredictor.ReportingEvent",
1139 REPORTING_EVENT_PARTIAL_HISTORY_CLEARED, 1138 REPORTING_EVENT_PARTIAL_HISTORY_CLEARED,
1140 REPORTING_EVENT_COUNT); 1139 REPORTING_EVENT_COUNT);
1141 } 1140 }
1142 } 1141 }
1143 1142
1144 void ResourcePrefetchPredictor::OnHistoryServiceLoaded( 1143 void ResourcePrefetchPredictor::OnHistoryServiceLoaded(
1145 history::HistoryService* history_service) { 1144 history::HistoryService* history_service) {
1146 OnHistoryAndCacheLoaded(); 1145 if (initialization_state_ == INITIALIZING) {
pasko 2016/12/12 19:15:43 DCHECK instead? I cannot see how we can end up wi
dullweber 2016/12/13 15:47:35 Ok, I removed it. The DCHECK() in OnHistoryAndCach
1147 history_service_observer_.Remove(history_service); 1146 OnHistoryAndCacheLoaded();
1147 }
1148 } 1148 }
1149 1149
1150 void ResourcePrefetchPredictor::ConnectToHistoryService() { 1150 void ResourcePrefetchPredictor::ConnectToHistoryService() {
1151 // Register for HistoryServiceLoading if it is not ready. 1151 // Register for HistoryServiceLoading if it is not ready.
1152 history::HistoryService* history_service = 1152 history::HistoryService* history_service =
1153 HistoryServiceFactory::GetForProfile(profile_, 1153 HistoryServiceFactory::GetForProfile(profile_,
1154 ServiceAccessType::EXPLICIT_ACCESS); 1154 ServiceAccessType::EXPLICIT_ACCESS);
1155 if (!history_service) 1155 if (!history_service)
pasko 2016/12/12 19:15:43 GetForProfile() with EXPLICIT_ACCESS never returns
dullweber 2016/12/13 15:47:35 That's right. I removed the conditions and use a D
pasko 2016/12/15 12:57:35 I was wrong here. Sorry. The history service may g
dullweber 2016/12/15 14:52:18 I reverted DCHECK(history_service) but added the D
1156 return; 1156 return;
1157 DCHECK(!history_service_observer_.IsObserving(history_service));
1158 history_service_observer_.Add(history_service);
1157 if (history_service->BackendLoaded()) { 1159 if (history_service->BackendLoaded()) {
1158 // HistoryService is already loaded. Continue with Initialization. 1160 // HistoryService is already loaded. Continue with Initialization.
1159 OnHistoryAndCacheLoaded(); 1161 OnHistoryAndCacheLoaded();
1160 return;
1161 } 1162 }
1162 DCHECK(!history_service_observer_.IsObserving(history_service));
1163 history_service_observer_.Add(history_service);
1164 return;
1165 } 1163 }
1166 1164
1167 //////////////////////////////////////////////////////////////////////////////// 1165 ////////////////////////////////////////////////////////////////////////////////
1168 // TestObserver. 1166 // TestObserver.
1169 1167
1170 TestObserver::~TestObserver() { 1168 TestObserver::~TestObserver() {
1171 predictor_->SetObserverForTesting(nullptr); 1169 predictor_->SetObserverForTesting(nullptr);
1172 } 1170 }
1173 1171
1174 TestObserver::TestObserver(ResourcePrefetchPredictor* predictor) 1172 TestObserver::TestObserver(ResourcePrefetchPredictor* predictor)
1175 : predictor_(predictor) { 1173 : predictor_(predictor) {
1176 predictor_->SetObserverForTesting(this); 1174 predictor_->SetObserverForTesting(this);
1177 } 1175 }
1178 1176
1179 } // namespace predictors 1177 } // namespace predictors
OLDNEW
« no previous file with comments | « chrome/browser/predictors/autocomplete_action_predictor_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698