Index: chrome/browser/predictors/resource_prefetch_common.cc |
diff --git a/chrome/browser/predictors/resource_prefetch_common.cc b/chrome/browser/predictors/resource_prefetch_common.cc |
index 27ea7933c98834c5ddcc57903fc9775dce60cd82..ccd3139e4d30b17fe8b225ec9201a3960270747e 100644 |
--- a/chrome/browser/predictors/resource_prefetch_common.cc |
+++ b/chrome/browser/predictors/resource_prefetch_common.cc |
@@ -7,14 +7,12 @@ |
#include <string> |
#include <tuple> |
-#include "base/command_line.h" |
-#include "base/metrics/field_trial.h" |
+#include "base/feature_list.h" |
+#include "base/metrics/field_trial_params.h" |
#include "chrome/browser/net/prediction_options.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/sessions/session_tab_helper.h" |
-#include "chrome/common/chrome_switches.h" |
#include "components/prefs/pref_service.h" |
-#include "components/variations/variations_associated_data.h" |
#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/web_contents.h" |
@@ -26,6 +24,10 @@ const char kModeParamName[] = "mode"; |
const char kLearningMode[] = "learning"; |
const char kExternalPrefetchingMode[] = "external-prefetching"; |
const char kPrefetchingMode[] = "prefetching"; |
+const char kKeyTypeParamName[] = "key-type"; |
+const char kUrlKeyType[] = "url"; |
+const char kHostKeyType[] = "host"; |
+const char kBothKeyType[] = "both"; |
namespace { |
@@ -61,18 +63,29 @@ bool IsSpeculativeResourcePrefetchingEnabled( |
if (!base::FeatureList::IsEnabled(kSpeculativeResourcePrefetchingFeature)) |
return false; |
- std::string mode_value = variations::GetVariationParamValueByFeature( |
+ std::string key_type_value = base::GetFieldTrialParamValueByFeature( |
Benoit L
2017/03/01 16:04:41
Do we really want URL-only?
If not, can we simpli
alexilin
2017/03/01 16:55:56
Done.
|
+ kSpeculativeResourcePrefetchingFeature, kKeyTypeParamName); |
+ if (key_type_value == kUrlKeyType) { |
+ config->mode |= ResourcePrefetchPredictorConfig::URL_LEARNING; |
+ } else if (key_type_value == kHostKeyType) { |
+ config->mode |= ResourcePrefetchPredictorConfig::HOST_LEARNING; |
+ } else if (key_type_value == kBothKeyType) { |
+ config->mode |= ResourcePrefetchPredictorConfig::URL_LEARNING | |
+ ResourcePrefetchPredictorConfig::HOST_LEARNING; |
+ } else { |
+ // Only host learning by default. |
+ config->mode |= ResourcePrefetchPredictorConfig::HOST_LEARNING; |
+ } |
+ |
+ std::string mode_value = base::GetFieldTrialParamValueByFeature( |
kSpeculativeResourcePrefetchingFeature, kModeParamName); |
if (mode_value == kLearningMode) { |
- config->mode |= ResourcePrefetchPredictorConfig::LEARNING; |
return true; |
} else if (mode_value == kExternalPrefetchingMode) { |
- config->mode |= ResourcePrefetchPredictorConfig::LEARNING | |
- ResourcePrefetchPredictorConfig::PREFETCHING_FOR_EXTERNAL; |
+ config->mode |= ResourcePrefetchPredictorConfig::PREFETCHING_FOR_EXTERNAL; |
return true; |
} else if (mode_value == kPrefetchingMode) { |
- config->mode |= ResourcePrefetchPredictorConfig::LEARNING | |
- ResourcePrefetchPredictorConfig::PREFETCHING_FOR_EXTERNAL | |
+ config->mode |= ResourcePrefetchPredictorConfig::PREFETCHING_FOR_EXTERNAL | |
ResourcePrefetchPredictorConfig::PREFETCHING_FOR_NAVIGATION; |
return true; |
} |
@@ -135,7 +148,15 @@ ResourcePrefetchPredictorConfig::~ResourcePrefetchPredictorConfig() { |
} |
bool ResourcePrefetchPredictorConfig::IsLearningEnabled() const { |
- return (mode & LEARNING) > 0; |
+ return IsURLLearningEnabled() || IsHostLearningEnabled(); |
+} |
+ |
+bool ResourcePrefetchPredictorConfig::IsURLLearningEnabled() const { |
+ return (mode & URL_LEARNING) > 0; |
+} |
+ |
+bool ResourcePrefetchPredictorConfig::IsHostLearningEnabled() const { |
+ return (mode & HOST_LEARNING) > 0; |
} |
bool ResourcePrefetchPredictorConfig::IsPrefetchingEnabledForSomeOrigin( |