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

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

Issue 2587443002: predictors: Make speculative_prefetch_predictor work with PlzNavigate (Closed)
Patch Set: From SessionID to SessionID::id_type 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
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 #include "chrome/browser/predictors/resource_prefetch_common.h" 5 #include "chrome/browser/predictors/resource_prefetch_common.h"
6 6
7 #include <string> 7 #include <string>
8 #include <tuple> 8 #include <tuple>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 ResourcePrefetchPredictorConfig::LEARNING | 69 ResourcePrefetchPredictorConfig::LEARNING |
70 ResourcePrefetchPredictorConfig::PREFETCHING_FOR_NAVIGATION | 70 ResourcePrefetchPredictorConfig::PREFETCHING_FOR_NAVIGATION |
71 ResourcePrefetchPredictorConfig::PREFETCHING_FOR_EXTERNAL; 71 ResourcePrefetchPredictorConfig::PREFETCHING_FOR_EXTERNAL;
72 return true; 72 return true;
73 } 73 }
74 } 74 }
75 75
76 return false; 76 return false;
77 } 77 }
78 78
79 NavigationID::NavigationID() 79 NavigationID::NavigationID() : session_id(-1) {}
80 : render_process_id(-1),
81 render_frame_id(-1) {
82 }
83 80
84 NavigationID::NavigationID(const NavigationID& other) 81 NavigationID::NavigationID(const NavigationID& other)
85 : render_process_id(other.render_process_id), 82 : session_id(other.session_id),
86 render_frame_id(other.render_frame_id),
87 main_frame_url(other.main_frame_url), 83 main_frame_url(other.main_frame_url),
88 creation_time(other.creation_time) { 84 creation_time(other.creation_time) {}
89 }
90 85
91 NavigationID::NavigationID(content::WebContents* web_contents) 86 NavigationID::NavigationID(content::WebContents* web_contents)
92 : render_process_id(web_contents->GetRenderProcessHost()->GetID()), 87 : session_id(SessionTabHelper::IdForTab(web_contents)),
93 render_frame_id(web_contents->GetMainFrame()->GetRoutingID()), 88 main_frame_url(web_contents->GetURL()),
94 main_frame_url(web_contents->GetURL()) { 89 creation_time(base::TimeTicks::Now()) {}
95 }
96 90
97 NavigationID::NavigationID(content::WebContents* web_contents, 91 NavigationID::NavigationID(content::WebContents* web_contents,
98 const GURL& main_frame_url, 92 const GURL& main_frame_url,
99 const base::TimeTicks& creation_time) 93 const base::TimeTicks& creation_time)
100 : render_process_id(web_contents->GetRenderProcessHost()->GetID()), 94 : session_id(SessionTabHelper::IdForTab(web_contents)),
101 render_frame_id(web_contents->GetMainFrame()->GetRoutingID()),
102 main_frame_url(main_frame_url), 95 main_frame_url(main_frame_url),
103 creation_time(creation_time) {} 96 creation_time(creation_time) {}
104 97
105 bool NavigationID::is_valid() const { 98 bool NavigationID::is_valid() const {
106 return render_process_id != -1 && render_frame_id != -1 && 99 return session_id != -1 && !main_frame_url.is_empty();
107 !main_frame_url.is_empty();
108 } 100 }
109 101
110 bool NavigationID::operator<(const NavigationID& rhs) const { 102 bool NavigationID::operator<(const NavigationID& rhs) const {
111 DCHECK(is_valid() && rhs.is_valid()); 103 DCHECK(is_valid() && rhs.is_valid());
112 return std::tie(render_process_id, render_frame_id, main_frame_url) < 104 return std::tie(session_id, main_frame_url) <
113 std::tie(rhs.render_process_id, rhs.render_frame_id, rhs.main_frame_url); 105 std::tie(rhs.session_id, rhs.main_frame_url);
114 } 106 }
115 107
116 bool NavigationID::operator==(const NavigationID& rhs) const { 108 bool NavigationID::operator==(const NavigationID& rhs) const {
117 DCHECK(is_valid() && rhs.is_valid()); 109 DCHECK(is_valid() && rhs.is_valid());
118 return IsSameRenderer(rhs) && main_frame_url == rhs.main_frame_url; 110 return session_id == rhs.session_id && main_frame_url == rhs.main_frame_url;
119 }
120
121 bool NavigationID::IsSameRenderer(const NavigationID& other) const {
122 DCHECK(is_valid() && other.is_valid());
123 return render_process_id == other.render_process_id &&
124 render_frame_id == other.render_frame_id;
125 } 111 }
126 112
127 ResourcePrefetchPredictorConfig::ResourcePrefetchPredictorConfig() 113 ResourcePrefetchPredictorConfig::ResourcePrefetchPredictorConfig()
128 : mode(0), 114 : mode(0),
129 max_navigation_lifetime_seconds(60), 115 max_navigation_lifetime_seconds(60),
130 max_urls_to_track(500), 116 max_urls_to_track(500),
131 max_hosts_to_track(200), 117 max_hosts_to_track(200),
132 min_url_visit_count(2), 118 min_url_visit_count(2),
133 max_resources_per_entry(50), 119 max_resources_per_entry(50),
134 max_consecutive_misses(3), 120 max_consecutive_misses(3),
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 169
184 bool ResourcePrefetchPredictorConfig::IsMoreResourcesEnabledForTest() const { 170 bool ResourcePrefetchPredictorConfig::IsMoreResourcesEnabledForTest() const {
185 return max_resources_per_entry == 100; 171 return max_resources_per_entry == 100;
186 } 172 }
187 173
188 bool ResourcePrefetchPredictorConfig::IsSmallDBEnabledForTest() const { 174 bool ResourcePrefetchPredictorConfig::IsSmallDBEnabledForTest() const {
189 return max_urls_to_track == 200 && max_hosts_to_track == 100; 175 return max_urls_to_track == 200 && max_hosts_to_track == 100;
190 } 176 }
191 177
192 } // namespace predictors 178 } // namespace predictors
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698