OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 is useful for building a simple URLRequestContext. Most creators | 5 // This class is useful for building a simple URLRequestContext. Most creators |
6 // of new URLRequestContexts should use this helper class to construct it. Call | 6 // of new URLRequestContexts should use this helper class to construct it. Call |
7 // any configuration params, and when done, invoke Build() to construct the | 7 // any configuration params, and when done, invoke Build() to construct the |
8 // URLRequestContext. This URLRequestContext will own all its own storage. | 8 // URLRequestContext. This URLRequestContext will own all its own storage. |
9 // | 9 // |
10 // URLRequestContextBuilder and its associated params classes are initially | 10 // URLRequestContextBuilder and its associated params classes are initially |
11 // populated with "sane" default values. Read through the comments to figure out | 11 // populated with "sane" default values. Read through the comments to figure out |
12 // what these are. | 12 // what these are. |
13 | 13 |
14 #ifndef NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ | 14 #ifndef NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ |
15 #define NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ | 15 #define NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ |
16 | 16 |
17 #include <string> | 17 #include <string> |
18 #include <vector> | 18 #include <vector> |
19 | 19 |
20 #include "base/basictypes.h" | 20 #include "base/basictypes.h" |
21 #include "base/files/file_path.h" | 21 #include "base/files/file_path.h" |
22 #include "base/memory/ref_counted.h" | 22 #include "base/memory/ref_counted.h" |
23 #include "base/memory/scoped_ptr.h" | 23 #include "base/memory/scoped_ptr.h" |
24 #include "base/memory/scoped_vector.h" | 24 #include "base/memory/scoped_vector.h" |
25 #include "base/memory/weak_ptr.h" | |
25 #include "build/build_config.h" | 26 #include "build/build_config.h" |
26 #include "net/base/net_export.h" | 27 #include "net/base/net_export.h" |
27 #include "net/base/network_delegate.h" | 28 #include "net/base/network_delegate.h" |
28 #include "net/dns/host_resolver.h" | 29 #include "net/dns/host_resolver.h" |
29 #include "net/proxy/proxy_config_service.h" | 30 #include "net/proxy/proxy_config_service.h" |
30 #include "net/proxy/proxy_service.h" | 31 #include "net/proxy/proxy_service.h" |
31 #include "net/quic/quic_protocol.h" | 32 #include "net/quic/quic_protocol.h" |
32 #include "net/socket/next_proto.h" | 33 #include "net/socket/next_proto.h" |
33 | 34 |
34 namespace base { | 35 namespace base { |
35 class SingleThreadTaskRunner; | 36 class SingleThreadTaskRunner; |
36 } | 37 } |
37 | 38 |
38 namespace net { | 39 namespace net { |
39 | 40 |
40 class ChannelIDService; | 41 class ChannelIDService; |
41 class CookieStore; | 42 class CookieStore; |
42 class FtpTransactionFactory; | 43 class FtpTransactionFactory; |
43 class HostMappingRules; | 44 class HostMappingRules; |
44 class HttpAuthHandlerFactory; | 45 class HttpAuthHandlerFactory; |
46 class HttpServerProperties; | |
45 class ProxyConfigService; | 47 class ProxyConfigService; |
46 class URLRequestContext; | 48 class URLRequestContext; |
47 class URLRequestInterceptor; | 49 class URLRequestInterceptor; |
48 | 50 |
49 class NET_EXPORT URLRequestContextBuilder { | 51 class NET_EXPORT URLRequestContextBuilder { |
50 public: | 52 public: |
51 struct NET_EXPORT HttpCacheParams { | 53 struct NET_EXPORT HttpCacheParams { |
52 enum Type { | 54 enum Type { |
53 IN_MEMORY, | 55 IN_MEMORY, |
54 DISK, | 56 DISK, |
(...skipping 145 matching lines...) Loading... | |
200 void SetFileTaskRunner( | 202 void SetFileTaskRunner( |
201 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); | 203 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); |
202 | 204 |
203 // Note that if SDCH is enabled without a policy object observing | 205 // Note that if SDCH is enabled without a policy object observing |
204 // the SDCH manager and handling at least Get-Dictionary events, the | 206 // the SDCH manager and handling at least Get-Dictionary events, the |
205 // result will be "Content-Encoding: sdch" advertisements, but no | 207 // result will be "Content-Encoding: sdch" advertisements, but no |
206 // dictionaries fetches and no specific dictionaries advertised. | 208 // dictionaries fetches and no specific dictionaries advertised. |
207 // SdchOwner in net/sdch/sdch_owner.h is a simple policy object. | 209 // SdchOwner in net/sdch/sdch_owner.h is a simple policy object. |
208 void set_sdch_enabled(bool enable) { sdch_enabled_ = enable; } | 210 void set_sdch_enabled(bool enable) { sdch_enabled_ = enable; } |
209 | 211 |
212 void set_http_server_properties( | |
213 const base::WeakPtr<HttpServerProperties>& http_server_properties) { | |
pauljensen
2015/06/15 15:57:42
I'm torn as to whether this should be a scoped_ptr
xunjieli
2015/06/15 18:41:36
I also prefer that storage takes ownership of the
xunjieli
2015/06/15 18:49:22
I guess if we make storage to take ownership of th
| |
214 http_server_properties_ = http_server_properties; | |
215 } | |
216 | |
210 URLRequestContext* Build(); | 217 URLRequestContext* Build(); |
211 | 218 |
212 private: | 219 private: |
213 struct NET_EXPORT SchemeFactory { | 220 struct NET_EXPORT SchemeFactory { |
214 SchemeFactory(const std::string& scheme, HttpAuthHandlerFactory* factory); | 221 SchemeFactory(const std::string& scheme, HttpAuthHandlerFactory* factory); |
215 ~SchemeFactory(); | 222 ~SchemeFactory(); |
216 | 223 |
217 std::string scheme; | 224 std::string scheme; |
218 HttpAuthHandlerFactory* factory; | 225 HttpAuthHandlerFactory* factory; |
219 }; | 226 }; |
(...skipping 21 matching lines...) Loading... | |
241 scoped_ptr<NetLog> net_log_; | 248 scoped_ptr<NetLog> net_log_; |
242 scoped_ptr<HostResolver> host_resolver_; | 249 scoped_ptr<HostResolver> host_resolver_; |
243 scoped_ptr<ChannelIDService> channel_id_service_; | 250 scoped_ptr<ChannelIDService> channel_id_service_; |
244 scoped_ptr<ProxyConfigService> proxy_config_service_; | 251 scoped_ptr<ProxyConfigService> proxy_config_service_; |
245 scoped_ptr<ProxyService> proxy_service_; | 252 scoped_ptr<ProxyService> proxy_service_; |
246 scoped_ptr<NetworkDelegate> network_delegate_; | 253 scoped_ptr<NetworkDelegate> network_delegate_; |
247 scoped_refptr<CookieStore> cookie_store_; | 254 scoped_refptr<CookieStore> cookie_store_; |
248 scoped_ptr<FtpTransactionFactory> ftp_transaction_factory_; | 255 scoped_ptr<FtpTransactionFactory> ftp_transaction_factory_; |
249 std::vector<SchemeFactory> extra_http_auth_handlers_; | 256 std::vector<SchemeFactory> extra_http_auth_handlers_; |
250 ScopedVector<URLRequestInterceptor> url_request_interceptors_; | 257 ScopedVector<URLRequestInterceptor> url_request_interceptors_; |
258 base::WeakPtr<HttpServerProperties> http_server_properties_; | |
251 | 259 |
252 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder); | 260 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder); |
253 }; | 261 }; |
254 | 262 |
255 } // namespace net | 263 } // namespace net |
256 | 264 |
257 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ | 265 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ |
OLD | NEW |