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/logging.h" | 10 #include "base/logging.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "net/http/http_auth_handler_factory.h" | 14 #include "net/http/http_auth_handler_factory.h" |
15 #include "net/http/http_response_body_drainer.h" | 15 #include "net/http/http_response_body_drainer.h" |
16 #include "net/http/http_stream_factory_impl.h" | 16 #include "net/http/http_stream_factory_impl.h" |
17 #include "net/http/url_security_manager.h" | 17 #include "net/http/url_security_manager.h" |
18 #include "net/proxy/proxy_service.h" | 18 #include "net/proxy/proxy_service.h" |
19 #include "net/socket/client_socket_factory.h" | 19 #include "net/socket/client_socket_factory.h" |
20 #include "net/socket/client_socket_pool_manager_impl.h" | 20 #include "net/socket/client_socket_pool_manager_impl.h" |
21 #include "net/spdy/spdy_session_pool.h" | 21 #include "net/spdy/spdy_session_pool.h" |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 net::ClientSocketPoolManager* CreateSocketPoolManager( | 25 net::ClientSocketPoolManager* CreateSocketPoolManager( |
| 26 net::HttpNetworkSession::SocketPoolType pool_type, |
26 const net::HttpNetworkSession::Params& params) { | 27 const net::HttpNetworkSession::Params& params) { |
27 // TODO(yutak): Differentiate WebSocket pool manager and allow more | 28 // TODO(yutak): Differentiate WebSocket pool manager and allow more |
28 // simultaneous connections for WebSockets. | 29 // simultaneous connections for WebSockets. |
29 return new net::ClientSocketPoolManagerImpl( | 30 return new net::ClientSocketPoolManagerImpl( |
30 params.net_log, | 31 params.net_log, |
31 params.client_socket_factory ? | 32 params.client_socket_factory ? |
32 params.client_socket_factory : | 33 params.client_socket_factory : |
33 net::ClientSocketFactory::GetDefaultFactory(), | 34 net::ClientSocketFactory::GetDefaultFactory(), |
34 params.host_resolver, | 35 params.host_resolver, |
35 params.cert_verifier, | 36 params.cert_verifier, |
36 params.server_bound_cert_service, | 37 params.server_bound_cert_service, |
37 params.transport_security_state, | 38 params.transport_security_state, |
38 params.ssl_host_info_factory, | 39 params.ssl_host_info_factory, |
39 params.ssl_session_cache_shard, | 40 params.ssl_session_cache_shard, |
40 params.proxy_service, | 41 params.proxy_service, |
41 params.ssl_config_service); | 42 params.ssl_config_service, |
| 43 pool_type); |
42 } | 44 } |
43 | 45 |
44 } // unnamed namespace | 46 } // unnamed namespace |
45 | 47 |
46 namespace net { | 48 namespace net { |
47 | 49 |
48 // TODO(mbelshe): Move the socket factories into HttpStreamFactory. | 50 // TODO(mbelshe): Move the socket factories into HttpStreamFactory. |
49 HttpNetworkSession::HttpNetworkSession(const Params& params) | 51 HttpNetworkSession::HttpNetworkSession(const Params& params) |
50 : net_log_(params.net_log), | 52 : net_log_(params.net_log), |
51 network_delegate_(params.network_delegate), | 53 network_delegate_(params.network_delegate), |
52 http_server_properties_(params.http_server_properties), | 54 http_server_properties_(params.http_server_properties), |
53 cert_verifier_(params.cert_verifier), | 55 cert_verifier_(params.cert_verifier), |
54 http_auth_handler_factory_(params.http_auth_handler_factory), | 56 http_auth_handler_factory_(params.http_auth_handler_factory), |
55 force_http_pipelining_(params.force_http_pipelining), | 57 force_http_pipelining_(params.force_http_pipelining), |
56 proxy_service_(params.proxy_service), | 58 proxy_service_(params.proxy_service), |
57 ssl_config_service_(params.ssl_config_service), | 59 ssl_config_service_(params.ssl_config_service), |
58 normal_socket_pool_manager_(CreateSocketPoolManager(params)), | 60 normal_socket_pool_manager_( |
59 websocket_socket_pool_manager_(CreateSocketPoolManager(params)), | 61 CreateSocketPoolManager(NORMAL_SOCKET_POOL, params)), |
| 62 websocket_socket_pool_manager_( |
| 63 CreateSocketPoolManager(WEBSOCKET_SOCKET_POOL, params)), |
60 spdy_session_pool_(params.host_resolver, | 64 spdy_session_pool_(params.host_resolver, |
61 params.ssl_config_service, | 65 params.ssl_config_service, |
62 params.http_server_properties), | 66 params.http_server_properties), |
63 ALLOW_THIS_IN_INITIALIZER_LIST(http_stream_factory_( | 67 ALLOW_THIS_IN_INITIALIZER_LIST(http_stream_factory_( |
64 new HttpStreamFactoryImpl(this))), | 68 new HttpStreamFactoryImpl(this))), |
65 params_(params) { | 69 params_(params) { |
66 DCHECK(proxy_service_); | 70 DCHECK(proxy_service_); |
67 DCHECK(ssl_config_service_); | 71 DCHECK(ssl_config_service_); |
68 CHECK(http_server_properties_); | 72 CHECK(http_server_properties_); |
69 } | 73 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 spdy_session_pool_.CloseIdleSessions(); | 139 spdy_session_pool_.CloseIdleSessions(); |
136 } | 140 } |
137 | 141 |
138 ClientSocketPoolManager* HttpNetworkSession::GetSocketPoolManager( | 142 ClientSocketPoolManager* HttpNetworkSession::GetSocketPoolManager( |
139 SocketPoolType pool_type) { | 143 SocketPoolType pool_type) { |
140 switch (pool_type) { | 144 switch (pool_type) { |
141 case NORMAL_SOCKET_POOL: | 145 case NORMAL_SOCKET_POOL: |
142 return normal_socket_pool_manager_.get(); | 146 return normal_socket_pool_manager_.get(); |
143 case WEBSOCKET_SOCKET_POOL: | 147 case WEBSOCKET_SOCKET_POOL: |
144 return websocket_socket_pool_manager_.get(); | 148 return websocket_socket_pool_manager_.get(); |
| 149 default: |
| 150 NOTREACHED(); |
| 151 break; |
145 } | 152 } |
146 NOTREACHED(); | |
147 return NULL; | 153 return NULL; |
148 } | 154 } |
149 | 155 |
150 } // namespace net | 156 } // namespace net |
OLD | NEW |