Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: chrome/browser/net/predictor_browsertest.cc

Issue 1857573002: [reland] Change net's predictor_tab_helper to use the new content Navigation API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update finch test config on chromeos Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/net/predictor_tab_helper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 EXPECT_EQ(0u, cross_site_connection_listener_->GetAcceptedSocketCount()); 1060 EXPECT_EQ(0u, cross_site_connection_listener_->GetAcceptedSocketCount());
1061 1061
1062 ui_test_utils::NavigateToURL(browser(), 1062 ui_test_utils::NavigateToURL(browser(),
1063 embedded_test_server()->GetURL("/title1.html")); 1063 embedded_test_server()->GetURL("/title1.html"));
1064 // 3 preconnects expected because ((2 + .33)*.66 + .33)*.66 + 1 = 2.23. 1064 // 3 preconnects expected because ((2 + .33)*.66 + .33)*.66 + 1 = 2.23.
1065 EXPECT_EQ(3, observer()->CrossSitePreconnected()); 1065 EXPECT_EQ(3, observer()->CrossSitePreconnected());
1066 cross_site_connection_listener_->WaitForAcceptedConnectionsOnUI(3u); 1066 cross_site_connection_listener_->WaitForAcceptedConnectionsOnUI(3u);
1067 } 1067 }
1068 1068
1069 IN_PROC_BROWSER_TEST_F(PredictorBrowserTest, 1069 IN_PROC_BROWSER_TEST_F(PredictorBrowserTest,
1070 RendererInitiatedNavigationPreconnect) {
1071 NavigateToCrossSiteHtmlUrl(1 /* num_cors */, "" /* file_suffix */);
1072 EXPECT_EQ(1, observer()->CrossSiteLearned());
1073 EXPECT_EQ(0u, cross_site_connection_listener_->GetAcceptedSocketCount());
1074
1075 // Now, navigate using a renderer initiated navigation and expect preconnects.
1076 EXPECT_TRUE(content::ExecuteScript(
1077 browser()->tab_strip_model()->GetActiveWebContents(),
1078 "window.location.href='/title1.html'"));
1079
1080 // The renderer initiated navigation is not synchronous, so just wait for the
1081 // preconnects to go through.
1082 // Note that ceil(2 + .33) + 1 = 4.
1083 cross_site_connection_listener_->WaitForAcceptedConnectionsOnUI(4u);
1084 }
1085
1086 IN_PROC_BROWSER_TEST_F(PredictorBrowserTest,
1070 PRE_ShutdownStartupCyclePreresolve) { 1087 PRE_ShutdownStartupCyclePreresolve) {
1071 // Prepare state that will be serialized on this shut-down and read on next 1088 // Prepare state that will be serialized on this shut-down and read on next
1072 // start-up. Ensure preresolution over preconnection. 1089 // start-up. Ensure preresolution over preconnection.
1073 LearnAboutInitialNavigation(startup_url_); 1090 LearnAboutInitialNavigation(startup_url_);
1074 // The target url will have a expected connection count of 2 after this call. 1091 // The target url will have a expected connection count of 2 after this call.
1075 InstallPredictorObserver(referring_url_, target_url_); 1092 InstallPredictorObserver(referring_url_, target_url_);
1076 LearnFromNavigation(referring_url_, target_url_); 1093 LearnFromNavigation(referring_url_, target_url_);
1077 1094
1078 // In order to reduce the expected connection count < .8, issue predictions 3 1095 // In order to reduce the expected connection count < .8, issue predictions 3
1079 // times. 2 * .66^3 ~= .58. 1096 // times. 2 * .66^3 ~= .58.
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 // Second navigation to content with an img. 1237 // Second navigation to content with an img.
1221 std::string img_content = 1238 std::string img_content =
1222 "<img src=\"" + preconnect_url.spec() + "test.gif\">"; 1239 "<img src=\"" + preconnect_url.spec() + "test.gif\">";
1223 NavigateToDataURLWithContent(img_content); 1240 NavigateToDataURLWithContent(img_content);
1224 connection_listener_->WaitUntilFirstConnectionRead(); 1241 connection_listener_->WaitUntilFirstConnectionRead();
1225 EXPECT_EQ(2u, connection_listener_->GetAcceptedSocketCount()); 1242 EXPECT_EQ(2u, connection_listener_->GetAcceptedSocketCount());
1226 EXPECT_EQ(1u, connection_listener_->GetReadSocketCount()); 1243 EXPECT_EQ(1u, connection_listener_->GetReadSocketCount());
1227 } 1244 }
1228 1245
1229 } // namespace chrome_browser_net 1246 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/net/predictor_tab_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698