blob: 51a6dbf7366d6fc292d49763c3a3c7032b9eb2b6 [file] [log] [blame]
[email protected]aa84a7e2012-03-15 21:29:061// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]f1d81922010-07-31 17:47:092// 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]18590f22011-07-29 16:41:287#include "base/compiler_specific.h"
[email protected]7c52ed92012-04-06 15:42:408#include "base/debug/alias.h"
[email protected]f1d81922010-07-31 17:47:099#include "base/string_util.h"
[email protected]9349cfb2010-08-31 18:00:5310#include "net/base/host_resolver.h"
[email protected]aa84a7e2012-03-15 21:29:0611#include "net/cookies/cookie_store.h"
[email protected]f6c21cb2011-02-16 19:45:4112#include "net/ftp/ftp_transaction_factory.h"
13#include "net/http/http_transaction_factory.h"
[email protected]7c52ed92012-04-06 15:42:4014#include "net/url_request/url_request.h"
[email protected]9349cfb2010-08-31 18:00:5315
[email protected]27a112c2011-01-06 04:19:3016namespace net {
17
[email protected]9349cfb2010-08-31 18:00:5318URLRequestContext::URLRequestContext()
[email protected]18590f22011-07-29 16:41:2819 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
20 net_log_(NULL),
[email protected]c3a7bce2010-10-18 17:36:5421 host_resolver_(NULL),
[email protected]822581d2010-12-16 17:27:1522 cert_verifier_(NULL),
[email protected]9c4eff22012-03-20 22:42:2923 server_bound_cert_service_(NULL),
[email protected]b97d7702011-10-16 01:11:0724 fraudulent_certificate_reporter_(NULL),
[email protected]9349cfb2010-08-31 18:00:5325 http_auth_handler_factory_(NULL),
[email protected]160014da2011-05-13 19:37:4626 proxy_service_(NULL),
[email protected]9349cfb2010-08-31 18:00:5327 network_delegate_(NULL),
[email protected]db96a882011-10-09 02:01:5428 http_server_properties_(NULL),
[email protected]70b92342010-10-12 05:54:0629 transport_security_state_(NULL),
[email protected]ede96662011-07-14 12:34:1830 ftp_auth_cache_(new FtpAuthCache),
[email protected]f6c21cb2011-02-16 19:45:4131 http_transaction_factory_(NULL),
[email protected]a8c1e7452011-05-14 06:17:0732 ftp_transaction_factory_(NULL),
[email protected]7c52ed92012-04-06 15:42:4033 job_factory_(NULL),
34 url_requests_(new std::set<const URLRequest*>) {
[email protected]9349cfb2010-08-31 18:00:5335}
[email protected]f1d81922010-07-31 17:47:0936
[email protected]d9696672011-03-15 22:45:0937void URLRequestContext::CopyFrom(URLRequestContext* other) {
38 // Copy URLRequestContext parameters.
[email protected]d9696672011-03-15 22:45:0939 set_net_log(other->net_log());
40 set_host_resolver(other->host_resolver());
41 set_cert_verifier(other->cert_verifier());
[email protected]9c4eff22012-03-20 22:42:2942 set_server_bound_cert_service(other->server_bound_cert_service());
[email protected]b97d7702011-10-16 01:11:0743 set_fraudulent_certificate_reporter(other->fraudulent_certificate_reporter());
[email protected]d9696672011-03-15 22:45:0944 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]db96a882011-10-09 02:01:5448 set_http_server_properties(other->http_server_properties());
[email protected]d9696672011-03-15 22:45:0949 set_cookie_store(other->cookie_store());
[email protected]d9696672011-03-15 22:45:0950 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]a8c1e7452011-05-14 06:17:0757 set_job_factory(other->job_factory());
[email protected]d9696672011-03-15 22:45:0958}
59
[email protected]d100e44f2011-01-26 22:47:1160void URLRequestContext::set_cookie_store(CookieStore* cookie_store) {
61 cookie_store_ = cookie_store;
62}
63
[email protected]f1d81922010-07-31 17:47:0964const std::string& URLRequestContext::GetUserAgent(const GURL& url) const {
65 return EmptyString();
66}
[email protected]9349cfb2010-08-31 18:00:5367
68URLRequestContext::~URLRequestContext() {
[email protected]7c52ed92012-04-06 15:42:4069 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]9349cfb2010-08-31 18:00:5380}
[email protected]2fb629202010-12-23 23:52:5781
[email protected]27a112c2011-01-06 04:19:3082} // namespace net