Chromium Code Reviews| 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 static bool IsHandledSubresource(net::URLRequest* request, | 217 static bool IsHandledSubresource(net::URLRequest* request, |
| 218 content::ResourceType resource_type); | 218 content::ResourceType resource_type); |
| 219 | 219 |
| 220 // Returns true if the subresource has a supported type. | 220 // Returns true if the subresource has a supported type. |
| 221 static bool IsHandledResourceType(content::ResourceType resource_type, | 221 static bool IsHandledResourceType(content::ResourceType resource_type, |
| 222 const std::string& mime_type); | 222 const std::string& mime_type); |
| 223 | 223 |
| 224 // Returns true if the request (should have a response in it) is "no-store". | 224 // Returns true if the request (should have a response in it) is "no-store". |
| 225 static bool IsNoStore(const net::URLRequest* request); | 225 static bool IsNoStore(const net::URLRequest* request); |
| 226 | 226 |
| 227 // Returns true if |redirect_data_map| contains confident redirect endpoint | |
|
pasko
2016/10/07 13:44:27
nit: iff
alexilin
2016/10/07 14:29:05
Done.
| |
| 228 // for |first_redirect| and assign it to the |final_redirect|. | |
|
pasko
2016/10/07 13:44:27
nit: s/assign/assigns/
pasko
2016/10/07 13:44:27
nit: first_redirect is not a good name, because a
alexilin
2016/10/07 14:29:05
Done.
| |
| 229 static bool GetFinalRedirect(const std::string& first_redirect, | |
| 230 RedirectDataMap* redirect_data_map, | |
|
pasko
2016/10/07 13:44:27
if the object (RedirectDataMap) is not modified by
alexilin
2016/10/07 14:29:06
Ok, thanks! I know this rule but I was confused by
| |
| 231 std::string* final_redirect); | |
|
pasko
2016/10/07 13:44:27
nit: |redirect_endpoint| sounds more intuitive
(f
alexilin
2016/10/07 14:29:05
Done.
| |
| 232 | |
| 227 // KeyedService methods override. | 233 // KeyedService methods override. |
| 228 void Shutdown() override; | 234 void Shutdown() override; |
| 229 | 235 |
| 230 // Functions called on different network events pertaining to the loading of | 236 // Functions called on different network events pertaining to the loading of |
| 231 // main frame resource or sub resources. | 237 // main frame resource or sub resources. |
| 232 void OnMainFrameRequest(const URLRequestSummary& request); | 238 void OnMainFrameRequest(const URLRequestSummary& request); |
| 233 void OnMainFrameResponse(const URLRequestSummary& response); | 239 void OnMainFrameResponse(const URLRequestSummary& response); |
| 234 void OnMainFrameRedirect(const URLRequestSummary& response); | 240 void OnMainFrameRedirect(const URLRequestSummary& response); |
| 235 void OnSubresourceResponse(const URLRequestSummary& response); | 241 void OnSubresourceResponse(const URLRequestSummary& response); |
| 236 | 242 |
| 237 // Called when onload completes for a navigation. We treat this point as the | 243 // 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 | 244 // "completion" of the navigation. The resources requested by the page up to |
| 239 // this point are the only ones considered for prefetching. | 245 // this point are the only ones considered for prefetching. |
| 240 void OnNavigationComplete(const NavigationID& nav_id_without_timing_info); | 246 void OnNavigationComplete(const NavigationID& nav_id_without_timing_info); |
| 241 | 247 |
| 242 // Returns true if there is PrefetchData that can be used for a URL and fills | 248 // Returns true iff there is PrefetchData that can be used for a |
| 243 // |urls| with resources that need to be prefetched. | 249 // |main_frame_url| and fills |urls| with resources that need to be |
| 250 // prefetched. | |
| 244 bool GetPrefetchData(const GURL& main_frame_url, std::vector<GURL>* urls); | 251 bool GetPrefetchData(const GURL& main_frame_url, std::vector<GURL>* urls); |
| 245 | 252 |
| 246 // Converts a PrefetchData into a list of URLs. | 253 // Returns true iff the |data_map| contains PrefetchData that can be used |
| 247 void PopulatePrefetcherRequest(const PrefetchData& data, | 254 // for a |main_frame_key| and fills |urls| with resources that need to be |
| 255 // prefetched. | |
| 256 bool PopulatePrefetcherRequest(const std::string& main_frame_key, | |
| 257 PrefetchDataMap* data_map, | |
|
pasko
2016/10/07 13:44:27
const reference here too
alexilin
2016/10/07 14:29:05
Done.
| |
| 248 std::vector<GURL>* urls); | 258 std::vector<GURL>* urls); |
| 249 | 259 |
| 250 public: | 260 public: |
| 251 // Starts prefetching if it is enabled and prefetching data exists for the | 261 // Starts prefetching if it is enabled and prefetching data exists for the |
| 252 // NavigationID either at the URL or at the host level. | 262 // NavigationID either at the URL or at the host level. |
| 253 void StartPrefetching(const GURL& main_frame_url); | 263 void StartPrefetching(const GURL& main_frame_url); |
| 254 | 264 |
| 255 // Stops prefetching that may be in progress corresponding to |navigation_id|. | 265 // Stops prefetching that may be in progress corresponding to |navigation_id|. |
| 256 void StopPrefetching(const GURL& main_frame_url); | 266 void StopPrefetching(const GURL& main_frame_url); |
| 257 | 267 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 359 | 369 |
| 360 ScopedObserver<history::HistoryService, history::HistoryServiceObserver> | 370 ScopedObserver<history::HistoryService, history::HistoryServiceObserver> |
| 361 history_service_observer_; | 371 history_service_observer_; |
| 362 | 372 |
| 363 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictor); | 373 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictor); |
| 364 }; | 374 }; |
| 365 | 375 |
| 366 } // namespace predictors | 376 } // namespace predictors |
| 367 | 377 |
| 368 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ | 378 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ |
| OLD | NEW |