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_CONFIG_H_ |
| 6 #define CHROME_BROWSER_PREDICTORS_LOADING_PREDICTOR_CONFIG_H_ |
| 7 |
| 8 #include <cstddef> |
| 9 |
| 10 class Profile; |
| 11 |
| 12 namespace predictors { |
| 13 |
| 14 struct LoadingPredictorConfig; |
| 15 |
| 16 // Returns whether the predictor is enabled, and populates |config|, if not |
| 17 // nullptr. |
| 18 bool IsLoadingPredictortEnabled(Profile* profile, |
| 19 LoadingPredictorConfig* config); |
| 20 |
| 21 // Indicates what caused the page load hint. |
| 22 enum class HintOrigin { NAVIGATION, EXTERNAL }; |
| 23 |
| 24 // Represents the config for the Loading predictor. |
| 25 struct LoadingPredictorConfig { |
| 26 // Initializes the config with default values. |
| 27 LoadingPredictorConfig(); |
| 28 LoadingPredictorConfig(const LoadingPredictorConfig& other); |
| 29 ~LoadingPredictorConfig(); |
| 30 |
| 31 // The mode the prefetcher is running in. Forms a bit map. |
| 32 enum Mode { |
| 33 LEARNING = 1 << 0, |
| 34 PREFETCHING_FOR_NAVIGATION = 1 << 2, // Should also turn on LEARNING. |
| 35 PREFETCHING_FOR_EXTERNAL = 1 << 3 // Should also turn on LEARNING. |
| 36 }; |
| 37 int mode; |
| 38 |
| 39 // Helpers to deal with mode. |
| 40 bool IsLearningEnabled() const; |
| 41 bool IsPrefetchingEnabledForSomeOrigin(Profile* profile) const; |
| 42 bool IsPrefetchingEnabledForOrigin(Profile* profile, HintOrigin origin) const; |
| 43 |
| 44 bool IsLowConfidenceForTest() const; |
| 45 bool IsHighConfidenceForTest() const; |
| 46 bool IsMoreResourcesEnabledForTest() const; |
| 47 bool IsSmallDBEnabledForTest() const; |
| 48 |
| 49 // If a navigation hasn't seen a load complete event in this much time, it |
| 50 // is considered abandoned. |
| 51 size_t max_navigation_lifetime_seconds; |
| 52 |
| 53 // Size of LRU caches for the URL and host data. |
| 54 size_t max_urls_to_track; |
| 55 size_t max_hosts_to_track; |
| 56 |
| 57 // The number of times we should have seen a visit to this URL in history |
| 58 // to start tracking it. This is to ensure we don't bother with oneoff |
| 59 // entries. For hosts we track each one. |
| 60 size_t min_url_visit_count; |
| 61 |
| 62 // The maximum number of resources to store per entry. |
| 63 size_t max_resources_per_entry; |
| 64 // The maximum number of origins to store per entry. |
| 65 size_t max_origins_per_entry; |
| 66 // The number of consecutive misses after which we stop tracking a resource |
| 67 // URL. |
| 68 size_t max_consecutive_misses; |
| 69 // The number of consecutive misses after which we stop tracking a redirect |
| 70 // endpoint. |
| 71 size_t max_redirect_consecutive_misses; |
| 72 |
| 73 // The minimum confidence (accuracy of hits) required for a resource to be |
| 74 // prefetched. |
| 75 float min_resource_confidence_to_trigger_prefetch; |
| 76 // The minimum number of times we must have a URL on record to prefetch it. |
| 77 size_t min_resource_hits_to_trigger_prefetch; |
| 78 |
| 79 // Maximum number of prefetches that can be inflight for a single navigation. |
| 80 size_t max_prefetches_inflight_per_navigation; |
| 81 // Maximum number of prefetches that can be inflight for a host for a single |
| 82 // navigation. |
| 83 size_t max_prefetches_inflight_per_host_per_navigation; |
| 84 // True iff the predictor could use a url-based database. |
| 85 bool is_url_learning_enabled; |
| 86 // True iff the predictor could use manifests. |
| 87 bool is_manifests_enabled; |
| 88 // True iff origin-based learning is enabled. |
| 89 bool is_origin_learning_enabled; |
| 90 }; |
| 91 |
| 92 } // namespace predictors |
| 93 |
| 94 #endif // CHROME_BROWSER_PREDICTORS_LOADING_PREDICTOR_CONFIG_H_ |
OLD | NEW |