OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // This class represents contextual information (cookies, cache, etc.) | 5 // This class represents contextual information (cookies, cache, etc.) |
6 // that's useful when processing resource requests. | 6 // that's useful when processing resource requests. |
7 // The class is reference-counted so that it can be cleaned up after any | 7 // The class is reference-counted so that it can be cleaned up after any |
8 // requests that are using it have been completed. | 8 // requests that are using it have been completed. |
9 | 9 |
10 #ifndef NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ | 10 #ifndef NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ |
11 #define NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ | 11 #define NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ |
12 | 12 |
13 #include "base/ref_counted.h" | 13 #include "base/ref_counted.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
15 #include "net/base/cookie_policy.h" | |
16 #include "net/base/cookie_store.h" | 15 #include "net/base/cookie_store.h" |
17 #include "net/base/host_resolver.h" | 16 #include "net/base/host_resolver.h" |
18 #include "net/base/ssl_config_service.h" | 17 #include "net/base/ssl_config_service.h" |
19 #include "net/base/transport_security_state.h" | 18 #include "net/base/transport_security_state.h" |
20 #include "net/ftp/ftp_auth_cache.h" | 19 #include "net/ftp/ftp_auth_cache.h" |
21 #include "net/proxy/proxy_service.h" | 20 #include "net/proxy/proxy_service.h" |
22 #include "net/url_request/request_tracker.h" | 21 #include "net/url_request/request_tracker.h" |
23 | 22 |
24 namespace net { | 23 namespace net { |
| 24 class CookiePolicy; |
25 class FtpTransactionFactory; | 25 class FtpTransactionFactory; |
26 class HttpTransactionFactory; | 26 class HttpTransactionFactory; |
27 class SocketStream; | 27 class SocketStream; |
28 } | 28 } |
29 class URLRequest; | 29 class URLRequest; |
30 | 30 |
31 // Subclass to provide application-specific context for URLRequest instances. | 31 // Subclass to provide application-specific context for URLRequest instances. |
32 class URLRequestContext : | 32 class URLRequestContext : |
33 public base::RefCountedThreadSafe<URLRequestContext> { | 33 public base::RefCountedThreadSafe<URLRequestContext> { |
34 public: | 34 public: |
35 URLRequestContext() | 35 URLRequestContext() |
36 : http_transaction_factory_(NULL), | 36 : http_transaction_factory_(NULL), |
37 ftp_transaction_factory_(NULL), | 37 ftp_transaction_factory_(NULL), |
38 cookie_store_(NULL), | 38 cookie_policy_(NULL), |
39 transport_security_state_(NULL) { | 39 transport_security_state_(NULL) { |
40 } | 40 } |
41 | 41 |
42 net::HostResolver* host_resolver() const { | 42 net::HostResolver* host_resolver() const { |
43 return host_resolver_; | 43 return host_resolver_; |
44 } | 44 } |
45 | 45 |
46 // Get the proxy service for this context. | 46 // Get the proxy service for this context. |
47 net::ProxyService* proxy_service() const { | 47 net::ProxyService* proxy_service() const { |
48 return proxy_service_; | 48 return proxy_service_; |
49 } | 49 } |
50 | 50 |
51 // Get the ssl config service for this context. | 51 // Get the ssl config service for this context. |
52 net::SSLConfigService* ssl_config_service() const { | 52 net::SSLConfigService* ssl_config_service() const { |
53 return ssl_config_service_; | 53 return ssl_config_service_; |
54 } | 54 } |
55 | 55 |
56 // Gets the http transaction factory for this context. | 56 // Gets the http transaction factory for this context. |
57 net::HttpTransactionFactory* http_transaction_factory() const { | 57 net::HttpTransactionFactory* http_transaction_factory() const { |
58 return http_transaction_factory_; | 58 return http_transaction_factory_; |
59 } | 59 } |
60 | 60 |
61 // Gets the ftp transaction factory for this context. | 61 // Gets the ftp transaction factory for this context. |
62 net::FtpTransactionFactory* ftp_transaction_factory() { | 62 net::FtpTransactionFactory* ftp_transaction_factory() { |
63 return ftp_transaction_factory_; | 63 return ftp_transaction_factory_; |
64 } | 64 } |
65 | 65 |
66 // Gets the cookie store for this context. | 66 // Gets the cookie store for this context (may be null). |
67 net::CookieStore* cookie_store() { return cookie_store_.get(); } | 67 net::CookieStore* cookie_store() { return cookie_store_.get(); } |
68 | 68 |
69 // Gets the cookie policy for this context. | 69 // Gets the cookie policy for this context (may be null). |
70 net::CookiePolicy* cookie_policy() { return &cookie_policy_; } | 70 net::CookiePolicy* cookie_policy() { return cookie_policy_; } |
71 | 71 |
72 net::TransportSecurityState* transport_security_state() { | 72 net::TransportSecurityState* transport_security_state() { |
73 return transport_security_state_; } | 73 return transport_security_state_; } |
74 | 74 |
75 // Gets the FTP authentication cache for this context. | 75 // Gets the FTP authentication cache for this context. |
76 net::FtpAuthCache* ftp_auth_cache() { return &ftp_auth_cache_; } | 76 net::FtpAuthCache* ftp_auth_cache() { return &ftp_auth_cache_; } |
77 | 77 |
78 // Gets the value of 'Accept-Charset' header field. | 78 // Gets the value of 'Accept-Charset' header field. |
79 const std::string& accept_charset() const { return accept_charset_; } | 79 const std::string& accept_charset() const { return accept_charset_; } |
80 | 80 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 virtual ~URLRequestContext() {} | 125 virtual ~URLRequestContext() {} |
126 | 126 |
127 // The following members are expected to be initialized and owned by | 127 // The following members are expected to be initialized and owned by |
128 // subclasses. | 128 // subclasses. |
129 scoped_refptr<net::HostResolver> host_resolver_; | 129 scoped_refptr<net::HostResolver> host_resolver_; |
130 scoped_refptr<net::ProxyService> proxy_service_; | 130 scoped_refptr<net::ProxyService> proxy_service_; |
131 scoped_refptr<net::SSLConfigService> ssl_config_service_; | 131 scoped_refptr<net::SSLConfigService> ssl_config_service_; |
132 net::HttpTransactionFactory* http_transaction_factory_; | 132 net::HttpTransactionFactory* http_transaction_factory_; |
133 net::FtpTransactionFactory* ftp_transaction_factory_; | 133 net::FtpTransactionFactory* ftp_transaction_factory_; |
134 scoped_refptr<net::CookieStore> cookie_store_; | 134 scoped_refptr<net::CookieStore> cookie_store_; |
135 net::CookiePolicy cookie_policy_; | 135 net::CookiePolicy* cookie_policy_; |
136 scoped_refptr<net::TransportSecurityState> transport_security_state_; | 136 scoped_refptr<net::TransportSecurityState> transport_security_state_; |
137 net::FtpAuthCache ftp_auth_cache_; | 137 net::FtpAuthCache ftp_auth_cache_; |
138 std::string accept_language_; | 138 std::string accept_language_; |
139 std::string accept_charset_; | 139 std::string accept_charset_; |
140 // The charset of the referrer where this request comes from. It's not | 140 // The charset of the referrer where this request comes from. It's not |
141 // used in communication with a server but is used to construct a suggested | 141 // used in communication with a server but is used to construct a suggested |
142 // filename for file download. | 142 // filename for file download. |
143 std::string referrer_charset_; | 143 std::string referrer_charset_; |
144 | 144 |
145 // Tracks the requests associated with this context. | 145 // Tracks the requests associated with this context. |
146 RequestTracker<URLRequest> url_request_tracker_; | 146 RequestTracker<URLRequest> url_request_tracker_; |
147 | 147 |
148 // Trakcs the socket streams associated with this context. | 148 // Trakcs the socket streams associated with this context. |
149 RequestTracker<net::SocketStream> socket_stream_tracker_; | 149 RequestTracker<net::SocketStream> socket_stream_tracker_; |
150 | 150 |
151 private: | 151 private: |
152 DISALLOW_COPY_AND_ASSIGN(URLRequestContext); | 152 DISALLOW_COPY_AND_ASSIGN(URLRequestContext); |
153 }; | 153 }; |
154 | 154 |
155 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ | 155 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_H_ |
OLD | NEW |