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

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

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

Powered by Google App Engine
This is Rietveld 408576698