| 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 c3177cdd124ce71d53eed9a3b69d503e9accb56e..6e566b2a042847dcbf98d3ecd3985cd0a24fef88 100644
|
| --- a/chrome/browser/predictors/resource_prefetch_predictor.h
|
| +++ b/chrome/browser/predictors/resource_prefetch_predictor.h
|
| @@ -99,6 +99,15 @@ class ResourcePrefetchPredictor
|
| URLRequestSummary* summary);
|
| };
|
|
|
| + // Stores information about inflight navigations.
|
| + struct Navigation {
|
| + explicit Navigation(const GURL& initial_url);
|
| + ~Navigation();
|
| +
|
| + GURL initial_url;
|
| + std::vector<URLRequestSummary> subresource_requests;
|
| + };
|
| +
|
| ResourcePrefetchPredictor(const ResourcePrefetchPredictorConfig& config,
|
| Profile* profile);
|
| ~ResourcePrefetchPredictor() override;
|
| @@ -146,6 +155,8 @@ class ResourcePrefetchPredictor
|
| FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, NavigationUrlNotInDB);
|
| FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest,
|
| NavigationUrlNotInDBAndDBFull);
|
| + FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, RedirectUrlNotInDB);
|
| + FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, RedirectUrlInDB);
|
| FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, OnMainFrameRequest);
|
| FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, OnMainFrameRedirect);
|
| FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest,
|
| @@ -161,8 +172,9 @@ class ResourcePrefetchPredictor
|
|
|
| typedef ResourcePrefetchPredictorTables::PrefetchData PrefetchData;
|
| typedef ResourcePrefetchPredictorTables::PrefetchDataMap PrefetchDataMap;
|
| - typedef std::map<NavigationID, linked_ptr<std::vector<URLRequestSummary> > >
|
| - NavigationMap;
|
| + typedef ResourcePrefetchPredictorTables::RedirectDataMap RedirectDataMap;
|
| +
|
| + typedef std::map<NavigationID, std::unique_ptr<Navigation>> NavigationMap;
|
|
|
| // Returns true if the main page request is supported for prediction.
|
| static bool IsHandledMainPage(net::URLRequest* request);
|
| @@ -216,9 +228,11 @@ class ResourcePrefetchPredictor
|
| void StartInitialization();
|
|
|
| // Callback for task to read predictor database. Takes ownership of
|
| - // |url_data_map| and |host_data_map|.
|
| + // all arguments.
|
| void CreateCaches(std::unique_ptr<PrefetchDataMap> url_data_map,
|
| - std::unique_ptr<PrefetchDataMap> host_data_map);
|
| + std::unique_ptr<PrefetchDataMap> host_data_map,
|
| + std::unique_ptr<RedirectDataMap> url_redirect_data_map,
|
| + std::unique_ptr<RedirectDataMap> host_redirect_data_map);
|
|
|
| // Called during initialization when history is read and the predictor
|
| // database has been read.
|
| @@ -239,20 +253,33 @@ class ResourcePrefetchPredictor
|
| // Callback for GetUrlVisitCountTask.
|
| void OnVisitCountLookup(size_t visit_count,
|
| const NavigationID& navigation_id,
|
| - const std::vector<URLRequestSummary>& requests);
|
| + const Navigation& navigation);
|
|
|
| // Removes the oldest entry in the input |data_map|, also deleting it from the
|
| // predictor database.
|
| void RemoveOldestEntryInPrefetchDataMap(PrefetchKeyType key_type,
|
| PrefetchDataMap* data_map);
|
|
|
| + void RemoveOldestEntryInRedirectDataMap(PrefetchKeyType key_type,
|
| + RedirectDataMap* data_map);
|
| +
|
| // Merges resources in |new_resources| into the |data_map| and correspondingly
|
| - // updates the predictor database.
|
| + // updates the predictor database. Also calls LearnRedirect if relevant.
|
| void LearnNavigation(const std::string& key,
|
| PrefetchKeyType key_type,
|
| const std::vector<URLRequestSummary>& new_resources,
|
| size_t max_data_map_size,
|
| - PrefetchDataMap* data_map);
|
| + PrefetchDataMap* data_map,
|
| + const std::string& redirect_origin_key,
|
| + RedirectDataMap* redirect_map);
|
| +
|
| + // Updates information about final redirect destination for |key| in
|
| + // |redirect_map| and correspondingly updates the predictor database
|
| + void LearnRedirect(const std::string& key,
|
| + PrefetchKeyType key_type,
|
| + const std::string& final_redirect,
|
| + size_t max_redirect_map_size,
|
| + RedirectDataMap* redirect_map);
|
|
|
| // Reports overall page load time.
|
| void ReportPageLoadTimeStats(base::TimeDelta plt) const;
|
| @@ -289,12 +316,13 @@ class ResourcePrefetchPredictor
|
| scoped_refptr<ResourcePrefetcherManager> prefetch_manager_;
|
| base::CancelableTaskTracker history_lookup_consumer_;
|
|
|
| - // Map of all the navigations in flight to their resource requests.
|
| - NavigationMap inflight_navigations_;
|
| -
|
| // Copy of the data in the predictor tables.
|
| std::unique_ptr<PrefetchDataMap> url_table_cache_;
|
| std::unique_ptr<PrefetchDataMap> host_table_cache_;
|
| + std::unique_ptr<RedirectDataMap> url_redirect_table_cache_;
|
| + std::unique_ptr<RedirectDataMap> host_redirect_table_cache_;
|
| +
|
| + NavigationMap inflight_navigations_;
|
|
|
| ScopedObserver<history::HistoryService, history::HistoryServiceObserver>
|
| history_service_observer_;
|
|
|