| 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 #include "net/url_request/url_request_context_builder.h" | 5 #include "net/url_request/url_request_context_builder.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 use_alternative_services(true), | 179 use_alternative_services(true), |
| 180 enable_quic(false), | 180 enable_quic(false), |
| 181 quic_store_server_configs_in_properties(false), | 181 quic_store_server_configs_in_properties(false), |
| 182 quic_delay_tcp_race(false), | 182 quic_delay_tcp_race(false), |
| 183 quic_max_number_of_lossy_connections(0), | 183 quic_max_number_of_lossy_connections(0), |
| 184 quic_packet_loss_threshold(1.0f) {} | 184 quic_packet_loss_threshold(1.0f) {} |
| 185 | 185 |
| 186 URLRequestContextBuilder::HttpNetworkSessionParams::~HttpNetworkSessionParams() | 186 URLRequestContextBuilder::HttpNetworkSessionParams::~HttpNetworkSessionParams() |
| 187 {} | 187 {} |
| 188 | 188 |
| 189 URLRequestContextBuilder::SchemeFactory::SchemeFactory( | |
| 190 const std::string& auth_scheme, | |
| 191 HttpAuthHandlerFactory* auth_handler_factory) | |
| 192 : scheme(auth_scheme), factory(auth_handler_factory) { | |
| 193 } | |
| 194 | |
| 195 URLRequestContextBuilder::SchemeFactory::~SchemeFactory() { | |
| 196 } | |
| 197 | |
| 198 URLRequestContextBuilder::URLRequestContextBuilder() | 189 URLRequestContextBuilder::URLRequestContextBuilder() |
| 199 : data_enabled_(false), | 190 : data_enabled_(false), |
| 200 #if !defined(DISABLE_FILE_SUPPORT) | 191 #if !defined(DISABLE_FILE_SUPPORT) |
| 201 file_enabled_(false), | 192 file_enabled_(false), |
| 202 #endif | 193 #endif |
| 203 #if !defined(DISABLE_FTP_SUPPORT) | 194 #if !defined(DISABLE_FTP_SUPPORT) |
| 204 ftp_enabled_(false), | 195 ftp_enabled_(false), |
| 205 #endif | 196 #endif |
| 206 http_cache_enabled_(true), | 197 http_cache_enabled_(true), |
| 207 throttling_enabled_(false), | 198 throttling_enabled_(false), |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 DCHECK(cookie_store); | 252 DCHECK(cookie_store); |
| 262 cookie_store_ = cookie_store; | 253 cookie_store_ = cookie_store; |
| 263 channel_id_service_ = channel_id_service.Pass(); | 254 channel_id_service_ = channel_id_service.Pass(); |
| 264 } | 255 } |
| 265 | 256 |
| 266 void URLRequestContextBuilder::SetFileTaskRunner( | 257 void URLRequestContextBuilder::SetFileTaskRunner( |
| 267 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { | 258 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) { |
| 268 file_task_runner_ = task_runner; | 259 file_task_runner_ = task_runner; |
| 269 } | 260 } |
| 270 | 261 |
| 262 void URLRequestContextBuilder::SetHttpAuthHandlerFactory( |
| 263 scoped_ptr<HttpAuthHandlerFactory> factory) { |
| 264 http_auth_handler_factory_ = factory.Pass(); |
| 265 } |
| 266 |
| 271 void URLRequestContextBuilder::SetHttpServerProperties( | 267 void URLRequestContextBuilder::SetHttpServerProperties( |
| 272 scoped_ptr<HttpServerProperties> http_server_properties) { | 268 scoped_ptr<HttpServerProperties> http_server_properties) { |
| 273 http_server_properties_ = http_server_properties.Pass(); | 269 http_server_properties_ = http_server_properties.Pass(); |
| 274 } | 270 } |
| 275 | 271 |
| 276 scoped_ptr<URLRequestContext> URLRequestContextBuilder::Build() { | 272 scoped_ptr<URLRequestContext> URLRequestContextBuilder::Build() { |
| 277 scoped_ptr<ContainerURLRequestContext> context( | 273 scoped_ptr<ContainerURLRequestContext> context( |
| 278 new ContainerURLRequestContext(file_task_runner_)); | 274 new ContainerURLRequestContext(file_task_runner_)); |
| 279 URLRequestContextStorage* storage = context->storage(); | 275 URLRequestContextStorage* storage = context->storage(); |
| 280 | 276 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 309 } | 305 } |
| 310 #endif // !defined(OS_LINUX) && !defined(OS_ANDROID) | 306 #endif // !defined(OS_LINUX) && !defined(OS_ANDROID) |
| 311 proxy_service_ = ProxyService::CreateUsingSystemProxyResolver( | 307 proxy_service_ = ProxyService::CreateUsingSystemProxyResolver( |
| 312 proxy_config_service_.Pass(), | 308 proxy_config_service_.Pass(), |
| 313 0, // This results in using the default value. | 309 0, // This results in using the default value. |
| 314 context->net_log()); | 310 context->net_log()); |
| 315 } | 311 } |
| 316 storage->set_proxy_service(proxy_service_.Pass()); | 312 storage->set_proxy_service(proxy_service_.Pass()); |
| 317 | 313 |
| 318 storage->set_ssl_config_service(new SSLConfigServiceDefaults); | 314 storage->set_ssl_config_service(new SSLConfigServiceDefaults); |
| 319 scoped_ptr<HttpAuthHandlerRegistryFactory> http_auth_handler_registry_factory( | 315 |
| 320 HttpAuthHandlerRegistryFactory::CreateDefault(context->host_resolver())); | 316 if (!http_auth_handler_factory_) { |
| 321 for (size_t i = 0; i < extra_http_auth_handlers_.size(); ++i) { | 317 http_auth_handler_factory_ = |
| 322 http_auth_handler_registry_factory->RegisterSchemeFactory( | 318 HttpAuthHandlerRegistryFactory::CreateDefault(context->host_resolver()); |
| 323 extra_http_auth_handlers_[i].scheme, | |
| 324 extra_http_auth_handlers_[i].factory); | |
| 325 } | 319 } |
| 326 storage->set_http_auth_handler_factory( | 320 |
| 327 http_auth_handler_registry_factory.Pass()); | 321 storage->set_http_auth_handler_factory(http_auth_handler_factory_.Pass()); |
| 328 | 322 |
| 329 if (cookie_store_) { | 323 if (cookie_store_) { |
| 330 storage->set_cookie_store(cookie_store_.get()); | 324 storage->set_cookie_store(cookie_store_.get()); |
| 331 storage->set_channel_id_service(channel_id_service_.Pass()); | 325 storage->set_channel_id_service(channel_id_service_.Pass()); |
| 332 } else { | 326 } else { |
| 333 storage->set_cookie_store(new CookieMonster(NULL, NULL)); | 327 storage->set_cookie_store(new CookieMonster(NULL, NULL)); |
| 334 // TODO(mmenke): This always creates a file thread, even when it ends up | 328 // TODO(mmenke): This always creates a file thread, even when it ends up |
| 335 // not being used. Consider lazily creating the thread. | 329 // not being used. Consider lazily creating the thread. |
| 336 storage->set_channel_id_service(make_scoped_ptr(new ChannelIDService( | 330 storage->set_channel_id_service(make_scoped_ptr(new ChannelIDService( |
| 337 new DefaultChannelIDStore(NULL), context->GetFileTaskRunner()))); | 331 new DefaultChannelIDStore(NULL), context->GetFileTaskRunner()))); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 } | 460 } |
| 467 url_request_interceptors_.weak_clear(); | 461 url_request_interceptors_.weak_clear(); |
| 468 } | 462 } |
| 469 storage->set_job_factory(top_job_factory.Pass()); | 463 storage->set_job_factory(top_job_factory.Pass()); |
| 470 // TODO(willchan): Support sdch. | 464 // TODO(willchan): Support sdch. |
| 471 | 465 |
| 472 return context.Pass(); | 466 return context.Pass(); |
| 473 } | 467 } |
| 474 | 468 |
| 475 } // namespace net | 469 } // namespace net |
| OLD | NEW |