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

Unified Diff: net/http/http_stream_factory_impl.cc

Issue 1017453008: Make GetAlternateProtocol return AlternativeService. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/server/origin/g in other methods too. Created 5 years, 9 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 | « net/http/http_server_properties_manager_unittest.cc ('k') | net/quic/quic_network_transaction_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_stream_factory_impl.cc
diff --git a/net/http/http_stream_factory_impl.cc b/net/http/http_stream_factory_impl.cc
index 54d2acb72e89ff8e8aabf1304b6fde0f1c6f71fb..f4c1ab290f9100596d662e944b07ac4ecb610fe9 100644
--- a/net/http/http_stream_factory_impl.cc
+++ b/net/http/http_stream_factory_impl.cc
@@ -186,18 +186,21 @@ AlternativeService HttpStreamFactoryImpl::GetAlternativeServiceRequestFor(
HostPortPair origin = HostPortPair::FromURL(original_url);
HttpServerProperties& http_server_properties =
*session_->http_server_properties();
- const AlternateProtocolInfo alternate =
- http_server_properties.GetAlternateProtocol(origin);
+ const AlternativeService alternative_service =
+ http_server_properties.GetAlternativeService(origin);
- if (alternate.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL)
+ if (alternative_service.protocol == UNINITIALIZED_ALTERNATE_PROTOCOL)
+ return kNoAlternativeService;
+ // TODO(bnc): Make sure that callers connect to the specified host, and that
+ // certificate requirements are enforced. Then remove the following two
+ // lines.
+ if (alternative_service.host != origin.host())
return kNoAlternativeService;
- const AlternativeService alternative_service(alternate.protocol,
- origin.host(), alternate.port);
if (http_server_properties.IsAlternativeServiceBroken(alternative_service)) {
HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_BROKEN);
return kNoAlternativeService;
}
- if (!IsAlternateProtocolValid(alternate.protocol)) {
+ if (!IsAlternateProtocolValid(alternative_service.protocol)) {
NOTREACHED();
return kNoAlternativeService;
}
@@ -210,22 +213,22 @@ AlternativeService HttpStreamFactoryImpl::GetAlternativeServiceRequestFor(
// allow protocol upgrades to user-controllable ports.
const int kUnrestrictedPort = 1024;
if (!session_->params().enable_user_alternate_protocol_ports &&
- (alternate.port >= kUnrestrictedPort &&
+ (alternative_service.port >= kUnrestrictedPort &&
origin.port() < kUnrestrictedPort))
return kNoAlternativeService;
- origin.set_port(alternate.port);
- if (alternate.protocol >= NPN_SPDY_MINIMUM_VERSION &&
- alternate.protocol <= NPN_SPDY_MAXIMUM_VERSION) {
+ origin.set_port(alternative_service.port);
+ if (alternative_service.protocol >= NPN_SPDY_MINIMUM_VERSION &&
+ alternative_service.protocol <= NPN_SPDY_MAXIMUM_VERSION) {
if (!HttpStreamFactory::spdy_enabled())
return kNoAlternativeService;
if (session_->HasSpdyExclusion(origin))
return kNoAlternativeService;
- *alternate_url = UpgradeUrlToHttps(original_url, alternate.port);
+ *alternate_url = UpgradeUrlToHttps(original_url, alternative_service.port);
} else {
- DCHECK_EQ(QUIC, alternate.protocol);
+ DCHECK_EQ(QUIC, alternative_service.protocol);
if (!session_->params().enable_quic)
return kNoAlternativeService;
@@ -235,7 +238,7 @@ AlternativeService HttpStreamFactoryImpl::GetAlternativeServiceRequestFor(
// the alternate request will be going via UDP to a different port.
*alternate_url = original_url;
}
- return AlternativeService(alternate.protocol, origin.host(), alternate.port);
+ return alternative_service;
}
void HttpStreamFactoryImpl::OrphanJob(Job* job, const Request* request) {
« no previous file with comments | « net/http/http_server_properties_manager_unittest.cc ('k') | net/quic/quic_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698