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

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

Issue 2482833002: Reland of predictors: Basic browsertest checks predictor learning. (Closed)
Patch Set: Rebase. Created 4 years, 1 month 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 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 void ResourcePrefetchPredictor::OnHistoryAndCacheLoaded() { 704 void ResourcePrefetchPredictor::OnHistoryAndCacheLoaded() {
705 DCHECK_CURRENTLY_ON(BrowserThread::UI); 705 DCHECK_CURRENTLY_ON(BrowserThread::UI);
706 DCHECK_EQ(INITIALIZING, initialization_state_); 706 DCHECK_EQ(INITIALIZING, initialization_state_);
707 707
708 // Initialize the prefetch manager only if prefetching is enabled. 708 // Initialize the prefetch manager only if prefetching is enabled.
709 if (config_.IsPrefetchingEnabled(profile_)) { 709 if (config_.IsPrefetchingEnabled(profile_)) {
710 prefetch_manager_ = new ResourcePrefetcherManager( 710 prefetch_manager_ = new ResourcePrefetcherManager(
711 this, config_, profile_->GetRequestContext()); 711 this, config_, profile_->GetRequestContext());
712 } 712 }
713 initialization_state_ = INITIALIZED; 713 initialization_state_ = INITIALIZED;
714
715 if (observer_)
716 observer_->OnPredictorInitialized();
714 } 717 }
715 718
716 void ResourcePrefetchPredictor::CleanupAbandonedNavigations( 719 void ResourcePrefetchPredictor::CleanupAbandonedNavigations(
717 const NavigationID& navigation_id) { 720 const NavigationID& navigation_id) {
718 static const base::TimeDelta max_navigation_age = 721 static const base::TimeDelta max_navigation_age =
719 base::TimeDelta::FromSeconds(config_.max_navigation_lifetime_seconds); 722 base::TimeDelta::FromSeconds(config_.max_navigation_lifetime_seconds);
720 723
721 base::TimeTicks time_now = base::TimeTicks::Now(); 724 base::TimeTicks time_now = base::TimeTicks::Now();
722 for (NavigationMap::iterator it = inflight_navigations_.begin(); 725 for (NavigationMap::iterator it = inflight_navigations_.begin();
723 it != inflight_navigations_.end();) { 726 it != inflight_navigations_.end();) {
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 TestObserver::~TestObserver() { 1169 TestObserver::~TestObserver() {
1167 predictor_->SetObserverForTesting(nullptr); 1170 predictor_->SetObserverForTesting(nullptr);
1168 } 1171 }
1169 1172
1170 TestObserver::TestObserver(ResourcePrefetchPredictor* predictor) 1173 TestObserver::TestObserver(ResourcePrefetchPredictor* predictor)
1171 : predictor_(predictor) { 1174 : predictor_(predictor) {
1172 predictor_->SetObserverForTesting(this); 1175 predictor_->SetObserverForTesting(this);
1173 } 1176 }
1174 1177
1175 } // namespace predictors 1178 } // namespace predictors
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698