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

Unified Diff: chrome/browser/net/predictor_browsertest.cc

Issue 2871323006: Make Network Predictor skip empty urls (Closed)
Patch Set: address comment Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/net/predictor.cc ('k') | net/http/http_stream_factory_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/net/predictor_browsertest.cc
diff --git a/chrome/browser/net/predictor_browsertest.cc b/chrome/browser/net/predictor_browsertest.cc
index 85c5f63dbb6fa8f8ac84f09d072fc16faa853ae4..60b264f2c31cc6c5132d90d7914a5ea07763079b 100644
--- a/chrome/browser/net/predictor_browsertest.cc
+++ b/chrome/browser/net/predictor_browsertest.cc
@@ -320,6 +320,7 @@ class CrossSitePredictorObserver
chrome_browser_net::UrlInfo::ResolutionMotivation motivation,
int count) override {
base::AutoLock lock(lock_);
+ preconnect_url_attempts_.insert(original_url);
if (original_url == cross_site_host_) {
cross_site_preconnected_ = std::max(cross_site_preconnected_, count);
} else if (original_url == source_host_) {
@@ -411,6 +412,11 @@ class CrossSitePredictorObserver
return HasHostBeenLookedUpLocked(url);
}
+ bool HasHostAttemptedToPreconnect(const GURL& url) {
+ base::AutoLock lock(lock_);
+ return base::ContainsKey(preconnect_url_attempts_, url);
+ }
+
void CheckForWaitingLoop() {
lock_.AssertAcquired();
if (waiting_on_dns_.is_empty())
@@ -465,6 +471,7 @@ class CrossSitePredictorObserver
int cross_site_preconnected_;
int same_site_preconnected_;
+ std::set<GURL> preconnect_url_attempts_;
std::set<GURL> successful_dns_lookups_;
std::set<GURL> unsuccessful_dns_lookups_;
base::RunLoop* dns_run_loop_;
@@ -875,6 +882,18 @@ IN_PROC_BROWSER_TEST_F(PredictorBrowserTest, SimplePreconnectFour) {
connection_listener_->WaitForAcceptedConnectionsOnUI(4u);
}
+// Regression test for crbug.com/721981.
+IN_PROC_BROWSER_TEST_F(PredictorBrowserTest, PreconnectNonHttpScheme) {
+ GURL url("chrome-native://dummyurl");
+ predictor()->PreconnectUrlAndSubresources(url, GURL());
+ base::RunLoop().RunUntilIdle();
+ // Since |url| is non-HTTP(s) scheme, Predictor will canonicalize it to an
+ // empty url. Make sure that there is no attempt to preconnect |url| or an
+ // empty url.
+ EXPECT_FALSE(observer()->HasHostAttemptedToPreconnect(url));
+ EXPECT_FALSE(observer()->HasHostAttemptedToPreconnect(GURL()));
+}
+
// Test the html test harness used to initiate cross site fetches. These
// initiate cross site subresource requests to the cross site test server.
// Inspect the predictor's internal state to make sure that they are properly
« no previous file with comments | « chrome/browser/net/predictor.cc ('k') | net/http/http_stream_factory_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698