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

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

Issue 2847183002: predictors: Introduce GlowplugPredictor. (Closed)
Patch Set: GlowplugPredictor -> LoadingPredictor Created 3 years, 7 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 1c7a5e6bdb63b88a94dee8386dedb162647cec80..2cd3c950895ace6aabeb4aa0cf8d2067fa9263e0 100644
--- a/chrome/browser/predictors/resource_prefetch_predictor.h
+++ b/chrome/browser/predictors/resource_prefetch_predictor.h
@@ -19,6 +19,7 @@
#include "base/scoped_observer.h"
#include "base/task/cancelable_task_tracker.h"
#include "base/time/time.h"
+#include "chrome/browser/predictors/loading_predictor_config.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"
@@ -103,8 +104,7 @@ class ResourcePrefetcherManager;
// recorded. Consider recording sub-frame responses independently or together
// with main frame.
class ResourcePrefetchPredictor
- : public KeyedService,
- public history::HistoryServiceObserver,
+ : public history::HistoryServiceObserver,
public base::SupportsWeakPtr<ResourcePrefetchPredictor>,
public precache::PrecacheManager::Delegate {
public:
@@ -195,13 +195,14 @@ class ResourcePrefetchPredictor
MAX
};
- ResourcePrefetchPredictor(const ResourcePrefetchPredictorConfig& config,
+ ResourcePrefetchPredictor(const LoadingPredictorConfig& config,
Profile* profile);
~ResourcePrefetchPredictor() override;
// Starts initialization by posting a task to the DB thread to read the
// predictor database.
void StartInitialization();
+ void Shutdown();
// Thread safe.
static bool ShouldRecordRequest(net::URLRequest* request,
@@ -236,14 +237,6 @@ class ResourcePrefetchPredictor
const NavigationID& navigation_id,
const base::TimeTicks& first_contentful_paint);
- // Starts prefetching if it is enabled for |origin| and prefetching data
- // exists for the |main_frame_url| either at the URL or at the host level.
- void StartPrefetching(const GURL& main_frame_url, PrefetchOrigin origin);
-
- // Stops prefetching that may be in progress corresponding to
- // |main_frame_url|.
- void StopPrefetching(const GURL& main_frame_url);
-
// Called when ResourcePrefetcher is finished, i.e. there is nothing pending
// in flight.
void OnPrefetchingFinished(
@@ -267,6 +260,15 @@ class ResourcePrefetchPredictor
void SetObserverForTesting(TestObserver* observer);
private:
+ // Starts prefetching if it is enabled for |origin| and prefetching data
+ // exists for the |main_frame_url| either at the URL or at the host level.
+ void StartPrefetching(const GURL& main_frame_url, HintOrigin origin);
+
+ // Stops prefetching that may be in progress corresponding to
+ // |main_frame_url|.
+ void StopPrefetching(const GURL& main_frame_url);
+
+ friend class LoadingPredictor;
friend class ::PredictorsHandler;
friend class ResourcePrefetchPredictorTest;
friend class ResourcePrefetchPredictorBrowserTest;
@@ -337,9 +339,6 @@ class ResourcePrefetchPredictor
static void SetAllowPortInUrlsForTesting(bool state);
- // KeyedService methods override.
- void Shutdown() override;
-
// Functions called on different network events pertaining to the loading of
// main frame resource or sub resources.
void OnMainFrameRequest(const URLRequestSummary& request);
@@ -476,7 +475,7 @@ class ResourcePrefetchPredictor
Profile* const profile_;
TestObserver* observer_;
- ResourcePrefetchPredictorConfig const config_;
+ const LoadingPredictorConfig config_;
InitializationState initialization_state_;
scoped_refptr<ResourcePrefetchPredictorTables> tables_;
scoped_refptr<ResourcePrefetcherManager> prefetch_manager_;

Powered by Google App Engine
This is Rietveld 408576698