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

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

Issue 2937623007: predictors: Move more methods from ResourcePrefetchPredictor into LoadingDataCollector. (Closed)
Patch Set: Make InitializationState type public. Created 3 years, 6 months 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 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; 16 using URLRequestSummary = ResourcePrefetchPredictor::URLRequestSummary;
17 17
18 LoadingPredictor::LoadingPredictor(const LoadingPredictorConfig& config, 18 LoadingPredictor::LoadingPredictor(const LoadingPredictorConfig& config,
19 Profile* profile) 19 Profile* profile)
20 : config_(config), 20 : config_(config),
21 profile_(profile), 21 profile_(profile),
22 resource_prefetch_predictor_( 22 resource_prefetch_predictor_(
23 base::MakeUnique<ResourcePrefetchPredictor>(config, profile)), 23 base::MakeUnique<ResourcePrefetchPredictor>(config, profile)),
24 stats_collector_(base::MakeUnique<LoadingStatsCollector>( 24 stats_collector_(base::MakeUnique<LoadingStatsCollector>(
25 resource_prefetch_predictor_.get(), 25 resource_prefetch_predictor_.get(),
26 config)), 26 config)),
27 loading_data_collector_(base::MakeUnique<LoadingDataCollector>( 27 loading_data_collector_(base::MakeUnique<LoadingDataCollector>(
28 resource_prefetch_predictor())) { 28 resource_prefetch_predictor_.get(),
29 stats_collector_.get(),
30 config)) {
29 resource_prefetch_predictor_->SetStatsCollector(stats_collector_.get()); 31 resource_prefetch_predictor_->SetStatsCollector(stats_collector_.get());
30 } 32 }
31 33
32 LoadingPredictor::~LoadingPredictor() = default; 34 LoadingPredictor::~LoadingPredictor() = default;
33 35
34 void LoadingPredictor::PrepareForPageLoad(const GURL& url, HintOrigin origin) { 36 void LoadingPredictor::PrepareForPageLoad(const GURL& url, HintOrigin origin) {
35 if (active_hints_.find(url) != active_hints_.end()) 37 if (active_hints_.find(url) != active_hints_.end())
36 return; 38 return;
37 ResourcePrefetchPredictor::Prediction prediction; 39 ResourcePrefetchPredictor::Prediction prediction;
38 if (!resource_prefetch_predictor_->GetPrefetchData(url, &prediction)) 40 if (!resource_prefetch_predictor_->GetPrefetchData(url, &prediction))
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 const GURL& initial_url = it->second; 144 const GURL& initial_url = it->second;
143 CancelActiveHint(active_hints_.find(initial_url)); 145 CancelActiveHint(active_hints_.find(initial_url));
144 it = active_navigations_.erase(it); 146 it = active_navigations_.erase(it);
145 } else { 147 } else {
146 ++it; 148 ++it;
147 } 149 }
148 } 150 }
149 } 151 }
150 152
151 } // namespace predictors 153 } // namespace predictors
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698