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

Unified Diff: chrome/browser/predictors/resource_prefetch_common.cc

Issue 2587443002: predictors: Make speculative_prefetch_predictor work with PlzNavigate (Closed)
Patch Set: Reworked Tests 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/predictors/resource_prefetch_common.cc
diff --git a/chrome/browser/predictors/resource_prefetch_common.cc b/chrome/browser/predictors/resource_prefetch_common.cc
index 25e0f43a87d8fe2dea6ecaff002fb685362a67f1..6b79557d462b06d62cc885b23af1907ebd876f71 100644
--- a/chrome/browser/predictors/resource_prefetch_common.cc
+++ b/chrome/browser/predictors/resource_prefetch_common.cc
@@ -76,52 +76,54 @@ bool IsSpeculativeResourcePrefetchingEnabled(
return false;
}
-NavigationID::NavigationID()
- : render_process_id(-1),
- render_frame_id(-1) {
+NavigationID::NavigationID() : frame_tree_node_id(-1) {
+ session_id.set_id(-1); // Invalid.
}
NavigationID::NavigationID(const NavigationID& other)
- : render_process_id(other.render_process_id),
- render_frame_id(other.render_frame_id),
+ : session_id(other.session_id),
+ frame_tree_node_id(other.frame_tree_node_id),
main_frame_url(other.main_frame_url),
- creation_time(other.creation_time) {
-}
+ creation_time(other.creation_time) {}
NavigationID::NavigationID(content::WebContents* web_contents)
- : render_process_id(web_contents->GetRenderProcessHost()->GetID()),
- render_frame_id(web_contents->GetMainFrame()->GetRoutingID()),
- main_frame_url(web_contents->GetURL()) {
+ : frame_tree_node_id(web_contents->GetMainFrame()->GetFrameTreeNodeId()),
+ main_frame_url(web_contents->GetURL()),
+ creation_time(base::TimeTicks::Now()) {
+ session_id.set_id(SessionTabHelper::IdForTab(web_contents));
}
NavigationID::NavigationID(content::WebContents* web_contents,
const GURL& main_frame_url,
const base::TimeTicks& creation_time)
- : render_process_id(web_contents->GetRenderProcessHost()->GetID()),
- render_frame_id(web_contents->GetMainFrame()->GetRoutingID()),
+ : frame_tree_node_id(web_contents->GetMainFrame()->GetFrameTreeNodeId()),
main_frame_url(main_frame_url),
- creation_time(creation_time) {}
+ creation_time(creation_time) {
+ session_id.set_id(SessionTabHelper::IdForTab(web_contents));
+}
bool NavigationID::is_valid() const {
- return render_process_id != -1 && render_frame_id != -1 &&
- !main_frame_url.is_empty();
+ return session_id.id() != -1 && !main_frame_url.is_empty();
ahemery 2016/12/19 14:53:41 frame_tree_node_id can be -1 and still be valid so
}
bool NavigationID::operator<(const NavigationID& rhs) const {
DCHECK(is_valid() && rhs.is_valid());
- return std::tie(render_process_id, render_frame_id, main_frame_url) <
- std::tie(rhs.render_process_id, rhs.render_frame_id, rhs.main_frame_url);
+ // Quick int copy to be able to use tie.
ahemery 2016/12/19 14:53:41 Tie uses lvalues
+ int id_lhs = session_id.id();
+ int id_rhs = rhs.session_id.id();
+ return std::tie(id_lhs, frame_tree_node_id, main_frame_url) <
+ std::tie(id_rhs, rhs.frame_tree_node_id, rhs.main_frame_url);
}
bool NavigationID::operator==(const NavigationID& rhs) const {
DCHECK(is_valid() && rhs.is_valid());
- return IsSameRenderer(rhs) && main_frame_url == rhs.main_frame_url;
+ return IsSameLocation(rhs) && main_frame_url == rhs.main_frame_url;
}
-bool NavigationID::IsSameRenderer(const NavigationID& other) const {
+bool NavigationID::IsSameLocation(const NavigationID& other) const {
DCHECK(is_valid() && other.is_valid());
- return render_process_id == other.render_process_id &&
- render_frame_id == other.render_frame_id;
+ return session_id.id() == other.session_id.id() &&
+ frame_tree_node_id == other.frame_tree_node_id;
}
ResourcePrefetchPredictorConfig::ResourcePrefetchPredictorConfig()

Powered by Google App Engine
This is Rietveld 408576698