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

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

Issue 1131293004: Add cross origin to Blink-driven preconnect (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase and new test Created 5 years, 5 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
Index: chrome/browser/net/predictor.cc
diff --git a/chrome/browser/net/predictor.cc b/chrome/browser/net/predictor.cc
index 9299b63358dec01e1bdd97292cf68ec474d075b8..79acd3c50e0ae6ee922cb086d8cddd4fa41746cb 100644
--- a/chrome/browser/net/predictor.cc
+++ b/chrome/browser/net/predictor.cc
@@ -87,6 +87,9 @@ const int Predictor::kMaxSpeculativeResolveQueueDelayMs =
(kExpectedResolutionTimeMs * Predictor::kTypicalSpeculativeGroupSize) /
Predictor::kMaxSpeculativeParallelResolves;
+// The default value of the credentials flag when preconnecting.
+static bool kAllowCredentialsOnPreconnect = true;
mmenke 2015/07/09 15:55:56 This is a confusing name. "kAllowCredentialsOnPre
Yoav Weiss 2015/07/09 16:19:39 renamed
+
static int g_max_queueing_delay_ms =
Predictor::kMaxSpeculativeResolveQueueDelayMs;
static size_t g_max_parallel_resolves =
@@ -265,8 +268,8 @@ void Predictor::AnticipateOmniboxUrl(const GURL& url, bool preconnectable) {
return; // We've done a preconnect recently.
last_omnibox_preconnect_ = now;
const int kConnectionsNeeded = 1;
- PreconnectUrl(
- CanonicalizeUrl(url), GURL(), motivation, kConnectionsNeeded);
+ PreconnectUrl(CanonicalizeUrl(url), GURL(), motivation,
+ kConnectionsNeeded, kAllowCredentialsOnPreconnect);
return; // Skip pre-resolution, since we'll open a connection.
}
} else {
@@ -305,8 +308,8 @@ void Predictor::PreconnectUrlAndSubresources(const GURL& url,
UrlInfo::ResolutionMotivation motivation(UrlInfo::EARLY_LOAD_MOTIVATED);
const int kConnectionsNeeded = 1;
- PreconnectUrl(CanonicalizeUrl(url), first_party_for_cookies,
- motivation, kConnectionsNeeded);
+ PreconnectUrl(CanonicalizeUrl(url), first_party_for_cookies, motivation,
+ kConnectionsNeeded, kAllowCredentialsOnPreconnect);
PredictFrameSubresources(url.GetWithEmptyPath(), first_party_for_cookies);
}
@@ -840,19 +843,20 @@ void Predictor::SaveDnsPrefetchStateForNextStartupAndTrim(
void Predictor::PreconnectUrl(const GURL& url,
const GURL& first_party_for_cookies,
UrlInfo::ResolutionMotivation motivation,
- int count) {
+ int count,
+ bool allow_credentials) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) ||
BrowserThread::CurrentlyOn(BrowserThread::IO));
if (BrowserThread::CurrentlyOn(BrowserThread::IO)) {
- PreconnectUrlOnIOThread(url, first_party_for_cookies, motivation, count);
+ PreconnectUrlOnIOThread(url, first_party_for_cookies, motivation, count,
+ allow_credentials);
} else {
BrowserThread::PostTask(
- BrowserThread::IO,
- FROM_HERE,
- base::Bind(&Predictor::PreconnectUrlOnIOThread,
- base::Unretained(this), url, first_party_for_cookies,
- motivation, count));
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&Predictor::PreconnectUrlOnIOThread, base::Unretained(this),
+ url, first_party_for_cookies, motivation, count,
+ allow_credentials));
}
}
@@ -860,7 +864,8 @@ void Predictor::PreconnectUrlOnIOThread(
const GURL& original_url,
const GURL& first_party_for_cookies,
UrlInfo::ResolutionMotivation motivation,
- int count) {
+ int count,
+ bool allow_credentials) {
// Skip the HSTS redirect.
GURL url = GetHSTSRedirectOnIOThread(original_url);
@@ -869,11 +874,8 @@ void Predictor::PreconnectUrlOnIOThread(
url, first_party_for_cookies, motivation, count);
}
- PreconnectOnIOThread(url,
- first_party_for_cookies,
- motivation,
- count,
- url_request_context_getter_.get());
+ PreconnectOnIOThread(url, first_party_for_cookies, motivation, count,
+ url_request_context_getter_.get(), allow_credentials);
}
void Predictor::PredictFrameSubresources(const GURL& url,
@@ -941,7 +943,8 @@ void Predictor::PrepareFrameSubresources(const GURL& original_url,
// provide a more carefully estimated preconnection count.
if (preconnect_enabled_) {
PreconnectUrlOnIOThread(url, first_party_for_cookies,
- UrlInfo::SELF_REFERAL_MOTIVATED, 2);
+ UrlInfo::SELF_REFERAL_MOTIVATED, 2,
+ kAllowCredentialsOnPreconnect);
}
return;
}
@@ -966,7 +969,7 @@ void Predictor::PrepareFrameSubresources(const GURL& original_url,
if (url.host() == future_url->first.host())
++count;
PreconnectUrlOnIOThread(future_url->first, first_party_for_cookies,
- motivation, count);
+ motivation, count, kAllowCredentialsOnPreconnect);
} else if (connection_expectation > kDNSPreresolutionWorthyExpectedValue) {
evalution = PRERESOLUTION;
future_url->second.preresolution_increment();

Powered by Google App Engine
This is Rietveld 408576698