| OLD | NEW |
| 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 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 RecordNavigationEvent(NAVIGATION_EVENT_NO_PREDICTIONS_FOR_URL); | 598 RecordNavigationEvent(NAVIGATION_EVENT_NO_PREDICTIONS_FOR_URL); |
| 599 } | 599 } |
| 600 } | 600 } |
| 601 | 601 |
| 602 // Remove the navigation from the inflight navigations. | 602 // Remove the navigation from the inflight navigations. |
| 603 std::vector<URLRequestSummary>* requests = (nav_it->second).release(); | 603 std::vector<URLRequestSummary>* requests = (nav_it->second).release(); |
| 604 inflight_navigations_.erase(nav_it); | 604 inflight_navigations_.erase(nav_it); |
| 605 | 605 |
| 606 // Kick off history lookup to determine if we should record the URL. | 606 // Kick off history lookup to determine if we should record the URL. |
| 607 HistoryService* history_service = HistoryServiceFactory::GetForProfile( | 607 HistoryService* history_service = HistoryServiceFactory::GetForProfile( |
| 608 profile_, Profile::EXPLICIT_ACCESS); | 608 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
| 609 DCHECK(history_service); | 609 DCHECK(history_service); |
| 610 history_service->ScheduleDBTask( | 610 history_service->ScheduleDBTask( |
| 611 scoped_ptr<history::HistoryDBTask>( | 611 scoped_ptr<history::HistoryDBTask>( |
| 612 new GetUrlVisitCountTask( | 612 new GetUrlVisitCountTask( |
| 613 navigation_id, | 613 navigation_id, |
| 614 requests, | 614 requests, |
| 615 base::Bind(&ResourcePrefetchPredictor::OnVisitCountLookup, | 615 base::Bind(&ResourcePrefetchPredictor::OnVisitCountLookup, |
| 616 AsWeakPtr()))), | 616 AsWeakPtr()))), |
| 617 &history_lookup_consumer_); | 617 &history_lookup_consumer_); |
| 618 } | 618 } |
| (...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1340 } | 1340 } |
| 1341 | 1341 |
| 1342 void ResourcePrefetchPredictor::OnHistoryServiceLoaded( | 1342 void ResourcePrefetchPredictor::OnHistoryServiceLoaded( |
| 1343 HistoryService* history_service) { | 1343 HistoryService* history_service) { |
| 1344 OnHistoryAndCacheLoaded(); | 1344 OnHistoryAndCacheLoaded(); |
| 1345 history_service_observer_.Remove(history_service); | 1345 history_service_observer_.Remove(history_service); |
| 1346 } | 1346 } |
| 1347 | 1347 |
| 1348 void ResourcePrefetchPredictor::ConnectToHistoryService() { | 1348 void ResourcePrefetchPredictor::ConnectToHistoryService() { |
| 1349 // Register for HistoryServiceLoading if it is not ready. | 1349 // Register for HistoryServiceLoading if it is not ready. |
| 1350 HistoryService* history_service = | 1350 HistoryService* history_service = HistoryServiceFactory::GetForProfile( |
| 1351 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 1351 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
| 1352 if (!history_service) | 1352 if (!history_service) |
| 1353 return; | 1353 return; |
| 1354 if (history_service->BackendLoaded()) { | 1354 if (history_service->BackendLoaded()) { |
| 1355 // HistoryService is already loaded. Continue with Initialization. | 1355 // HistoryService is already loaded. Continue with Initialization. |
| 1356 OnHistoryAndCacheLoaded(); | 1356 OnHistoryAndCacheLoaded(); |
| 1357 return; | 1357 return; |
| 1358 } | 1358 } |
| 1359 DCHECK(!history_service_observer_.IsObserving(history_service)); | 1359 DCHECK(!history_service_observer_.IsObserving(history_service)); |
| 1360 history_service_observer_.Add(history_service); | 1360 history_service_observer_.Add(history_service); |
| 1361 return; | 1361 return; |
| 1362 } | 1362 } |
| 1363 | 1363 |
| 1364 } // namespace predictors | 1364 } // namespace predictors |
| OLD | NEW |