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 #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 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 } | 702 } |
703 | 703 |
704 void ResourcePrefetchPredictor::CleanupAbandonedNavigations( | 704 void ResourcePrefetchPredictor::CleanupAbandonedNavigations( |
705 const NavigationID& navigation_id) { | 705 const NavigationID& navigation_id) { |
706 static const base::TimeDelta max_navigation_age = | 706 static const base::TimeDelta max_navigation_age = |
707 base::TimeDelta::FromSeconds(config_.max_navigation_lifetime_seconds); | 707 base::TimeDelta::FromSeconds(config_.max_navigation_lifetime_seconds); |
708 | 708 |
709 base::TimeTicks time_now = base::TimeTicks::Now(); | 709 base::TimeTicks time_now = base::TimeTicks::Now(); |
710 for (NavigationMap::iterator it = inflight_navigations_.begin(); | 710 for (NavigationMap::iterator it = inflight_navigations_.begin(); |
711 it != inflight_navigations_.end();) { | 711 it != inflight_navigations_.end();) { |
712 if (it->first.IsSameRenderer(navigation_id) || | 712 if ((it->first.session_id.id() == navigation_id.session_id.id()) || |
713 (time_now - it->first.creation_time > max_navigation_age)) { | 713 (time_now - it->first.creation_time > max_navigation_age)) { |
714 inflight_navigations_.erase(it++); | 714 inflight_navigations_.erase(it++); |
715 } else { | 715 } else { |
716 ++it; | 716 ++it; |
717 } | 717 } |
718 } | 718 } |
719 } | 719 } |
720 | 720 |
721 void ResourcePrefetchPredictor::DeleteAllUrls() { | 721 void ResourcePrefetchPredictor::DeleteAllUrls() { |
722 inflight_navigations_.clear(); | 722 inflight_navigations_.clear(); |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1149 TestObserver::~TestObserver() { | 1149 TestObserver::~TestObserver() { |
1150 predictor_->SetObserverForTesting(nullptr); | 1150 predictor_->SetObserverForTesting(nullptr); |
1151 } | 1151 } |
1152 | 1152 |
1153 TestObserver::TestObserver(ResourcePrefetchPredictor* predictor) | 1153 TestObserver::TestObserver(ResourcePrefetchPredictor* predictor) |
1154 : predictor_(predictor) { | 1154 : predictor_(predictor) { |
1155 predictor_->SetObserverForTesting(this); | 1155 predictor_->SetObserverForTesting(this); |
1156 } | 1156 } |
1157 | 1157 |
1158 } // namespace predictors | 1158 } // namespace predictors |
OLD | NEW |