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

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

Issue 2397943004: predictors: Use redirect data in prefetch. (Closed)
Patch Set: Non-empty check. Created 4 years, 2 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
« no previous file with comments | « no previous file | chrome/browser/predictors/resource_prefetch_predictor.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, 148 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest,
149 NavigationUrlNotInDBAndDBFull); 149 NavigationUrlNotInDBAndDBFull);
150 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, RedirectUrlNotInDB); 150 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, RedirectUrlNotInDB);
151 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, RedirectUrlInDB); 151 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, RedirectUrlInDB);
152 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, OnMainFrameRequest); 152 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, OnMainFrameRequest);
153 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, OnMainFrameRedirect); 153 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, OnMainFrameRedirect);
154 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, 154 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest,
155 OnSubresourceResponse); 155 OnSubresourceResponse);
156 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, GetCorrectPLT); 156 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, GetCorrectPLT);
157 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, HandledResourceTypes); 157 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, HandledResourceTypes);
158 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest,
159 PopulatePrefetcherRequest);
160 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, GetRedirectEndpoint);
161 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, GetPrefetchData);
158 162
159 enum InitializationState { 163 enum InitializationState {
160 NOT_INITIALIZED = 0, 164 NOT_INITIALIZED = 0,
161 INITIALIZING = 1, 165 INITIALIZING = 1,
162 INITIALIZED = 2 166 INITIALIZED = 2
163 }; 167 };
164 168
165 // Stores information about inflight navigations. 169 // Stores information about inflight navigations.
166 struct PageRequestSummary { 170 struct PageRequestSummary {
167 explicit PageRequestSummary(const GURL& initial_url); 171 explicit PageRequestSummary(const GURL& initial_url);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 static bool IsHandledSubresource(net::URLRequest* request, 221 static bool IsHandledSubresource(net::URLRequest* request,
218 content::ResourceType resource_type); 222 content::ResourceType resource_type);
219 223
220 // Returns true if the subresource has a supported type. 224 // Returns true if the subresource has a supported type.
221 static bool IsHandledResourceType(content::ResourceType resource_type, 225 static bool IsHandledResourceType(content::ResourceType resource_type,
222 const std::string& mime_type); 226 const std::string& mime_type);
223 227
224 // Returns true if the request (should have a response in it) is "no-store". 228 // Returns true if the request (should have a response in it) is "no-store".
225 static bool IsNoStore(const net::URLRequest* request); 229 static bool IsNoStore(const net::URLRequest* request);
226 230
231 // Returns true iff |redirect_data_map| contains confident redirect endpoint
232 // for |entry_point| and assigns it to the |redirect_endpoint|.
233 static bool GetRedirectEndpoint(const std::string& entry_point,
234 const RedirectDataMap& redirect_data_map,
235 std::string* redirect_endpoint);
236
227 // KeyedService methods override. 237 // KeyedService methods override.
228 void Shutdown() override; 238 void Shutdown() override;
229 239
230 // Functions called on different network events pertaining to the loading of 240 // Functions called on different network events pertaining to the loading of
231 // main frame resource or sub resources. 241 // main frame resource or sub resources.
232 void OnMainFrameRequest(const URLRequestSummary& request); 242 void OnMainFrameRequest(const URLRequestSummary& request);
233 void OnMainFrameResponse(const URLRequestSummary& response); 243 void OnMainFrameResponse(const URLRequestSummary& response);
234 void OnMainFrameRedirect(const URLRequestSummary& response); 244 void OnMainFrameRedirect(const URLRequestSummary& response);
235 void OnSubresourceResponse(const URLRequestSummary& response); 245 void OnSubresourceResponse(const URLRequestSummary& response);
236 246
237 // Called when onload completes for a navigation. We treat this point as the 247 // Called when onload completes for a navigation. We treat this point as the
238 // "completion" of the navigation. The resources requested by the page up to 248 // "completion" of the navigation. The resources requested by the page up to
239 // this point are the only ones considered for prefetching. 249 // this point are the only ones considered for prefetching.
240 void OnNavigationComplete(const NavigationID& nav_id_without_timing_info); 250 void OnNavigationComplete(const NavigationID& nav_id_without_timing_info);
241 251
242 // Returns true if there is PrefetchData that can be used for a URL and fills 252 // Returns true iff there is PrefetchData that can be used for a
243 // |urls| with resources that need to be prefetched. 253 // |main_frame_url| and fills |urls| with resources that need to be
254 // prefetched.
244 bool GetPrefetchData(const GURL& main_frame_url, std::vector<GURL>* urls); 255 bool GetPrefetchData(const GURL& main_frame_url, std::vector<GURL>* urls);
245 256
246 // Converts a PrefetchData into a list of URLs. 257 // Returns true iff the |data_map| contains PrefetchData that can be used
247 void PopulatePrefetcherRequest(const PrefetchData& data, 258 // for a |main_frame_key| and fills |urls| with resources that need to be
259 // prefetched.
260 bool PopulatePrefetcherRequest(const std::string& main_frame_key,
261 const PrefetchDataMap& data_map,
248 std::vector<GURL>* urls); 262 std::vector<GURL>* urls);
249 263
250 public: 264 public:
251 // Starts prefetching if it is enabled and prefetching data exists for the 265 // Starts prefetching if it is enabled and prefetching data exists for the
252 // NavigationID either at the URL or at the host level. 266 // NavigationID either at the URL or at the host level.
253 void StartPrefetching(const GURL& main_frame_url); 267 void StartPrefetching(const GURL& main_frame_url);
254 268
255 // Stops prefetching that may be in progress corresponding to |navigation_id|. 269 // Stops prefetching that may be in progress corresponding to |navigation_id|.
256 void StopPrefetching(const GURL& main_frame_url); 270 void StopPrefetching(const GURL& main_frame_url);
257 271
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 373
360 ScopedObserver<history::HistoryService, history::HistoryServiceObserver> 374 ScopedObserver<history::HistoryService, history::HistoryServiceObserver>
361 history_service_observer_; 375 history_service_observer_;
362 376
363 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictor); 377 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictor);
364 }; 378 };
365 379
366 } // namespace predictors 380 } // namespace predictors
367 381
368 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ 382 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/predictors/resource_prefetch_predictor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698