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_COMMON_H_ | 5 #ifndef CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_COMMON_H_ |
6 #define CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_COMMON_H_ | 6 #define CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_COMMON_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/feature_list.h" | |
11 #include "base/time/time.h" | 10 #include "base/time/time.h" |
12 #include "components/sessions/core/session_id.h" | 11 #include "components/sessions/core/session_id.h" |
13 #include "url/gurl.h" | 12 #include "url/gurl.h" |
14 | 13 |
15 class Profile; | 14 class Profile; |
16 | 15 |
17 namespace content { | 16 namespace content { |
18 class WebContents; | 17 class WebContents; |
19 } | 18 } |
20 | 19 |
21 namespace predictors { | 20 namespace predictors { |
22 | 21 |
23 extern const char kSpeculativeResourcePrefetchingFeatureName[]; | 22 extern const char kSpeculativeResourcePrefetchingFeatureName[]; |
24 extern const char kModeParamName[]; | 23 extern const char kModeParamName[]; |
25 extern const char kLearningMode[]; | 24 extern const char kLearningMode[]; |
26 extern const char kExternalPrefetchingMode[]; | 25 extern const char kExternalPrefetchingMode[]; |
27 extern const char kPrefetchingMode[]; | 26 extern const char kPrefetchingMode[]; |
| 27 extern const char kKeyTypeParamName[]; |
| 28 extern const char kUrlKeyType[]; |
| 29 extern const char kHostKeyType[]; |
| 30 extern const char kBothKeyType[]; |
28 | 31 |
29 struct ResourcePrefetchPredictorConfig; | 32 struct ResourcePrefetchPredictorConfig; |
30 | 33 |
31 // Returns true if prefetching is enabled. And will initilize the |config| | 34 // Returns true if prefetching is enabled. And will initilize the |config| |
32 // fields to the appropritate values. | 35 // fields to the appropritate values. |
33 bool IsSpeculativeResourcePrefetchingEnabled( | 36 bool IsSpeculativeResourcePrefetchingEnabled( |
34 Profile* profile, | 37 Profile* profile, |
35 ResourcePrefetchPredictorConfig* config); | 38 ResourcePrefetchPredictorConfig* config); |
36 | 39 |
37 // Represents the type of key based on which prefetch data is stored. | 40 // Represents the type of key based on which prefetch data is stored. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 72 |
70 // Represents the config for the resource prefetch prediction algorithm. | 73 // Represents the config for the resource prefetch prediction algorithm. |
71 struct ResourcePrefetchPredictorConfig { | 74 struct ResourcePrefetchPredictorConfig { |
72 // Initializes the config with default values. | 75 // Initializes the config with default values. |
73 ResourcePrefetchPredictorConfig(); | 76 ResourcePrefetchPredictorConfig(); |
74 ResourcePrefetchPredictorConfig(const ResourcePrefetchPredictorConfig& other); | 77 ResourcePrefetchPredictorConfig(const ResourcePrefetchPredictorConfig& other); |
75 ~ResourcePrefetchPredictorConfig(); | 78 ~ResourcePrefetchPredictorConfig(); |
76 | 79 |
77 // The mode the prefetcher is running in. Forms a bit map. | 80 // The mode the prefetcher is running in. Forms a bit map. |
78 enum Mode { | 81 enum Mode { |
79 LEARNING = 1 << 0, | 82 URL_LEARNING = 1 << 0, |
80 PREFETCHING_FOR_NAVIGATION = 1 << 2, // Also enables LEARNING. | 83 HOST_LEARNING = 1 << 1, |
81 PREFETCHING_FOR_EXTERNAL = 1 << 3 // Also enables LEARNING. | 84 PREFETCHING_FOR_NAVIGATION = 1 << 2, |
| 85 PREFETCHING_FOR_EXTERNAL = 1 << 3 |
82 }; | 86 }; |
83 int mode; | 87 int mode; |
84 | 88 |
85 // Helpers to deal with mode. | 89 // Helpers to deal with mode. |
86 bool IsLearningEnabled() const; | 90 bool IsLearningEnabled() const; |
| 91 bool IsURLLearningEnabled() const; |
| 92 bool IsHostLearningEnabled() const; |
87 bool IsPrefetchingEnabledForSomeOrigin(Profile* profile) const; | 93 bool IsPrefetchingEnabledForSomeOrigin(Profile* profile) const; |
88 bool IsPrefetchingEnabledForOrigin(Profile* profile, | 94 bool IsPrefetchingEnabledForOrigin(Profile* profile, |
89 PrefetchOrigin origin) const; | 95 PrefetchOrigin origin) const; |
90 | 96 |
91 bool IsLowConfidenceForTest() const; | 97 bool IsLowConfidenceForTest() const; |
92 bool IsHighConfidenceForTest() const; | 98 bool IsHighConfidenceForTest() const; |
93 bool IsMoreResourcesEnabledForTest() const; | 99 bool IsMoreResourcesEnabledForTest() const; |
94 bool IsSmallDBEnabledForTest() const; | 100 bool IsSmallDBEnabledForTest() const; |
95 | 101 |
96 // If a navigation hasn't seen a load complete event in this much time, it | 102 // If a navigation hasn't seen a load complete event in this much time, it |
(...skipping 23 matching lines...) Expand all Loading... |
120 // Maximum number of prefetches that can be inflight for a single navigation. | 126 // Maximum number of prefetches that can be inflight for a single navigation. |
121 size_t max_prefetches_inflight_per_navigation; | 127 size_t max_prefetches_inflight_per_navigation; |
122 // Maximum number of prefetches that can be inflight for a host for a single | 128 // Maximum number of prefetches that can be inflight for a host for a single |
123 // navigation. | 129 // navigation. |
124 size_t max_prefetches_inflight_per_host_per_navigation; | 130 size_t max_prefetches_inflight_per_host_per_navigation; |
125 }; | 131 }; |
126 | 132 |
127 } // namespace predictors | 133 } // namespace predictors |
128 | 134 |
129 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_COMMON_H_ | 135 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_COMMON_H_ |
OLD | NEW |