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