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

Side by Side Diff: chrome/browser/predictors/resource_prefetch_common.h

Issue 2538743002: predictors: Add a origin for prefetch requests, remove the URL/host settings. (Closed)
Patch Set: . Created 4 years 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
« no previous file with comments | « no previous file | chrome/browser/predictors/resource_prefetch_common.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_COMMON_H_ 5 #ifndef CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_COMMON_H_
6 #define CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_COMMON_H_ 6 #define CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_COMMON_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 14 matching lines...) Expand all
25 bool IsSpeculativeResourcePrefetchingEnabled( 25 bool IsSpeculativeResourcePrefetchingEnabled(
26 Profile* profile, 26 Profile* profile,
27 ResourcePrefetchPredictorConfig* config); 27 ResourcePrefetchPredictorConfig* config);
28 28
29 // Represents the type of key based on which prefetch data is stored. 29 // Represents the type of key based on which prefetch data is stored.
30 enum PrefetchKeyType { 30 enum PrefetchKeyType {
31 PREFETCH_KEY_TYPE_HOST, 31 PREFETCH_KEY_TYPE_HOST,
32 PREFETCH_KEY_TYPE_URL 32 PREFETCH_KEY_TYPE_URL
33 }; 33 };
34 34
35 // Indicates what caused the prefetch request.
36 enum class PrefetchOrigin { NAVIGATION, EXTERNAL };
37
35 // Represents a single navigation for a render frame. 38 // Represents a single navigation for a render frame.
36 struct NavigationID { 39 struct NavigationID {
37 NavigationID(); 40 NavigationID();
38 NavigationID(int render_process_id, 41 NavigationID(int render_process_id,
39 int render_frame_id, 42 int render_frame_id,
40 const GURL& main_frame_url); 43 const GURL& main_frame_url);
41 NavigationID(const NavigationID& other); 44 NavigationID(const NavigationID& other);
42 explicit NavigationID(content::WebContents* web_contents); 45 explicit NavigationID(content::WebContents* web_contents);
43 bool operator<(const NavigationID& rhs) const; 46 bool operator<(const NavigationID& rhs) const;
44 bool operator==(const NavigationID& rhs) const; 47 bool operator==(const NavigationID& rhs) const;
45 48
46 bool IsSameRenderer(const NavigationID& other) const; 49 bool IsSameRenderer(const NavigationID& other) const;
47 50
48 // Returns true iff the render_process_id_, render_frame_id_ and 51 // Returns true iff the render_process_id_, render_frame_id_ and
49 // frame_url_ has been set correctly. 52 // frame_url_ has been set correctly.
50 bool is_valid() const; 53 bool is_valid() const;
51 54
52 int render_process_id; 55 int render_process_id;
53 int render_frame_id; 56 int render_frame_id;
54 GURL main_frame_url; 57 GURL main_frame_url;
55 58
56 // NOTE: Even though we store the creation time here, it is not used during 59 // NOTE: Even though we store the creation time here, it is not used during
57 // comparison of two NavigationIDs because it cannot always be determined 60 // comparison of two NavigationIDs because it cannot always be determined
58 // correctly. 61 // correctly.
59 base::TimeTicks creation_time; 62 base::TimeTicks creation_time;
60 }; 63 };
61 64
62 // Represents the config for the resource prefetch prediction algorithm. It is 65 // Represents the config for the resource prefetch prediction algorithm.
63 // useful for running experiments.
64 struct ResourcePrefetchPredictorConfig { 66 struct ResourcePrefetchPredictorConfig {
65 // Initializes the config with default values. 67 // Initializes the config with default values.
66 ResourcePrefetchPredictorConfig(); 68 ResourcePrefetchPredictorConfig();
67 ResourcePrefetchPredictorConfig(const ResourcePrefetchPredictorConfig& other); 69 ResourcePrefetchPredictorConfig(const ResourcePrefetchPredictorConfig& other);
68 ~ResourcePrefetchPredictorConfig(); 70 ~ResourcePrefetchPredictorConfig();
69 71
70 // The mode the prefetcher is running in. Forms a bit map. 72 // The mode the prefetcher is running in. Forms a bit map.
71 enum Mode { 73 enum Mode {
72 URL_LEARNING = 1 << 0, 74 LEARNING = 1 << 0,
73 HOST_LEARNING = 1 << 1, 75 PREFETCHING_FOR_NAVIGATION = 1 << 2, // Also enables LEARNING.
74 URL_PREFETCHING = 1 << 2, // Should also turn on URL_LEARNING. 76 PREFETCHING_FOR_EXTERNAL = 1 << 3 // Also enables LEARNING.
75 HOST_PREFETCHING = 1 << 3 // Should also turn on HOST_LEARNING.
76 }; 77 };
77 int mode; 78 int mode;
78 79
79 // Helpers to deal with mode. 80 // Helpers to deal with mode.
80 bool IsLearningEnabled() const; 81 bool IsLearningEnabled() const;
81 bool IsPrefetchingEnabled(Profile* profile) const; 82 bool IsPrefetchingEnabledForSomeOrigin(Profile* profile) const;
82 bool IsURLLearningEnabled() const; 83 bool IsPrefetchingEnabledForOrigin(Profile* profile,
83 bool IsHostLearningEnabled() const; 84 PrefetchOrigin origin) const;
84 bool IsURLPrefetchingEnabled(Profile* profile) const;
85 bool IsHostPrefetchingEnabled(Profile* profile) const;
86 85
87 bool IsLowConfidenceForTest() const; 86 bool IsLowConfidenceForTest() const;
88 bool IsHighConfidenceForTest() const; 87 bool IsHighConfidenceForTest() const;
89 bool IsMoreResourcesEnabledForTest() const; 88 bool IsMoreResourcesEnabledForTest() const;
90 bool IsSmallDBEnabledForTest() const; 89 bool IsSmallDBEnabledForTest() const;
91 90
92 // If a navigation hasn't seen a load complete event in this much time, it 91 // If a navigation hasn't seen a load complete event in this much time, it
93 // is considered abandoned. 92 // is considered abandoned.
94 size_t max_navigation_lifetime_seconds; 93 size_t max_navigation_lifetime_seconds;
95 94
(...skipping 20 matching lines...) Expand all
116 // Maximum number of prefetches that can be inflight for a single navigation. 115 // Maximum number of prefetches that can be inflight for a single navigation.
117 size_t max_prefetches_inflight_per_navigation; 116 size_t max_prefetches_inflight_per_navigation;
118 // Maximum number of prefetches that can be inflight for a host for a single 117 // Maximum number of prefetches that can be inflight for a host for a single
119 // navigation. 118 // navigation.
120 size_t max_prefetches_inflight_per_host_per_navigation; 119 size_t max_prefetches_inflight_per_host_per_navigation;
121 }; 120 };
122 121
123 } // namespace predictors 122 } // namespace predictors
124 123
125 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_COMMON_H_ 124 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_COMMON_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/predictors/resource_prefetch_common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698