Chromium Code Reviews| 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 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 bool enable_quic; | 84 bool enable_quic; |
| 85 bool enable_insecure_quic; | 85 bool enable_insecure_quic; |
| 86 QuicTagVector quic_connection_options; | 86 QuicTagVector quic_connection_options; |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 URLRequestContextBuilder(); | 89 URLRequestContextBuilder(); |
| 90 ~URLRequestContextBuilder(); | 90 ~URLRequestContextBuilder(); |
| 91 | 91 |
| 92 // These functions are mutually exclusive. The ProxyConfigService, if | 92 // These functions are mutually exclusive. The ProxyConfigService, if |
| 93 // set, will be used to construct a ProxyService. | 93 // set, will be used to construct a ProxyService. |
| 94 void set_proxy_config_service(ProxyConfigService* proxy_config_service) { | 94 void set_proxy_config_service( |
| 95 proxy_config_service_.reset(proxy_config_service); | 95 scoped_ptr<ProxyConfigService> proxy_config_service) { |
| 96 proxy_config_service_ = proxy_config_service.Pass(); | |
| 96 } | 97 } |
| 97 void set_proxy_service(ProxyService* proxy_service) { | 98 void set_proxy_service(scoped_ptr<ProxyService> proxy_service) { |
| 98 proxy_service_.reset(proxy_service); | 99 proxy_service_ = proxy_service.Pass(); |
| 99 } | 100 } |
| 100 | 101 |
| 101 // Call these functions to specify hard-coded Accept-Language | 102 // Call these functions to specify hard-coded Accept-Language |
| 102 // or User-Agent header values for all requests that don't | 103 // or User-Agent header values for all requests that don't |
| 103 // have the headers already set. | 104 // have the headers already set. |
| 104 void set_accept_language(const std::string& accept_language) { | 105 void set_accept_language(const std::string& accept_language) { |
| 105 accept_language_ = accept_language; | 106 accept_language_ = accept_language; |
| 106 } | 107 } |
| 107 void set_user_agent(const std::string& user_agent) { | 108 void set_user_agent(const std::string& user_agent) { |
| 108 user_agent_ = user_agent; | 109 user_agent_ = user_agent; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 122 | 123 |
| 123 #if !defined(DISABLE_FTP_SUPPORT) | 124 #if !defined(DISABLE_FTP_SUPPORT) |
| 124 // Control support for ftp:// requests. By default it's disabled. | 125 // Control support for ftp:// requests. By default it's disabled. |
| 125 void set_ftp_enabled(bool enable) { | 126 void set_ftp_enabled(bool enable) { |
| 126 ftp_enabled_ = enable; | 127 ftp_enabled_ = enable; |
| 127 } | 128 } |
| 128 #endif | 129 #endif |
| 129 | 130 |
| 130 // TODO(mmenke): Probably makes sense to get rid of this, and have consumers | 131 // TODO(mmenke): Probably makes sense to get rid of this, and have consumers |
| 131 // set their own NetLog::Observers instead. | 132 // set their own NetLog::Observers instead. |
| 132 void set_net_log(NetLog* net_log) { | 133 void set_net_log(NetLog* net_log) { net_log_ = net_log; } |
|
mmenke
2015/08/20 15:51:07
Maybe an extra comment, just for emphasis.
"Unlik
pauljensen
2015/08/20 21:45:14
Done.
| |
| 133 net_log_.reset(net_log); | |
| 134 } | |
| 135 | 134 |
| 136 // By default host_resolver is constructed with CreateDefaultResolver. | 135 // By default host_resolver is constructed with CreateDefaultResolver. |
| 137 void set_host_resolver(HostResolver* host_resolver) { | 136 void set_host_resolver(scoped_ptr<HostResolver> host_resolver) { |
| 138 host_resolver_.reset(host_resolver); | 137 host_resolver_ = host_resolver.Pass(); |
| 139 } | 138 } |
| 140 | 139 |
| 141 // Uses BasicNetworkDelegate by default. Note that calling Build will unset | 140 // Uses BasicNetworkDelegate by default. Note that calling Build will unset |
| 142 // any custom delegate in builder, so this must be called each time before | 141 // any custom delegate in builder, so this must be called each time before |
| 143 // Build is called. | 142 // Build is called. |
| 144 void set_network_delegate(NetworkDelegate* delegate) { | 143 void set_network_delegate(scoped_ptr<NetworkDelegate> delegate) { |
| 145 network_delegate_.reset(delegate); | 144 network_delegate_ = delegate.Pass(); |
| 146 } | 145 } |
| 147 | 146 |
| 148 // Adds additional auth handler factories to be used in addition to what is | 147 // Adds additional auth handler factories to be used in addition to what is |
| 149 // provided in the default |HttpAuthHandlerRegistryFactory|. The auth |scheme| | 148 // provided in the default |HttpAuthHandlerRegistryFactory|. The auth |scheme| |
| 150 // and |factory| are provided. The builder takes ownership of the factory and | 149 // and |factory| are provided. The builder takes ownership of the factory and |
| 151 // Build() must be called after this method. | 150 // Build() must be called after this method. |
| 152 void add_http_auth_handler_factory(const std::string& scheme, | 151 void add_http_auth_handler_factory(const std::string& scheme, |
| 153 HttpAuthHandlerFactory* factory) { | 152 HttpAuthHandlerFactory* factory) { |
| 154 extra_http_auth_handlers_.push_back(SchemeFactory(scheme, factory)); | 153 extra_http_auth_handlers_.push_back(SchemeFactory(scheme, factory)); |
| 155 } | 154 } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 // result will be "Content-Encoding: sdch" advertisements, but no | 214 // result will be "Content-Encoding: sdch" advertisements, but no |
| 216 // dictionaries fetches and no specific dictionaries advertised. | 215 // dictionaries fetches and no specific dictionaries advertised. |
| 217 // SdchOwner in net/sdch/sdch_owner.h is a simple policy object. | 216 // SdchOwner in net/sdch/sdch_owner.h is a simple policy object. |
| 218 void set_sdch_enabled(bool enable) { sdch_enabled_ = enable; } | 217 void set_sdch_enabled(bool enable) { sdch_enabled_ = enable; } |
| 219 | 218 |
| 220 // Sets a specific HttpServerProperties for use in the | 219 // Sets a specific HttpServerProperties for use in the |
| 221 // URLRequestContext rather than creating a default HttpServerPropertiesImpl. | 220 // URLRequestContext rather than creating a default HttpServerPropertiesImpl. |
| 222 void SetHttpServerProperties( | 221 void SetHttpServerProperties( |
| 223 scoped_ptr<HttpServerProperties> http_server_properties); | 222 scoped_ptr<HttpServerProperties> http_server_properties); |
| 224 | 223 |
| 225 URLRequestContext* Build(); | 224 scoped_ptr<URLRequestContext> Build(); |
| 226 | 225 |
| 227 private: | 226 private: |
| 228 struct NET_EXPORT SchemeFactory { | 227 struct NET_EXPORT SchemeFactory { |
| 229 SchemeFactory(const std::string& scheme, HttpAuthHandlerFactory* factory); | 228 SchemeFactory(const std::string& scheme, HttpAuthHandlerFactory* factory); |
| 230 ~SchemeFactory(); | 229 ~SchemeFactory(); |
| 231 | 230 |
| 232 std::string scheme; | 231 std::string scheme; |
| 233 HttpAuthHandlerFactory* factory; | 232 HttpAuthHandlerFactory* factory; |
| 234 }; | 233 }; |
| 235 | 234 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 247 #endif | 246 #endif |
| 248 bool http_cache_enabled_; | 247 bool http_cache_enabled_; |
| 249 bool throttling_enabled_; | 248 bool throttling_enabled_; |
| 250 bool backoff_enabled_; | 249 bool backoff_enabled_; |
| 251 bool sdch_enabled_; | 250 bool sdch_enabled_; |
| 252 | 251 |
| 253 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; | 252 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; |
| 254 HttpCacheParams http_cache_params_; | 253 HttpCacheParams http_cache_params_; |
| 255 HttpNetworkSessionParams http_network_session_params_; | 254 HttpNetworkSessionParams http_network_session_params_; |
| 256 base::FilePath transport_security_persister_path_; | 255 base::FilePath transport_security_persister_path_; |
| 257 scoped_ptr<NetLog> net_log_; | 256 NetLog* net_log_; |
| 258 scoped_ptr<HostResolver> host_resolver_; | 257 scoped_ptr<HostResolver> host_resolver_; |
| 259 scoped_ptr<ChannelIDService> channel_id_service_; | 258 scoped_ptr<ChannelIDService> channel_id_service_; |
| 260 scoped_ptr<ProxyConfigService> proxy_config_service_; | 259 scoped_ptr<ProxyConfigService> proxy_config_service_; |
| 261 scoped_ptr<ProxyService> proxy_service_; | 260 scoped_ptr<ProxyService> proxy_service_; |
| 262 scoped_ptr<NetworkDelegate> network_delegate_; | 261 scoped_ptr<NetworkDelegate> network_delegate_; |
| 263 scoped_refptr<CookieStore> cookie_store_; | 262 scoped_refptr<CookieStore> cookie_store_; |
| 264 scoped_ptr<FtpTransactionFactory> ftp_transaction_factory_; | 263 scoped_ptr<FtpTransactionFactory> ftp_transaction_factory_; |
| 265 std::vector<SchemeFactory> extra_http_auth_handlers_; | 264 std::vector<SchemeFactory> extra_http_auth_handlers_; |
| 266 ScopedVector<URLRequestInterceptor> url_request_interceptors_; | 265 ScopedVector<URLRequestInterceptor> url_request_interceptors_; |
| 267 scoped_ptr<HttpServerProperties> http_server_properties_; | 266 scoped_ptr<HttpServerProperties> http_server_properties_; |
| 268 | 267 |
| 269 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder); | 268 DISALLOW_COPY_AND_ASSIGN(URLRequestContextBuilder); |
| 270 }; | 269 }; |
| 271 | 270 |
| 272 } // namespace net | 271 } // namespace net |
| 273 | 272 |
| 274 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ | 273 #endif // NET_URL_REQUEST_URL_REQUEST_CONTEXT_BUILDER_H_ |
| OLD | NEW |