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

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

Issue 2896713003: Create LoadingDataCollector class and have observers rely on it instead of ResourcePrefetchPredictor (Closed)
Patch Set: Rebase, merge loading_stats_collector. Created 3 years, 6 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 4363b37543195798cefcdd1b1b7892d1fb69c150..685d2781c28521efc2c4407f274aa6636aadd5e2 100644
--- a/chrome/browser/predictors/resource_prefetch_predictor.h
+++ b/chrome/browser/predictors/resource_prefetch_predictor.h
@@ -76,7 +76,7 @@ class LoadingStatsCollector;
//
// The overall flow of the resource prefetching algorithm is as follows:
//
-// * ResourcePrefetchPredictorObserver - Listens for URL requests, responses and
+// * LoadingPredictorObserver - Listens for URL requests, responses and
// redirects (client-side redirects are not supported) on the IO thread (via
// ResourceDispatcherHostDelegate) and posts tasks to the
// ResourcePrefetchPredictor on the UI thread. This is owned by the
@@ -85,7 +85,7 @@ class LoadingStatsCollector;
// to a sql database. Runs entirely on the DB thread. Owned by the
// PredictorDatabase.
// * ResourcePrefetchPredictor - Learns about resource requirements per URL in
-// the UI thread through the ResourcePrefetchPredictorObserver and persists
+// the UI thread through the LoadingPredictorObserver and persists
// it to disk in the DB thread through the ResourcePrefetchPredictorTables. It
// initiates resource prefetching using the ResourcePrefetcherManager. Owned
// by profile.
@@ -200,12 +200,6 @@ class ResourcePrefetchPredictor
virtual void StartInitialization();
virtual void Shutdown();
- // Thread safe.
- static bool ShouldRecordRequest(net::URLRequest* request,
- content::ResourceType resource_type);
- static bool ShouldRecordResponse(net::URLRequest* response);
- static bool ShouldRecordRedirect(net::URLRequest* response);
-
// Determines the resource type from the declared one, falling back to MIME
// type detection when it is not explicit.
static content::ResourceType GetResourceType(
@@ -218,21 +212,6 @@ class ResourcePrefetchPredictor
const std::string& mime_type,
content::ResourceType fallback);
- // 'ResourcePrefetchPredictorObserver' calls the below functions to inform the
- // predictor of main frame and resource requests. Should only be called if the
- // corresponding Should* functions return true.
- void RecordURLRequest(const URLRequestSummary& request);
- void RecordURLResponse(const URLRequestSummary& response);
- void RecordURLRedirect(const URLRequestSummary& response);
-
- // Called when the main frame of a page completes loading.
- void RecordMainFrameLoadComplete(const NavigationID& navigation_id);
-
- // Called after the main frame's first contentful paint.
- void RecordFirstContentfulPaint(
- const NavigationID& navigation_id,
- const base::TimeTicks& first_contentful_paint);
-
// Called when ResourcePrefetcher is finished, i.e. there is nothing pending
// in flight.
void OnPrefetchingFinished(
@@ -265,6 +244,21 @@ class ResourcePrefetchPredictor
Prediction* prediction) const;
private:
+ // 'LoadingPredictorObserver' calls the below functions to inform the
+ // predictor of main frame and resource requests. Should only be called if the
+ // corresponding Should* functions return true.
+ void RecordURLRequest(const URLRequestSummary& request);
+ void RecordURLResponse(const URLRequestSummary& response);
+ void RecordURLRedirect(const URLRequestSummary& response);
+
+ // Called when the main frame of a page completes loading.
+ void RecordMainFrameLoadComplete(const NavigationID& navigation_id);
+
+ // Called after the main frame's first contentful paint.
+ void RecordFirstContentfulPaint(
+ const NavigationID& navigation_id,
+ const base::TimeTicks& first_contentful_paint);
+
// Starts prefetching if it is enabled 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);
@@ -275,6 +269,7 @@ class ResourcePrefetchPredictor
friend class LoadingPredictor;
friend class ::PredictorsHandler;
+ friend class LoadingDataCollector;
friend class ResourcePrefetchPredictorTest;
friend class ResourcePrefetchPredictorBrowserTest;
@@ -302,7 +297,6 @@ class ResourcePrefetchPredictor
FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest,
OnSubresourceResponse);
FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, GetCorrectPLT);
- FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, HandledResourceTypes);
FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest,
PopulatePrefetcherRequest);
FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, PopulateFromManifest);
@@ -332,22 +326,9 @@ class ResourcePrefetchPredictor
typedef std::map<NavigationID, std::unique_ptr<PageRequestSummary>>
NavigationMap;
- // Returns true if the main page request is supported for prediction.
- static bool IsHandledMainPage(net::URLRequest* request);
-
- // Returns true if the subresource request is supported for prediction.
- static bool IsHandledSubresource(net::URLRequest* request,
- content::ResourceType resource_type);
-
- // Returns true if the subresource has a supported type.
- static bool IsHandledResourceType(content::ResourceType resource_type,
- const std::string& mime_type);
-
// Returns true if the request (should have a response in it) is "no-store".
static bool IsNoStore(const net::URLRequest& request);
- static void SetAllowPortInUrlsForTesting(bool state);
-
// Functions called on different network events pertaining to the loading of
// main frame resource or sub resources.
void OnMainFrameRequest(const URLRequestSummary& request);

Powered by Google App Engine
This is Rietveld 408576698