| 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 void ResetPredictor() { | 236 void ResetPredictor() { |
| 237 ResourcePrefetchPredictorConfig config; | 237 ResourcePrefetchPredictorConfig config; |
| 238 config.max_urls_to_track = 3; | 238 config.max_urls_to_track = 3; |
| 239 config.max_hosts_to_track = 2; | 239 config.max_hosts_to_track = 2; |
| 240 config.min_url_visit_count = 2; | 240 config.min_url_visit_count = 2; |
| 241 config.max_resources_per_entry = 4; | 241 config.max_resources_per_entry = 4; |
| 242 config.max_consecutive_misses = 2; | 242 config.max_consecutive_misses = 2; |
| 243 config.min_resource_confidence_to_trigger_prefetch = 0.5; | 243 config.min_resource_confidence_to_trigger_prefetch = 0.5; |
| 244 | 244 |
| 245 // TODO(shishir): Enable the prefetching mode in the tests. | 245 // TODO(shishir): Enable the prefetching mode in the tests. |
| 246 config.mode |= ResourcePrefetchPredictorConfig::URL_LEARNING; | 246 config.mode |= ResourcePrefetchPredictorConfig::LEARNING; |
| 247 config.mode |= ResourcePrefetchPredictorConfig::HOST_LEARNING; | |
| 248 predictor_.reset(new ResourcePrefetchPredictor(config, profile_.get())); | 247 predictor_.reset(new ResourcePrefetchPredictor(config, profile_.get())); |
| 249 predictor_->set_mock_tables(mock_tables_); | 248 predictor_->set_mock_tables(mock_tables_); |
| 250 } | 249 } |
| 251 | 250 |
| 252 void InitializeSampleData(); | 251 void InitializeSampleData(); |
| 253 | 252 |
| 254 content::TestBrowserThreadBundle thread_bundle_; | 253 content::TestBrowserThreadBundle thread_bundle_; |
| 255 std::unique_ptr<TestingProfile> profile_; | 254 std::unique_ptr<TestingProfile> profile_; |
| 256 net::TestURLRequestContext url_request_context_; | 255 net::TestURLRequestContext url_request_context_; |
| 257 | 256 |
| (...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1544 net::MEDIUM, false, false); | 1543 net::MEDIUM, false, false); |
| 1545 predictor_->url_table_cache_->insert( | 1544 predictor_->url_table_cache_->insert( |
| 1546 std::make_pair(www_google_url.primary_key(), www_google_url)); | 1545 std::make_pair(www_google_url.primary_key(), www_google_url)); |
| 1547 | 1546 |
| 1548 urls.clear(); | 1547 urls.clear(); |
| 1549 EXPECT_TRUE(predictor_->GetPrefetchData(main_frame_url, &urls)); | 1548 EXPECT_TRUE(predictor_->GetPrefetchData(main_frame_url, &urls)); |
| 1550 EXPECT_THAT(urls, UnorderedElementsAre(GURL(font_url))); | 1549 EXPECT_THAT(urls, UnorderedElementsAre(GURL(font_url))); |
| 1551 } | 1550 } |
| 1552 | 1551 |
| 1553 } // namespace predictors | 1552 } // namespace predictors |
| OLD | NEW |