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 "build/build_config.h" | 25 #include "build/build_config.h" |
25 #include "net/base/net_export.h" | 26 #include "net/base/net_export.h" |
26 #include "net/base/network_delegate.h" | 27 #include "net/base/network_delegate.h" |
27 #include "net/dns/host_resolver.h" | 28 #include "net/dns/host_resolver.h" |
28 #include "net/proxy/proxy_config_service.h" | 29 #include "net/proxy/proxy_config_service.h" |
29 #include "net/proxy/proxy_service.h" | 30 #include "net/proxy/proxy_service.h" |
30 #include "net/quic/quic_protocol.h" | 31 #include "net/quic/quic_protocol.h" |
31 #include "net/socket/next_proto.h" | 32 #include "net/socket/next_proto.h" |
32 | 33 |
33 namespace base { | 34 namespace base { |
34 class SingleThreadTaskRunner; | 35 class SingleThreadTaskRunner; |
35 } | 36 } |
36 | 37 |
37 namespace net { | 38 namespace net { |
38 | 39 |
39 class ChannelIDService; | 40 class ChannelIDService; |
40 class CookieStore; | 41 class CookieStore; |
41 class FtpTransactionFactory; | 42 class FtpTransactionFactory; |
42 class HostMappingRules; | 43 class HostMappingRules; |
43 class HttpAuthHandlerFactory; | 44 class HttpAuthHandlerFactory; |
44 class ProxyConfigService; | 45 class ProxyConfigService; |
45 class URLRequestContext; | 46 class URLRequestContext; |
| 47 class URLRequestInterceptor; |
46 | 48 |
47 class NET_EXPORT URLRequestContextBuilder { | 49 class NET_EXPORT URLRequestContextBuilder { |
48 public: | 50 public: |
49 struct NET_EXPORT HttpCacheParams { | 51 struct NET_EXPORT HttpCacheParams { |
50 enum Type { | 52 enum Type { |
51 IN_MEMORY, | 53 IN_MEMORY, |
52 DISK, | 54 DISK, |
53 }; | 55 }; |
54 | 56 |
55 HttpCacheParams(); | 57 HttpCacheParams(); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 void set_quic_connection_options( | 175 void set_quic_connection_options( |
174 const QuicTagVector& quic_connection_options) { | 176 const QuicTagVector& quic_connection_options) { |
175 http_network_session_params_.quic_connection_options = | 177 http_network_session_params_.quic_connection_options = |
176 quic_connection_options; | 178 quic_connection_options; |
177 } | 179 } |
178 | 180 |
179 void set_throttling_enabled(bool throttling_enabled) { | 181 void set_throttling_enabled(bool throttling_enabled) { |
180 throttling_enabled_ = throttling_enabled; | 182 throttling_enabled_ = throttling_enabled; |
181 } | 183 } |
182 | 184 |
| 185 void SetInterceptors( |
| 186 ScopedVector<URLRequestInterceptor> url_request_interceptors); |
| 187 |
183 // Override the default in-memory cookie store and channel id service. | 188 // Override the default in-memory cookie store and channel id service. |
184 // |cookie_store| must not be NULL. |channel_id_service| may be NULL to | 189 // |cookie_store| must not be NULL. |channel_id_service| may be NULL to |
185 // disable channel id for this context. | 190 // disable channel id for this context. |
186 // Note that a persistent cookie store should not be used with an in-memory | 191 // Note that a persistent cookie store should not be used with an in-memory |
187 // channel id service, and one cookie store should not be shared between | 192 // channel id service, and one cookie store should not be shared between |
188 // multiple channel-id stores (or used both with and without a channel id | 193 // multiple channel-id stores (or used both with and without a channel id |
189 // store). | 194 // store). |
190 void SetCookieAndChannelIdStores( | 195 void SetCookieAndChannelIdStores( |
191 const scoped_refptr<CookieStore>& cookie_store, | 196 const scoped_refptr<CookieStore>& cookie_store, |
192 scoped_ptr<ChannelIDService> channel_id_service); | 197 scoped_ptr<ChannelIDService> channel_id_service); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 base::FilePath transport_security_persister_path_; | 234 base::FilePath transport_security_persister_path_; |
230 scoped_ptr<NetLog> net_log_; | 235 scoped_ptr<NetLog> net_log_; |
231 scoped_ptr<HostResolver> host_resolver_; | 236 scoped_ptr<HostResolver> host_resolver_; |
232 scoped_ptr<ChannelIDService> channel_id_service_; | 237 scoped_ptr<ChannelIDService> channel_id_service_; |
233 scoped_ptr<ProxyConfigService> proxy_config_service_; | 238 scoped_ptr<ProxyConfigService> proxy_config_service_; |
234 scoped_ptr<ProxyService> proxy_service_; | 239 scoped_ptr<ProxyService> proxy_service_; |
235 scoped_ptr<NetworkDelegate> network_delegate_; | 240 scoped_ptr<NetworkDelegate> network_delegate_; |
236 scoped_refptr<CookieStore> cookie_store_; | 241 scoped_refptr<CookieStore> cookie_store_; |
237 scoped_ptr<FtpTransactionFactory> ftp_transaction_factory_; | 242 scoped_ptr<FtpTransactionFactory> ftp_transaction_factory_; |
238 std::vector<SchemeFactory> extra_http_auth_handlers_; | 243 std::vector<SchemeFactory> extra_http_auth_handlers_; |
| 244 ScopedVector<URLRequestInterceptor> url_request_interceptors_; |
239 | 245 |
240 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder); | 246 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder); |
241 }; | 247 }; |
242 | 248 |
243 } // namespace net | 249 } // namespace net |
244 | 250 |
245 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ | 251 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ |
OLD | NEW |