| 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_predictor.h" | 5 #include "chrome/browser/predictors/resource_prefetch_predictor.h" |
| 6 | 6 |
| 7 #include <iostream> | 7 #include <iostream> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 | 229 |
| 230 void ResetPredictor() { | 230 void ResetPredictor() { |
| 231 ResourcePrefetchPredictorConfig config; | 231 ResourcePrefetchPredictorConfig config; |
| 232 config.max_urls_to_track = 3; | 232 config.max_urls_to_track = 3; |
| 233 config.max_hosts_to_track = 2; | 233 config.max_hosts_to_track = 2; |
| 234 config.min_url_visit_count = 2; | 234 config.min_url_visit_count = 2; |
| 235 config.max_resources_per_entry = 4; | 235 config.max_resources_per_entry = 4; |
| 236 config.max_consecutive_misses = 2; | 236 config.max_consecutive_misses = 2; |
| 237 config.min_resource_confidence_to_trigger_prefetch = 0.5; | 237 config.min_resource_confidence_to_trigger_prefetch = 0.5; |
| 238 config.is_url_learning_enabled = true; | 238 config.is_url_learning_enabled = true; |
| 239 config.is_manifests_enabled = true; |
| 239 | 240 |
| 240 config.mode |= ResourcePrefetchPredictorConfig::LEARNING; | 241 config.mode |= ResourcePrefetchPredictorConfig::LEARNING; |
| 241 predictor_.reset(new ResourcePrefetchPredictor(config, profile_.get())); | 242 predictor_.reset(new ResourcePrefetchPredictor(config, profile_.get())); |
| 242 predictor_->set_mock_tables(mock_tables_); | 243 predictor_->set_mock_tables(mock_tables_); |
| 243 } | 244 } |
| 244 | 245 |
| 245 void InitializeSampleData(); | 246 void InitializeSampleData(); |
| 246 void TestRedirectStatusHistogram( | 247 void TestRedirectStatusHistogram( |
| 247 const std::string& predictor_initial_key, | 248 const std::string& predictor_initial_key, |
| 248 const std::string& predictor_key, | 249 const std::string& predictor_key, |
| (...skipping 1610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1859 predictor_->host_table_cache_->insert( | 1860 predictor_->host_table_cache_->insert( |
| 1860 std::make_pair(google.primary_key(), google)); | 1861 std::make_pair(google.primary_key(), google)); |
| 1861 | 1862 |
| 1862 predictor_->StartPrefetching(GURL(main_frame_url), PrefetchOrigin::EXTERNAL); | 1863 predictor_->StartPrefetching(GURL(main_frame_url), PrefetchOrigin::EXTERNAL); |
| 1863 predictor_->StopPrefetching(GURL(main_frame_url)); | 1864 predictor_->StopPrefetching(GURL(main_frame_url)); |
| 1864 histogram_tester_->ExpectTotalCount( | 1865 histogram_tester_->ExpectTotalCount( |
| 1865 internal::kResourcePrefetchPredictorPrefetchingDurationHistogram, 1); | 1866 internal::kResourcePrefetchPredictorPrefetchingDurationHistogram, 1); |
| 1866 } | 1867 } |
| 1867 | 1868 |
| 1868 } // namespace predictors | 1869 } // namespace predictors |
| OLD | NEW |