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

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

Issue 2847183002: predictors: Introduce GlowplugPredictor. (Closed)
Patch Set: GlowplugPredictor -> LoadingPredictor 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/predictors/loading_predictor_config.h"
6 #include "chrome/browser/predictors/resource_prefetch_common.h"
7
8 namespace predictors {
9
10 bool IsLoadingPredictortEnabled(Profile* profile,
11 LoadingPredictorConfig* config) {
12 return IsSpeculativeResourcePrefetchingEnabled(profile, config);
13 }
14
15 LoadingPredictorConfig::LoadingPredictorConfig()
16 : mode(0),
17 max_navigation_lifetime_seconds(60),
18 max_urls_to_track(500),
19 max_hosts_to_track(200),
20 min_url_visit_count(2),
21 max_resources_per_entry(50),
22 max_origins_per_entry(50),
23 max_consecutive_misses(3),
24 max_redirect_consecutive_misses(5),
25 min_resource_confidence_to_trigger_prefetch(0.7f),
26 min_resource_hits_to_trigger_prefetch(2),
27 max_prefetches_inflight_per_navigation(5),
28 max_prefetches_inflight_per_host_per_navigation(3),
29 is_url_learning_enabled(false),
30 is_manifests_enabled(false),
31 is_origin_learning_enabled(false) {}
32
33 LoadingPredictorConfig::LoadingPredictorConfig(
34 const LoadingPredictorConfig& other) = default;
35
36 LoadingPredictorConfig::~LoadingPredictorConfig() = default;
37
38 bool LoadingPredictorConfig::IsLearningEnabled() const {
39 return (mode & LEARNING) > 0;
40 }
41
42 bool LoadingPredictorConfig::IsPrefetchingEnabledForSomeOrigin(
43 Profile* profile) const {
44 int mask = PREFETCHING_FOR_NAVIGATION | PREFETCHING_FOR_EXTERNAL;
45 return internal::IsPrefetchingEnabledInternal(profile, mode, mask);
46 }
47
48 bool LoadingPredictorConfig::IsPrefetchingEnabledForOrigin(
49 Profile* profile,
50 HintOrigin origin) const {
51 int mask = 0;
52 switch (origin) {
53 case HintOrigin::NAVIGATION:
54 mask = PREFETCHING_FOR_NAVIGATION;
55 break;
56 case HintOrigin::EXTERNAL:
57 mask = PREFETCHING_FOR_EXTERNAL;
58 break;
59 }
60 return internal::IsPrefetchingEnabledInternal(profile, mode, mask);
61 }
62
63 bool LoadingPredictorConfig::IsLowConfidenceForTest() const {
64 return min_url_visit_count == 1 &&
65 std::abs(min_resource_confidence_to_trigger_prefetch - 0.5f) < 1e-6 &&
66 min_resource_hits_to_trigger_prefetch == 1;
67 }
68
69 bool LoadingPredictorConfig::IsHighConfidenceForTest() const {
70 return min_url_visit_count == 3 &&
71 std::abs(min_resource_confidence_to_trigger_prefetch - 0.9f) < 1e-6 &&
72 min_resource_hits_to_trigger_prefetch == 3;
73 }
74
75 bool LoadingPredictorConfig::IsMoreResourcesEnabledForTest() const {
76 return max_resources_per_entry == 100;
77 }
78
79 bool LoadingPredictorConfig::IsSmallDBEnabledForTest() const {
80 return max_urls_to_track == 200 && max_hosts_to_track == 100;
81 }
82
83 } // namespace predictors
OLDNEW
« no previous file with comments | « chrome/browser/predictors/loading_predictor_config.h ('k') | chrome/browser/predictors/loading_predictor_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698