license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 1 | // Copyright (c) 2006-2008 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. | ||||
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 | |||||
8 | #include "base/ref_counted.h" | ||||
[email protected] | a3b006eea | 2008-10-22 21:23:08 | [diff] [blame] | 9 | #include "base/scoped_ptr.h" |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 10 | #include "net/http/http_transaction_factory.h" |
11 | |||||
12 | namespace net { | ||||
13 | |||||
[email protected] | c689457 | 2009-06-16 17:10:10 | [diff] [blame] | 14 | class ClientSocketFactory; |
[email protected] | 8a00f00a | 2009-06-12 00:49:38 | [diff] [blame] | 15 | class HostResolver; |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 16 | class HttpNetworkSession; |
[email protected] | 928fb58 | 2008-08-11 15:40:23 | [diff] [blame] | 17 | class ProxyInfo; |
[email protected] | 63de95b | 2008-12-10 04:11:27 | [diff] [blame] | 18 | class ProxyService; |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 19 | |
20 | class HttpNetworkLayer : public HttpTransactionFactory { | ||||
21 | public: | ||||
[email protected] | c689457 | 2009-06-16 17:10:10 | [diff] [blame] | 22 | // |socket_factory|, |proxy_service| and |host_resolver| must remain valid |
23 | // for the lifetime of HttpNetworkLayer. | ||||
24 | HttpNetworkLayer(ClientSocketFactory* socket_factory, | ||||
25 | HostResolver* host_resolver, ProxyService* proxy_service); | ||||
[email protected] | e7f2964 | 2009-03-02 22:53:18 | [diff] [blame] | 26 | // Construct a HttpNetworkLayer with an existing HttpNetworkSession which |
27 | // contains a valid ProxyService. | ||||
28 | explicit HttpNetworkLayer(HttpNetworkSession* session); | ||||
[email protected] | 7b822b2b | 2008-08-05 00:15:45 | [diff] [blame] | 29 | ~HttpNetworkLayer(); |
30 | |||||
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 31 | // This function hides the details of how a network layer gets instantiated |
32 | // and allows other implementations to be substituted. | ||||
[email protected] | 8a00f00a | 2009-06-12 00:49:38 | [diff] [blame] | 33 | static HttpTransactionFactory* CreateFactory(HostResolver* host_resolver, |
34 | ProxyService* proxy_service); | ||||
[email protected] | e7f2964 | 2009-03-02 22:53:18 | [diff] [blame] | 35 | // Create a transaction factory that instantiate a network layer over an |
36 | // existing network session. Network session contains some valuable | ||||
37 | // information (e.g. authentication data) that we want to share across | ||||
38 | // multiple network layers. This method exposes the implementation details | ||||
39 | // of a network layer, use this method with an existing network layer only | ||||
40 | // when network session is shared. | ||||
41 | static HttpTransactionFactory* CreateFactory(HttpNetworkSession* session); | ||||
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 42 | |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 43 | // HttpTransactionFactory methods: |
44 | virtual HttpTransaction* CreateTransaction(); | ||||
45 | virtual HttpCache* GetCache(); | ||||
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 46 | virtual void Suspend(bool suspend); |
47 | |||||
[email protected] | e7f2964 | 2009-03-02 22:53:18 | [diff] [blame] | 48 | HttpNetworkSession* GetSession(); |
49 | |||||
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 50 | private: |
[email protected] | c689457 | 2009-06-16 17:10:10 | [diff] [blame] | 51 | // The factory we will use to create network sockets. |
52 | ClientSocketFactory* socket_factory_; | ||||
53 | |||||
[email protected] | 8a00f00a | 2009-06-12 00:49:38 | [diff] [blame] | 54 | // The host resolver being used for the session. |
[email protected] | 94a0d3d9 | 2009-06-27 01:50:14 | [diff] [blame^] | 55 | scoped_refptr<HostResolver> host_resolver_; |
[email protected] | 8a00f00a | 2009-06-12 00:49:38 | [diff] [blame] | 56 | |
[email protected] | 63de95b | 2008-12-10 04:11:27 | [diff] [blame] | 57 | // The proxy service being used for the session. |
[email protected] | db8f44c | 2008-12-13 04:52:01 | [diff] [blame] | 58 | ProxyService* proxy_service_; |
[email protected] | a3b006eea | 2008-10-22 21:23:08 | [diff] [blame] | 59 | |
initial.commit | 586acc5fe | 2008-07-26 22:42:52 | [diff] [blame] | 60 | scoped_refptr<HttpNetworkSession> session_; |
61 | bool suspended_; | ||||
62 | }; | ||||
63 | |||||
64 | } // namespace net | ||||
65 | |||||
66 | #endif // NET_HTTP_HTTP_NETWORK_LAYER_H_ |