| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 void RecordMainFrameLoadComplete(const NavigationID& navigation_id); | 153 void RecordMainFrameLoadComplete(const NavigationID& navigation_id); |
| 154 | 154 |
| 155 // Starts prefetching if it is enabled for |origin| and prefetching data | 155 // Starts prefetching if it is enabled for |origin| and prefetching data |
| 156 // exists for the |main_frame_url| either at the URL or at the host level. | 156 // exists for the |main_frame_url| either at the URL or at the host level. |
| 157 void StartPrefetching(const GURL& main_frame_url, PrefetchOrigin origin); | 157 void StartPrefetching(const GURL& main_frame_url, PrefetchOrigin origin); |
| 158 | 158 |
| 159 // Stops prefetching that may be in progress corresponding to | 159 // Stops prefetching that may be in progress corresponding to |
| 160 // |main_frame_url|. | 160 // |main_frame_url|. |
| 161 void StopPrefetching(const GURL& main_frame_url); | 161 void StopPrefetching(const GURL& main_frame_url); |
| 162 | 162 |
| 163 // Called when ResourcePrefetcher is finished, i.e. there is nothing pending |
| 164 // in flight. |
| 165 void OnPrefetchingFinished(const GURL& main_frame_url); |
| 166 |
| 163 // Sets the |observer| to be notified when the resource prefetch predictor | 167 // Sets the |observer| to be notified when the resource prefetch predictor |
| 164 // data changes. Previously registered observer will be discarded. Call | 168 // data changes. Previously registered observer will be discarded. Call |
| 165 // this with nullptr parameter to de-register observer. | 169 // this with nullptr parameter to de-register observer. |
| 166 void SetObserverForTesting(TestObserver* observer); | 170 void SetObserverForTesting(TestObserver* observer); |
| 167 | 171 |
| 168 private: | 172 private: |
| 169 friend class ::PredictorsHandler; | 173 friend class ::PredictorsHandler; |
| 170 friend class ResourcePrefetchPredictorTest; | 174 friend class ResourcePrefetchPredictorTest; |
| 171 friend class ResourcePrefetchPredictorBrowserTest; | 175 friend class ResourcePrefetchPredictorBrowserTest; |
| 172 | 176 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 // has changed. All methods are invoked on the UI thread. | 364 // has changed. All methods are invoked on the UI thread. |
| 361 class TestObserver { | 365 class TestObserver { |
| 362 public: | 366 public: |
| 363 // De-registers itself from |predictor_| on destruction. | 367 // De-registers itself from |predictor_| on destruction. |
| 364 virtual ~TestObserver(); | 368 virtual ~TestObserver(); |
| 365 | 369 |
| 366 virtual void OnNavigationLearned( | 370 virtual void OnNavigationLearned( |
| 367 size_t url_visit_count, | 371 size_t url_visit_count, |
| 368 const ResourcePrefetchPredictor::PageRequestSummary& summary) {} | 372 const ResourcePrefetchPredictor::PageRequestSummary& summary) {} |
| 369 | 373 |
| 374 virtual void OnPrefetchingFinished(const GURL& main_frame_url) {} |
| 375 |
| 370 virtual void OnPredictorInitialized() {} | 376 virtual void OnPredictorInitialized() {} |
| 371 | 377 |
| 372 protected: | 378 protected: |
| 373 // |predictor| must be non-NULL and has to outlive the TestObserver. | 379 // |predictor| must be non-NULL and has to outlive the TestObserver. |
| 374 // Also the predictor must not have a TestObserver set. | 380 // Also the predictor must not have a TestObserver set. |
| 375 explicit TestObserver(ResourcePrefetchPredictor* predictor); | 381 explicit TestObserver(ResourcePrefetchPredictor* predictor); |
| 376 | 382 |
| 377 private: | 383 private: |
| 378 ResourcePrefetchPredictor* predictor_; | 384 ResourcePrefetchPredictor* predictor_; |
| 379 | 385 |
| 380 DISALLOW_COPY_AND_ASSIGN(TestObserver); | 386 DISALLOW_COPY_AND_ASSIGN(TestObserver); |
| 381 }; | 387 }; |
| 382 | 388 |
| 383 } // namespace predictors | 389 } // namespace predictors |
| 384 | 390 |
| 385 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ | 391 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ |
| OLD | NEW |