| 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 <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| 11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 12 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
| 13 #include "chrome/browser/net/prediction_options.h" | 13 #include "chrome/browser/net/prediction_options.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 18 #include "content/public/browser/render_frame_host.h" |
| 18 #include "content/public/browser/render_process_host.h" | 19 #include "content/public/browser/render_process_host.h" |
| 19 #include "content/public/browser/render_view_host.h" | |
| 20 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 21 | 21 |
| 22 using base::FieldTrialList; | 22 using base::FieldTrialList; |
| 23 using std::string; | 23 using std::string; |
| 24 using std::vector; | 24 using std::vector; |
| 25 | 25 |
| 26 namespace predictors { | 26 namespace predictors { |
| 27 | 27 |
| 28 const char kSpeculativePrefetchingTrialName[] = | 28 const char kSpeculativePrefetchingTrialName[] = |
| 29 "SpeculativeResourcePrefetching"; | 29 "SpeculativeResourcePrefetching"; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 158 |
| 159 NavigationID::NavigationID(const NavigationID& other) | 159 NavigationID::NavigationID(const NavigationID& other) |
| 160 : render_process_id(other.render_process_id), | 160 : render_process_id(other.render_process_id), |
| 161 render_frame_id(other.render_frame_id), | 161 render_frame_id(other.render_frame_id), |
| 162 main_frame_url(other.main_frame_url), | 162 main_frame_url(other.main_frame_url), |
| 163 creation_time(other.creation_time) { | 163 creation_time(other.creation_time) { |
| 164 } | 164 } |
| 165 | 165 |
| 166 NavigationID::NavigationID(content::WebContents* web_contents) | 166 NavigationID::NavigationID(content::WebContents* web_contents) |
| 167 : render_process_id(web_contents->GetRenderProcessHost()->GetID()), | 167 : render_process_id(web_contents->GetRenderProcessHost()->GetID()), |
| 168 render_frame_id(web_contents->GetRenderViewHost()->GetRoutingID()), | 168 render_frame_id(web_contents->GetMainFrame()->GetRoutingID()), |
| 169 main_frame_url(web_contents->GetURL()) { | 169 main_frame_url(web_contents->GetURL()) { |
| 170 } | 170 } |
| 171 | 171 |
| 172 bool NavigationID::is_valid() const { | 172 bool NavigationID::is_valid() const { |
| 173 return render_process_id != -1 && render_frame_id != -1 && | 173 return render_process_id != -1 && render_frame_id != -1 && |
| 174 !main_frame_url.is_empty(); | 174 !main_frame_url.is_empty(); |
| 175 } | 175 } |
| 176 | 176 |
| 177 bool NavigationID::operator<(const NavigationID& rhs) const { | 177 bool NavigationID::operator<(const NavigationID& rhs) const { |
| 178 DCHECK(is_valid() && rhs.is_valid()); | 178 DCHECK(is_valid() && rhs.is_valid()); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 | 263 |
| 264 bool ResourcePrefetchPredictorConfig::IsMoreResourcesEnabledForTest() const { | 264 bool ResourcePrefetchPredictorConfig::IsMoreResourcesEnabledForTest() const { |
| 265 return max_resources_per_entry == 100; | 265 return max_resources_per_entry == 100; |
| 266 } | 266 } |
| 267 | 267 |
| 268 bool ResourcePrefetchPredictorConfig::IsSmallDBEnabledForTest() const { | 268 bool ResourcePrefetchPredictorConfig::IsSmallDBEnabledForTest() const { |
| 269 return max_urls_to_track == 200 && max_hosts_to_track == 100; | 269 return max_urls_to_track == 200 && max_hosts_to_track == 100; |
| 270 } | 270 } |
| 271 | 271 |
| 272 } // namespace predictors | 272 } // namespace predictors |
| OLD | NEW |