Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: chrome/browser/predictors/resource_prefetch_predictor.cc

Issue 2815103002: predictors: Enable origin learning with a flag. (Closed)
Patch Set: . Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "chrome/browser/predictors/resource_prefetch_predictor.h" 5 #include "chrome/browser/predictors/resource_prefetch_predictor.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 786
787 NavigationMap::const_iterator nav_it = 787 NavigationMap::const_iterator nav_it =
788 inflight_navigations_.find(response.navigation_id); 788 inflight_navigations_.find(response.navigation_id);
789 if (nav_it == inflight_navigations_.end()) 789 if (nav_it == inflight_navigations_.end())
790 return; 790 return;
791 auto& page_request_summary = *nav_it->second; 791 auto& page_request_summary = *nav_it->second;
792 792
793 if (!response.is_no_store) 793 if (!response.is_no_store)
794 page_request_summary.subresource_requests.push_back(response); 794 page_request_summary.subresource_requests.push_back(response);
795 795
796 if (config_.is_origin_prediction_enabled) 796 if (config_.is_origin_learning_enabled)
797 UpdateOrAddToOrigins(&page_request_summary.origins, response); 797 UpdateOrAddToOrigins(&page_request_summary.origins, response);
798 } 798 }
799 799
800 void ResourcePrefetchPredictor::OnSubresourceRedirect( 800 void ResourcePrefetchPredictor::OnSubresourceRedirect(
801 const URLRequestSummary& response) { 801 const URLRequestSummary& response) {
802 DCHECK_CURRENTLY_ON(BrowserThread::UI); 802 DCHECK_CURRENTLY_ON(BrowserThread::UI);
803 DCHECK_EQ(INITIALIZED, initialization_state_); 803 DCHECK_EQ(INITIALIZED, initialization_state_);
804 804
805 if (!config_.is_origin_prediction_enabled) 805 if (!config_.is_origin_learning_enabled)
806 return; 806 return;
807 807
808 NavigationMap::const_iterator nav_it = 808 NavigationMap::const_iterator nav_it =
809 inflight_navigations_.find(response.navigation_id); 809 inflight_navigations_.find(response.navigation_id);
810 if (nav_it == inflight_navigations_.end()) 810 if (nav_it == inflight_navigations_.end())
811 return; 811 return;
812 auto& page_request_summary = *nav_it->second; 812 auto& page_request_summary = *nav_it->second;
813 UpdateOrAddToOrigins(&page_request_summary.origins, response); 813 UpdateOrAddToOrigins(&page_request_summary.origins, response);
814 } 814 }
815 815
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 url_redirect_table_cache_.get()); 1231 url_redirect_table_cache_.get());
1232 } 1232 }
1233 } 1233 }
1234 1234
1235 // Host level data - no cutoff, always learn the navigation if enabled. 1235 // Host level data - no cutoff, always learn the navigation if enabled.
1236 const std::string host = summary.main_frame_url.host(); 1236 const std::string host = summary.main_frame_url.host();
1237 LearnNavigation(host, PREFETCH_KEY_TYPE_HOST, summary.subresource_requests, 1237 LearnNavigation(host, PREFETCH_KEY_TYPE_HOST, summary.subresource_requests,
1238 config_.max_hosts_to_track, host_table_cache_.get(), 1238 config_.max_hosts_to_track, host_table_cache_.get(),
1239 summary.initial_url.host(), host_redirect_table_cache_.get()); 1239 summary.initial_url.host(), host_redirect_table_cache_.get());
1240 1240
1241 if (config_.is_origin_prediction_enabled) { 1241 if (config_.is_origin_learning_enabled) {
1242 LearnOrigins(host, summary.origins, config_.max_hosts_to_track, 1242 LearnOrigins(host, summary.origins, config_.max_hosts_to_track,
1243 origin_table_cache_.get()); 1243 origin_table_cache_.get());
1244 } 1244 }
1245 1245
1246 if (observer_) 1246 if (observer_)
1247 observer_->OnNavigationLearned(url_visit_count, summary); 1247 observer_->OnNavigationLearned(url_visit_count, summary);
1248 } 1248 }
1249 1249
1250 void ResourcePrefetchPredictor::LearnNavigation( 1250 void ResourcePrefetchPredictor::LearnNavigation(
1251 const std::string& key, 1251 const std::string& key,
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
1706 TestObserver::~TestObserver() { 1706 TestObserver::~TestObserver() {
1707 predictor_->SetObserverForTesting(nullptr); 1707 predictor_->SetObserverForTesting(nullptr);
1708 } 1708 }
1709 1709
1710 TestObserver::TestObserver(ResourcePrefetchPredictor* predictor) 1710 TestObserver::TestObserver(ResourcePrefetchPredictor* predictor)
1711 : predictor_(predictor) { 1711 : predictor_(predictor) {
1712 predictor_->SetObserverForTesting(this); 1712 predictor_->SetObserverForTesting(this);
1713 } 1713 }
1714 1714
1715 } // namespace predictors 1715 } // namespace predictors
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698