| 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 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 : loop_(base::MessageLoop::TYPE_DEFAULT), | 173 : loop_(base::MessageLoop::TYPE_DEFAULT), |
| 174 ui_thread_(content::BrowserThread::UI, &loop_), | 174 ui_thread_(content::BrowserThread::UI, &loop_), |
| 175 db_thread_(content::BrowserThread::DB, &loop_), | 175 db_thread_(content::BrowserThread::DB, &loop_), |
| 176 profile_(new TestingProfile()), | 176 profile_(new TestingProfile()), |
| 177 mock_tables_(new StrictMock<MockResourcePrefetchPredictorTables>()), | 177 mock_tables_(new StrictMock<MockResourcePrefetchPredictorTables>()), |
| 178 empty_url_data_(PREFETCH_KEY_TYPE_URL, std::string()), | 178 empty_url_data_(PREFETCH_KEY_TYPE_URL, std::string()), |
| 179 empty_host_data_(PREFETCH_KEY_TYPE_HOST, std::string()) {} | 179 empty_host_data_(PREFETCH_KEY_TYPE_HOST, std::string()) {} |
| 180 | 180 |
| 181 ResourcePrefetchPredictorTest::~ResourcePrefetchPredictorTest() { | 181 ResourcePrefetchPredictorTest::~ResourcePrefetchPredictorTest() { |
| 182 profile_.reset(NULL); | 182 profile_.reset(NULL); |
| 183 loop_.RunUntilIdle(); | 183 base::RunLoop().RunUntilIdle(); |
| 184 } | 184 } |
| 185 | 185 |
| 186 void ResourcePrefetchPredictorTest::SetUp() { | 186 void ResourcePrefetchPredictorTest::SetUp() { |
| 187 InitializeSampleData(); | 187 InitializeSampleData(); |
| 188 | 188 |
| 189 ASSERT_TRUE(profile_->CreateHistoryService(true, false)); | 189 ASSERT_TRUE(profile_->CreateHistoryService(true, false)); |
| 190 profile_->BlockUntilHistoryProcessesPendingRequests(); | 190 profile_->BlockUntilHistoryProcessesPendingRequests(); |
| 191 EXPECT_TRUE(HistoryServiceFactory::GetForProfile( | 191 EXPECT_TRUE(HistoryServiceFactory::GetForProfile( |
| 192 profile_.get(), ServiceAccessType::EXPLICIT_ACCESS)); | 192 profile_.get(), ServiceAccessType::EXPLICIT_ACCESS)); |
| 193 // Initialize the predictor with empty data. | 193 // Initialize the predictor with empty data. |
| (...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 // The page load time will be collected by RPP_HISTOGRAM_MEDIUM_TIMES, which | 963 // The page load time will be collected by RPP_HISTOGRAM_MEDIUM_TIMES, which |
| 964 // has a upper bound of 3 minutes. | 964 // has a upper bound of 3 minutes. |
| 965 base::TimeDelta plt = | 965 base::TimeDelta plt = |
| 966 predictor_->OnNavigationComplete(main_frame.navigation_id); | 966 predictor_->OnNavigationComplete(main_frame.navigation_id); |
| 967 EXPECT_LT(plt, base::TimeDelta::FromSeconds(180)); | 967 EXPECT_LT(plt, base::TimeDelta::FromSeconds(180)); |
| 968 | 968 |
| 969 profile_->BlockUntilHistoryProcessesPendingRequests(); | 969 profile_->BlockUntilHistoryProcessesPendingRequests(); |
| 970 } | 970 } |
| 971 | 971 |
| 972 } // namespace predictors | 972 } // namespace predictors |
| OLD | NEW |