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

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

Issue 377063002: Revert of Add a probability to Alternate-Protocol support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/http/http_stream_factory_impl.h ('k') | net/http/http_stream_factory_impl_job.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 "net/http/http_stream_factory_impl.h" 5 #include "net/http/http_stream_factory_impl.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "net/base/net_log.h" 12 #include "net/base/net_log.h"
13 #include "net/base/net_util.h" 13 #include "net/base/net_util.h"
14 #include "net/http/http_network_session.h" 14 #include "net/http/http_network_session.h"
15 #include "net/http/http_server_properties.h" 15 #include "net/http/http_server_properties.h"
16 #include "net/http/http_stream_factory_impl_job.h" 16 #include "net/http/http_stream_factory_impl_job.h"
17 #include "net/http/http_stream_factory_impl_request.h" 17 #include "net/http/http_stream_factory_impl_request.h"
18 #include "net/spdy/spdy_http_stream.h" 18 #include "net/spdy/spdy_http_stream.h"
19 #include "url/gurl.h" 19 #include "url/gurl.h"
20 20
21 namespace net { 21 namespace net {
22 22
23 namespace { 23 namespace {
24 24
25 const AlternateProtocolInfo kNoAlternateProtocol = 25 const PortAlternateProtocolPair kNoAlternateProtocol = {
26 AlternateProtocolInfo(0, UNINITIALIZED_ALTERNATE_PROTOCOL, 0); 26 0, UNINITIALIZED_ALTERNATE_PROTOCOL
27 };
27 28
28 GURL UpgradeUrlToHttps(const GURL& original_url, int port) { 29 GURL UpgradeUrlToHttps(const GURL& original_url, int port) {
29 GURL::Replacements replacements; 30 GURL::Replacements replacements;
30 // new_sheme and new_port need to be in scope here because GURL::Replacements 31 // new_sheme and new_port need to be in scope here because GURL::Replacements
31 // references the memory contained by them directly. 32 // references the memory contained by them directly.
32 const std::string new_scheme = "https"; 33 const std::string new_scheme = "https";
33 const std::string new_port = base::IntToString(port); 34 const std::string new_port = base::IntToString(port);
34 replacements.SetSchemeStr(new_scheme); 35 replacements.SetSchemeStr(new_scheme);
35 replacements.SetPortStr(new_port); 36 replacements.SetPortStr(new_port);
36 return original_url.ReplaceComponents(replacements); 37 return original_url.ReplaceComponents(replacements);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 WebSocketHandshakeStreamBase::CreateHelper* 104 WebSocketHandshakeStreamBase::CreateHelper*
104 websocket_handshake_stream_create_helper, 105 websocket_handshake_stream_create_helper,
105 const BoundNetLog& net_log) { 106 const BoundNetLog& net_log) {
106 Request* request = new Request(request_info.url, 107 Request* request = new Request(request_info.url,
107 this, 108 this,
108 delegate, 109 delegate,
109 websocket_handshake_stream_create_helper, 110 websocket_handshake_stream_create_helper,
110 net_log); 111 net_log);
111 112
112 GURL alternate_url; 113 GURL alternate_url;
113 AlternateProtocolInfo alternate = 114 PortAlternateProtocolPair alternate =
114 GetAlternateProtocolRequestFor(request_info.url, &alternate_url); 115 GetAlternateProtocolRequestFor(request_info.url, &alternate_url);
115 Job* alternate_job = NULL; 116 Job* alternate_job = NULL;
116 if (alternate.protocol != UNINITIALIZED_ALTERNATE_PROTOCOL) { 117 if (alternate.protocol != UNINITIALIZED_ALTERNATE_PROTOCOL) {
117 // Never share connection with other jobs for FTP requests. 118 // Never share connection with other jobs for FTP requests.
118 DCHECK(!request_info.url.SchemeIs("ftp")); 119 DCHECK(!request_info.url.SchemeIs("ftp"));
119 120
120 HttpRequestInfo alternate_request_info = request_info; 121 HttpRequestInfo alternate_request_info = request_info;
121 alternate_request_info.url = alternate_url; 122 alternate_request_info.url = alternate_url;
122 alternate_job = 123 alternate_job =
123 new Job(this, session_, alternate_request_info, priority, 124 new Job(this, session_, alternate_request_info, priority,
(...skipping 23 matching lines...) Expand all
147 } 148 }
148 149
149 void HttpStreamFactoryImpl::PreconnectStreams( 150 void HttpStreamFactoryImpl::PreconnectStreams(
150 int num_streams, 151 int num_streams,
151 const HttpRequestInfo& request_info, 152 const HttpRequestInfo& request_info,
152 RequestPriority priority, 153 RequestPriority priority,
153 const SSLConfig& server_ssl_config, 154 const SSLConfig& server_ssl_config,
154 const SSLConfig& proxy_ssl_config) { 155 const SSLConfig& proxy_ssl_config) {
155 DCHECK(!for_websockets_); 156 DCHECK(!for_websockets_);
156 GURL alternate_url; 157 GURL alternate_url;
157 AlternateProtocolInfo alternate = 158 PortAlternateProtocolPair alternate =
158 GetAlternateProtocolRequestFor(request_info.url, &alternate_url); 159 GetAlternateProtocolRequestFor(request_info.url, &alternate_url);
159 Job* job = NULL; 160 Job* job = NULL;
160 if (alternate.protocol != UNINITIALIZED_ALTERNATE_PROTOCOL) { 161 if (alternate.protocol != UNINITIALIZED_ALTERNATE_PROTOCOL) {
161 HttpRequestInfo alternate_request_info = request_info; 162 HttpRequestInfo alternate_request_info = request_info;
162 alternate_request_info.url = alternate_url; 163 alternate_request_info.url = alternate_url;
163 job = new Job(this, session_, alternate_request_info, priority, 164 job = new Job(this, session_, alternate_request_info, priority,
164 server_ssl_config, proxy_ssl_config, session_->net_log()); 165 server_ssl_config, proxy_ssl_config, session_->net_log());
165 job->MarkAsAlternate(request_info.url, alternate); 166 job->MarkAsAlternate(request_info.url, alternate);
166 } else { 167 } else {
167 job = new Job(this, session_, request_info, priority, 168 job = new Job(this, session_, request_info, priority,
168 server_ssl_config, proxy_ssl_config, session_->net_log()); 169 server_ssl_config, proxy_ssl_config, session_->net_log());
169 } 170 }
170 preconnect_job_set_.insert(job); 171 preconnect_job_set_.insert(job);
171 job->Preconnect(num_streams); 172 job->Preconnect(num_streams);
172 } 173 }
173 174
174 const HostMappingRules* HttpStreamFactoryImpl::GetHostMappingRules() const { 175 const HostMappingRules* HttpStreamFactoryImpl::GetHostMappingRules() const {
175 return session_->params().host_mapping_rules; 176 return session_->params().host_mapping_rules;
176 } 177 }
177 178
178 AlternateProtocolInfo HttpStreamFactoryImpl::GetAlternateProtocolRequestFor( 179 PortAlternateProtocolPair HttpStreamFactoryImpl::GetAlternateProtocolRequestFor(
179 const GURL& original_url, 180 const GURL& original_url,
180 GURL* alternate_url) { 181 GURL* alternate_url) {
181 if (!session_->params().use_alternate_protocols) 182 if (!session_->params().use_alternate_protocols)
182 return kNoAlternateProtocol; 183 return kNoAlternateProtocol;
183 184
184 if (original_url.SchemeIs("ftp")) 185 if (original_url.SchemeIs("ftp"))
185 return kNoAlternateProtocol; 186 return kNoAlternateProtocol;
186 187
187 HostPortPair origin = HostPortPair(original_url.HostNoBrackets(), 188 HostPortPair origin = HostPortPair(original_url.HostNoBrackets(),
188 original_url.EffectiveIntPort()); 189 original_url.EffectiveIntPort());
189 190
190 HttpServerProperties& http_server_properties = 191 HttpServerProperties& http_server_properties =
191 *session_->http_server_properties(); 192 *session_->http_server_properties();
192 if (!http_server_properties.HasAlternateProtocol(origin)) 193 if (!http_server_properties.HasAlternateProtocol(origin))
193 return kNoAlternateProtocol; 194 return kNoAlternateProtocol;
194 195
195 AlternateProtocolInfo alternate = 196 PortAlternateProtocolPair alternate =
196 http_server_properties.GetAlternateProtocol(origin); 197 http_server_properties.GetAlternateProtocol(origin);
197 if (alternate.protocol == ALTERNATE_PROTOCOL_BROKEN) { 198 if (alternate.protocol == ALTERNATE_PROTOCOL_BROKEN) {
198 HistogramAlternateProtocolUsage( 199 HistogramAlternateProtocolUsage(
199 ALTERNATE_PROTOCOL_USAGE_BROKEN, 200 ALTERNATE_PROTOCOL_USAGE_BROKEN,
200 http_server_properties.GetAlternateProtocolExperiment()); 201 http_server_properties.GetAlternateProtocolExperiment());
201 return kNoAlternateProtocol; 202 return kNoAlternateProtocol;
202 } 203 }
203 204
204 if (!IsAlternateProtocolValid(alternate.protocol)) { 205 if (!IsAlternateProtocolValid(alternate.protocol)) {
205 NOTREACHED(); 206 NOTREACHED();
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 delete job; 302 delete job;
302 } 303 }
303 304
304 void HttpStreamFactoryImpl::OnPreconnectsComplete(const Job* job) { 305 void HttpStreamFactoryImpl::OnPreconnectsComplete(const Job* job) {
305 preconnect_job_set_.erase(job); 306 preconnect_job_set_.erase(job);
306 delete job; 307 delete job;
307 OnPreconnectsCompleteInternal(); 308 OnPreconnectsCompleteInternal();
308 } 309 }
309 310
310 } // namespace net 311 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_stream_factory_impl.h ('k') | net/http/http_stream_factory_impl_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698