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