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

Side by Side Diff: chrome/browser/predictors/resource_prefetch_predictor.h

Issue 2755093002: predictors: Mark before_first_contentful_paint for resources fetched before fcp. (Closed)
Patch Set: Use TimeTicks::Now() for request response time in SummarizeResponse. Created 3 years, 8 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 unified diff | Download patch
OLDNEW
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // Stores the data that we need to get from the URLRequest. 107 // Stores the data that we need to get from the URLRequest.
108 struct URLRequestSummary { 108 struct URLRequestSummary {
109 URLRequestSummary(); 109 URLRequestSummary();
110 URLRequestSummary(const URLRequestSummary& other); 110 URLRequestSummary(const URLRequestSummary& other);
111 ~URLRequestSummary(); 111 ~URLRequestSummary();
112 112
113 NavigationID navigation_id; 113 NavigationID navigation_id;
114 GURL resource_url; 114 GURL resource_url;
115 content::ResourceType resource_type; 115 content::ResourceType resource_type;
116 net::RequestPriority priority; 116 net::RequestPriority priority;
117 base::TimeTicks response_time;
118 bool before_first_contentful_paint;
117 119
118 // Only for responses. 120 // Only for responses.
119 std::string mime_type; 121 std::string mime_type;
120 bool was_cached; 122 bool was_cached;
121 GURL redirect_url; // Empty unless request was redirected to a valid url. 123 GURL redirect_url; // Empty unless request was redirected to a valid url.
122 124
123 bool has_validators; 125 bool has_validators;
124 bool always_revalidate; 126 bool always_revalidate;
125 127
126 // Initializes a |URLRequestSummary| from a |URLRequest| response. 128 // Initializes a |URLRequestSummary| from a |URLRequest| response.
127 // Returns true for success. Note: NavigationID is NOT initialized 129 // Returns true for success. Note: NavigationID is NOT initialized
128 // by this function. 130 // by this function.
129 static bool SummarizeResponse(const net::URLRequest& request, 131 static bool SummarizeResponse(const net::URLRequest& request,
130 URLRequestSummary* summary); 132 URLRequestSummary* summary);
131 }; 133 };
132 134
133 // Stores the data learned from a single navigation. 135 // Stores the data learned from a single navigation.
134 struct PageRequestSummary { 136 struct PageRequestSummary {
135 explicit PageRequestSummary(const GURL& main_frame_url); 137 explicit PageRequestSummary(const GURL& main_frame_url);
136 PageRequestSummary(const PageRequestSummary& other); 138 PageRequestSummary(const PageRequestSummary& other);
137 ~PageRequestSummary(); 139 ~PageRequestSummary();
138 140
139 GURL main_frame_url; 141 GURL main_frame_url;
140 GURL initial_url; 142 GURL initial_url;
143 base::TimeTicks first_contentful_paint;
141 144
142 // Stores all subresource requests within a single navigation, from initial 145 // Stores all subresource requests within a single navigation, from initial
143 // main frame request to navigation completion. 146 // main frame request to navigation completion.
144 std::vector<URLRequestSummary> subresource_requests; 147 std::vector<URLRequestSummary> subresource_requests;
145 }; 148 };
146 149
147 // Stores a result of prediction. Essentially, |subresource_urls| is main 150 // Stores a result of prediction. Essentially, |subresource_urls| is main
148 // result and other fields are used for diagnosis and histograms reporting. 151 // result and other fields are used for diagnosis and histograms reporting.
149 struct Prediction { 152 struct Prediction {
150 Prediction(); 153 Prediction();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 // 'ResourcePrefetchPredictorObserver' calls the below functions to inform the 201 // 'ResourcePrefetchPredictorObserver' calls the below functions to inform the
199 // predictor of main frame and resource requests. Should only be called if the 202 // predictor of main frame and resource requests. Should only be called if the
200 // corresponding Should* functions return true. 203 // corresponding Should* functions return true.
201 void RecordURLRequest(const URLRequestSummary& request); 204 void RecordURLRequest(const URLRequestSummary& request);
202 void RecordURLResponse(const URLRequestSummary& response); 205 void RecordURLResponse(const URLRequestSummary& response);
203 void RecordURLRedirect(const URLRequestSummary& response); 206 void RecordURLRedirect(const URLRequestSummary& response);
204 207
205 // Called when the main frame of a page completes loading. 208 // Called when the main frame of a page completes loading.
206 void RecordMainFrameLoadComplete(const NavigationID& navigation_id); 209 void RecordMainFrameLoadComplete(const NavigationID& navigation_id);
207 210
211 // Called after the main frame's first contentful paint.
212 void RecordFirstContentfulPaint(
213 const NavigationID& navigation_id,
214 const base::TimeTicks& first_contentful_paint);
215
208 // Starts prefetching if it is enabled for |origin| and prefetching data 216 // Starts prefetching if it is enabled for |origin| and prefetching data
209 // exists for the |main_frame_url| either at the URL or at the host level. 217 // exists for the |main_frame_url| either at the URL or at the host level.
210 void StartPrefetching(const GURL& main_frame_url, PrefetchOrigin origin); 218 void StartPrefetching(const GURL& main_frame_url, PrefetchOrigin origin);
211 219
212 // Stops prefetching that may be in progress corresponding to 220 // Stops prefetching that may be in progress corresponding to
213 // |main_frame_url|. 221 // |main_frame_url|.
214 void StopPrefetching(const GURL& main_frame_url); 222 void StopPrefetching(const GURL& main_frame_url);
215 223
216 // Called when ResourcePrefetcher is finished, i.e. there is nothing pending 224 // Called when ResourcePrefetcher is finished, i.e. there is nothing pending
217 // in flight. 225 // in flight.
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 473
466 private: 474 private:
467 ResourcePrefetchPredictor* predictor_; 475 ResourcePrefetchPredictor* predictor_;
468 476
469 DISALLOW_COPY_AND_ASSIGN(TestObserver); 477 DISALLOW_COPY_AND_ASSIGN(TestObserver);
470 }; 478 };
471 479
472 } // namespace predictors 480 } // namespace predictors
473 481
474 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ 482 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698