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

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

Issue 2896713003: Create LoadingDataCollector class and have observers rely on it instead of ResourcePrefetchPredictor (Closed)
Patch Set: Move some logic into new class. 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 "chrome/browser/predictors/loading_data_collector.h"
8 #include "chrome/browser/predictors/resource_prefetch_predictor.h" 9 #include "chrome/browser/predictors/resource_prefetch_predictor.h"
9 10
10 namespace predictors { 11 namespace predictors {
11 12
12 LoadingPredictor::LoadingPredictor(const LoadingPredictorConfig& config, 13 LoadingPredictor::LoadingPredictor(const LoadingPredictorConfig& config,
13 Profile* profile) { 14 Profile* profile) {
14 resource_prefetch_predictor_ = 15 resource_prefetch_predictor_ =
15 base::MakeUnique<ResourcePrefetchPredictor>(config, profile); 16 base::MakeUnique<ResourcePrefetchPredictor>(config, profile);
17 loading_data_collector_ =
18 base::MakeUnique<LoadingDataCollector>(resource_prefetch_predictor());
16 } 19 }
17 20
18 LoadingPredictor::~LoadingPredictor() = default; 21 LoadingPredictor::~LoadingPredictor() = default;
19 22
20 void LoadingPredictor::PrepareForPageLoad(const GURL& url, HintOrigin origin) { 23 void LoadingPredictor::PrepareForPageLoad(const GURL& url, HintOrigin origin) {
21 resource_prefetch_predictor_->StartPrefetching(url, origin); 24 resource_prefetch_predictor_->StartPrefetching(url, origin);
22 } 25 }
23 26
24 void LoadingPredictor::CancelPageLoadHint(const GURL& url) { 27 void LoadingPredictor::CancelPageLoadHint(const GURL& url) {
25 resource_prefetch_predictor_->StopPrefetching(url); 28 resource_prefetch_predictor_->StopPrefetching(url);
26 } 29 }
27 30
28 void LoadingPredictor::StartInitialization() { 31 void LoadingPredictor::StartInitialization() {
29 resource_prefetch_predictor_->StartInitialization(); 32 resource_prefetch_predictor_->StartInitialization();
30 } 33 }
31 34
35 LoadingDataCollector* LoadingPredictor::loading_data_collector() const {
36 return loading_data_collector_.get();
37 }
38
32 ResourcePrefetchPredictor* LoadingPredictor::resource_prefetch_predictor() 39 ResourcePrefetchPredictor* LoadingPredictor::resource_prefetch_predictor()
33 const { 40 const {
34 return resource_prefetch_predictor_.get(); 41 return resource_prefetch_predictor_.get();
35 } 42 }
36 43
37 void LoadingPredictor::Shutdown() { 44 void LoadingPredictor::Shutdown() {
38 resource_prefetch_predictor_->Shutdown(); 45 resource_prefetch_predictor_->Shutdown();
39 } 46 }
40 47
41 } // namespace predictors 48 } // namespace predictors
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698