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

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

Issue 6402002: Simplify HttpCache/HttpNetworkLayer/HttpNetworkSession interaction. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nits. Created 9 years, 10 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_network_layer.h ('k') | net/http/http_network_layer_unittest.cc » ('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) 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_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/string_split.h" 9 #include "base/string_split.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "net/http/http_network_session.h" 11 #include "net/http/http_network_session.h"
12 #include "net/http/http_network_transaction.h" 12 #include "net/http/http_network_transaction.h"
13 #include "net/socket/client_socket_factory.h" 13 #include "net/socket/client_socket_factory.h"
14 #include "net/spdy/spdy_framer.h" 14 #include "net/spdy/spdy_framer.h"
15 #include "net/spdy/spdy_session.h" 15 #include "net/spdy/spdy_session.h"
16 #include "net/spdy/spdy_session_pool.h" 16 #include "net/spdy/spdy_session_pool.h"
17 17
18 namespace net { 18 namespace net {
19 19
20 //----------------------------------------------------------------------------- 20 //-----------------------------------------------------------------------------
21
22 HttpNetworkLayer::HttpNetworkLayer(
23 ClientSocketFactory* socket_factory,
24 HostResolver* host_resolver,
25 CertVerifier* cert_verifier,
26 DnsRRResolver* dnsrr_resolver,
27 DnsCertProvenanceChecker* dns_cert_checker,
28 SSLHostInfoFactory* ssl_host_info_factory,
29 ProxyService* proxy_service,
30 SSLConfigService* ssl_config_service,
31 HttpAuthHandlerFactory* http_auth_handler_factory,
32 HttpNetworkDelegate* network_delegate,
33 NetLog* net_log)
34 : socket_factory_(socket_factory),
35 host_resolver_(host_resolver),
36 cert_verifier_(cert_verifier),
37 dnsrr_resolver_(dnsrr_resolver),
38 dns_cert_checker_(dns_cert_checker),
39 ssl_host_info_factory_(ssl_host_info_factory),
40 proxy_service_(proxy_service),
41 ssl_config_service_(ssl_config_service),
42 session_(NULL),
43 spdy_session_pool_(NULL),
44 http_auth_handler_factory_(http_auth_handler_factory),
45 network_delegate_(network_delegate),
46 net_log_(net_log),
47 suspended_(false) {
48 DCHECK(proxy_service_);
49 DCHECK(ssl_config_service_.get());
50 }
51
52 HttpNetworkLayer::HttpNetworkLayer(
53 ClientSocketFactory* socket_factory,
54 HostResolver* host_resolver,
55 CertVerifier* cert_verifier,
56 DnsRRResolver* dnsrr_resolver,
57 DnsCertProvenanceChecker* dns_cert_checker,
58 SSLHostInfoFactory* ssl_host_info_factory,
59 ProxyService* proxy_service,
60 SSLConfigService* ssl_config_service,
61 SpdySessionPool* spdy_session_pool,
62 HttpAuthHandlerFactory* http_auth_handler_factory,
63 HttpNetworkDelegate* network_delegate,
64 NetLog* net_log)
65 : socket_factory_(socket_factory),
66 host_resolver_(host_resolver),
67 cert_verifier_(cert_verifier),
68 dnsrr_resolver_(dnsrr_resolver),
69 dns_cert_checker_(dns_cert_checker),
70 ssl_host_info_factory_(ssl_host_info_factory),
71 proxy_service_(proxy_service),
72 ssl_config_service_(ssl_config_service),
73 session_(NULL),
74 spdy_session_pool_(spdy_session_pool),
75 http_auth_handler_factory_(http_auth_handler_factory),
76 network_delegate_(network_delegate),
77 net_log_(net_log),
78 suspended_(false) {
79 DCHECK(proxy_service_);
80 DCHECK(ssl_config_service_.get());
81 }
82
83 HttpNetworkLayer::HttpNetworkLayer(HttpNetworkSession* session) 21 HttpNetworkLayer::HttpNetworkLayer(HttpNetworkSession* session)
84 : socket_factory_(ClientSocketFactory::GetDefaultFactory()), 22 : session_(session),
85 host_resolver_(NULL),
86 cert_verifier_(NULL),
87 dnsrr_resolver_(NULL),
88 dns_cert_checker_(NULL),
89 ssl_host_info_factory_(NULL),
90 ssl_config_service_(NULL),
91 session_(session),
92 spdy_session_pool_(NULL),
93 http_auth_handler_factory_(NULL),
94 network_delegate_(NULL),
95 net_log_(NULL),
96 suspended_(false) { 23 suspended_(false) {
97 DCHECK(session_.get()); 24 DCHECK(session_.get());
98 } 25 }
99 26
100 HttpNetworkLayer::~HttpNetworkLayer() { 27 HttpNetworkLayer::~HttpNetworkLayer() {
101 } 28 }
102 29
103 //----------------------------------------------------------------------------- 30 //-----------------------------------------------------------------------------
104 31
105 // static 32 // static
106 HttpTransactionFactory* HttpNetworkLayer::CreateFactory( 33 HttpTransactionFactory* HttpNetworkLayer::CreateFactory(
107 HostResolver* host_resolver,
108 CertVerifier* cert_verifier,
109 DnsRRResolver* dnsrr_resolver,
110 DnsCertProvenanceChecker* dns_cert_checker,
111 SSLHostInfoFactory* ssl_host_info_factory,
112 ProxyService* proxy_service,
113 SSLConfigService* ssl_config_service,
114 HttpAuthHandlerFactory* http_auth_handler_factory,
115 HttpNetworkDelegate* network_delegate,
116 NetLog* net_log) {
117 DCHECK(proxy_service);
118
119 return new HttpNetworkLayer(ClientSocketFactory::GetDefaultFactory(),
120 host_resolver, cert_verifier, dnsrr_resolver,
121 dns_cert_checker,
122 ssl_host_info_factory, proxy_service,
123 ssl_config_service, http_auth_handler_factory,
124 network_delegate,
125 net_log);
126 }
127
128 // static
129 HttpTransactionFactory* HttpNetworkLayer::CreateFactory(
130 HttpNetworkSession* session) { 34 HttpNetworkSession* session) {
131 DCHECK(session); 35 DCHECK(session);
132 36
133 return new HttpNetworkLayer(session); 37 return new HttpNetworkLayer(session);
134 } 38 }
135 39
136 // static 40 // static
137 void HttpNetworkLayer::EnableSpdy(const std::string& mode) { 41 void HttpNetworkLayer::EnableSpdy(const std::string& mode) {
138 static const char kOff[] = "off"; 42 static const char kOff[] = "off";
139 static const char kSSL[] = "ssl"; 43 static const char kSSL[] = "ssl";
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 139
236 trans->reset(new HttpNetworkTransaction(GetSession())); 140 trans->reset(new HttpNetworkTransaction(GetSession()));
237 return OK; 141 return OK;
238 } 142 }
239 143
240 HttpCache* HttpNetworkLayer::GetCache() { 144 HttpCache* HttpNetworkLayer::GetCache() {
241 return NULL; 145 return NULL;
242 } 146 }
243 147
244 HttpNetworkSession* HttpNetworkLayer::GetSession() { 148 HttpNetworkSession* HttpNetworkLayer::GetSession() {
245 if (!session_) {
246 DCHECK(proxy_service_);
247 if (!spdy_session_pool_.get())
248 spdy_session_pool_.reset(new SpdySessionPool(ssl_config_service_));
249 session_ = new HttpNetworkSession(
250 host_resolver_,
251 cert_verifier_,
252 dnsrr_resolver_,
253 dns_cert_checker_,
254 ssl_host_info_factory_,
255 proxy_service_,
256 socket_factory_,
257 ssl_config_service_,
258 spdy_session_pool_.release(),
259 http_auth_handler_factory_,
260 network_delegate_,
261 net_log_);
262 // These were just temps for lazy-initializing HttpNetworkSession.
263 host_resolver_ = NULL;
264 cert_verifier_ = NULL;
265 dnsrr_resolver_ = NULL;
266 dns_cert_checker_ = NULL;
267 ssl_host_info_factory_ = NULL;
268 proxy_service_ = NULL;
269 socket_factory_ = NULL;
270 http_auth_handler_factory_ = NULL;
271 net_log_ = NULL;
272 network_delegate_ = NULL;
273 }
274 return session_; 149 return session_;
275 } 150 }
276 151
277 void HttpNetworkLayer::Suspend(bool suspend) { 152 void HttpNetworkLayer::Suspend(bool suspend) {
278 suspended_ = suspend; 153 suspended_ = suspend;
279 154
280 if (suspend && session_) 155 if (suspend && session_)
281 session_->tcp_socket_pool()->CloseIdleSockets(); 156 session_->tcp_socket_pool()->CloseIdleSockets();
282 } 157 }
283 158
284 } // namespace net 159 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_layer.h ('k') | net/http/http_network_layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698