Chromium Code Reviews| 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 edd31665ca0c79fdba83182c09523da9678bdd82..1521a681bb0aa48ee835f04c6be4b9897a47d429 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 { |
|
Benoit L
2016/09/19 13:53:48
Navigation and requests are vague, overloaded word
alexilin
2016/09/19 16:49:25
This is actually an opposite thing :) This is a ve
|
| + explicit Navigation(const GURL& initial_url); |
| + ~Navigation(); |
| + |
| + GURL initial_url; |
| + std::vector<URLRequestSummary> requests; |
|
Benoit L
2016/09/19 13:53:48
Is there some invariant here, such as:
- requests
alexilin
2016/09/19 16:49:25
Related with misunderstanding in the comment above
|
| + }; |
| + |
| ResourcePrefetchPredictor(const ResourcePrefetchPredictorConfig& config, |
| Profile* profile); |
| ~ResourcePrefetchPredictor() override; |
| @@ -153,6 +162,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, |
| @@ -181,11 +192,14 @@ class ResourcePrefetchPredictor |
| }; |
| typedef ResourcePrefetchPredictorTables::ResourceRow ResourceRow; |
| - typedef ResourcePrefetchPredictorTables::ResourceRows ResourceRows; |
| typedef ResourcePrefetchPredictorTables::PrefetchData PrefetchData; |
| typedef ResourcePrefetchPredictorTables::PrefetchDataMap PrefetchDataMap; |
| - typedef std::map<NavigationID, linked_ptr<std::vector<URLRequestSummary> > > |
| - NavigationMap; |
| + |
| + typedef ResourcePrefetchPredictorTables::RedirectRow RedirectRow; |
| + typedef ResourcePrefetchPredictorTables::RedirectData RedirectData; |
| + typedef ResourcePrefetchPredictorTables::RedirectDataMap RedirectDataMap; |
| + |
| + typedef std::map<NavigationID, std::unique_ptr<Navigation>> NavigationMap; |
| typedef std::map<NavigationID, std::unique_ptr<Result>> ResultsMap; |
| // Returns true if the main page request is supported for prediction. |
| @@ -240,9 +254,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. |
| @@ -263,13 +279,16 @@ 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. |
| void LearnNavigation(const std::string& key, |
| @@ -278,6 +297,14 @@ class ResourcePrefetchPredictor |
| size_t max_data_map_size, |
| PrefetchDataMap* data_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; |
| @@ -332,13 +359,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_; |
| ResultsMap results_map_; |
| ScopedObserver<history::HistoryService, history::HistoryServiceObserver> |