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

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

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