Chromium Code Reviews| 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 kEnableUrlLearningParamName[]; | |
| 28 | 28 |
| 29 struct ResourcePrefetchPredictorConfig; | 29 struct ResourcePrefetchPredictorConfig; |
| 30 | 30 |
| 31 // Returns true if prefetching is enabled. And will initilize the |config| | 31 // Returns true if prefetching is enabled. And will initilize the |config| |
| 32 // fields to the appropritate values. | 32 // fields to the appropritate values. |
| 33 bool IsSpeculativeResourcePrefetchingEnabled( | 33 bool IsSpeculativeResourcePrefetchingEnabled( |
| 34 Profile* profile, | 34 Profile* profile, |
| 35 ResourcePrefetchPredictorConfig* config); | 35 ResourcePrefetchPredictorConfig* config); |
| 36 | 36 |
| 37 // Represents the type of key based on which prefetch data is stored. | 37 // Represents the type of key based on which prefetch data is stored. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 // Represents the config for the resource prefetch prediction algorithm. | 70 // Represents the config for the resource prefetch prediction algorithm. |
| 71 struct ResourcePrefetchPredictorConfig { | 71 struct ResourcePrefetchPredictorConfig { |
| 72 // Initializes the config with default values. | 72 // Initializes the config with default values. |
| 73 ResourcePrefetchPredictorConfig(); | 73 ResourcePrefetchPredictorConfig(); |
| 74 ResourcePrefetchPredictorConfig(const ResourcePrefetchPredictorConfig& other); | 74 ResourcePrefetchPredictorConfig(const ResourcePrefetchPredictorConfig& other); |
| 75 ~ResourcePrefetchPredictorConfig(); | 75 ~ResourcePrefetchPredictorConfig(); |
| 76 | 76 |
| 77 // The mode the prefetcher is running in. Forms a bit map. | 77 // The mode the prefetcher is running in. Forms a bit map. |
| 78 enum Mode { | 78 enum Mode { |
| 79 LEARNING = 1 << 0, | 79 LEARNING = 1 << 0, |
| 80 PREFETCHING_FOR_NAVIGATION = 1 << 2, // Also enables LEARNING. | 80 PREFETCHING_FOR_NAVIGATION = 1 << 2, |
|
Benoit L
2017/03/01 17:07:01
nit: Why dropping the comment?
alexilin
2017/03/01 17:18:51
This comment is confusing in my opinion. It should
| |
| 81 PREFETCHING_FOR_EXTERNAL = 1 << 3 // Also enables LEARNING. | 81 PREFETCHING_FOR_EXTERNAL = 1 << 3 |
| 82 }; | 82 }; |
| 83 int mode; | 83 int mode; |
| 84 | 84 |
| 85 // Helpers to deal with mode. | 85 // Helpers to deal with mode. |
| 86 bool IsLearningEnabled() const; | 86 bool IsLearningEnabled() const; |
| 87 bool IsPrefetchingEnabledForSomeOrigin(Profile* profile) const; | 87 bool IsPrefetchingEnabledForSomeOrigin(Profile* profile) const; |
| 88 bool IsPrefetchingEnabledForOrigin(Profile* profile, | 88 bool IsPrefetchingEnabledForOrigin(Profile* profile, |
| 89 PrefetchOrigin origin) const; | 89 PrefetchOrigin origin) const; |
| 90 | 90 |
| 91 bool IsLowConfidenceForTest() const; | 91 bool IsLowConfidenceForTest() const; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 115 // prefetched. | 115 // prefetched. |
| 116 float min_resource_confidence_to_trigger_prefetch; | 116 float min_resource_confidence_to_trigger_prefetch; |
| 117 // The minimum number of times we must have a URL on record to prefetch it. | 117 // The minimum number of times we must have a URL on record to prefetch it. |
| 118 size_t min_resource_hits_to_trigger_prefetch; | 118 size_t min_resource_hits_to_trigger_prefetch; |
| 119 | 119 |
| 120 // Maximum number of prefetches that can be inflight for a single navigation. | 120 // Maximum number of prefetches that can be inflight for a single navigation. |
| 121 size_t max_prefetches_inflight_per_navigation; | 121 size_t max_prefetches_inflight_per_navigation; |
| 122 // Maximum number of prefetches that can be inflight for a host for a single | 122 // Maximum number of prefetches that can be inflight for a host for a single |
| 123 // navigation. | 123 // navigation. |
| 124 size_t max_prefetches_inflight_per_host_per_navigation; | 124 size_t max_prefetches_inflight_per_host_per_navigation; |
| 125 // True iff the predictor could use a url-based database. | |
| 126 bool is_url_learning_enabled; | |
| 125 }; | 127 }; |
| 126 | 128 |
| 127 } // namespace predictors | 129 } // namespace predictors |
| 128 | 130 |
| 129 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_COMMON_H_ | 131 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_COMMON_H_ |
| OLD | NEW |