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