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/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 int render_process_id; | 52 int render_process_id; |
| 53 int render_frame_id; | 53 int render_frame_id; |
| 54 GURL main_frame_url; | 54 GURL main_frame_url; |
| 55 | 55 |
| 56 // NOTE: Even though we store the creation time here, it is not used during | 56 // NOTE: Even though we store the creation time here, it is not used during |
| 57 // comparison of two NavigationIDs because it cannot always be determined | 57 // comparison of two NavigationIDs because it cannot always be determined |
| 58 // correctly. | 58 // correctly. |
| 59 base::TimeTicks creation_time; | 59 base::TimeTicks creation_time; |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 // Represents the config for the resource prefetch prediction algorithm. It is | 62 // Represents the config for the resource prefetch prediction algorithm. |
| 63 // useful for running experiments. | |
| 64 struct ResourcePrefetchPredictorConfig { | 63 struct ResourcePrefetchPredictorConfig { |
| 65 // Initializes the config with default values. | 64 // Initializes the config with default values. |
| 66 ResourcePrefetchPredictorConfig(); | 65 ResourcePrefetchPredictorConfig(); |
| 67 ResourcePrefetchPredictorConfig(const ResourcePrefetchPredictorConfig& other); | 66 ResourcePrefetchPredictorConfig(const ResourcePrefetchPredictorConfig& other); |
| 68 ~ResourcePrefetchPredictorConfig(); | 67 ~ResourcePrefetchPredictorConfig(); |
| 69 | 68 |
| 69 // Indicates what caused the prefetch request. | |
| 70 enum Origin { ORIGIN_NAVIGATION = 0, ORIGIN_EXTERNAL = 1 }; | |
|
pasko
2016/11/29 14:44:44
Please move it out of ResourcePrefetchPredictorCon
Benoit L
2016/11/29 17:02:51
Done.
| |
| 71 | |
| 70 // The mode the prefetcher is running in. Forms a bit map. | 72 // The mode the prefetcher is running in. Forms a bit map. |
| 71 enum Mode { | 73 enum Mode { |
| 72 URL_LEARNING = 1 << 0, | 74 LEARNING = 1 << 0, |
| 73 HOST_LEARNING = 1 << 1, | 75 PREFETCHING_FOR_NAVIGATION = 1 << 2, // Also enables LEARNING. |
| 74 URL_PREFETCHING = 1 << 2, // Should also turn on URL_LEARNING. | 76 PREFETCHING_FOR_EXTERNAL = 1 << 3 // Also enables LEARNING. |
| 75 HOST_PREFETCHING = 1 << 3 // Should also turn on HOST_LEARNING. | |
| 76 }; | 77 }; |
| 77 int mode; | 78 int mode; |
| 78 | 79 |
| 79 // Helpers to deal with mode. | 80 // Helpers to deal with mode. |
| 80 bool IsLearningEnabled() const; | 81 bool IsLearningEnabled() const; |
| 81 bool IsPrefetchingEnabled(Profile* profile) const; | 82 bool IsAnyPrefetchingEnabled(Profile* profile) const; |
| 82 bool IsURLLearningEnabled() const; | 83 bool IsPrefetchingEnabled(Profile* profile, Origin origin) const; |
|
pasko
2016/11/29 14:44:44
how about:
IsPrefetchingEnabledForOrigin(profile,
Benoit L
2016/11/29 17:02:51
Done.
| |
| 83 bool IsHostLearningEnabled() const; | |
| 84 bool IsURLPrefetchingEnabled(Profile* profile) const; | |
| 85 bool IsHostPrefetchingEnabled(Profile* profile) const; | |
| 86 | 84 |
| 87 bool IsLowConfidenceForTest() const; | 85 bool IsLowConfidenceForTest() const; |
| 88 bool IsHighConfidenceForTest() const; | 86 bool IsHighConfidenceForTest() const; |
| 89 bool IsMoreResourcesEnabledForTest() const; | 87 bool IsMoreResourcesEnabledForTest() const; |
| 90 bool IsSmallDBEnabledForTest() const; | 88 bool IsSmallDBEnabledForTest() const; |
| 91 | 89 |
| 92 // If a navigation hasn't seen a load complete event in this much time, it | 90 // If a navigation hasn't seen a load complete event in this much time, it |
| 93 // is considered abandoned. | 91 // is considered abandoned. |
| 94 size_t max_navigation_lifetime_seconds; | 92 size_t max_navigation_lifetime_seconds; |
| 95 | 93 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 116 // Maximum number of prefetches that can be inflight for a single navigation. | 114 // Maximum number of prefetches that can be inflight for a single navigation. |
| 117 size_t max_prefetches_inflight_per_navigation; | 115 size_t max_prefetches_inflight_per_navigation; |
| 118 // Maximum number of prefetches that can be inflight for a host for a single | 116 // Maximum number of prefetches that can be inflight for a host for a single |
| 119 // navigation. | 117 // navigation. |
| 120 size_t max_prefetches_inflight_per_host_per_navigation; | 118 size_t max_prefetches_inflight_per_host_per_navigation; |
| 121 }; | 119 }; |
| 122 | 120 |
| 123 } // namespace predictors | 121 } // namespace predictors |
| 124 | 122 |
| 125 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_COMMON_H_ | 123 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_COMMON_H_ |
| OLD | NEW |