| 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 void OnMainFrameRequest(const URLRequestSummary& request); | 233 void OnMainFrameRequest(const URLRequestSummary& request); |
| 234 void OnMainFrameResponse(const URLRequestSummary& response); | 234 void OnMainFrameResponse(const URLRequestSummary& response); |
| 235 void OnMainFrameRedirect(const URLRequestSummary& response); | 235 void OnMainFrameRedirect(const URLRequestSummary& response); |
| 236 void OnSubresourceResponse(const URLRequestSummary& response); | 236 void OnSubresourceResponse(const URLRequestSummary& response); |
| 237 | 237 |
| 238 // Called when onload completes for a navigation. We treat this point as the | 238 // Called when onload completes for a navigation. We treat this point as the |
| 239 // "completion" of the navigation. The resources requested by the page up to | 239 // "completion" of the navigation. The resources requested by the page up to |
| 240 // this point are the only ones considered for prefetching. | 240 // this point are the only ones considered for prefetching. |
| 241 void OnNavigationComplete(const NavigationID& nav_id_without_timing_info); | 241 void OnNavigationComplete(const NavigationID& nav_id_without_timing_info); |
| 242 | 242 |
| 243 // Returns true if there is PrefetchData that can be used for the | 243 // Returns true if there is PrefetchData that can be used for a URL and fills |
| 244 // navigation and fills in the |prefetch_data| to resources that need to be | 244 // |urls| with resources that need to be prefetched. |
| 245 // prefetched. | 245 bool GetPrefetchData(const GURL& main_frame_url, std::vector<GURL>* urls); |
| 246 bool GetPrefetchData(const NavigationID& navigation_id, | |
| 247 std::vector<GURL>* urls, | |
| 248 PrefetchKeyType* key_type); | |
| 249 | 246 |
| 250 // Converts a PrefetchData into a list of URLs. | 247 // Converts a PrefetchData into a list of URLs. |
| 251 void PopulatePrefetcherRequest(const PrefetchData& data, | 248 void PopulatePrefetcherRequest(const PrefetchData& data, |
| 252 std::vector<GURL>* urls); | 249 std::vector<GURL>* urls); |
| 253 | 250 |
| 251 public: |
| 254 // Starts prefetching if it is enabled and prefetching data exists for the | 252 // Starts prefetching if it is enabled and prefetching data exists for the |
| 255 // NavigationID either at the URL or at the host level. | 253 // NavigationID either at the URL or at the host level. |
| 256 void StartPrefetching(const NavigationID& navigation_id); | 254 void StartPrefetching(const GURL& main_frame_url); |
| 257 | 255 |
| 258 // Stops prefetching that may be in progress corresponding to |navigation_id|. | 256 // Stops prefetching that may be in progress corresponding to |navigation_id|. |
| 259 void StopPrefetching(const NavigationID& navigation_id); | 257 void StopPrefetching(const GURL& main_frame_url); |
| 260 | 258 |
| 259 private: |
| 261 // Starts initialization by posting a task to the DB thread to read the | 260 // Starts initialization by posting a task to the DB thread to read the |
| 262 // predictor database. | 261 // predictor database. |
| 263 void StartInitialization(); | 262 void StartInitialization(); |
| 264 | 263 |
| 265 // Callback for task to read predictor database. Takes ownership of | 264 // Callback for task to read predictor database. Takes ownership of |
| 266 // all arguments. | 265 // all arguments. |
| 267 void CreateCaches(std::unique_ptr<PrefetchDataMap> url_data_map, | 266 void CreateCaches(std::unique_ptr<PrefetchDataMap> url_data_map, |
| 268 std::unique_ptr<PrefetchDataMap> host_data_map, | 267 std::unique_ptr<PrefetchDataMap> host_data_map, |
| 269 std::unique_ptr<RedirectDataMap> url_redirect_data_map, | 268 std::unique_ptr<RedirectDataMap> url_redirect_data_map, |
| 270 std::unique_ptr<RedirectDataMap> host_redirect_data_map); | 269 std::unique_ptr<RedirectDataMap> host_redirect_data_map); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 | 360 |
| 362 ScopedObserver<history::HistoryService, history::HistoryServiceObserver> | 361 ScopedObserver<history::HistoryService, history::HistoryServiceObserver> |
| 363 history_service_observer_; | 362 history_service_observer_; |
| 364 | 363 |
| 365 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictor); | 364 DISALLOW_COPY_AND_ASSIGN(ResourcePrefetchPredictor); |
| 366 }; | 365 }; |
| 367 | 366 |
| 368 } // namespace predictors | 367 } // namespace predictors |
| 369 | 368 |
| 370 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ | 369 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ |
| OLD | NEW |