Index: chrome/browser/predictors/resource_prefetch_predictor.h |
diff --git a/chrome/browser/predictors/resource_prefetch_predictor.h b/chrome/browser/predictors/resource_prefetch_predictor.h |
index c6eb7157c458f932467670b46cdffb12150189f1..80918db83b0141ea9362dcb232029ae4bed14f88 100644 |
--- a/chrome/browser/predictors/resource_prefetch_predictor.h |
+++ b/chrome/browser/predictors/resource_prefetch_predictor.h |
@@ -13,11 +13,13 @@ |
#include "base/memory/linked_ptr.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/memory/weak_ptr.h" |
+#include "base/scoped_observer.h" |
#include "base/task/cancelable_task_tracker.h" |
#include "base/time/time.h" |
#include "chrome/browser/predictors/resource_prefetch_common.h" |
#include "chrome/browser/predictors/resource_prefetch_predictor_tables.h" |
#include "chrome/browser/predictors/resource_prefetcher.h" |
+#include "components/history/core/browser/history_service_observer.h" |
#include "components/history/core/browser/history_types.h" |
#include "components/keyed_service/core/keyed_service.h" |
#include "content/public/browser/notification_observer.h" |
@@ -75,6 +77,7 @@ class ResourcePrefetcherManager; |
class ResourcePrefetchPredictor |
: public KeyedService, |
public content::NotificationObserver, |
+ public history::HistoryServiceObserver, |
public base::SupportsWeakPtr<ResourcePrefetchPredictor> { |
public: |
// Stores the data that we need to get from the URLRequest. |
@@ -126,6 +129,9 @@ class ResourcePrefetchPredictor |
PrefetchKeyType key_type, |
ResourcePrefetcher::RequestVector* requests); |
+ // history::HistoryServiceObserver: |
+ void OnHistoryServiceLoaded(HistoryService* history_service) override; |
+ |
private: |
friend class ::PredictorsHandler; |
friend class ResourcePrefetchPredictorTest; |
@@ -288,6 +294,11 @@ class ResourcePrefetchPredictor |
tables_ = tables; |
} |
+ // If HistoryService exists and its Backend is loaded, |
+ // calls the OnHistoryAndCacheLoaded. |
+ // Else wait for the OnHistoryServiceLoaded event. |
+ void CheckForHistoryService(); |
+ |
Profile* const profile_; |
ResourcePrefetchPredictorConfig const config_; |
InitializationState initialization_state_; |
@@ -306,6 +317,9 @@ class ResourcePrefetchPredictor |
ResultsMap results_map_; |
STLValueDeleter<ResultsMap> results_map_deleter_; |
+ ScopedObserver<HistoryService, history::HistoryServiceObserver> |
+ history_service_observer_; |
+ |
DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictor); |
}; |