| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_predictor_test_util.h" | 5 #include "chrome/browser/predictors/resource_prefetch_predictor_test_util.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "chrome/browser/predictors/resource_prefetch_predictor_tables.h" | |
| 10 | |
| 11 namespace predictors { | 9 namespace predictors { |
| 12 | 10 |
| 13 using URLRequestSummary = ResourcePrefetchPredictor::URLRequestSummary; | 11 using URLRequestSummary = ResourcePrefetchPredictor::URLRequestSummary; |
| 14 using PageRequestSummary = ResourcePrefetchPredictor::PageRequestSummary; | 12 using PageRequestSummary = ResourcePrefetchPredictor::PageRequestSummary; |
| 15 | 13 |
| 16 void InitializeResourceData(ResourceData* resource, | 14 void InitializeResourceData(ResourceData* resource, |
| 17 const std::string& resource_url, | 15 const std::string& resource_url, |
| 18 content::ResourceType resource_type, | 16 content::ResourceType resource_type, |
| 19 int number_of_hits, | 17 int number_of_hits, |
| 20 int number_of_misses, | 18 int number_of_misses, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 } | 60 } |
| 63 | 61 |
| 64 RedirectData CreateRedirectData(const std::string& primary_key, | 62 RedirectData CreateRedirectData(const std::string& primary_key, |
| 65 uint64_t last_visit_time) { | 63 uint64_t last_visit_time) { |
| 66 RedirectData data; | 64 RedirectData data; |
| 67 data.set_primary_key(primary_key); | 65 data.set_primary_key(primary_key); |
| 68 data.set_last_visit_time(last_visit_time); | 66 data.set_last_visit_time(last_visit_time); |
| 69 return data; | 67 return data; |
| 70 } | 68 } |
| 71 | 69 |
| 70 precache::PrecacheManifest CreateManifestData(uint64_t id) { |
| 71 precache::PrecacheManifestId* manifest_id = |
| 72 new precache::PrecacheManifestId(); |
| 73 manifest_id->set_id(id); |
| 74 precache::PrecacheManifest manifest; |
| 75 manifest.set_allocated_id(manifest_id); |
| 76 return manifest; |
| 77 } |
| 78 |
| 72 NavigationID CreateNavigationID(SessionID::id_type tab_id, | 79 NavigationID CreateNavigationID(SessionID::id_type tab_id, |
| 73 const std::string& main_frame_url) { | 80 const std::string& main_frame_url) { |
| 74 NavigationID navigation_id; | 81 NavigationID navigation_id; |
| 75 navigation_id.tab_id = tab_id; | 82 navigation_id.tab_id = tab_id; |
| 76 navigation_id.main_frame_url = GURL(main_frame_url); | 83 navigation_id.main_frame_url = GURL(main_frame_url); |
| 77 navigation_id.creation_time = base::TimeTicks::Now(); | 84 navigation_id.creation_time = base::TimeTicks::Now(); |
| 78 return navigation_id; | 85 return navigation_id; |
| 79 } | 86 } |
| 80 | 87 |
| 81 PageRequestSummary CreatePageRequestSummary( | 88 PageRequestSummary CreatePageRequestSummary( |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 return equal; | 264 return equal; |
| 258 } | 265 } |
| 259 | 266 |
| 260 bool operator==(const PrecacheResource& lhs, const PrecacheResource& rhs) { | 267 bool operator==(const PrecacheResource& lhs, const PrecacheResource& rhs) { |
| 261 return lhs.url() == rhs.url() && | 268 return lhs.url() == rhs.url() && |
| 262 std::fabs(lhs.weight_ratio() - rhs.weight_ratio()) < | 269 std::fabs(lhs.weight_ratio() - rhs.weight_ratio()) < |
| 263 std::numeric_limits<double>::epsilon(); | 270 std::numeric_limits<double>::epsilon(); |
| 264 } | 271 } |
| 265 | 272 |
| 266 } // namespace precache | 273 } // namespace precache |
| OLD | NEW |