| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 void StopPrefetching(const GURL& main_frame_url); | 156 void StopPrefetching(const GURL& main_frame_url); |
| 157 | 157 |
| 158 // Sets the |observer| to be notified when the resource prefetch predictor | 158 // Sets the |observer| to be notified when the resource prefetch predictor |
| 159 // data changes. Previously registered observer will be discarded. Call | 159 // data changes. Previously registered observer will be discarded. Call |
| 160 // this with nullptr parameter to de-register observer. | 160 // this with nullptr parameter to de-register observer. |
| 161 void SetObserverForTesting(TestObserver* observer); | 161 void SetObserverForTesting(TestObserver* observer); |
| 162 | 162 |
| 163 private: | 163 private: |
| 164 friend class ::PredictorsHandler; | 164 friend class ::PredictorsHandler; |
| 165 friend class ResourcePrefetchPredictorTest; | 165 friend class ResourcePrefetchPredictorTest; |
| 166 friend class ResourcePrefetchPredictorBrowserTest; |
| 166 | 167 |
| 167 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, DeleteUrls); | 168 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, DeleteUrls); |
| 168 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, | 169 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, |
| 169 LazilyInitializeEmpty); | 170 LazilyInitializeEmpty); |
| 170 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, | 171 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, |
| 171 LazilyInitializeWithData); | 172 LazilyInitializeWithData); |
| 172 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, | 173 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, |
| 173 NavigationNotRecorded); | 174 NavigationNotRecorded); |
| 174 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, NavigationUrlInDB); | 175 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, NavigationUrlInDB); |
| 175 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, NavigationUrlNotInDB); | 176 FRIEND_TEST_ALL_PREFIXES(ResourcePrefetchPredictorTest, NavigationUrlNotInDB); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 // has changed. All methods are invoked on the UI thread. | 359 // has changed. All methods are invoked on the UI thread. |
| 359 class TestObserver { | 360 class TestObserver { |
| 360 public: | 361 public: |
| 361 // De-registers itself from |predictor_| on destruction. | 362 // De-registers itself from |predictor_| on destruction. |
| 362 virtual ~TestObserver(); | 363 virtual ~TestObserver(); |
| 363 | 364 |
| 364 virtual void OnNavigationLearned( | 365 virtual void OnNavigationLearned( |
| 365 size_t url_visit_count, | 366 size_t url_visit_count, |
| 366 const ResourcePrefetchPredictor::PageRequestSummary& summary) {} | 367 const ResourcePrefetchPredictor::PageRequestSummary& summary) {} |
| 367 | 368 |
| 369 virtual void OnPredictorInitialized() {} |
| 370 |
| 368 protected: | 371 protected: |
| 369 // |predictor| must be non-NULL and has to outlive the TestObserver. | 372 // |predictor| must be non-NULL and has to outlive the TestObserver. |
| 370 // Also the predictor must not have a TestObserver set. | 373 // Also the predictor must not have a TestObserver set. |
| 371 explicit TestObserver(ResourcePrefetchPredictor* predictor); | 374 explicit TestObserver(ResourcePrefetchPredictor* predictor); |
| 372 | 375 |
| 373 private: | 376 private: |
| 374 ResourcePrefetchPredictor* predictor_; | 377 ResourcePrefetchPredictor* predictor_; |
| 375 | 378 |
| 376 DISALLOW_COPY_AND_ASSIGN(TestObserver); | 379 DISALLOW_COPY_AND_ASSIGN(TestObserver); |
| 377 }; | 380 }; |
| 378 | 381 |
| 379 } // namespace predictors | 382 } // namespace predictors |
| 380 | 383 |
| 381 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ | 384 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ |
| OLD | NEW |