OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/system_monitor/system_monitor.h" |
13 #include "base/threading/non_thread_safe.h" | 14 #include "base/threading/non_thread_safe.h" |
14 #include "net/base/net_api.h" | 15 #include "net/base/net_api.h" |
15 #include "net/http/http_transaction_factory.h" | 16 #include "net/http/http_transaction_factory.h" |
16 | 17 |
17 namespace net { | 18 namespace net { |
18 | 19 |
19 class CertVerifier; | 20 class CertVerifier; |
20 class ClientSocketFactory; | 21 class ClientSocketFactory; |
21 class DnsCertProvenanceChecker; | 22 class DnsCertProvenanceChecker; |
22 class DnsRRResolver; | 23 class DnsRRResolver; |
23 class HostResolver; | 24 class HostResolver; |
24 class HttpAuthHandlerFactory; | 25 class HttpAuthHandlerFactory; |
25 class HttpNetworkSession; | 26 class HttpNetworkSession; |
26 class NetLog; | 27 class NetLog; |
27 class NetworkDelegate; | 28 class NetworkDelegate; |
28 class ProxyService; | 29 class ProxyService; |
29 class SpdySessionPool; | 30 class SpdySessionPool; |
30 class SSLConfigService; | 31 class SSLConfigService; |
31 class SSLHostInfoFactory; | 32 class SSLHostInfoFactory; |
32 | 33 |
33 class NET_API HttpNetworkLayer : public HttpTransactionFactory, | 34 class NET_API HttpNetworkLayer : public HttpTransactionFactory, |
| 35 public base::SystemMonitor::PowerObserver, |
34 NON_EXPORTED_BASE(public base::NonThreadSafe) { | 36 NON_EXPORTED_BASE(public base::NonThreadSafe) { |
35 public: | 37 public: |
36 // Construct a HttpNetworkLayer with an existing HttpNetworkSession which | 38 // Construct a HttpNetworkLayer with an existing HttpNetworkSession which |
37 // contains a valid ProxyService. | 39 // contains a valid ProxyService. |
38 explicit HttpNetworkLayer(HttpNetworkSession* session); | 40 explicit HttpNetworkLayer(HttpNetworkSession* session); |
39 virtual ~HttpNetworkLayer(); | 41 virtual ~HttpNetworkLayer(); |
40 | 42 |
41 // Create a transaction factory that instantiate a network layer over an | 43 // Create a transaction factory that instantiate a network layer over an |
42 // existing network session. Network session contains some valuable | 44 // existing network session. Network session contains some valuable |
43 // information (e.g. authentication data) that we want to share across | 45 // information (e.g. authentication data) that we want to share across |
44 // multiple network layers. This method exposes the implementation details | 46 // multiple network layers. This method exposes the implementation details |
45 // of a network layer, use this method with an existing network layer only | 47 // of a network layer, use this method with an existing network layer only |
46 // when network session is shared. | 48 // when network session is shared. |
47 static HttpTransactionFactory* CreateFactory(HttpNetworkSession* session); | 49 static HttpTransactionFactory* CreateFactory(HttpNetworkSession* session); |
48 | 50 |
49 // Enable the spdy protocol. | 51 // Enable the spdy protocol. |
50 // Without calling this function, SPDY is disabled. The mode can be: | 52 // Without calling this function, SPDY is disabled. The mode can be: |
51 // "" : (default) SSL and compression are enabled, flow | 53 // "" : (default) SSL and compression are enabled, flow |
52 // control disabled. | 54 // control disabled. |
53 // "no-ssl" : disables SSL. | 55 // "no-ssl" : disables SSL. |
54 // "no-compress" : disables compression. | 56 // "no-compress" : disables compression. |
55 // "flow-control": enables flow control. | 57 // "flow-control": enables flow control. |
56 // "none" : disables both SSL and compression. | 58 // "none" : disables both SSL and compression. |
57 static void EnableSpdy(const std::string& mode); | 59 static void EnableSpdy(const std::string& mode); |
58 | 60 |
59 // HttpTransactionFactory methods: | 61 // HttpTransactionFactory methods: |
60 virtual int CreateTransaction(scoped_ptr<HttpTransaction>* trans); | 62 virtual int CreateTransaction(scoped_ptr<HttpTransaction>* trans); |
61 virtual HttpCache* GetCache(); | 63 virtual HttpCache* GetCache(); |
62 virtual HttpNetworkSession* GetSession(); | 64 virtual HttpNetworkSession* GetSession(); |
63 virtual void Suspend(bool suspend); | 65 |
| 66 // base::SystemMonitor::PowerObserver methods: |
| 67 virtual void OnSuspend(); |
| 68 virtual void OnResume(); |
64 | 69 |
65 private: | 70 private: |
66 const scoped_refptr<HttpNetworkSession> session_; | 71 const scoped_refptr<HttpNetworkSession> session_; |
67 bool suspended_; | 72 bool suspended_; |
68 }; | 73 }; |
69 | 74 |
70 } // namespace net | 75 } // namespace net |
71 | 76 |
72 #endif // NET_HTTP_HTTP_NETWORK_LAYER_H_ | 77 #endif // NET_HTTP_HTTP_NETWORK_LAYER_H_ |
OLD | NEW |