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 cec2207d48f5d4d8e62642162e41a75cbbbdb7e7..e2bc592928d42e90ddc3d9c55a1ca77ed0324ecf 100644 |
| --- a/chrome/browser/predictors/resource_prefetch_predictor.h |
| +++ b/chrome/browser/predictors/resource_prefetch_predictor.h |
| @@ -104,6 +104,17 @@ class ResourcePrefetchPredictor |
| public base::SupportsWeakPtr<ResourcePrefetchPredictor>, |
| public precache::PrecacheManager::Delegate { |
| public: |
| + struct OriginRequestSummary { |
|
alexilin
2017/04/10 14:58:28
Do we really need this struct?
Can't we derive the
Benoit L
2017/04/11 09:04:05
You're right, this is not strictly necessary.
This
alexilin
2017/04/11 09:42:19
Sgtm. Anyway, we would have to reconstruct this ma
|
| + OriginRequestSummary(); |
| + OriginRequestSummary(const OriginRequestSummary& other); |
| + ~OriginRequestSummary(); |
| + |
| + GURL origin; |
| + bool always_access_network; |
| + bool accessed_network; |
| + int first_occurrence; |
| + }; |
| + |
| // Stores the data that we need to get from the URLRequest. |
| struct URLRequestSummary { |
| URLRequestSummary(); |
| @@ -122,6 +133,8 @@ class ResourcePrefetchPredictor |
| bool has_validators; |
| bool always_revalidate; |
| + bool is_no_store; |
| + bool network_accessed; |
| // Initializes a |URLRequestSummary| from a |URLRequest| response. |
| // Returns true for success. Note: NavigationID is NOT initialized |
| @@ -142,6 +155,9 @@ class ResourcePrefetchPredictor |
| // Stores all subresource requests within a single navigation, from initial |
| // main frame request to navigation completion. |
| std::vector<URLRequestSummary> subresource_requests; |
| + // Map of origin -> OriginRequestSummary. Only one instance of each origin |
| + // is kept per navigation, but the summary is updated several times. |
| + std::map<GURL, OriginRequestSummary> origins; |
| }; |
| // Stores a result of prediction. Essentially, |subresource_urls| is main |
| @@ -280,6 +296,7 @@ class ResourcePrefetchPredictor |
| typedef ResourcePrefetchPredictorTables::PrefetchDataMap PrefetchDataMap; |
| typedef ResourcePrefetchPredictorTables::RedirectDataMap RedirectDataMap; |
| typedef ResourcePrefetchPredictorTables::ManifestDataMap ManifestDataMap; |
| + typedef ResourcePrefetchPredictorTables::OriginDataMap OriginDataMap; |
| typedef std::map<NavigationID, std::unique_ptr<PageRequestSummary>> |
| NavigationMap; |
| @@ -296,7 +313,7 @@ class ResourcePrefetchPredictor |
| 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 bool IsNoStore(const net::URLRequest& request); |
| // Returns true iff |redirect_data_map| contains confident redirect endpoint |
| // for |entry_point| and assigns it to the |redirect_endpoint|. |
| @@ -315,6 +332,7 @@ class ResourcePrefetchPredictor |
| void OnMainFrameResponse(const URLRequestSummary& response); |
| void OnMainFrameRedirect(const URLRequestSummary& response); |
| void OnSubresourceResponse(const URLRequestSummary& response); |
| + void OnSubresourceRedirect(const URLRequestSummary& response); |
| // Called when onload completes for a navigation. We treat this point as the |
| // "completion" of the navigation. The resources requested by the page up to |
| @@ -341,7 +359,8 @@ class ResourcePrefetchPredictor |
| std::unique_ptr<PrefetchDataMap> host_data_map, |
| std::unique_ptr<RedirectDataMap> url_redirect_data_map, |
| std::unique_ptr<RedirectDataMap> host_redirect_data_map, |
| - std::unique_ptr<ManifestDataMap> manifest_data_map); |
| + std::unique_ptr<ManifestDataMap> manifest_data_map, |
| + std::unique_ptr<OriginDataMap> origin_data_map); |
| // Called during initialization when history is read and the predictor |
| // database has been read. |
| @@ -371,6 +390,7 @@ class ResourcePrefetchPredictor |
| RedirectDataMap* data_map); |
| void RemoveOldestEntryInManifestDataMap(ManifestDataMap* data_map); |
| + void RemoveOldestEntryInOriginDataMap(OriginDataMap* data_map); |
| // Merges resources in |new_resources| into the |data_map| and correspondingly |
| // updates the predictor database. Also calls LearnRedirect if relevant. |
| @@ -390,6 +410,11 @@ class ResourcePrefetchPredictor |
| size_t max_redirect_map_size, |
| RedirectDataMap* redirect_map); |
| + void LearnOrigins(const std::string& host, |
| + const std::map<GURL, OriginRequestSummary>& summaries, |
| + size_t max_data_map_size, |
| + OriginDataMap* data_map); |
| + |
| // Reports database readiness metric defined as percentage of navigated hosts |
| // found in DB for last X entries in history. |
| void ReportDatabaseReadiness(const history::TopHostsList& top_hosts) const; |
| @@ -426,6 +451,7 @@ class ResourcePrefetchPredictor |
| std::unique_ptr<RedirectDataMap> url_redirect_table_cache_; |
| std::unique_ptr<RedirectDataMap> host_redirect_table_cache_; |
| std::unique_ptr<ManifestDataMap> manifest_table_cache_; |
| + std::unique_ptr<OriginDataMap> origin_table_cache_; |
| std::map<GURL, base::TimeTicks> inflight_prefetches_; |
| NavigationMap inflight_navigations_; |