| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1352 LearnAboutInitialNavigation(startup_url_); | 1352 LearnAboutInitialNavigation(startup_url_); |
| 1353 // The target URL will have an expected connection count of 2 after this call. | 1353 // The target URL will have an expected connection count of 2 after this call. |
| 1354 InstallPredictorObserver(referring_url_, target_url_); | 1354 InstallPredictorObserver(referring_url_, target_url_); |
| 1355 LearnFromNavigation(referring_url_, target_url_); | 1355 LearnFromNavigation(referring_url_, target_url_); |
| 1356 | 1356 |
| 1357 // In order to reduce the expected connection count < .8, issue predictions 3 | 1357 // In order to reduce the expected connection count < .8, issue predictions 3 |
| 1358 // times. 2 * .66^3 ~= .58. | 1358 // times. 2 * .66^3 ~= .58. |
| 1359 PrepareFrameSubresources(referring_url_); | 1359 PrepareFrameSubresources(referring_url_); |
| 1360 PrepareFrameSubresources(referring_url_); | 1360 PrepareFrameSubresources(referring_url_); |
| 1361 PrepareFrameSubresources(referring_url_); | 1361 PrepareFrameSubresources(referring_url_); |
| 1362 |
| 1363 // The onload event is required to persist prefs. |
| 1364 ui_test_utils::NavigateToURL(browser(), referring_url_); |
| 1362 } | 1365 } |
| 1363 | 1366 |
| 1364 IN_PROC_BROWSER_TEST_F(PredictorBrowserTest, ShutdownStartupCyclePreresolve) { | 1367 IN_PROC_BROWSER_TEST_F(PredictorBrowserTest, ShutdownStartupCyclePreresolve) { |
| 1365 // Make sure this data has been loaded into the Predictor, by inspecting that | 1368 // Make sure this data has been loaded into the Predictor, by inspecting that |
| 1366 // the Predictor starts making the expected hostname requests. | 1369 // the Predictor starts making the expected hostname requests. |
| 1367 PrepareFrameSubresources(referring_url_); | 1370 PrepareFrameSubresources(referring_url_); |
| 1368 observer()->WaitUntilHostLookedUp(target_url_); | 1371 observer()->WaitUntilHostLookedUp(target_url_); |
| 1369 | 1372 |
| 1370 // Verify that both urls were requested by the predictor. Note that the | 1373 // Verify that both urls were requested by the predictor. Note that the |
| 1371 // startup URL may be requested before the observer attaches itself. | 1374 // startup URL may be requested before the observer attaches itself. |
| 1372 ExpectUrlRequestedFromPredictor(startup_url_); | 1375 ExpectUrlRequestedFromPredictor(startup_url_); |
| 1373 EXPECT_FALSE(observer()->HostFound(target_url_)); | 1376 EXPECT_FALSE(observer()->HostFound(target_url_)); |
| 1374 } | 1377 } |
| 1375 | 1378 |
| 1376 IN_PROC_BROWSER_TEST_F(PredictorBrowserTest, PRE_ClearData) { | 1379 IN_PROC_BROWSER_TEST_F(PredictorBrowserTest, PRE_ClearData) { |
| 1377 // The target url will have a expected connection count of 2 after this call. | 1380 // The target url will have a expected connection count of 2 after this call. |
| 1378 InstallPredictorObserver(referring_url_, target_url_); | 1381 InstallPredictorObserver(referring_url_, target_url_); |
| 1379 LearnFromNavigation(referring_url_, target_url_); | 1382 LearnFromNavigation(referring_url_, target_url_); |
| 1383 |
| 1384 // The onload event is required to persist prefs. |
| 1385 ui_test_utils::NavigateToURL(browser(), referring_url_); |
| 1380 } | 1386 } |
| 1381 | 1387 |
| 1382 // Ensure predictive data is cleared when the history is cleared. | 1388 // Ensure predictive data is cleared when the history is cleared. |
| 1383 IN_PROC_BROWSER_TEST_F(PredictorBrowserTest, ClearData) { | 1389 IN_PROC_BROWSER_TEST_F(PredictorBrowserTest, ClearData) { |
| 1384 std::string cleared_startup_list; | 1390 std::string cleared_startup_list; |
| 1385 std::string cleared_referral_list; | 1391 std::string cleared_referral_list; |
| 1386 | 1392 |
| 1387 // The pref should persist after startup. | 1393 // The pref should persist after startup. |
| 1388 GetListFromPrefsAsString(prefs::kDnsPrefetchingStartupList, | 1394 GetListFromPrefsAsString(prefs::kDnsPrefetchingStartupList, |
| 1389 &cleared_startup_list); | 1395 &cleared_startup_list); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1549 // Second navigation to content with an img. | 1555 // Second navigation to content with an img. |
| 1550 std::string img_content = | 1556 std::string img_content = |
| 1551 "<img src=\"" + preconnect_url.spec() + "test.gif\">"; | 1557 "<img src=\"" + preconnect_url.spec() + "test.gif\">"; |
| 1552 NavigateToDataURLWithContent(img_content); | 1558 NavigateToDataURLWithContent(img_content); |
| 1553 connection_listener_->WaitUntilFirstConnectionRead(); | 1559 connection_listener_->WaitUntilFirstConnectionRead(); |
| 1554 EXPECT_EQ(2u, connection_listener_->GetAcceptedSocketCount()); | 1560 EXPECT_EQ(2u, connection_listener_->GetAcceptedSocketCount()); |
| 1555 EXPECT_EQ(1u, connection_listener_->GetReadSocketCount()); | 1561 EXPECT_EQ(1u, connection_listener_->GetReadSocketCount()); |
| 1556 } | 1562 } |
| 1557 | 1563 |
| 1558 } // namespace chrome_browser_net | 1564 } // namespace chrome_browser_net |
| OLD | NEW |