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

Unified Diff: chrome/browser/predictors/resource_prefetch_predictor.h

Issue 573553004: Eliminate NOTIFICATION_HISTORY_LOADED notification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed styling issues Created 6 years, 2 months 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/resource_prefetch_predictor.h
diff --git a/chrome/browser/predictors/resource_prefetch_predictor.h b/chrome/browser/predictors/resource_prefetch_predictor.h
index c6eb7157c458f932467670b46cdffb12150189f1..bcca5249028f1ea36c7738cf0cd63252e57ca9f5 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,10 @@ class ResourcePrefetchPredictor
tables_ = tables;
}
+ // If HistoryService is loaded then calls the Initialization function
+ // else Observe for the HistoryService to be loaded.
sdefresne 2014/11/03 19:14:13 nit: s/Observe/wait for OnHistoryLoaded event/ may
nshaik 2014/11/04 00:13:05 Done.
+ bool CheckForHistoryService();
+
Profile* const profile_;
ResourcePrefetchPredictorConfig const config_;
InitializationState initialization_state_;
@@ -306,6 +316,9 @@ class ResourcePrefetchPredictor
ResultsMap results_map_;
STLValueDeleter<ResultsMap> results_map_deleter_;
+ ScopedObserver<HistoryService, history::HistoryServiceObserver>
+ history_service_observer_;
+
DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictor);
};

Powered by Google App Engine
This is Rietveld 408576698