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

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

Issue 117933003: Remove the speculative resource prefetching code. This was experimental code added 1.5 years ago an… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync Created 6 years, 11 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_COMMON_H_
6 #define CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_COMMON_H_
7
8 #include "base/time/time.h"
9 #include "url/gurl.h"
10
11 class Profile;
12
13 namespace content {
14 class WebContents;
15 }
16
17 namespace predictors {
18
19 struct ResourcePrefetchPredictorConfig;
20
21 // Returns true if prefetching is enabled. And will initilize the |config|
22 // fields to the appropritate values.
23 bool IsSpeculativeResourcePrefetchingEnabled(
24 Profile* profile,
25 ResourcePrefetchPredictorConfig* config);
26
27 // Represents the type of key based on which prefetch data is stored.
28 enum PrefetchKeyType {
29 PREFETCH_KEY_TYPE_HOST,
30 PREFETCH_KEY_TYPE_URL
31 };
32
33 // Represents a single navigation for a render view.
34 struct NavigationID {
35 // TODO(shishir): Maybe take process_id, view_id and url as input in
36 // constructor.
37 NavigationID();
38 NavigationID(const NavigationID& other);
39 explicit NavigationID(content::WebContents* web_contents);
40 bool operator<(const NavigationID& rhs) const;
41 bool operator==(const NavigationID& rhs) const;
42
43 bool IsSameRenderer(const NavigationID& other) const;
44
45 // Returns true iff the render_process_id_, render_view_id_ and
46 // main_frame_url_ has been set correctly.
47 bool is_valid() const;
48
49 int render_process_id;
50 int render_view_id;
51 GURL main_frame_url;
52
53 // NOTE: Even though we store the creation time here, it is not used during
54 // comparison of two NavigationIDs because it cannot always be determined
55 // correctly.
56 base::TimeTicks creation_time;
57 };
58
59 // Represents the config for the resource prefetch prediction algorithm. It is
60 // useful for running experiments.
61 struct ResourcePrefetchPredictorConfig {
62 // Initializes the config with default values.
63 ResourcePrefetchPredictorConfig();
64 ~ResourcePrefetchPredictorConfig();
65
66 // The mode the prefetcher is running in. Forms a bit map.
67 enum Mode {
68 URL_LEARNING = 1 << 0,
69 HOST_LEARNING = 1 << 1,
70 URL_PREFETCHING = 1 << 2, // Should also turn on URL_LEARNING.
71 HOST_PRFETCHING = 1 << 3 // Should also turn on HOST_LEARNING.
72 };
73 int mode;
74
75 // Helpers to deal with mode.
76 bool IsLearningEnabled() const;
77 bool IsPrefetchingEnabled() const;
78 bool IsURLLearningEnabled() const;
79 bool IsHostLearningEnabled() const;
80 bool IsURLPrefetchingEnabled() const;
81 bool IsHostPrefetchingEnabled() const;
82
83 // If a navigation hasn't seen a load complete event in this much time, it
84 // is considered abandoned.
85 int max_navigation_lifetime_seconds;
86
87 // Size of LRU caches for the URL and host data.
88 int max_urls_to_track;
89 int max_hosts_to_track;
90
91 // The number of times we should have seen a visit to this URL in history
92 // to start tracking it. This is to ensure we don't bother with oneoff
93 // entries. For hosts we track each one.
94 int min_url_visit_count;
95
96 // The maximum number of resources to store per entry.
97 int max_resources_per_entry;
98 // The number of consecutive misses after we stop tracking a resource URL.
99 int max_consecutive_misses;
100
101 // The minimum confidence (accuracy of hits) required for a resource to be
102 // prefetched.
103 float min_resource_confidence_to_trigger_prefetch;
104 // The minimum number of times we must have a URL on record to prefetch it.
105 int min_resource_hits_to_trigger_prefetch;
106
107 // Maximum number of prefetches that can be inflight for a single navigation.
108 int max_prefetches_inflight_per_navigation;
109 // Maximum number of prefetches that can be inflight for a host for a single
110 // navigation.
111 int max_prefetches_inflight_per_host_per_navigation;
112 };
113
114 } // namespace predictors
115
116 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_COMMON_H_
OLDNEW
« no previous file with comments | « chrome/browser/predictors/predictor_database.cc ('k') | chrome/browser/predictors/resource_prefetch_common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698