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

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: Tests + rebase 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 e8a88fbbeeae763f00a1544c92f3aa94e4a653cb..3dc81a16b2b234bf0e0afbb01ef7b955aa3ed237 100644
--- a/chrome/browser/predictors/resource_prefetch_predictor.h
+++ b/chrome/browser/predictors/resource_prefetch_predictor.h
@@ -95,7 +95,7 @@ class ResourcePrefetcherManager;
//
// 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
@@ -104,7 +104,7 @@ class ResourcePrefetcherManager;
// 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.
@@ -219,12 +219,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(
@@ -237,7 +231,7 @@ class ResourcePrefetchPredictor
const std::string& mime_type,
content::ResourceType fallback);
- // 'ResourcePrefetchPredictorObserver' calls the below functions to inform the
+ // '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);
@@ -285,6 +279,7 @@ class ResourcePrefetchPredictor
friend class LoadingPredictor;
friend class ::PredictorsHandler;
+ friend class LoadingDataCollectorTest;
Benoit L 2017/06/02 12:43:59 Is this needed?
trevordixon 2017/06/06 13:08:04 No longer.
friend class ResourcePrefetchPredictorTest;
friend class ResourcePrefetchPredictorBrowserTest;
@@ -312,7 +307,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);
@@ -342,22 +336,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