| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| 11 #include "chrome/browser/predictors/loading_data_collector.h" | 11 #include "chrome/browser/predictors/loading_data_collector.h" |
| 12 #include "chrome/browser/predictors/loading_stats_collector.h" | 12 #include "chrome/browser/predictors/loading_stats_collector.h" |
| 13 #include "chrome/browser/predictors/resource_prefetch_common.h" | 13 #include "chrome/browser/predictors/resource_prefetch_common.h" |
| 14 #include "chrome/browser/predictors/resource_prefetch_predictor.h" | 14 #include "chrome/browser/predictors/resource_prefetch_predictor.h" |
| 15 | 15 |
| 16 namespace predictors { | 16 namespace predictors { |
| 17 | 17 |
| 18 using URLRequestSummary = ResourcePrefetchPredictor::URLRequestSummary; | |
| 19 | |
| 20 LoadingPredictor::LoadingPredictor(const LoadingPredictorConfig& config, | 18 LoadingPredictor::LoadingPredictor(const LoadingPredictorConfig& config, |
| 21 Profile* profile) | 19 Profile* profile) |
| 22 : config_(config), | 20 : config_(config), |
| 23 profile_(profile), | 21 profile_(profile), |
| 24 resource_prefetch_predictor_( | 22 resource_prefetch_predictor_( |
| 25 base::MakeUnique<ResourcePrefetchPredictor>(config, profile)), | 23 base::MakeUnique<ResourcePrefetchPredictor>(config, profile)), |
| 26 stats_collector_(base::MakeUnique<LoadingStatsCollector>( | 24 stats_collector_(base::MakeUnique<LoadingStatsCollector>( |
| 27 resource_prefetch_predictor_.get(), | 25 resource_prefetch_predictor_.get(), |
| 28 config)), | 26 config)), |
| 29 loading_data_collector_(base::MakeUnique<LoadingDataCollector>( | 27 loading_data_collector_(base::MakeUnique<LoadingDataCollector>( |
| 30 resource_prefetch_predictor())), | 28 resource_prefetch_predictor_.get(), |
| 29 stats_collector_.get(), |
| 30 config)), |
| 31 observer_(nullptr), | 31 observer_(nullptr), |
| 32 weak_factory_(this) { | 32 weak_factory_(this) { |
| 33 resource_prefetch_predictor_->SetStatsCollector(stats_collector_.get()); | 33 resource_prefetch_predictor_->SetStatsCollector(stats_collector_.get()); |
| 34 preconnect_manager_ = base::MakeUnique<PreconnectManager>( | 34 preconnect_manager_ = base::MakeUnique<PreconnectManager>( |
| 35 GetWeakPtr(), profile_->GetRequestContext()); | 35 GetWeakPtr(), profile_->GetRequestContext()); |
| 36 } | 36 } |
| 37 | 37 |
| 38 LoadingPredictor::~LoadingPredictor() = default; | 38 LoadingPredictor::~LoadingPredictor() = default; |
| 39 | 39 |
| 40 void LoadingPredictor::PrepareForPageLoad(const GURL& url, HintOrigin origin) { | 40 void LoadingPredictor::PrepareForPageLoad(const GURL& url, HintOrigin origin) { |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 TestLoadingObserver::~TestLoadingObserver() { | 294 TestLoadingObserver::~TestLoadingObserver() { |
| 295 predictor_->SetObserverForTesting(nullptr); | 295 predictor_->SetObserverForTesting(nullptr); |
| 296 } | 296 } |
| 297 | 297 |
| 298 TestLoadingObserver::TestLoadingObserver(LoadingPredictor* predictor) | 298 TestLoadingObserver::TestLoadingObserver(LoadingPredictor* predictor) |
| 299 : predictor_(predictor) { | 299 : predictor_(predictor) { |
| 300 predictor_->SetObserverForTesting(this); | 300 predictor_->SetObserverForTesting(this); |
| 301 } | 301 } |
| 302 | 302 |
| 303 } // namespace predictors | 303 } // namespace predictors |
| OLD | NEW |