| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/loading_predictor.h" | 5 #include "chrome/browser/predictors/loading_predictor.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #include "chrome/browser/predictors/loading_data_collector.h" | 9 #include "chrome/browser/predictors/loading_data_collector.h" |
| 10 #include "chrome/browser/predictors/loading_stats_collector.h" | 10 #include "chrome/browser/predictors/loading_stats_collector.h" |
| 11 #include "chrome/browser/predictors/resource_prefetch_common.h" | 11 #include "chrome/browser/predictors/resource_prefetch_common.h" |
| 12 #include "chrome/browser/predictors/resource_prefetch_predictor.h" | 12 #include "chrome/browser/predictors/resource_prefetch_predictor.h" |
| 13 | 13 |
| 14 namespace predictors { | 14 namespace predictors { |
| 15 | 15 |
| 16 using URLRequestSummary = ResourcePrefetchPredictor::URLRequestSummary; | |
| 17 | |
| 18 LoadingPredictor::LoadingPredictor(const LoadingPredictorConfig& config, | 16 LoadingPredictor::LoadingPredictor(const LoadingPredictorConfig& config, |
| 19 Profile* profile) | 17 Profile* profile) |
| 20 : config_(config), | 18 : config_(config), |
| 21 profile_(profile), | 19 profile_(profile), |
| 22 resource_prefetch_predictor_( | 20 resource_prefetch_predictor_( |
| 23 base::MakeUnique<ResourcePrefetchPredictor>(config, profile)), | 21 base::MakeUnique<ResourcePrefetchPredictor>(config, profile)), |
| 24 stats_collector_(base::MakeUnique<LoadingStatsCollector>( | 22 stats_collector_(base::MakeUnique<LoadingStatsCollector>( |
| 25 resource_prefetch_predictor_.get(), | 23 resource_prefetch_predictor_.get(), |
| 26 config)), | 24 config)), |
| 27 loading_data_collector_(base::MakeUnique<LoadingDataCollector>( | 25 loading_data_collector_(base::MakeUnique<LoadingDataCollector>( |
| 28 resource_prefetch_predictor())), | 26 resource_prefetch_predictor_.get(), |
| 27 stats_collector_.get(), |
| 28 config)), |
| 29 weak_factory_(this) { | 29 weak_factory_(this) { |
| 30 resource_prefetch_predictor_->SetStatsCollector(stats_collector_.get()); | 30 resource_prefetch_predictor_->SetStatsCollector(stats_collector_.get()); |
| 31 } | 31 } |
| 32 | 32 |
| 33 LoadingPredictor::~LoadingPredictor() = default; | 33 LoadingPredictor::~LoadingPredictor() = default; |
| 34 | 34 |
| 35 void LoadingPredictor::PrepareForPageLoad(const GURL& url, HintOrigin origin) { | 35 void LoadingPredictor::PrepareForPageLoad(const GURL& url, HintOrigin origin) { |
| 36 if (active_hints_.find(url) != active_hints_.end()) | 36 if (active_hints_.find(url) != active_hints_.end()) |
| 37 return; | 37 return; |
| 38 ResourcePrefetchPredictor::Prediction prediction; | 38 ResourcePrefetchPredictor::Prediction prediction; |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 const GURL& initial_url = it->second; | 143 const GURL& initial_url = it->second; |
| 144 CancelActiveHint(active_hints_.find(initial_url)); | 144 CancelActiveHint(active_hints_.find(initial_url)); |
| 145 it = active_navigations_.erase(it); | 145 it = active_navigations_.erase(it); |
| 146 } else { | 146 } else { |
| 147 ++it; | 147 ++it; |
| 148 } | 148 } |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 | 151 |
| 152 } // namespace predictors | 152 } // namespace predictors |
| OLD | NEW |