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 #ifndef NET_HTTP_HTTP_NETWORK_LAYER_H_ | 5 #ifndef NET_HTTP_HTTP_NETWORK_LAYER_H_ |
6 #define NET_HTTP_HTTP_NETWORK_LAYER_H_ | 6 #define NET_HTTP_HTTP_NETWORK_LAYER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 class HttpNetworkSession; | 25 class HttpNetworkSession; |
26 class NetLog; | 26 class NetLog; |
27 class ProxyService; | 27 class ProxyService; |
28 class SpdySessionPool; | 28 class SpdySessionPool; |
29 class SSLConfigService; | 29 class SSLConfigService; |
30 class SSLHostInfoFactory; | 30 class SSLHostInfoFactory; |
31 | 31 |
32 class HttpNetworkLayer : public HttpTransactionFactory, | 32 class HttpNetworkLayer : public HttpTransactionFactory, |
33 public base::NonThreadSafe { | 33 public base::NonThreadSafe { |
34 public: | 34 public: |
35 // |socket_factory|, |proxy_service|, |host_resolver|, etc. must remain | |
36 // valid for the lifetime of HttpNetworkLayer. | |
37 // TODO(wtc): we only need the next constructor. | |
38 HttpNetworkLayer(ClientSocketFactory* socket_factory, | |
39 HostResolver* host_resolver, | |
40 CertVerifier* cert_verifier, | |
41 DnsRRResolver* dnsrr_resolver, | |
42 DnsCertProvenanceChecker* dns_cert_checker, | |
43 SSLHostInfoFactory* ssl_host_info_factory, | |
44 ProxyService* proxy_service, | |
45 SSLConfigService* ssl_config_service, | |
46 HttpAuthHandlerFactory* http_auth_handler_factory, | |
47 HttpNetworkDelegate* network_delegate, | |
48 NetLog* net_log); | |
49 HttpNetworkLayer( | |
50 ClientSocketFactory* socket_factory, | |
51 HostResolver* host_resolver, | |
52 CertVerifier* cert_verifier, | |
53 DnsRRResolver* dnsrr_resolver, | |
54 DnsCertProvenanceChecker* dns_cert_checker, | |
55 SSLHostInfoFactory* ssl_host_info_factory, | |
56 ProxyService* proxy_service, | |
57 SSLConfigService* ssl_config_service, | |
58 SpdySessionPool* spdy_session_pool, | |
59 HttpAuthHandlerFactory* http_auth_handler_factory, | |
60 HttpNetworkDelegate* network_delegate, | |
61 NetLog* net_log); | |
62 | |
63 // Construct a HttpNetworkLayer with an existing HttpNetworkSession which | 35 // Construct a HttpNetworkLayer with an existing HttpNetworkSession which |
64 // contains a valid ProxyService. | 36 // contains a valid ProxyService. |
65 explicit HttpNetworkLayer(HttpNetworkSession* session); | 37 explicit HttpNetworkLayer(HttpNetworkSession* session); |
66 ~HttpNetworkLayer(); | 38 virtual ~HttpNetworkLayer(); |
67 | |
68 // This function hides the details of how a network layer gets instantiated | |
69 // and allows other implementations to be substituted. | |
70 static HttpTransactionFactory* CreateFactory( | |
71 HostResolver* host_resolver, | |
72 CertVerifier* cert_verifier, | |
73 DnsRRResolver* dnsrr_resolver, | |
74 DnsCertProvenanceChecker* dns_cert_checker, | |
75 SSLHostInfoFactory* ssl_host_info_factory, | |
76 ProxyService* proxy_service, | |
77 SSLConfigService* ssl_config_service, | |
78 HttpAuthHandlerFactory* http_auth_handler_factory, | |
79 HttpNetworkDelegate* network_delegate, | |
80 NetLog* net_log); | |
81 | 39 |
82 // Create a transaction factory that instantiate a network layer over an | 40 // Create a transaction factory that instantiate a network layer over an |
83 // existing network session. Network session contains some valuable | 41 // existing network session. Network session contains some valuable |
84 // information (e.g. authentication data) that we want to share across | 42 // information (e.g. authentication data) that we want to share across |
85 // multiple network layers. This method exposes the implementation details | 43 // multiple network layers. This method exposes the implementation details |
86 // of a network layer, use this method with an existing network layer only | 44 // of a network layer, use this method with an existing network layer only |
87 // when network session is shared. | 45 // when network session is shared. |
88 static HttpTransactionFactory* CreateFactory(HttpNetworkSession* session); | 46 static HttpTransactionFactory* CreateFactory(HttpNetworkSession* session); |
89 | 47 |
90 // Enable the spdy protocol. | 48 // Enable the spdy protocol. |
91 // Without calling this function, SPDY is disabled. The mode can be: | 49 // Without calling this function, SPDY is disabled. The mode can be: |
92 // "" : (default) SSL and compression are enabled, flow | 50 // "" : (default) SSL and compression are enabled, flow |
93 // control disabled. | 51 // control disabled. |
94 // "no-ssl" : disables SSL. | 52 // "no-ssl" : disables SSL. |
95 // "no-compress" : disables compression. | 53 // "no-compress" : disables compression. |
96 // "flow-control": enables flow control. | 54 // "flow-control": enables flow control. |
97 // "none" : disables both SSL and compression. | 55 // "none" : disables both SSL and compression. |
98 static void EnableSpdy(const std::string& mode); | 56 static void EnableSpdy(const std::string& mode); |
99 | 57 |
100 // HttpTransactionFactory methods: | 58 // HttpTransactionFactory methods: |
101 virtual int CreateTransaction(scoped_ptr<HttpTransaction>* trans); | 59 virtual int CreateTransaction(scoped_ptr<HttpTransaction>* trans); |
102 virtual HttpCache* GetCache(); | 60 virtual HttpCache* GetCache(); |
103 virtual HttpNetworkSession* GetSession(); | 61 virtual HttpNetworkSession* GetSession(); |
104 virtual void Suspend(bool suspend); | 62 virtual void Suspend(bool suspend); |
105 | 63 |
106 private: | 64 private: |
107 // The factory we will use to create network sockets. | 65 const scoped_refptr<HttpNetworkSession> session_; |
108 ClientSocketFactory* socket_factory_; | |
109 | |
110 // The host resolver, proxy service, etc. that will be used when lazily | |
111 // creating |session_|. | |
112 HostResolver* host_resolver_; | |
113 CertVerifier* cert_verifier_; | |
114 DnsRRResolver* dnsrr_resolver_; | |
115 DnsCertProvenanceChecker* dns_cert_checker_; | |
116 SSLHostInfoFactory* ssl_host_info_factory_; | |
117 scoped_refptr<ProxyService> proxy_service_; | |
118 | |
119 // The SSL config service being used for the session. | |
120 scoped_refptr<SSLConfigService> ssl_config_service_; | |
121 | |
122 scoped_refptr<HttpNetworkSession> session_; | |
123 scoped_ptr<SpdySessionPool> spdy_session_pool_; | |
124 | |
125 HttpAuthHandlerFactory* http_auth_handler_factory_; | |
126 HttpNetworkDelegate* network_delegate_; | |
127 NetLog* net_log_; | |
128 | |
129 bool suspended_; | 66 bool suspended_; |
130 }; | 67 }; |
131 | 68 |
132 } // namespace net | 69 } // namespace net |
133 | 70 |
134 #endif // NET_HTTP_HTTP_NETWORK_LAYER_H_ | 71 #endif // NET_HTTP_HTTP_NETWORK_LAYER_H_ |
OLD | NEW |