OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 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 | 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 | 7 |
8 #include "base/ref_counted.h" | 8 #include "base/ref_counted.h" |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "net/http/http_transaction_factory.h" | 10 #include "net/http/http_transaction_factory.h" |
11 | 11 |
12 namespace net { | 12 namespace net { |
13 | 13 |
14 class HttpNetworkSession; | 14 class HttpNetworkSession; |
15 class ProxyInfo; | 15 class ProxyInfo; |
16 class ProxyService; | 16 class ProxyService; |
17 | 17 |
18 class HttpNetworkLayer : public HttpTransactionFactory { | 18 class HttpNetworkLayer : public HttpTransactionFactory { |
19 public: | 19 public: |
20 // |proxy_service| must remain valid for the lifetime of HttpNetworkLayer. | 20 // |proxy_service| must remain valid for the lifetime of HttpNetworkLayer. |
21 explicit HttpNetworkLayer(ProxyService* proxy_service); | 21 explicit HttpNetworkLayer(ProxyService* proxy_service); |
| 22 // Construct a HttpNetworkLayer with an existing HttpNetworkSession which |
| 23 // contains a valid ProxyService. |
| 24 explicit HttpNetworkLayer(HttpNetworkSession* session); |
22 ~HttpNetworkLayer(); | 25 ~HttpNetworkLayer(); |
23 | 26 |
24 // This function hides the details of how a network layer gets instantiated | 27 // This function hides the details of how a network layer gets instantiated |
25 // and allows other implementations to be substituted. | 28 // and allows other implementations to be substituted. |
26 static HttpTransactionFactory* CreateFactory(ProxyService* proxy_service); | 29 static HttpTransactionFactory* CreateFactory(ProxyService* proxy_service); |
| 30 // Create a transaction factory that instantiate a network layer over an |
| 31 // existing network session. Network session contains some valuable |
| 32 // information (e.g. authentication data) that we want to share across |
| 33 // multiple network layers. This method exposes the implementation details |
| 34 // of a network layer, use this method with an existing network layer only |
| 35 // when network session is shared. |
| 36 static HttpTransactionFactory* CreateFactory(HttpNetworkSession* session); |
27 | 37 |
28 // HttpTransactionFactory methods: | 38 // HttpTransactionFactory methods: |
29 virtual HttpTransaction* CreateTransaction(); | 39 virtual HttpTransaction* CreateTransaction(); |
30 virtual HttpCache* GetCache(); | 40 virtual HttpCache* GetCache(); |
31 virtual void Suspend(bool suspend); | 41 virtual void Suspend(bool suspend); |
32 | 42 |
| 43 HttpNetworkSession* GetSession(); |
| 44 |
33 private: | 45 private: |
34 // The proxy service being used for the session. | 46 // The proxy service being used for the session. |
35 ProxyService* proxy_service_; | 47 ProxyService* proxy_service_; |
36 | 48 |
37 scoped_refptr<HttpNetworkSession> session_; | 49 scoped_refptr<HttpNetworkSession> session_; |
38 bool suspended_; | 50 bool suspended_; |
39 }; | 51 }; |
40 | 52 |
41 } // namespace net | 53 } // namespace net |
42 | 54 |
43 #endif // NET_HTTP_HTTP_NETWORK_LAYER_H_ | 55 #endif // NET_HTTP_HTTP_NETWORK_LAYER_H_ |
44 | 56 |
OLD | NEW |