| 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 | 213 |
| 214 // Called when ResourcePrefetcher is finished, i.e. there is nothing pending | 214 // Called when ResourcePrefetcher is finished, i.e. there is nothing pending |
| 215 // in flight. | 215 // in flight. |
| 216 void OnPrefetchingFinished( | 216 void OnPrefetchingFinished( |
| 217 const GURL& main_frame_url, | 217 const GURL& main_frame_url, |
| 218 std::unique_ptr<ResourcePrefetcher::PrefetcherStats> stats); | 218 std::unique_ptr<ResourcePrefetcher::PrefetcherStats> stats); |
| 219 | 219 |
| 220 // Returns true if prefetching data exists for the |main_frame_url|. | 220 // Returns true if prefetching data exists for the |main_frame_url|. |
| 221 virtual bool IsUrlPrefetchable(const GURL& main_frame_url); | 221 virtual bool IsUrlPrefetchable(const GURL& main_frame_url); |
| 222 | 222 |
| 223 // Returns true iff |resource| has sufficient confidence level and required |
| 224 // number of hits. |
| 225 bool IsResourcePrefetchable(const ResourceData& resource) const; |
| 226 |
| 223 // Sets the |observer| to be notified when the resource prefetch predictor | 227 // Sets the |observer| to be notified when the resource prefetch predictor |
| 224 // data changes. Previously registered observer will be discarded. Call | 228 // data changes. Previously registered observer will be discarded. Call |
| 225 // this with nullptr parameter to de-register observer. | 229 // this with nullptr parameter to de-register observer. |
| 226 void SetObserverForTesting(TestObserver* observer); | 230 void SetObserverForTesting(TestObserver* observer); |
| 227 | 231 |
| 228 private: | 232 private: |
| 229 friend class ::PredictorsHandler; | 233 friend class ::PredictorsHandler; |
| 230 friend class ResourcePrefetchPredictorTest; | 234 friend class ResourcePrefetchPredictorTest; |
| 231 friend class ResourcePrefetchPredictorBrowserTest; | 235 friend class ResourcePrefetchPredictorBrowserTest; |
| 232 | 236 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 RedirectDataMap* redirect_map); | 367 RedirectDataMap* redirect_map); |
| 364 | 368 |
| 365 // Updates information about final redirect destination for |key| in | 369 // Updates information about final redirect destination for |key| in |
| 366 // |redirect_map| and correspondingly updates the predictor database. | 370 // |redirect_map| and correspondingly updates the predictor database. |
| 367 void LearnRedirect(const std::string& key, | 371 void LearnRedirect(const std::string& key, |
| 368 PrefetchKeyType key_type, | 372 PrefetchKeyType key_type, |
| 369 const std::string& final_redirect, | 373 const std::string& final_redirect, |
| 370 size_t max_redirect_map_size, | 374 size_t max_redirect_map_size, |
| 371 RedirectDataMap* redirect_map); | 375 RedirectDataMap* redirect_map); |
| 372 | 376 |
| 373 // Returns true iff |resource| has sufficient confidence level and required | |
| 374 // number of hits. | |
| 375 bool IsResourcePrefetchable(const ResourceData& resource) const; | |
| 376 | |
| 377 // Reports database readiness metric defined as percentage of navigated hosts | 377 // Reports database readiness metric defined as percentage of navigated hosts |
| 378 // found in DB for last X entries in history. | 378 // found in DB for last X entries in history. |
| 379 void ReportDatabaseReadiness(const history::TopHostsList& top_hosts) const; | 379 void ReportDatabaseReadiness(const history::TopHostsList& top_hosts) const; |
| 380 | 380 |
| 381 // history::HistoryServiceObserver: | 381 // history::HistoryServiceObserver: |
| 382 void OnURLsDeleted(history::HistoryService* history_service, | 382 void OnURLsDeleted(history::HistoryService* history_service, |
| 383 bool all_history, | 383 bool all_history, |
| 384 bool expired, | 384 bool expired, |
| 385 const history::URLRows& deleted_rows, | 385 const history::URLRows& deleted_rows, |
| 386 const std::set<GURL>& favicon_urls) override; | 386 const std::set<GURL>& favicon_urls) override; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 | 448 |
| 449 private: | 449 private: |
| 450 ResourcePrefetchPredictor* predictor_; | 450 ResourcePrefetchPredictor* predictor_; |
| 451 | 451 |
| 452 DISALLOW_COPY_AND_ASSIGN(TestObserver); | 452 DISALLOW_COPY_AND_ASSIGN(TestObserver); |
| 453 }; | 453 }; |
| 454 | 454 |
| 455 } // namespace predictors | 455 } // namespace predictors |
| 456 | 456 |
| 457 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ | 457 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ |
| OLD | NEW |