Remove now unneeded AnimateNow calls
[chromium-blink-merge.git] / net / http / http_network_session.h
blob51e22922c08cd0ca54bf892bf09c98cc61190698
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
3 // found in the LICENSE file.
5 #ifndef NET_HTTP_HTTP_NETWORK_SESSION_H_
6 #define NET_HTTP_HTTP_NETWORK_SESSION_H_
8 #include <set>
9 #include <string>
10 #include <vector>
12 #include "base/basictypes.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h"
15 #include "base/threading/non_thread_safe.h"
16 #include "net/base/host_port_pair.h"
17 #include "net/base/net_export.h"
18 #include "net/dns/host_resolver.h"
19 #include "net/http/http_auth_cache.h"
20 #include "net/http/http_stream_factory.h"
21 #include "net/quic/quic_stream_factory.h"
22 #include "net/socket/next_proto.h"
23 #include "net/spdy/spdy_session_pool.h"
24 #include "net/ssl/ssl_client_auth_cache.h"
26 namespace base {
27 class Value;
30 namespace net {
32 class CertVerifier;
33 class ChannelIDService;
34 class ClientSocketFactory;
35 class ClientSocketPoolManager;
36 class CTVerifier;
37 class HostResolver;
38 class HpackHuffmanAggregator;
39 class HttpAuthHandlerFactory;
40 class HttpNetworkSessionPeer;
41 class HttpProxyClientSocketPool;
42 class HttpResponseBodyDrainer;
43 class HttpServerProperties;
44 class NetLog;
45 class NetworkDelegate;
46 class ProxyDelegate;
47 class ProxyService;
48 class QuicClock;
49 class QuicCryptoClientStreamFactory;
50 class QuicServerInfoFactory;
51 class SOCKSClientSocketPool;
52 class SSLClientSocketPool;
53 class SSLConfigService;
54 class TransportClientSocketPool;
55 class TransportSecurityState;
57 // This class holds session objects used by HttpNetworkTransaction objects.
58 class NET_EXPORT HttpNetworkSession
59 : public base::RefCounted<HttpNetworkSession>,
60 NON_EXPORTED_BASE(public base::NonThreadSafe) {
61 public:
62 struct NET_EXPORT Params {
63 Params();
64 ~Params();
66 ClientSocketFactory* client_socket_factory;
67 HostResolver* host_resolver;
68 CertVerifier* cert_verifier;
69 ChannelIDService* channel_id_service;
70 TransportSecurityState* transport_security_state;
71 CTVerifier* cert_transparency_verifier;
72 ProxyService* proxy_service;
73 std::string ssl_session_cache_shard;
74 SSLConfigService* ssl_config_service;
75 HttpAuthHandlerFactory* http_auth_handler_factory;
76 NetworkDelegate* network_delegate;
77 base::WeakPtr<HttpServerProperties> http_server_properties;
78 NetLog* net_log;
79 HostMappingRules* host_mapping_rules;
80 bool enable_ssl_connect_job_waiting;
81 bool ignore_certificate_errors;
82 uint16 testing_fixed_http_port;
83 uint16 testing_fixed_https_port;
84 bool enable_tcp_fast_open_for_ssl;
86 bool force_spdy_single_domain;
87 bool enable_spdy_compression;
88 bool enable_spdy_ping_based_connection_checking;
89 NextProto spdy_default_protocol;
90 // The protocols supported by NPN (next protocol negotiation) during the
91 // SSL handshake as well as by HTTP Alternate-Protocol.
92 // TODO(mmenke): This is currently empty by default, and alternate
93 // protocols are disabled. We should use some reasonable
94 // defaults.
95 NextProtoVector next_protos;
96 size_t spdy_stream_initial_recv_window_size;
97 size_t spdy_initial_max_concurrent_streams;
98 size_t spdy_max_concurrent_streams_limit;
99 SpdySessionPool::TimeFunc time_func;
100 std::string trusted_spdy_proxy;
101 // Controls whether or not ssl is used when in SPDY mode.
102 bool force_spdy_over_ssl;
103 // Controls whether or not SPDY is used without NPN.
104 bool force_spdy_always;
105 // URLs to exclude from forced SPDY.
106 std::set<HostPortPair> forced_spdy_exclusions;
107 // Noe: Using this in the case of NPN for HTTP only results in the browser
108 // trying SSL and then falling back to http.
109 bool use_alternate_protocols;
110 double alternate_protocol_probability_threshold;
111 bool enable_websocket_over_spdy;
113 bool enable_quic;
114 bool enable_quic_port_selection;
115 bool quic_always_require_handshake_confirmation;
116 bool quic_disable_connection_pooling;
117 HostPortPair origin_to_force_quic_on;
118 QuicClock* quic_clock; // Will be owned by QuicStreamFactory.
119 QuicRandom* quic_random;
120 size_t quic_max_packet_length;
121 std::string quic_user_agent_id;
122 bool enable_user_alternate_protocol_ports;
123 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory;
124 QuicVersionVector quic_supported_versions;
125 QuicTagVector quic_connection_options;
126 ProxyDelegate* proxy_delegate;
129 enum SocketPoolType {
130 NORMAL_SOCKET_POOL,
131 WEBSOCKET_SOCKET_POOL,
132 NUM_SOCKET_POOL_TYPES
135 explicit HttpNetworkSession(const Params& params);
137 HttpAuthCache* http_auth_cache() { return &http_auth_cache_; }
138 SSLClientAuthCache* ssl_client_auth_cache() {
139 return &ssl_client_auth_cache_;
142 void AddResponseDrainer(HttpResponseBodyDrainer* drainer);
144 void RemoveResponseDrainer(HttpResponseBodyDrainer* drainer);
146 TransportClientSocketPool* GetTransportSocketPool(SocketPoolType pool_type);
147 SSLClientSocketPool* GetSSLSocketPool(SocketPoolType pool_type);
148 SOCKSClientSocketPool* GetSocketPoolForSOCKSProxy(
149 SocketPoolType pool_type,
150 const HostPortPair& socks_proxy);
151 HttpProxyClientSocketPool* GetSocketPoolForHTTPProxy(
152 SocketPoolType pool_type,
153 const HostPortPair& http_proxy);
154 SSLClientSocketPool* GetSocketPoolForSSLWithProxy(
155 SocketPoolType pool_type,
156 const HostPortPair& proxy_server);
158 CertVerifier* cert_verifier() { return cert_verifier_; }
159 ProxyService* proxy_service() { return proxy_service_; }
160 SSLConfigService* ssl_config_service() { return ssl_config_service_.get(); }
161 SpdySessionPool* spdy_session_pool() { return &spdy_session_pool_; }
162 QuicStreamFactory* quic_stream_factory() { return &quic_stream_factory_; }
163 HttpAuthHandlerFactory* http_auth_handler_factory() {
164 return http_auth_handler_factory_;
166 NetworkDelegate* network_delegate() {
167 return network_delegate_;
169 base::WeakPtr<HttpServerProperties> http_server_properties() {
170 return http_server_properties_;
172 HttpStreamFactory* http_stream_factory() {
173 return http_stream_factory_.get();
175 HttpStreamFactory* http_stream_factory_for_websocket() {
176 return http_stream_factory_for_websocket_.get();
178 NetLog* net_log() {
179 return net_log_;
181 HpackHuffmanAggregator* huffman_aggregator() {
182 return huffman_aggregator_.get();
185 // Creates a Value summary of the state of the socket pools. The caller is
186 // responsible for deleting the returned value.
187 base::Value* SocketPoolInfoToValue() const;
189 // Creates a Value summary of the state of the SPDY sessions. The caller is
190 // responsible for deleting the returned value.
191 base::Value* SpdySessionPoolInfoToValue() const;
193 // Creates a Value summary of the state of the QUIC sessions and
194 // configuration. The caller is responsible for deleting the returned value.
195 base::Value* QuicInfoToValue() const;
197 void CloseAllConnections();
198 void CloseIdleConnections();
200 // Returns the original Params used to construct this session.
201 const Params& params() const { return params_; }
203 bool IsProtocolEnabled(AlternateProtocol protocol) const;
205 void GetNextProtos(std::vector<std::string>* next_protos) const;
207 // Convenience function for searching through |params_| for
208 // |forced_spdy_exclusions|.
209 bool HasSpdyExclusion(HostPortPair host_port_pair) const;
211 private:
212 friend class base::RefCounted<HttpNetworkSession>;
213 friend class HttpNetworkSessionPeer;
215 ~HttpNetworkSession();
217 ClientSocketPoolManager* GetSocketPoolManager(SocketPoolType pool_type);
219 NetLog* const net_log_;
220 NetworkDelegate* const network_delegate_;
221 const base::WeakPtr<HttpServerProperties> http_server_properties_;
222 CertVerifier* const cert_verifier_;
223 HttpAuthHandlerFactory* const http_auth_handler_factory_;
225 // Not const since it's modified by HttpNetworkSessionPeer for testing.
226 ProxyService* proxy_service_;
227 const scoped_refptr<SSLConfigService> ssl_config_service_;
229 HttpAuthCache http_auth_cache_;
230 SSLClientAuthCache ssl_client_auth_cache_;
231 scoped_ptr<ClientSocketPoolManager> normal_socket_pool_manager_;
232 scoped_ptr<ClientSocketPoolManager> websocket_socket_pool_manager_;
233 QuicStreamFactory quic_stream_factory_;
234 SpdySessionPool spdy_session_pool_;
235 scoped_ptr<HttpStreamFactory> http_stream_factory_;
236 scoped_ptr<HttpStreamFactory> http_stream_factory_for_websocket_;
237 std::set<HttpResponseBodyDrainer*> response_drainers_;
239 // TODO(jgraettinger): Remove when Huffman collection is complete.
240 scoped_ptr<HpackHuffmanAggregator> huffman_aggregator_;
242 std::vector<std::string> next_protos_;
243 bool enabled_protocols_[NUM_VALID_ALTERNATE_PROTOCOLS];
245 Params params_;
248 } // namespace net
250 #endif // NET_HTTP_HTTP_NETWORK_SESSION_H_