OLD | NEW |
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 } | 74 } |
75 | 75 |
76 return false; | 76 return false; |
77 } | 77 } |
78 | 78 |
79 NavigationID::NavigationID() | 79 NavigationID::NavigationID() |
80 : render_process_id(-1), | 80 : render_process_id(-1), |
81 render_frame_id(-1) { | 81 render_frame_id(-1) { |
82 } | 82 } |
83 | 83 |
84 NavigationID::NavigationID(int render_process_id, | |
85 int render_frame_id, | |
86 const GURL& main_frame_url) | |
87 : render_process_id(render_process_id), | |
88 render_frame_id(render_frame_id), | |
89 main_frame_url(main_frame_url) {} | |
90 | |
91 NavigationID::NavigationID(const NavigationID& other) | 84 NavigationID::NavigationID(const NavigationID& other) |
92 : render_process_id(other.render_process_id), | 85 : render_process_id(other.render_process_id), |
93 render_frame_id(other.render_frame_id), | 86 render_frame_id(other.render_frame_id), |
94 main_frame_url(other.main_frame_url), | 87 main_frame_url(other.main_frame_url), |
95 creation_time(other.creation_time) { | 88 creation_time(other.creation_time) { |
96 } | 89 } |
97 | 90 |
98 NavigationID::NavigationID(content::WebContents* web_contents) | 91 NavigationID::NavigationID(content::WebContents* web_contents) |
99 : render_process_id(web_contents->GetRenderProcessHost()->GetID()), | 92 : render_process_id(web_contents->GetRenderProcessHost()->GetID()), |
100 render_frame_id(web_contents->GetMainFrame()->GetRoutingID()), | 93 render_frame_id(web_contents->GetMainFrame()->GetRoutingID()), |
101 main_frame_url(web_contents->GetURL()) { | 94 main_frame_url(web_contents->GetURL()) { |
102 } | 95 } |
103 | 96 |
| 97 NavigationID::NavigationID(content::WebContents* web_contents, |
| 98 const GURL& main_frame_url, |
| 99 const base::TimeTicks& creation_time) |
| 100 : render_process_id(web_contents->GetRenderProcessHost()->GetID()), |
| 101 render_frame_id(web_contents->GetMainFrame()->GetRoutingID()), |
| 102 main_frame_url(main_frame_url), |
| 103 creation_time(creation_time) {} |
| 104 |
104 bool NavigationID::is_valid() const { | 105 bool NavigationID::is_valid() const { |
105 return render_process_id != -1 && render_frame_id != -1 && | 106 return render_process_id != -1 && render_frame_id != -1 && |
106 !main_frame_url.is_empty(); | 107 !main_frame_url.is_empty(); |
107 } | 108 } |
108 | 109 |
109 bool NavigationID::operator<(const NavigationID& rhs) const { | 110 bool NavigationID::operator<(const NavigationID& rhs) const { |
110 DCHECK(is_valid() && rhs.is_valid()); | 111 DCHECK(is_valid() && rhs.is_valid()); |
111 return std::tie(render_process_id, render_frame_id, main_frame_url) < | 112 return std::tie(render_process_id, render_frame_id, main_frame_url) < |
112 std::tie(rhs.render_process_id, rhs.render_frame_id, rhs.main_frame_url); | 113 std::tie(rhs.render_process_id, rhs.render_frame_id, rhs.main_frame_url); |
113 } | 114 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 | 183 |
183 bool ResourcePrefetchPredictorConfig::IsMoreResourcesEnabledForTest() const { | 184 bool ResourcePrefetchPredictorConfig::IsMoreResourcesEnabledForTest() const { |
184 return max_resources_per_entry == 100; | 185 return max_resources_per_entry == 100; |
185 } | 186 } |
186 | 187 |
187 bool ResourcePrefetchPredictorConfig::IsSmallDBEnabledForTest() const { | 188 bool ResourcePrefetchPredictorConfig::IsSmallDBEnabledForTest() const { |
188 return max_urls_to_track == 200 && max_hosts_to_track == 100; | 189 return max_urls_to_track == 200 && max_hosts_to_track == 100; |
189 } | 190 } |
190 | 191 |
191 } // namespace predictors | 192 } // namespace predictors |
OLD | NEW |