| 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 224   } | 224   } | 
| 225 | 225 | 
| 226   void ResetPredictor() { | 226   void ResetPredictor() { | 
| 227     ResourcePrefetchPredictorConfig config; | 227     ResourcePrefetchPredictorConfig config; | 
| 228     config.max_urls_to_track = 3; | 228     config.max_urls_to_track = 3; | 
| 229     config.max_hosts_to_track = 2; | 229     config.max_hosts_to_track = 2; | 
| 230     config.min_url_visit_count = 2; | 230     config.min_url_visit_count = 2; | 
| 231     config.max_resources_per_entry = 4; | 231     config.max_resources_per_entry = 4; | 
| 232     config.max_consecutive_misses = 2; | 232     config.max_consecutive_misses = 2; | 
| 233     config.min_resource_confidence_to_trigger_prefetch = 0.5; | 233     config.min_resource_confidence_to_trigger_prefetch = 0.5; | 
|  | 234     config.is_url_learning_enabled = true; | 
| 234 | 235 | 
| 235     // TODO(shishir): Enable the prefetching mode in the tests. |  | 
| 236     config.mode |= ResourcePrefetchPredictorConfig::LEARNING; | 236     config.mode |= ResourcePrefetchPredictorConfig::LEARNING; | 
| 237     predictor_.reset(new ResourcePrefetchPredictor(config, profile_.get())); | 237     predictor_.reset(new ResourcePrefetchPredictor(config, profile_.get())); | 
| 238     predictor_->set_mock_tables(mock_tables_); | 238     predictor_->set_mock_tables(mock_tables_); | 
| 239   } | 239   } | 
| 240 | 240 | 
| 241   void InitializeSampleData(); | 241   void InitializeSampleData(); | 
| 242   void TestRedirectStatusHistogram( | 242   void TestRedirectStatusHistogram( | 
| 243       const std::string& predictor_initial_key, | 243       const std::string& predictor_initial_key, | 
| 244       const std::string& predictor_key, | 244       const std::string& predictor_key, | 
| 245       const std::string& navigation_initial_url, | 245       const std::string& navigation_initial_url, | 
| (...skipping 1463 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1709   predictor_->host_table_cache_->insert( | 1709   predictor_->host_table_cache_->insert( | 
| 1710       std::make_pair(google.primary_key(), google)); | 1710       std::make_pair(google.primary_key(), google)); | 
| 1711 | 1711 | 
| 1712   predictor_->StartPrefetching(GURL(main_frame_url), PrefetchOrigin::EXTERNAL); | 1712   predictor_->StartPrefetching(GURL(main_frame_url), PrefetchOrigin::EXTERNAL); | 
| 1713   predictor_->StopPrefetching(GURL(main_frame_url)); | 1713   predictor_->StopPrefetching(GURL(main_frame_url)); | 
| 1714   histogram_tester_->ExpectTotalCount( | 1714   histogram_tester_->ExpectTotalCount( | 
| 1715       internal::kResourcePrefetchPredictorPrefetchingDurationHistogram, 1); | 1715       internal::kResourcePrefetchPredictorPrefetchingDurationHistogram, 1); | 
| 1716 } | 1716 } | 
| 1717 | 1717 | 
| 1718 }  // namespace predictors | 1718 }  // namespace predictors | 
| OLD | NEW | 
|---|