OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_layer.h" | 5 #include "net/http/http_network_layer.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/string_split.h" | 8 #include "base/string_split.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "net/http/http_network_session.h" | 10 #include "net/http/http_network_session.h" |
11 #include "net/http/http_network_transaction.h" | 11 #include "net/http/http_network_transaction.h" |
12 #include "net/socket/client_socket_factory.h" | 12 #include "net/socket/client_socket_factory.h" |
13 #include "net/spdy/spdy_framer.h" | 13 #include "net/spdy/spdy_framer.h" |
14 #include "net/spdy/spdy_session.h" | 14 #include "net/spdy/spdy_session.h" |
15 #include "net/spdy/spdy_session_pool.h" | 15 #include "net/spdy/spdy_session_pool.h" |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 | 18 |
19 //----------------------------------------------------------------------------- | 19 //----------------------------------------------------------------------------- |
20 | 20 |
21 // static | 21 // static |
22 HttpTransactionFactory* HttpNetworkLayer::CreateFactory( | 22 HttpTransactionFactory* HttpNetworkLayer::CreateFactory( |
23 HostResolver* host_resolver, | 23 HostResolver* host_resolver, |
24 DnsRRResolver* dnsrr_resolver, | 24 DnsRRResolver* dnsrr_resolver, |
| 25 SSLHostInfoFactory* ssl_host_info_factory, |
25 ProxyService* proxy_service, | 26 ProxyService* proxy_service, |
26 SSLConfigService* ssl_config_service, | 27 SSLConfigService* ssl_config_service, |
27 HttpAuthHandlerFactory* http_auth_handler_factory, | 28 HttpAuthHandlerFactory* http_auth_handler_factory, |
28 HttpNetworkDelegate* network_delegate, | 29 HttpNetworkDelegate* network_delegate, |
29 NetLog* net_log) { | 30 NetLog* net_log) { |
30 DCHECK(proxy_service); | 31 DCHECK(proxy_service); |
31 | 32 |
32 return new HttpNetworkLayer(ClientSocketFactory::GetDefaultFactory(), | 33 return new HttpNetworkLayer(ClientSocketFactory::GetDefaultFactory(), |
33 host_resolver, dnsrr_resolver, proxy_service, | 34 host_resolver, dnsrr_resolver, |
| 35 ssl_host_info_factory, proxy_service, |
34 ssl_config_service, http_auth_handler_factory, | 36 ssl_config_service, http_auth_handler_factory, |
35 network_delegate, | 37 network_delegate, |
36 net_log); | 38 net_log); |
37 } | 39 } |
38 | 40 |
39 // static | 41 // static |
40 HttpTransactionFactory* HttpNetworkLayer::CreateFactory( | 42 HttpTransactionFactory* HttpNetworkLayer::CreateFactory( |
41 HttpNetworkSession* session) { | 43 HttpNetworkSession* session) { |
42 DCHECK(session); | 44 DCHECK(session); |
43 | 45 |
44 return new HttpNetworkLayer(session); | 46 return new HttpNetworkLayer(session); |
45 } | 47 } |
46 | 48 |
47 //----------------------------------------------------------------------------- | 49 //----------------------------------------------------------------------------- |
48 HttpNetworkLayer::HttpNetworkLayer( | 50 HttpNetworkLayer::HttpNetworkLayer( |
49 ClientSocketFactory* socket_factory, | 51 ClientSocketFactory* socket_factory, |
50 HostResolver* host_resolver, | 52 HostResolver* host_resolver, |
51 DnsRRResolver* dnsrr_resolver, | 53 DnsRRResolver* dnsrr_resolver, |
| 54 SSLHostInfoFactory* ssl_host_info_factory, |
52 ProxyService* proxy_service, | 55 ProxyService* proxy_service, |
53 SSLConfigService* ssl_config_service, | 56 SSLConfigService* ssl_config_service, |
54 HttpAuthHandlerFactory* http_auth_handler_factory, | 57 HttpAuthHandlerFactory* http_auth_handler_factory, |
55 HttpNetworkDelegate* network_delegate, | 58 HttpNetworkDelegate* network_delegate, |
56 NetLog* net_log) | 59 NetLog* net_log) |
57 : socket_factory_(socket_factory), | 60 : socket_factory_(socket_factory), |
58 host_resolver_(host_resolver), | 61 host_resolver_(host_resolver), |
59 dnsrr_resolver_(dnsrr_resolver), | 62 dnsrr_resolver_(dnsrr_resolver), |
| 63 ssl_host_info_factory_(ssl_host_info_factory), |
60 proxy_service_(proxy_service), | 64 proxy_service_(proxy_service), |
61 ssl_config_service_(ssl_config_service), | 65 ssl_config_service_(ssl_config_service), |
62 session_(NULL), | 66 session_(NULL), |
63 spdy_session_pool_(NULL), | 67 spdy_session_pool_(NULL), |
64 http_auth_handler_factory_(http_auth_handler_factory), | 68 http_auth_handler_factory_(http_auth_handler_factory), |
65 network_delegate_(network_delegate), | 69 network_delegate_(network_delegate), |
66 net_log_(net_log), | 70 net_log_(net_log), |
67 suspended_(false) { | 71 suspended_(false) { |
68 DCHECK(proxy_service_); | 72 DCHECK(proxy_service_); |
69 DCHECK(ssl_config_service_.get()); | 73 DCHECK(ssl_config_service_.get()); |
70 } | 74 } |
71 | 75 |
72 HttpNetworkLayer::HttpNetworkLayer( | 76 HttpNetworkLayer::HttpNetworkLayer( |
73 ClientSocketFactory* socket_factory, | 77 ClientSocketFactory* socket_factory, |
74 HostResolver* host_resolver, | 78 HostResolver* host_resolver, |
75 DnsRRResolver* dnsrr_resolver, | 79 DnsRRResolver* dnsrr_resolver, |
| 80 SSLHostInfoFactory* ssl_host_info_factory, |
76 ProxyService* proxy_service, | 81 ProxyService* proxy_service, |
77 SSLConfigService* ssl_config_service, | 82 SSLConfigService* ssl_config_service, |
78 SpdySessionPool* spdy_session_pool, | 83 SpdySessionPool* spdy_session_pool, |
79 HttpAuthHandlerFactory* http_auth_handler_factory, | 84 HttpAuthHandlerFactory* http_auth_handler_factory, |
80 HttpNetworkDelegate* network_delegate, | 85 HttpNetworkDelegate* network_delegate, |
81 NetLog* net_log) | 86 NetLog* net_log) |
82 : socket_factory_(socket_factory), | 87 : socket_factory_(socket_factory), |
83 host_resolver_(host_resolver), | 88 host_resolver_(host_resolver), |
84 dnsrr_resolver_(dnsrr_resolver), | 89 dnsrr_resolver_(dnsrr_resolver), |
| 90 ssl_host_info_factory_(ssl_host_info_factory), |
85 proxy_service_(proxy_service), | 91 proxy_service_(proxy_service), |
86 ssl_config_service_(ssl_config_service), | 92 ssl_config_service_(ssl_config_service), |
87 session_(NULL), | 93 session_(NULL), |
88 spdy_session_pool_(spdy_session_pool), | 94 spdy_session_pool_(spdy_session_pool), |
89 http_auth_handler_factory_(http_auth_handler_factory), | 95 http_auth_handler_factory_(http_auth_handler_factory), |
90 network_delegate_(network_delegate), | 96 network_delegate_(network_delegate), |
91 net_log_(net_log), | 97 net_log_(net_log), |
92 suspended_(false) { | 98 suspended_(false) { |
93 DCHECK(proxy_service_); | 99 DCHECK(proxy_service_); |
94 DCHECK(ssl_config_service_.get()); | 100 DCHECK(ssl_config_service_.get()); |
95 } | 101 } |
96 | 102 |
97 HttpNetworkLayer::HttpNetworkLayer(HttpNetworkSession* session) | 103 HttpNetworkLayer::HttpNetworkLayer(HttpNetworkSession* session) |
98 : socket_factory_(ClientSocketFactory::GetDefaultFactory()), | 104 : socket_factory_(ClientSocketFactory::GetDefaultFactory()), |
99 dnsrr_resolver_(NULL), | 105 dnsrr_resolver_(NULL), |
| 106 ssl_host_info_factory_(NULL), |
100 ssl_config_service_(NULL), | 107 ssl_config_service_(NULL), |
101 session_(session), | 108 session_(session), |
102 spdy_session_pool_(NULL), | 109 spdy_session_pool_(NULL), |
103 http_auth_handler_factory_(NULL), | 110 http_auth_handler_factory_(NULL), |
104 network_delegate_(NULL), | 111 network_delegate_(NULL), |
105 net_log_(NULL), | 112 net_log_(NULL), |
106 suspended_(false) { | 113 suspended_(false) { |
107 DCHECK(session_.get()); | 114 DCHECK(session_.get()); |
108 } | 115 } |
109 | 116 |
(...skipping 20 matching lines...) Expand all Loading... |
130 } | 137 } |
131 | 138 |
132 HttpNetworkSession* HttpNetworkLayer::GetSession() { | 139 HttpNetworkSession* HttpNetworkLayer::GetSession() { |
133 if (!session_) { | 140 if (!session_) { |
134 DCHECK(proxy_service_); | 141 DCHECK(proxy_service_); |
135 if (!spdy_session_pool_.get()) | 142 if (!spdy_session_pool_.get()) |
136 spdy_session_pool_.reset(new SpdySessionPool(ssl_config_service_)); | 143 spdy_session_pool_.reset(new SpdySessionPool(ssl_config_service_)); |
137 session_ = new HttpNetworkSession( | 144 session_ = new HttpNetworkSession( |
138 host_resolver_, | 145 host_resolver_, |
139 dnsrr_resolver_, | 146 dnsrr_resolver_, |
| 147 ssl_host_info_factory_, |
140 proxy_service_, | 148 proxy_service_, |
141 socket_factory_, | 149 socket_factory_, |
142 ssl_config_service_, | 150 ssl_config_service_, |
143 spdy_session_pool_.release(), | 151 spdy_session_pool_.release(), |
144 http_auth_handler_factory_, | 152 http_auth_handler_factory_, |
145 network_delegate_, | 153 network_delegate_, |
146 net_log_); | 154 net_log_); |
147 // These were just temps for lazy-initializing HttpNetworkSession. | 155 // These were just temps for lazy-initializing HttpNetworkSession. |
148 host_resolver_ = NULL; | 156 host_resolver_ = NULL; |
149 dnsrr_resolver_ = NULL; | 157 dnsrr_resolver_ = NULL; |
| 158 ssl_host_info_factory_ = NULL; |
150 proxy_service_ = NULL; | 159 proxy_service_ = NULL; |
151 socket_factory_ = NULL; | 160 socket_factory_ = NULL; |
152 http_auth_handler_factory_ = NULL; | 161 http_auth_handler_factory_ = NULL; |
153 net_log_ = NULL; | 162 net_log_ = NULL; |
154 network_delegate_ = NULL; | 163 network_delegate_ = NULL; |
155 } | 164 } |
156 return session_; | 165 return session_; |
157 } | 166 } |
158 | 167 |
159 // static | 168 // static |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 pair.protocol = HttpAlternateProtocols::NPN_SPDY_2; | 241 pair.protocol = HttpAlternateProtocols::NPN_SPDY_2; |
233 HttpAlternateProtocols::ForceAlternateProtocol(pair); | 242 HttpAlternateProtocols::ForceAlternateProtocol(pair); |
234 } else if (option.empty() && it == spdy_options.begin()) { | 243 } else if (option.empty() && it == spdy_options.begin()) { |
235 continue; | 244 continue; |
236 } else { | 245 } else { |
237 LOG(DFATAL) << "Unrecognized spdy option: " << option; | 246 LOG(DFATAL) << "Unrecognized spdy option: " << option; |
238 } | 247 } |
239 } | 248 } |
240 } | 249 } |
241 } // namespace net | 250 } // namespace net |
OLD | NEW |