blob: 54989410c0a1437d6d52631022fbc007fc042394 [file] [log] [blame]
[email protected]fa55e192010-02-15 14:25:501// Copyright (c) 2010 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit586acc5fe2008-07-26 22:42:524
5#ifndef NET_HTTP_HTTP_NETWORK_LAYER_H_
6#define NET_HTTP_HTTP_NETWORK_LAYER_H_
7
[email protected]650e2cae2009-10-21 23:52:078#include <string>
9
initial.commit586acc5fe2008-07-26 22:42:5210#include "base/ref_counted.h"
[email protected]a3b006eea2008-10-22 21:23:0811#include "base/scoped_ptr.h"
initial.commit586acc5fe2008-07-26 22:42:5212#include "net/http/http_transaction_factory.h"
13
14namespace net {
15
[email protected]c6894572009-06-16 17:10:1016class ClientSocketFactory;
[email protected]8a00f00a2009-06-12 00:49:3817class HostResolver;
[email protected]fa55e192010-02-15 14:25:5018class HttpAuthHandlerFactory;
[email protected]ac039522010-06-15 16:39:4419class HttpNetworkDelegate;
initial.commit586acc5fe2008-07-26 22:42:5220class HttpNetworkSession;
[email protected]06650c52010-06-03 00:49:1721class NetLog;
[email protected]d13c3272010-02-04 00:24:5122class NetworkChangeNotifier;
[email protected]928fb582008-08-11 15:40:2323class ProxyInfo;
[email protected]63de95b2008-12-10 04:11:2724class ProxyService;
[email protected]61a86c42010-04-19 22:45:5325class SpdySessionPool;
[email protected]db36938c2009-08-19 21:48:4226class SSLConfigService;
initial.commit586acc5fe2008-07-26 22:42:5227
28class HttpNetworkLayer : public HttpTransactionFactory {
29 public:
[email protected]d13c3272010-02-04 00:24:5130 // |socket_factory|, |network_change_notifier|, |proxy_service| and
31 // |host_resolver| must remain valid for the lifetime of HttpNetworkLayer.
[email protected]c6894572009-06-16 17:10:1032 HttpNetworkLayer(ClientSocketFactory* socket_factory,
[email protected]d13c3272010-02-04 00:24:5133 NetworkChangeNotifier* network_change_notifier,
[email protected]db36938c2009-08-19 21:48:4234 HostResolver* host_resolver, ProxyService* proxy_service,
[email protected]fa55e192010-02-15 14:25:5035 SSLConfigService* ssl_config_service,
[email protected]06650c52010-06-03 00:49:1736 HttpAuthHandlerFactory* http_auth_handler_factory,
[email protected]ac039522010-06-15 16:39:4437 HttpNetworkDelegate* network_delegate,
[email protected]06650c52010-06-03 00:49:1738 NetLog* net_log);
[email protected]e7f29642009-03-02 22:53:1839 // Construct a HttpNetworkLayer with an existing HttpNetworkSession which
40 // contains a valid ProxyService.
41 explicit HttpNetworkLayer(HttpNetworkSession* session);
[email protected]7b822b2b2008-08-05 00:15:4542 ~HttpNetworkLayer();
43
initial.commit586acc5fe2008-07-26 22:42:5244 // This function hides the details of how a network layer gets instantiated
45 // and allows other implementations to be substituted.
[email protected]db36938c2009-08-19 21:48:4246 static HttpTransactionFactory* CreateFactory(
[email protected]d13c3272010-02-04 00:24:5147 NetworkChangeNotifier* network_change_notifier,
[email protected]db36938c2009-08-19 21:48:4248 HostResolver* host_resolver,
49 ProxyService* proxy_service,
[email protected]fa55e192010-02-15 14:25:5050 SSLConfigService* ssl_config_service,
[email protected]06650c52010-06-03 00:49:1751 HttpAuthHandlerFactory* http_auth_handler_factory,
[email protected]ac039522010-06-15 16:39:4452 HttpNetworkDelegate* network_delegate,
[email protected]06650c52010-06-03 00:49:1753 NetLog* net_log);
[email protected]e7f29642009-03-02 22:53:1854 // 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.commit586acc5fe2008-07-26 22:42:5261
initial.commit586acc5fe2008-07-26 22:42:5262 // HttpTransactionFactory methods:
[email protected]1638d602009-09-24 03:49:1763 virtual int CreateTransaction(scoped_ptr<HttpTransaction>* trans);
initial.commit586acc5fe2008-07-26 22:42:5264 virtual HttpCache* GetCache();
[email protected]659a26022009-10-06 02:22:1065 virtual HttpNetworkSession* GetSession();
initial.commit586acc5fe2008-07-26 22:42:5266 virtual void Suspend(bool suspend);
67
[email protected]955fc2e72010-02-08 20:37:3068 // Enable the spdy protocol.
69 // Without calling this function, SPDY is disabled. The mode can be:
[email protected]650e2cae2009-10-21 23:52:0770 // "" : (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]955fc2e72010-02-08 20:37:3074 static void EnableSpdy(const std::string& mode);
[email protected]7adaccb2009-10-13 04:43:2175
initial.commit586acc5fe2008-07-26 22:42:5276 private:
[email protected]c6894572009-06-16 17:10:1077 // The factory we will use to create network sockets.
78 ClientSocketFactory* socket_factory_;
79
[email protected]d13c3272010-02-04 00:24:5180 NetworkChangeNotifier* network_change_notifier_;
81
[email protected]e52deec2009-08-21 19:48:3982 // The host resolver and proxy service that will be used when lazily
[email protected]80d6524d2009-08-18 03:58:0983 // creating |session_|.
[email protected]94a0d3d92009-06-27 01:50:1484 scoped_refptr<HostResolver> host_resolver_;
[email protected]80d6524d2009-08-18 03:58:0985 scoped_refptr<ProxyService> proxy_service_;
[email protected]a3b006eea2008-10-22 21:23:0886
[email protected]db36938c2009-08-19 21:48:4287 // The SSL config service being used for the session.
88 scoped_refptr<SSLConfigService> ssl_config_service_;
89
initial.commit586acc5fe2008-07-26 22:42:5290 scoped_refptr<HttpNetworkSession> session_;
[email protected]61a86c42010-04-19 22:45:5391 scoped_refptr<SpdySessionPool> spdy_session_pool_;
[email protected]d1eda932009-11-04 01:03:1092
[email protected]fa55e192010-02-15 14:25:5093 HttpAuthHandlerFactory* http_auth_handler_factory_;
[email protected]ac039522010-06-15 16:39:4494 HttpNetworkDelegate* network_delegate_;
[email protected]06650c52010-06-03 00:49:1795 NetLog* net_log_;
[email protected]fa55e192010-02-15 14:25:5096
initial.commit586acc5fe2008-07-26 22:42:5297 bool suspended_;
[email protected]955fc2e72010-02-08 20:37:3098 static bool force_spdy_;
initial.commit586acc5fe2008-07-26 22:42:5299};
100
101} // namespace net
102
103#endif // NET_HTTP_HTTP_NETWORK_LAYER_H_