OLD | NEW |
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_network_session.h" | 5 #include "net/http/http_network_session.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/debug/stack_trace.h" | 10 #include "base/debug/stack_trace.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "net/http/http_auth_handler_factory.h" | 15 #include "net/http/http_auth_handler_factory.h" |
16 #include "net/http/http_response_body_drainer.h" | 16 #include "net/http/http_response_body_drainer.h" |
17 #include "net/http/http_stream_factory_impl.h" | 17 #include "net/http/http_stream_factory_impl.h" |
18 #include "net/http/url_security_manager.h" | 18 #include "net/http/url_security_manager.h" |
19 #include "net/proxy/proxy_service.h" | 19 #include "net/proxy/proxy_service.h" |
20 #include "net/quic/crypto/quic_random.h" | 20 #include "net/quic/crypto/quic_random.h" |
21 #include "net/quic/quic_clock.h" | 21 #include "net/quic/quic_clock.h" |
22 #include "net/quic/quic_crypto_client_stream_factory.h" | 22 #include "net/quic/quic_crypto_client_stream_factory.h" |
23 #include "net/quic/quic_protocol.h" | 23 #include "net/quic/quic_protocol.h" |
24 #include "net/quic/quic_stream_factory.h" | 24 #include "net/quic/quic_stream_factory.h" |
25 #include "net/quic/quic_utils.h" | 25 #include "net/quic/quic_utils.h" |
26 #include "net/socket/client_socket_factory.h" | 26 #include "net/socket/client_socket_factory.h" |
27 #include "net/socket/client_socket_pool_manager_impl.h" | 27 #include "net/socket/client_socket_pool_manager_impl.h" |
28 #include "net/socket/next_proto.h" | 28 #include "net/socket/next_proto.h" |
| 29 #include "net/socket/ssl_client_socket.h" |
29 #include "net/spdy/hpack_huffman_aggregator.h" | 30 #include "net/spdy/hpack_huffman_aggregator.h" |
30 #include "net/spdy/spdy_session_pool.h" | 31 #include "net/spdy/spdy_session_pool.h" |
31 | 32 |
32 namespace { | 33 namespace { |
33 | 34 |
34 net::ClientSocketPoolManager* CreateSocketPoolManager( | 35 net::ClientSocketPoolManager* CreateSocketPoolManager( |
35 net::HttpNetworkSession::SocketPoolType pool_type, | 36 net::HttpNetworkSession::SocketPoolType pool_type, |
36 const net::HttpNetworkSession::Params& params) { | 37 const net::HttpNetworkSession::Params& params) { |
37 // TODO(yutak): Differentiate WebSocket pool manager and allow more | 38 // TODO(yutak): Differentiate WebSocket pool manager and allow more |
38 // simultaneous connections for WebSockets. | 39 // simultaneous connections for WebSockets. |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 160 |
160 // TODO(rtenneti): bug 116575 - consider combining the NextProto and | 161 // TODO(rtenneti): bug 116575 - consider combining the NextProto and |
161 // AlternateProtocol. | 162 // AlternateProtocol. |
162 for (std::vector<NextProto>::const_iterator it = params_.next_protos.begin(); | 163 for (std::vector<NextProto>::const_iterator it = params_.next_protos.begin(); |
163 it != params_.next_protos.end(); ++it) { | 164 it != params_.next_protos.end(); ++it) { |
164 NextProto proto = *it; | 165 NextProto proto = *it; |
165 | 166 |
166 // Add the protocol to the TLS next protocol list, except for QUIC | 167 // Add the protocol to the TLS next protocol list, except for QUIC |
167 // since it uses UDP. | 168 // since it uses UDP. |
168 if (proto != kProtoQUIC1SPDY3) { | 169 if (proto != kProtoQUIC1SPDY3) { |
169 next_protos_.push_back(SSLClientSocket::NextProtoToString(proto)); | 170 next_protos_.push_back(proto); |
170 } | 171 } |
171 | 172 |
172 // Enable the corresponding alternate protocol, except for HTTP | 173 // Enable the corresponding alternate protocol, except for HTTP |
173 // which has not corresponding alternative. | 174 // which has not corresponding alternative. |
174 if (proto != kProtoHTTP11) { | 175 if (proto != kProtoHTTP11) { |
175 AlternateProtocol alternate = AlternateProtocolFromNextProto(proto); | 176 AlternateProtocol alternate = AlternateProtocolFromNextProto(proto); |
176 if (!IsAlternateProtocolValid(alternate)) { | 177 if (!IsAlternateProtocolValid(alternate)) { |
177 NOTREACHED() << "Invalid next proto: " << proto; | 178 NOTREACHED() << "Invalid next proto: " << proto; |
178 continue; | 179 continue; |
179 } | 180 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 websocket_socket_pool_manager_->CloseIdleSockets(); | 278 websocket_socket_pool_manager_->CloseIdleSockets(); |
278 spdy_session_pool_.CloseCurrentIdleSessions(); | 279 spdy_session_pool_.CloseCurrentIdleSessions(); |
279 } | 280 } |
280 | 281 |
281 bool HttpNetworkSession::IsProtocolEnabled(AlternateProtocol protocol) const { | 282 bool HttpNetworkSession::IsProtocolEnabled(AlternateProtocol protocol) const { |
282 DCHECK(IsAlternateProtocolValid(protocol)); | 283 DCHECK(IsAlternateProtocolValid(protocol)); |
283 return enabled_protocols_[ | 284 return enabled_protocols_[ |
284 protocol - ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION]; | 285 protocol - ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION]; |
285 } | 286 } |
286 | 287 |
287 void HttpNetworkSession::GetNextProtos( | 288 void HttpNetworkSession::GetNextProtos(NextProtoVector* next_protos) const { |
288 std::vector<std::string>* next_protos) const { | |
289 if (HttpStreamFactory::spdy_enabled()) { | 289 if (HttpStreamFactory::spdy_enabled()) { |
290 *next_protos = next_protos_; | 290 *next_protos = next_protos_; |
291 } else { | 291 } else { |
292 next_protos->clear(); | 292 next_protos->clear(); |
293 } | 293 } |
294 } | 294 } |
295 | 295 |
296 bool HttpNetworkSession::HasSpdyExclusion( | 296 bool HttpNetworkSession::HasSpdyExclusion( |
297 HostPortPair host_port_pair) const { | 297 HostPortPair host_port_pair) const { |
298 return params_.forced_spdy_exclusions.find(host_port_pair) != | 298 return params_.forced_spdy_exclusions.find(host_port_pair) != |
299 params_.forced_spdy_exclusions.end(); | 299 params_.forced_spdy_exclusions.end(); |
300 } | 300 } |
301 | 301 |
302 ClientSocketPoolManager* HttpNetworkSession::GetSocketPoolManager( | 302 ClientSocketPoolManager* HttpNetworkSession::GetSocketPoolManager( |
303 SocketPoolType pool_type) { | 303 SocketPoolType pool_type) { |
304 switch (pool_type) { | 304 switch (pool_type) { |
305 case NORMAL_SOCKET_POOL: | 305 case NORMAL_SOCKET_POOL: |
306 return normal_socket_pool_manager_.get(); | 306 return normal_socket_pool_manager_.get(); |
307 case WEBSOCKET_SOCKET_POOL: | 307 case WEBSOCKET_SOCKET_POOL: |
308 return websocket_socket_pool_manager_.get(); | 308 return websocket_socket_pool_manager_.get(); |
309 default: | 309 default: |
310 NOTREACHED(); | 310 NOTREACHED(); |
311 break; | 311 break; |
312 } | 312 } |
313 return NULL; | 313 return NULL; |
314 } | 314 } |
315 | 315 |
316 } // namespace net | 316 } // namespace net |
OLD | NEW |