[email protected] | aa84a7e | 2012-03-15 21:29:06 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | f1d8192 | 2010-07-31 17:47:09 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "net/url_request/url_request_context.h" |
| 6 | |
[email protected] | 18590f2 | 2011-07-29 16:41:28 | [diff] [blame] | 7 | #include "base/compiler_specific.h" |
[email protected] | 7c52ed9 | 2012-04-06 15:42:40 | [diff] [blame^] | 8 | #include "base/debug/alias.h" |
[email protected] | f1d8192 | 2010-07-31 17:47:09 | [diff] [blame] | 9 | #include "base/string_util.h" |
[email protected] | 9349cfb | 2010-08-31 18:00:53 | [diff] [blame] | 10 | #include "net/base/host_resolver.h" |
[email protected] | aa84a7e | 2012-03-15 21:29:06 | [diff] [blame] | 11 | #include "net/cookies/cookie_store.h" |
[email protected] | f6c21cb | 2011-02-16 19:45:41 | [diff] [blame] | 12 | #include "net/ftp/ftp_transaction_factory.h" |
| 13 | #include "net/http/http_transaction_factory.h" |
[email protected] | 7c52ed9 | 2012-04-06 15:42:40 | [diff] [blame^] | 14 | #include "net/url_request/url_request.h" |
[email protected] | 9349cfb | 2010-08-31 18:00:53 | [diff] [blame] | 15 | |
[email protected] | 27a112c | 2011-01-06 04:19:30 | [diff] [blame] | 16 | namespace net { |
| 17 | |
[email protected] | 9349cfb | 2010-08-31 18:00:53 | [diff] [blame] | 18 | URLRequestContext::URLRequestContext() |
[email protected] | 18590f2 | 2011-07-29 16:41:28 | [diff] [blame] | 19 | : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), |
| 20 | net_log_(NULL), |
[email protected] | c3a7bce | 2010-10-18 17:36:54 | [diff] [blame] | 21 | host_resolver_(NULL), |
[email protected] | 822581d | 2010-12-16 17:27:15 | [diff] [blame] | 22 | cert_verifier_(NULL), |
[email protected] | 9c4eff2 | 2012-03-20 22:42:29 | [diff] [blame] | 23 | server_bound_cert_service_(NULL), |
[email protected] | b97d770 | 2011-10-16 01:11:07 | [diff] [blame] | 24 | fraudulent_certificate_reporter_(NULL), |
[email protected] | 9349cfb | 2010-08-31 18:00:53 | [diff] [blame] | 25 | http_auth_handler_factory_(NULL), |
[email protected] | 160014da | 2011-05-13 19:37:46 | [diff] [blame] | 26 | proxy_service_(NULL), |
[email protected] | 9349cfb | 2010-08-31 18:00:53 | [diff] [blame] | 27 | network_delegate_(NULL), |
[email protected] | db96a88 | 2011-10-09 02:01:54 | [diff] [blame] | 28 | http_server_properties_(NULL), |
[email protected] | 70b9234 | 2010-10-12 05:54:06 | [diff] [blame] | 29 | transport_security_state_(NULL), |
[email protected] | ede9666 | 2011-07-14 12:34:18 | [diff] [blame] | 30 | ftp_auth_cache_(new FtpAuthCache), |
[email protected] | f6c21cb | 2011-02-16 19:45:41 | [diff] [blame] | 31 | http_transaction_factory_(NULL), |
[email protected] | a8c1e745 | 2011-05-14 06:17:07 | [diff] [blame] | 32 | ftp_transaction_factory_(NULL), |
[email protected] | 7c52ed9 | 2012-04-06 15:42:40 | [diff] [blame^] | 33 | job_factory_(NULL), |
| 34 | url_requests_(new std::set<const URLRequest*>) { |
[email protected] | 9349cfb | 2010-08-31 18:00:53 | [diff] [blame] | 35 | } |
[email protected] | f1d8192 | 2010-07-31 17:47:09 | [diff] [blame] | 36 | |
[email protected] | d969667 | 2011-03-15 22:45:09 | [diff] [blame] | 37 | void URLRequestContext::CopyFrom(URLRequestContext* other) { |
| 38 | // Copy URLRequestContext parameters. |
[email protected] | d969667 | 2011-03-15 22:45:09 | [diff] [blame] | 39 | set_net_log(other->net_log()); |
| 40 | set_host_resolver(other->host_resolver()); |
| 41 | set_cert_verifier(other->cert_verifier()); |
[email protected] | 9c4eff2 | 2012-03-20 22:42:29 | [diff] [blame] | 42 | set_server_bound_cert_service(other->server_bound_cert_service()); |
[email protected] | b97d770 | 2011-10-16 01:11:07 | [diff] [blame] | 43 | set_fraudulent_certificate_reporter(other->fraudulent_certificate_reporter()); |
[email protected] | d969667 | 2011-03-15 22:45:09 | [diff] [blame] | 44 | set_http_auth_handler_factory(other->http_auth_handler_factory()); |
| 45 | set_proxy_service(other->proxy_service()); |
| 46 | set_ssl_config_service(other->ssl_config_service()); |
| 47 | set_network_delegate(other->network_delegate()); |
[email protected] | db96a88 | 2011-10-09 02:01:54 | [diff] [blame] | 48 | set_http_server_properties(other->http_server_properties()); |
[email protected] | d969667 | 2011-03-15 22:45:09 | [diff] [blame] | 49 | set_cookie_store(other->cookie_store()); |
[email protected] | d969667 | 2011-03-15 22:45:09 | [diff] [blame] | 50 | set_transport_security_state(other->transport_security_state()); |
| 51 | // FTPAuthCache is unique per context. |
| 52 | set_accept_language(other->accept_language()); |
| 53 | set_accept_charset(other->accept_charset()); |
| 54 | set_referrer_charset(other->referrer_charset()); |
| 55 | set_http_transaction_factory(other->http_transaction_factory()); |
| 56 | set_ftp_transaction_factory(other->ftp_transaction_factory()); |
[email protected] | a8c1e745 | 2011-05-14 06:17:07 | [diff] [blame] | 57 | set_job_factory(other->job_factory()); |
[email protected] | d969667 | 2011-03-15 22:45:09 | [diff] [blame] | 58 | } |
| 59 | |
[email protected] | d100e44f | 2011-01-26 22:47:11 | [diff] [blame] | 60 | void URLRequestContext::set_cookie_store(CookieStore* cookie_store) { |
| 61 | cookie_store_ = cookie_store; |
| 62 | } |
| 63 | |
[email protected] | f1d8192 | 2010-07-31 17:47:09 | [diff] [blame] | 64 | const std::string& URLRequestContext::GetUserAgent(const GURL& url) const { |
| 65 | return EmptyString(); |
| 66 | } |
[email protected] | 9349cfb | 2010-08-31 18:00:53 | [diff] [blame] | 67 | |
| 68 | URLRequestContext::~URLRequestContext() { |
[email protected] | 7c52ed9 | 2012-04-06 15:42:40 | [diff] [blame^] | 69 | int num_requests = url_requests_->size(); |
| 70 | if (num_requests != 0) { |
| 71 | // We're leaking URLRequests :( Dump the URL of the first one and record how |
| 72 | // many we leaked so we have an idea of how bad it is. |
| 73 | char url_buf[128]; |
| 74 | const URLRequest* request = *url_requests_->begin(); |
| 75 | base::strlcpy(url_buf, request->url().spec().c_str(), arraysize(url_buf)); |
| 76 | base::debug::Alias(url_buf); |
| 77 | base::debug::Alias(&num_requests); |
| 78 | CHECK(false); |
| 79 | } |
[email protected] | 9349cfb | 2010-08-31 18:00:53 | [diff] [blame] | 80 | } |
[email protected] | 2fb62920 | 2010-12-23 23:52:57 | [diff] [blame] | 81 | |
[email protected] | 27a112c | 2011-01-06 04:19:30 | [diff] [blame] | 82 | } // namespace net |