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

Side by Side Diff: net/http/http_stream_factory.cc

Issue 1824903002: Change the AlternativeServiceMap with SchemeOriginPair key. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « net/http/http_stream_factory.h ('k') | net/http/http_stream_factory_impl.cc » ('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 "net/http/http_stream_factory.h" 5 #include "net/http/http_stream_factory.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_split.h" 9 #include "base/strings/string_split.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 18 matching lines...) Expand all
29 HttpStreamFactory::~HttpStreamFactory() {} 29 HttpStreamFactory::~HttpStreamFactory() {}
30 30
31 // static 31 // static
32 void HttpStreamFactory::ResetStaticSettingsToInit() { 32 void HttpStreamFactory::ResetStaticSettingsToInit() {
33 spdy_enabled_ = true; 33 spdy_enabled_ = true;
34 } 34 }
35 35
36 void HttpStreamFactory::ProcessAlternativeServices( 36 void HttpStreamFactory::ProcessAlternativeServices(
37 HttpNetworkSession* session, 37 HttpNetworkSession* session,
38 const HttpResponseHeaders* headers, 38 const HttpResponseHeaders* headers,
39 const HostPortPair& http_host_port_pair) { 39 const url::SchemeHostPort& http_host_port_pair) {
40 if (session->params().parse_alternative_services) { 40 if (session->params().parse_alternative_services) {
41 if (headers->HasHeader(kAlternativeServiceHeader)) { 41 if (headers->HasHeader(kAlternativeServiceHeader)) {
42 std::string alternative_service_str; 42 std::string alternative_service_str;
43 headers->GetNormalizedHeader(kAlternativeServiceHeader, 43 headers->GetNormalizedHeader(kAlternativeServiceHeader,
44 &alternative_service_str); 44 &alternative_service_str);
45 ProcessAlternativeService(session->http_server_properties(), 45 ProcessAlternativeService(session->http_server_properties(),
46 alternative_service_str, http_host_port_pair, 46 alternative_service_str, http_host_port_pair,
47 *session); 47 *session);
48 } 48 }
49 // If "Alt-Svc" is enabled, then ignore "Alternate-Protocol". 49 // If "Alt-Svc" is enabled, then ignore "Alternate-Protocol".
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 return url.ReplaceComponents(replacements); 82 return url.ReplaceComponents(replacements);
83 } 83 }
84 return url; 84 return url;
85 } 85 }
86 86
87 HttpStreamFactory::HttpStreamFactory() {} 87 HttpStreamFactory::HttpStreamFactory() {}
88 88
89 void HttpStreamFactory::ProcessAlternativeService( 89 void HttpStreamFactory::ProcessAlternativeService(
90 const base::WeakPtr<HttpServerProperties>& http_server_properties, 90 const base::WeakPtr<HttpServerProperties>& http_server_properties,
91 base::StringPiece alternative_service_str, 91 base::StringPiece alternative_service_str,
92 const HostPortPair& http_host_port_pair, 92 const url::SchemeHostPort& scheme_origin_pair,
93 const HttpNetworkSession& session) { 93 const HttpNetworkSession& session) {
94 SpdyAltSvcWireFormat::AlternativeServiceVector alternative_service_vector; 94 SpdyAltSvcWireFormat::AlternativeServiceVector alternative_service_vector;
95 if (!SpdyAltSvcWireFormat::ParseHeaderFieldValue( 95 if (!SpdyAltSvcWireFormat::ParseHeaderFieldValue(
96 alternative_service_str, &alternative_service_vector)) { 96 alternative_service_str, &alternative_service_vector)) {
97 return; 97 return;
98 } 98 }
99 99
100 // Convert SpdyAltSvcWireFormat::AlternativeService entries 100 // Convert SpdyAltSvcWireFormat::AlternativeService entries
101 // to net::AlternativeServiceInfo. 101 // to net::AlternativeServiceInfo.
102 AlternativeServiceInfoVector alternative_service_info_vector; 102 AlternativeServiceInfoVector alternative_service_info_vector;
(...skipping 27 matching lines...) Expand all
130 AlternativeService alternative_service(protocol, 130 AlternativeService alternative_service(protocol,
131 alternative_service_entry.host, 131 alternative_service_entry.host,
132 alternative_service_entry.port); 132 alternative_service_entry.port);
133 base::Time expiration = 133 base::Time expiration =
134 base::Time::Now() + 134 base::Time::Now() +
135 base::TimeDelta::FromSeconds(alternative_service_entry.max_age); 135 base::TimeDelta::FromSeconds(alternative_service_entry.max_age);
136 AlternativeServiceInfo alternative_service_info(alternative_service, 136 AlternativeServiceInfo alternative_service_info(alternative_service,
137 expiration); 137 expiration);
138 alternative_service_info_vector.push_back(alternative_service_info); 138 alternative_service_info_vector.push_back(alternative_service_info);
139 } 139 }
140 HostPortPair rewrite_host =
141 RewriteHost(HostPortPair::FromSchemeHostPort(scheme_origin_pair));
140 142
141 http_server_properties->SetAlternativeServices( 143 http_server_properties->SetAlternativeServices(
142 RewriteHost(http_host_port_pair), alternative_service_info_vector); 144 url::SchemeHostPort(scheme_origin_pair.scheme(), rewrite_host.host(),
145 rewrite_host.port()),
146 alternative_service_info_vector);
143 } 147 }
144 148
145 void HttpStreamFactory::ProcessAlternateProtocol( 149 void HttpStreamFactory::ProcessAlternateProtocol(
146 const base::WeakPtr<HttpServerProperties>& http_server_properties, 150 const base::WeakPtr<HttpServerProperties>& http_server_properties,
147 const std::vector<std::string>& alternate_protocol_values, 151 const std::vector<std::string>& alternate_protocol_values,
148 const HostPortPair& http_host_port_pair, 152 const url::SchemeHostPort& scheme_origin_pair,
149 const HttpNetworkSession& session) { 153 const HttpNetworkSession& session) {
150 AlternateProtocol protocol = UNINITIALIZED_ALTERNATE_PROTOCOL; 154 AlternateProtocol protocol = UNINITIALIZED_ALTERNATE_PROTOCOL;
151 int port = 0; 155 int port = 0;
152 bool is_valid = true; 156 bool is_valid = true;
153 for (size_t i = 0; i < alternate_protocol_values.size(); ++i) { 157 for (size_t i = 0; i < alternate_protocol_values.size(); ++i) {
154 base::StringPiece alternate_protocol_str = alternate_protocol_values[i]; 158 base::StringPiece alternate_protocol_str = alternate_protocol_values[i];
155 if (base::StartsWith(alternate_protocol_str, "p=", 159 if (base::StartsWith(alternate_protocol_str, "p=",
156 base::CompareCase::SENSITIVE)) { 160 base::CompareCase::SENSITIVE)) {
157 // Ignore deprecated probability. 161 // Ignore deprecated probability.
158 continue; 162 continue;
(...skipping 24 matching lines...) Expand all
183 !session.IsProtocolEnabled(protocol)) { 187 !session.IsProtocolEnabled(protocol)) {
184 DVLOG(1) << kAlternateProtocolHeader 188 DVLOG(1) << kAlternateProtocolHeader
185 << " header has unrecognized protocol: " 189 << " header has unrecognized protocol: "
186 << port_protocol_vector[1]; 190 << port_protocol_vector[1];
187 is_valid = false; 191 is_valid = false;
188 break; 192 break;
189 } 193 }
190 } 194 }
191 195
192 if (!is_valid || protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) { 196 if (!is_valid || protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) {
193 http_server_properties->ClearAlternativeServices(http_host_port_pair); 197 http_server_properties->ClearAlternativeServices(scheme_origin_pair);
194 return; 198 return;
195 } 199 }
196 200
201 HostPortPair rewrite_host =
202 RewriteHost(HostPortPair::FromSchemeHostPort(scheme_origin_pair));
203
197 http_server_properties->SetAlternativeService( 204 http_server_properties->SetAlternativeService(
198 RewriteHost(http_host_port_pair), 205 url::SchemeHostPort(scheme_origin_pair.scheme(), rewrite_host.host(),
206 rewrite_host.port()),
199 AlternativeService(protocol, "", static_cast<uint16_t>(port)), 207 AlternativeService(protocol, "", static_cast<uint16_t>(port)),
200 base::Time::Now() + base::TimeDelta::FromDays(30)); 208 base::Time::Now() + base::TimeDelta::FromDays(30));
201 } 209 }
202 210
203 HostPortPair HttpStreamFactory::RewriteHost(HostPortPair host_port_pair) { 211 HostPortPair HttpStreamFactory::RewriteHost(HostPortPair host_port_pair) {
204 const HostMappingRules* mapping_rules = GetHostMappingRules(); 212 const HostMappingRules* mapping_rules = GetHostMappingRules();
205 if (mapping_rules) 213 if (mapping_rules)
206 mapping_rules->RewriteHost(&host_port_pair); 214 mapping_rules->RewriteHost(&host_port_pair);
207 return host_port_pair; 215 return host_port_pair;
208 } 216 }
209 217
210 } // namespace net 218 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_stream_factory.h ('k') | net/http/http_stream_factory_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698