[email protected] | fa55e19 | 2010-02-15 14:25:50 | [diff] [blame] | 1 | // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 4 | |
| 5 | #ifndef NET_HTTP_HTTP_NETWORK_LAYER_H_ |
| 6 | #define NET_HTTP_HTTP_NETWORK_LAYER_H_ |
| 7 | |
[email protected] | 650e2cae | 2009-10-21 23:52:07 | [diff] [blame] | 8 | #include <string> |
| 9 | |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 10 | #include "base/ref_counted.h" |
[email protected] | a3b006eea | 2008-10-22 21:23:08 | [diff] [blame] | 11 | #include "base/scoped_ptr.h" |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 12 | #include "net/http/http_transaction_factory.h" |
| 13 | |
| 14 | namespace net { |
| 15 | |
[email protected] | c689457 | 2009-06-16 17:10:10 | [diff] [blame] | 16 | class ClientSocketFactory; |
[email protected] | 8a00f00a | 2009-06-12 00:49:38 | [diff] [blame] | 17 | class HostResolver; |
[email protected] | fa55e19 | 2010-02-15 14:25:50 | [diff] [blame] | 18 | class HttpAuthHandlerFactory; |
[email protected] | ac03952 | 2010-06-15 16:39:44 | [diff] [blame] | 19 | class HttpNetworkDelegate; |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 20 | class HttpNetworkSession; |
[email protected] | 06650c5 | 2010-06-03 00:49:17 | [diff] [blame] | 21 | class NetLog; |
[email protected] | d13c327 | 2010-02-04 00:24:51 | [diff] [blame] | 22 | class NetworkChangeNotifier; |
[email protected] | 928fb58 | 2008-08-11 15:40:23 | [diff] [blame] | 23 | class ProxyInfo; |
[email protected] | 63de95b | 2008-12-10 04:11:27 | [diff] [blame] | 24 | class ProxyService; |
[email protected] | 61a86c4 | 2010-04-19 22:45:53 | [diff] [blame] | 25 | class SpdySessionPool; |
[email protected] | db36938c | 2009-08-19 21:48:42 | [diff] [blame] | 26 | class SSLConfigService; |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 27 | |
| 28 | class HttpNetworkLayer : public HttpTransactionFactory { |
| 29 | public: |
[email protected] | d13c327 | 2010-02-04 00:24:51 | [diff] [blame] | 30 | // |socket_factory|, |network_change_notifier|, |proxy_service| and |
| 31 | // |host_resolver| must remain valid for the lifetime of HttpNetworkLayer. |
[email protected] | c689457 | 2009-06-16 17:10:10 | [diff] [blame] | 32 | HttpNetworkLayer(ClientSocketFactory* socket_factory, |
[email protected] | d13c327 | 2010-02-04 00:24:51 | [diff] [blame] | 33 | NetworkChangeNotifier* network_change_notifier, |
[email protected] | db36938c | 2009-08-19 21:48:42 | [diff] [blame] | 34 | HostResolver* host_resolver, ProxyService* proxy_service, |
[email protected] | fa55e19 | 2010-02-15 14:25:50 | [diff] [blame] | 35 | SSLConfigService* ssl_config_service, |
[email protected] | 06650c5 | 2010-06-03 00:49:17 | [diff] [blame] | 36 | HttpAuthHandlerFactory* http_auth_handler_factory, |
[email protected] | ac03952 | 2010-06-15 16:39:44 | [diff] [blame] | 37 | HttpNetworkDelegate* network_delegate, |
[email protected] | 06650c5 | 2010-06-03 00:49:17 | [diff] [blame] | 38 | NetLog* net_log); |
[email protected] | e7f2964 | 2009-03-02 22:53:18 | [diff] [blame] | 39 | // Construct a HttpNetworkLayer with an existing HttpNetworkSession which |
| 40 | // contains a valid ProxyService. |
| 41 | explicit HttpNetworkLayer(HttpNetworkSession* session); |
[email protected] | 7b822b2b | 2008-08-05 00:15:45 | [diff] [blame] | 42 | ~HttpNetworkLayer(); |
| 43 | |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 44 | // This function hides the details of how a network layer gets instantiated |
| 45 | // and allows other implementations to be substituted. |
[email protected] | db36938c | 2009-08-19 21:48:42 | [diff] [blame] | 46 | static HttpTransactionFactory* CreateFactory( |
[email protected] | d13c327 | 2010-02-04 00:24:51 | [diff] [blame] | 47 | NetworkChangeNotifier* network_change_notifier, |
[email protected] | db36938c | 2009-08-19 21:48:42 | [diff] [blame] | 48 | HostResolver* host_resolver, |
| 49 | ProxyService* proxy_service, |
[email protected] | fa55e19 | 2010-02-15 14:25:50 | [diff] [blame] | 50 | SSLConfigService* ssl_config_service, |
[email protected] | 06650c5 | 2010-06-03 00:49:17 | [diff] [blame] | 51 | HttpAuthHandlerFactory* http_auth_handler_factory, |
[email protected] | ac03952 | 2010-06-15 16:39:44 | [diff] [blame] | 52 | HttpNetworkDelegate* network_delegate, |
[email protected] | 06650c5 | 2010-06-03 00:49:17 | [diff] [blame] | 53 | NetLog* net_log); |
[email protected] | e7f2964 | 2009-03-02 22:53:18 | [diff] [blame] | 54 | // Create a transaction factory that instantiate a network layer over an |
| 55 | // existing network session. Network session contains some valuable |
| 56 | // information (e.g. authentication data) that we want to share across |
| 57 | // multiple network layers. This method exposes the implementation details |
| 58 | // of a network layer, use this method with an existing network layer only |
| 59 | // when network session is shared. |
| 60 | static HttpTransactionFactory* CreateFactory(HttpNetworkSession* session); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 61 | |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 62 | // HttpTransactionFactory methods: |
[email protected] | 1638d60 | 2009-09-24 03:49:17 | [diff] [blame] | 63 | virtual int CreateTransaction(scoped_ptr<HttpTransaction>* trans); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 64 | virtual HttpCache* GetCache(); |
[email protected] | 659a2602 | 2009-10-06 02:22:10 | [diff] [blame] | 65 | virtual HttpNetworkSession* GetSession(); |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 66 | virtual void Suspend(bool suspend); |
| 67 | |
[email protected] | 955fc2e7 | 2010-02-08 20:37:30 | [diff] [blame] | 68 | // Enable the spdy protocol. |
| 69 | // Without calling this function, SPDY is disabled. The mode can be: |
[email protected] | 650e2cae | 2009-10-21 23:52:07 | [diff] [blame] | 70 | // "" : (default) SSL and compression are enabled. |
| 71 | // "no-ssl" : disables SSL. |
| 72 | // "no-compress" : disables compression. |
| 73 | // "none" : disables both SSL and compression. |
[email protected] | 955fc2e7 | 2010-02-08 20:37:30 | [diff] [blame] | 74 | static void EnableSpdy(const std::string& mode); |
[email protected] | 7adaccb | 2009-10-13 04:43:21 | [diff] [blame] | 75 | |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 76 | private: |
[email protected] | c689457 | 2009-06-16 17:10:10 | [diff] [blame] | 77 | // The factory we will use to create network sockets. |
| 78 | ClientSocketFactory* socket_factory_; |
| 79 | |
[email protected] | d13c327 | 2010-02-04 00:24:51 | [diff] [blame] | 80 | NetworkChangeNotifier* network_change_notifier_; |
| 81 | |
[email protected] | e52deec | 2009-08-21 19:48:39 | [diff] [blame] | 82 | // The host resolver and proxy service that will be used when lazily |
[email protected] | 80d6524d | 2009-08-18 03:58:09 | [diff] [blame] | 83 | // creating |session_|. |
[email protected] | 94a0d3d9 | 2009-06-27 01:50:14 | [diff] [blame] | 84 | scoped_refptr<HostResolver> host_resolver_; |
[email protected] | 80d6524d | 2009-08-18 03:58:09 | [diff] [blame] | 85 | scoped_refptr<ProxyService> proxy_service_; |
[email protected] | a3b006eea | 2008-10-22 21:23:08 | [diff] [blame] | 86 | |
[email protected] | db36938c | 2009-08-19 21:48:42 | [diff] [blame] | 87 | // The SSL config service being used for the session. |
| 88 | scoped_refptr<SSLConfigService> ssl_config_service_; |
| 89 | |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 90 | scoped_refptr<HttpNetworkSession> session_; |
[email protected] | 61a86c4 | 2010-04-19 22:45:53 | [diff] [blame] | 91 | scoped_refptr<SpdySessionPool> spdy_session_pool_; |
[email protected] | d1eda93 | 2009-11-04 01:03:10 | [diff] [blame] | 92 | |
[email protected] | fa55e19 | 2010-02-15 14:25:50 | [diff] [blame] | 93 | HttpAuthHandlerFactory* http_auth_handler_factory_; |
[email protected] | ac03952 | 2010-06-15 16:39:44 | [diff] [blame] | 94 | HttpNetworkDelegate* network_delegate_; |
[email protected] | 06650c5 | 2010-06-03 00:49:17 | [diff] [blame] | 95 | NetLog* net_log_; |
[email protected] | fa55e19 | 2010-02-15 14:25:50 | [diff] [blame] | 96 | |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 97 | bool suspended_; |
[email protected] | 955fc2e7 | 2010-02-08 20:37:30 | [diff] [blame] | 98 | static bool force_spdy_; |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 99 | }; |
| 100 | |
| 101 | } // namespace net |
| 102 | |
| 103 | #endif // NET_HTTP_HTTP_NETWORK_LAYER_H_ |