| 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 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 } | 708 } |
| 709 | 709 |
| 710 void ResourcePrefetchPredictor::CleanupAbandonedNavigations( | 710 void ResourcePrefetchPredictor::CleanupAbandonedNavigations( |
| 711 const NavigationID& navigation_id) { | 711 const NavigationID& navigation_id) { |
| 712 static const base::TimeDelta max_navigation_age = | 712 static const base::TimeDelta max_navigation_age = |
| 713 base::TimeDelta::FromSeconds(config_.max_navigation_lifetime_seconds); | 713 base::TimeDelta::FromSeconds(config_.max_navigation_lifetime_seconds); |
| 714 | 714 |
| 715 base::TimeTicks time_now = base::TimeTicks::Now(); | 715 base::TimeTicks time_now = base::TimeTicks::Now(); |
| 716 for (NavigationMap::iterator it = inflight_navigations_.begin(); | 716 for (NavigationMap::iterator it = inflight_navigations_.begin(); |
| 717 it != inflight_navigations_.end();) { | 717 it != inflight_navigations_.end();) { |
| 718 if (it->first.IsSameRenderer(navigation_id) || | 718 if ((it->first.session_id == navigation_id.session_id) || |
| 719 (time_now - it->first.creation_time > max_navigation_age)) { | 719 (time_now - it->first.creation_time > max_navigation_age)) { |
| 720 inflight_navigations_.erase(it++); | 720 inflight_navigations_.erase(it++); |
| 721 } else { | 721 } else { |
| 722 ++it; | 722 ++it; |
| 723 } | 723 } |
| 724 } | 724 } |
| 725 } | 725 } |
| 726 | 726 |
| 727 void ResourcePrefetchPredictor::DeleteAllUrls() { | 727 void ResourcePrefetchPredictor::DeleteAllUrls() { |
| 728 inflight_navigations_.clear(); | 728 inflight_navigations_.clear(); |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1155 TestObserver::~TestObserver() { | 1155 TestObserver::~TestObserver() { |
| 1156 predictor_->SetObserverForTesting(nullptr); | 1156 predictor_->SetObserverForTesting(nullptr); |
| 1157 } | 1157 } |
| 1158 | 1158 |
| 1159 TestObserver::TestObserver(ResourcePrefetchPredictor* predictor) | 1159 TestObserver::TestObserver(ResourcePrefetchPredictor* predictor) |
| 1160 : predictor_(predictor) { | 1160 : predictor_(predictor) { |
| 1161 predictor_->SetObserverForTesting(this); | 1161 predictor_->SetObserverForTesting(this); |
| 1162 } | 1162 } |
| 1163 | 1163 |
| 1164 } // namespace predictors | 1164 } // namespace predictors |
| OLD | NEW |