OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ | 5 #ifndef CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ |
6 #define CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ | 6 #define CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 // Stores the data that we need to get from the URLRequest. | 105 // Stores the data that we need to get from the URLRequest. |
106 struct URLRequestSummary { | 106 struct URLRequestSummary { |
107 URLRequestSummary(); | 107 URLRequestSummary(); |
108 URLRequestSummary(const URLRequestSummary& other); | 108 URLRequestSummary(const URLRequestSummary& other); |
109 ~URLRequestSummary(); | 109 ~URLRequestSummary(); |
110 | 110 |
111 NavigationID navigation_id; | 111 NavigationID navigation_id; |
112 GURL resource_url; | 112 GURL resource_url; |
113 content::ResourceType resource_type; | 113 content::ResourceType resource_type; |
114 net::RequestPriority priority; | 114 net::RequestPriority priority; |
115 bool before_first_contentful_paint; | |
alexilin
2017/03/17 14:46:46
You need to initialize this field in URLRequestSum
trevordixon
2017/03/27 12:30:08
Done.
| |
115 | 116 |
116 // Only for responses. | 117 // Only for responses. |
117 std::string mime_type; | 118 std::string mime_type; |
118 bool was_cached; | 119 bool was_cached; |
119 GURL redirect_url; // Empty unless request was redirected to a valid url. | 120 GURL redirect_url; // Empty unless request was redirected to a valid url. |
120 | 121 |
121 bool has_validators; | 122 bool has_validators; |
122 bool always_revalidate; | 123 bool always_revalidate; |
123 | 124 |
124 // Initializes a |URLRequestSummary| from a |URLRequest| response. | 125 // Initializes a |URLRequestSummary| from a |URLRequest| response. |
125 // Returns true for success. Note: NavigationID is NOT initialized | 126 // Returns true for success. Note: NavigationID is NOT initialized |
126 // by this function. | 127 // by this function. |
127 static bool SummarizeResponse(const net::URLRequest& request, | 128 static bool SummarizeResponse(const net::URLRequest& request, |
128 URLRequestSummary* summary); | 129 URLRequestSummary* summary); |
129 }; | 130 }; |
130 | 131 |
131 // Stores the data learned from a single navigation. | 132 // Stores the data learned from a single navigation. |
132 struct PageRequestSummary { | 133 struct PageRequestSummary { |
133 explicit PageRequestSummary(const GURL& main_frame_url); | 134 explicit PageRequestSummary(const GURL& main_frame_url); |
134 PageRequestSummary(const PageRequestSummary& other); | 135 PageRequestSummary(const PageRequestSummary& other); |
135 ~PageRequestSummary(); | 136 ~PageRequestSummary(); |
136 | 137 |
137 GURL main_frame_url; | 138 GURL main_frame_url; |
138 GURL initial_url; | 139 GURL initial_url; |
140 base::TimeDelta first_contentful_paint_time; | |
alexilin
2017/03/17 14:46:46
Unused field.
trevordixon
2017/03/27 12:30:08
Oops.
| |
139 | 141 |
140 // Stores all subresource requests within a single navigation, from initial | 142 // Stores all subresource requests within a single navigation, from initial |
141 // main frame request to navigation completion. | 143 // main frame request to navigation completion. |
142 std::vector<URLRequestSummary> subresource_requests; | 144 std::vector<URLRequestSummary> subresource_requests; |
143 }; | 145 }; |
144 | 146 |
145 // Stores a result of prediction. Essentially, |subresource_urls| is main | 147 // Stores a result of prediction. Essentially, |subresource_urls| is main |
146 // result and other fields are used for diagnosis and histograms reporting. | 148 // result and other fields are used for diagnosis and histograms reporting. |
147 struct Prediction { | 149 struct Prediction { |
148 Prediction(); | 150 Prediction(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 // 'ResourcePrefetchPredictorObserver' calls the below functions to inform the | 198 // 'ResourcePrefetchPredictorObserver' calls the below functions to inform the |
197 // predictor of main frame and resource requests. Should only be called if the | 199 // predictor of main frame and resource requests. Should only be called if the |
198 // corresponding Should* functions return true. | 200 // corresponding Should* functions return true. |
199 void RecordURLRequest(const URLRequestSummary& request); | 201 void RecordURLRequest(const URLRequestSummary& request); |
200 void RecordURLResponse(const URLRequestSummary& response); | 202 void RecordURLResponse(const URLRequestSummary& response); |
201 void RecordURLRedirect(const URLRequestSummary& response); | 203 void RecordURLRedirect(const URLRequestSummary& response); |
202 | 204 |
203 // Called when the main frame of a page completes loading. | 205 // Called when the main frame of a page completes loading. |
204 void RecordMainFrameLoadComplete(const NavigationID& navigation_id); | 206 void RecordMainFrameLoadComplete(const NavigationID& navigation_id); |
205 | 207 |
208 void RecordFirstContentfulPaint(const NavigationID navigation_id); | |
alexilin
2017/03/17 14:46:46
Please, add a comment to this function.
trevordixon
2017/03/27 12:30:08
Done.
| |
209 | |
206 // Starts prefetching if it is enabled for |origin| and prefetching data | 210 // Starts prefetching if it is enabled for |origin| and prefetching data |
207 // exists for the |main_frame_url| either at the URL or at the host level. | 211 // exists for the |main_frame_url| either at the URL or at the host level. |
208 void StartPrefetching(const GURL& main_frame_url, PrefetchOrigin origin); | 212 void StartPrefetching(const GURL& main_frame_url, PrefetchOrigin origin); |
209 | 213 |
210 // Stops prefetching that may be in progress corresponding to | 214 // Stops prefetching that may be in progress corresponding to |
211 // |main_frame_url|. | 215 // |main_frame_url|. |
212 void StopPrefetching(const GURL& main_frame_url); | 216 void StopPrefetching(const GURL& main_frame_url); |
213 | 217 |
214 // Called when ResourcePrefetcher is finished, i.e. there is nothing pending | 218 // Called when ResourcePrefetcher is finished, i.e. there is nothing pending |
215 // in flight. | 219 // in flight. |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
451 | 455 |
452 private: | 456 private: |
453 ResourcePrefetchPredictor* predictor_; | 457 ResourcePrefetchPredictor* predictor_; |
454 | 458 |
455 DISALLOW_COPY_AND_ASSIGN(TestObserver); | 459 DISALLOW_COPY_AND_ASSIGN(TestObserver); |
456 }; | 460 }; |
457 | 461 |
458 } // namespace predictors | 462 } // namespace predictors |
459 | 463 |
460 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ | 464 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ |
OLD | NEW |