Commit e3f7c0ab authored by zhenw's avatar zhenw Committed by Commit bot

Use more flexible field trial control on resource prefetching for mobile web

The switches are integrated with the new predictive network actions unified preference.

BUG=405690, 406203

Review URL: https://codereview.chromium.org/633373005

Cr-Commit-Position: refs/heads/master@{#299316}
parent 31083014
...@@ -74,11 +74,16 @@ struct ResourcePrefetchPredictorConfig { ...@@ -74,11 +74,16 @@ struct ResourcePrefetchPredictorConfig {
// Helpers to deal with mode. // Helpers to deal with mode.
bool IsLearningEnabled() const; bool IsLearningEnabled() const;
bool IsPrefetchingEnabled() const; bool IsPrefetchingEnabled(Profile* profile) const;
bool IsURLLearningEnabled() const; bool IsURLLearningEnabled() const;
bool IsHostLearningEnabled() const; bool IsHostLearningEnabled() const;
bool IsURLPrefetchingEnabled() const; bool IsURLPrefetchingEnabled(Profile* profile) const;
bool IsHostPrefetchingEnabled() const; bool IsHostPrefetchingEnabled(Profile* profile) const;
bool IsLowConfidenceForTest() const;
bool IsHighConfidenceForTest() const;
bool IsMoreResourcesEnabledForTest() const;
bool IsSmallDBEnabledForTest() const;
// If a navigation hasn't seen a load complete event in this much time, it // If a navigation hasn't seen a load complete event in this much time, it
// is considered abandoned. // is considered abandoned.
......
This diff is collapsed.
...@@ -312,9 +312,9 @@ ResourcePrefetchPredictor::ResourcePrefetchPredictor( ...@@ -312,9 +312,9 @@ ResourcePrefetchPredictor::ResourcePrefetchPredictor(
// Some form of learning has to be enabled. // Some form of learning has to be enabled.
DCHECK(config_.IsLearningEnabled()); DCHECK(config_.IsLearningEnabled());
if (config_.IsURLPrefetchingEnabled()) if (config_.IsURLPrefetchingEnabled(profile_))
DCHECK(config_.IsURLLearningEnabled()); DCHECK(config_.IsURLLearningEnabled());
if (config_.IsHostPrefetchingEnabled()) if (config_.IsHostPrefetchingEnabled(profile_))
DCHECK(config_.IsHostLearningEnabled()); DCHECK(config_.IsHostLearningEnabled());
} }
...@@ -577,8 +577,9 @@ bool ResourcePrefetchPredictor::GetPrefetchData( ...@@ -577,8 +577,9 @@ bool ResourcePrefetchPredictor::GetPrefetchData(
*key_type = PREFETCH_KEY_TYPE_URL; *key_type = PREFETCH_KEY_TYPE_URL;
const GURL& main_frame_url = navigation_id.main_frame_url; const GURL& main_frame_url = navigation_id.main_frame_url;
bool use_url_data = config_.IsPrefetchingEnabled() ? bool use_url_data = config_.IsPrefetchingEnabled(profile_) ?
config_.IsURLPrefetchingEnabled() : config_.IsURLLearningEnabled(); config_.IsURLPrefetchingEnabled(profile_) :
config_.IsURLLearningEnabled();
if (use_url_data) { if (use_url_data) {
PrefetchDataMap::const_iterator iterator = PrefetchDataMap::const_iterator iterator =
url_table_cache_->find(main_frame_url.spec()); url_table_cache_->find(main_frame_url.spec());
...@@ -588,8 +589,9 @@ bool ResourcePrefetchPredictor::GetPrefetchData( ...@@ -588,8 +589,9 @@ bool ResourcePrefetchPredictor::GetPrefetchData(
if (!prefetch_requests->empty()) if (!prefetch_requests->empty())
return true; return true;
bool use_host_data = config_.IsPrefetchingEnabled() ? bool use_host_data = config_.IsPrefetchingEnabled(profile_) ?
config_.IsHostPrefetchingEnabled() : config_.IsHostLearningEnabled(); config_.IsHostPrefetchingEnabled(profile_) :
config_.IsHostLearningEnabled();
if (use_host_data) { if (use_host_data) {
PrefetchDataMap::const_iterator iterator = PrefetchDataMap::const_iterator iterator =
host_table_cache_->find(main_frame_url.host()); host_table_cache_->find(main_frame_url.host());
...@@ -712,7 +714,7 @@ void ResourcePrefetchPredictor::OnHistoryAndCacheLoaded() { ...@@ -712,7 +714,7 @@ void ResourcePrefetchPredictor::OnHistoryAndCacheLoaded() {
content::Source<Profile>(profile_)); content::Source<Profile>(profile_));
// Initialize the prefetch manager only if prefetching is enabled. // Initialize the prefetch manager only if prefetching is enabled.
if (config_.IsPrefetchingEnabled()) { if (config_.IsPrefetchingEnabled(profile_)) {
prefetch_manager_ = new ResourcePrefetcherManager( prefetch_manager_ = new ResourcePrefetcherManager(
this, config_, profile_->GetRequestContext()); this, config_, profile_->GetRequestContext());
} }
......
...@@ -585,6 +585,7 @@ ...@@ -585,6 +585,7 @@
'browser/power/process_power_collector_unittest.cc', 'browser/power/process_power_collector_unittest.cc',
'browser/predictors/autocomplete_action_predictor_table_unittest.cc', 'browser/predictors/autocomplete_action_predictor_table_unittest.cc',
'browser/predictors/autocomplete_action_predictor_unittest.cc', 'browser/predictors/autocomplete_action_predictor_unittest.cc',
'browser/predictors/resource_prefetch_common_unittest.cc',
'browser/predictors/resource_prefetch_predictor_unittest.cc', 'browser/predictors/resource_prefetch_predictor_unittest.cc',
'browser/predictors/resource_prefetch_predictor_tables_unittest.cc', 'browser/predictors/resource_prefetch_predictor_tables_unittest.cc',
'browser/predictors/resource_prefetcher_unittest.cc', 'browser/predictors/resource_prefetcher_unittest.cc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment