Chromium Code Reviews| 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 1583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1594 1, main_frame_url, script_url + "2", content::RESOURCE_TYPE_SCRIPT); | 1594 1, main_frame_url, script_url + "2", content::RESOURCE_TYPE_SCRIPT); |
| 1595 predictor_->RecordURLResponse(new_script); | 1595 predictor_->RecordURLResponse(new_script); |
| 1596 | 1596 |
| 1597 predictor_->RecordMainFrameLoadComplete(main_frame.navigation_id); | 1597 predictor_->RecordMainFrameLoadComplete(main_frame.navigation_id); |
| 1598 profile_->BlockUntilHistoryProcessesPendingRequests(); | 1598 profile_->BlockUntilHistoryProcessesPendingRequests(); |
| 1599 | 1599 |
| 1600 histogram_tester_->ExpectBucketCount( | 1600 histogram_tester_->ExpectBucketCount( |
| 1601 internal::kResourcePrefetchPredictorRecallHistogram, 50, 1); | 1601 internal::kResourcePrefetchPredictorRecallHistogram, 50, 1); |
| 1602 histogram_tester_->ExpectBucketCount( | 1602 histogram_tester_->ExpectBucketCount( |
| 1603 internal::kResourcePrefetchPredictorPrecisionHistogram, 33, 1); | 1603 internal::kResourcePrefetchPredictorPrecisionHistogram, 33, 1); |
| 1604 histogram_tester_->ExpectBucketCount( | |
| 1605 internal::kResourcePrefetchPredictorCountHistogram, 3, 1); | |
| 1606 } | |
| 1607 | |
| 1608 TEST_F(ResourcePrefetchPredictorTest, TestPrefetchingDurationHistogram) { | |
| 1609 // Prefetching duration for an url without resoruces in the database | |
|
Benoit L
2017/02/09 02:24:52
nit: resources
alexilin
2017/02/09 15:50:19
Done.
| |
| 1610 // shouldn't be recorded. | |
| 1611 const std::string main_frame_url = "http://google.com/?query=cats"; | |
| 1612 predictor_->StartPrefetching(GURL(main_frame_url), PrefetchOrigin::EXTERNAL); | |
| 1613 predictor_->StopPrefetching(GURL(main_frame_url)); | |
| 1614 histogram_tester_->ExpectTotalCount( | |
| 1615 internal::kResourcePrefetchPredictorPrefetchingDurationHistogram, 0); | |
| 1616 | |
| 1617 // Fill the database to record a duration. | |
| 1618 PrefetchData google = CreatePrefetchData("google.com", 1); | |
| 1619 InitializeResourceData( | |
| 1620 google.add_resources(), "https://cdn.google.com/script.js", | |
| 1621 content::RESOURCE_TYPE_SCRIPT, 10, 0, 1, 2.1, net::MEDIUM, false, false); | |
| 1622 predictor_->host_table_cache_->insert( | |
| 1623 std::make_pair(google.primary_key(), google)); | |
| 1624 | |
| 1625 predictor_->StartPrefetching(GURL(main_frame_url), PrefetchOrigin::EXTERNAL); | |
| 1626 predictor_->StopPrefetching(GURL(main_frame_url)); | |
| 1627 histogram_tester_->ExpectTotalCount( | |
| 1628 internal::kResourcePrefetchPredictorPrefetchingDurationHistogram, 1); | |
| 1604 } | 1629 } |
| 1605 | 1630 |
| 1606 } // namespace predictors | 1631 } // namespace predictors |
| OLD | NEW |