OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_PREDICTORS_LOADING_PREDICTOR_H_ |
| 6 #define CHROME_BROWSER_PREDICTORS_LOADING_PREDICTOR_H_ |
| 7 |
| 8 #include <memory> |
| 9 |
| 10 #include "base/memory/weak_ptr.h" |
| 11 #include "chrome/browser/predictors/resource_prefetch_common.h" |
| 12 #include "chrome/browser/predictors/resource_prefetch_predictor.h" |
| 13 #include "components/keyed_service/core/keyed_service.h" |
| 14 |
| 15 class Profile; |
| 16 |
| 17 namespace predictors { |
| 18 |
| 19 class ResourcePrefetchPredictor; |
| 20 |
| 21 // Entry point for the Loading predictor. |
| 22 // From a high-level request (GURL and motivation) and a database of historical |
| 23 // data, initiates predictive actions to speed up page loads. |
| 24 // |
| 25 // See ResourcePrefetchPredictor for a description of the resource prefetch |
| 26 // predictor. |
| 27 // |
| 28 // All methods must be called from the UI thread. |
| 29 class LoadingPredictor : public KeyedService, |
| 30 public base::SupportsWeakPtr<LoadingPredictor> { |
| 31 public: |
| 32 LoadingPredictor(const LoadingPredictorConfig& config, Profile* profile); |
| 33 ~LoadingPredictor() override; |
| 34 |
| 35 // Hints that a page load is expected for |url|, with the hint coming from a |
| 36 // given |origin|. May trigger actions, such as prefetch and/or preconnect. |
| 37 void PrepareForPageLoad(const GURL& url, HintOrigin origin); |
| 38 |
| 39 // Indicates that a page load hint is no longer active. |
| 40 void CancelPageLoadHint(const GURL& url); |
| 41 |
| 42 // Don't use, internal only. |
| 43 ResourcePrefetchPredictor* resource_prefetch_predictor() const; |
| 44 |
| 45 // KeyedService: |
| 46 void Shutdown() override; |
| 47 |
| 48 private: |
| 49 std::unique_ptr<ResourcePrefetchPredictor> resource_prefetch_predictor_; |
| 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(LoadingPredictor); |
| 52 }; |
| 53 |
| 54 } // namespace predictors |
| 55 |
| 56 #endif // CHROME_BROWSER_PREDICTORS_LOADING_PREDICTOR_H_ |
OLD | NEW |