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

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

Issue 2887133003: predictors: Refactor resource_prefetch_predictor triggering. (Closed)
Patch Set: . Created 3 years, 7 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/resource_prefetch_predictor.h" 8 #include "chrome/browser/predictors/resource_prefetch_predictor.h"
9 9
10 namespace predictors { 10 namespace predictors {
11 11
12 LoadingPredictor::LoadingPredictor(const LoadingPredictorConfig& config, 12 LoadingPredictor::LoadingPredictor(const LoadingPredictorConfig& config,
13 Profile* profile) { 13 Profile* profile)
14 resource_prefetch_predictor_ = 14 : resource_prefetch_predictor_(
15 base::MakeUnique<ResourcePrefetchPredictor>(config, profile); 15 base::MakeUnique<ResourcePrefetchPredictor>(config, profile)) {}
alexilin 2017/05/23 11:01:38 Do you think it's better to construct the pointer
Benoit L 2017/05/29 16:45:14 We are trying to remove "new" as possible from Chr
16 }
17 16
18 LoadingPredictor::~LoadingPredictor() = default; 17 LoadingPredictor::~LoadingPredictor() = default;
19 18
20 void LoadingPredictor::PrepareForPageLoad(const GURL& url, HintOrigin origin) { 19 void LoadingPredictor::PrepareForPageLoad(const GURL& url, HintOrigin origin) {
21 resource_prefetch_predictor_->StartPrefetching(url, origin); 20 if (resource_prefetch_predictor_->CanPrefetchUrlForOrigin(url, origin))
alexilin 2017/05/23 11:01:38 Shouldn't it be like LoadingPredictor tries to get
Benoit L 2017/05/29 16:45:14 That's the eventual goal yes, but it doesn't seem
21 resource_prefetch_predictor_->StartPrefetching(url, origin);
22 } 22 }
23 23
24 void LoadingPredictor::CancelPageLoadHint(const GURL& url) { 24 void LoadingPredictor::CancelPageLoadHint(const GURL& url) {
25 resource_prefetch_predictor_->StopPrefetching(url); 25 resource_prefetch_predictor_->StopPrefetching(url);
26 } 26 }
27 27
28 void LoadingPredictor::StartInitialization() { 28 void LoadingPredictor::StartInitialization() {
29 resource_prefetch_predictor_->StartInitialization(); 29 resource_prefetch_predictor_->StartInitialization();
30 } 30 }
31 31
32 ResourcePrefetchPredictor* LoadingPredictor::resource_prefetch_predictor() 32 ResourcePrefetchPredictor* LoadingPredictor::resource_prefetch_predictor()
33 const { 33 const {
34 return resource_prefetch_predictor_.get(); 34 return resource_prefetch_predictor_.get();
35 } 35 }
36 36
37 void LoadingPredictor::Shutdown() { 37 void LoadingPredictor::Shutdown() {
38 resource_prefetch_predictor_->Shutdown(); 38 resource_prefetch_predictor_->Shutdown();
39 } 39 }
40 40
41 } // namespace predictors 41 } // namespace predictors
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698