Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Side by Side Diff: net/url_request/url_request_context.cc

Issue 10006009: Track URLRequestContext references in a set. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Nits Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/url_request/url_request_context.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.h" 5 #include "net/url_request/url_request_context.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/debug/alias.h"
8 #include "base/string_util.h" 9 #include "base/string_util.h"
9 #include "net/base/host_resolver.h" 10 #include "net/base/host_resolver.h"
10 #include "net/cookies/cookie_store.h" 11 #include "net/cookies/cookie_store.h"
11 #include "net/ftp/ftp_transaction_factory.h" 12 #include "net/ftp/ftp_transaction_factory.h"
12 #include "net/http/http_transaction_factory.h" 13 #include "net/http/http_transaction_factory.h"
14 #include "net/url_request/url_request.h"
13 15
14 namespace net { 16 namespace net {
15 17
16 URLRequestContext::URLRequestContext() 18 URLRequestContext::URLRequestContext()
17 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), 19 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
18 net_log_(NULL), 20 net_log_(NULL),
19 host_resolver_(NULL), 21 host_resolver_(NULL),
20 cert_verifier_(NULL), 22 cert_verifier_(NULL),
21 server_bound_cert_service_(NULL), 23 server_bound_cert_service_(NULL),
22 fraudulent_certificate_reporter_(NULL), 24 fraudulent_certificate_reporter_(NULL),
23 http_auth_handler_factory_(NULL), 25 http_auth_handler_factory_(NULL),
24 proxy_service_(NULL), 26 proxy_service_(NULL),
25 network_delegate_(NULL), 27 network_delegate_(NULL),
26 http_server_properties_(NULL), 28 http_server_properties_(NULL),
27 transport_security_state_(NULL), 29 transport_security_state_(NULL),
28 ftp_auth_cache_(new FtpAuthCache), 30 ftp_auth_cache_(new FtpAuthCache),
29 http_transaction_factory_(NULL), 31 http_transaction_factory_(NULL),
30 ftp_transaction_factory_(NULL), 32 ftp_transaction_factory_(NULL),
31 job_factory_(NULL) { 33 job_factory_(NULL),
34 url_requests_(new std::set<const URLRequest*>) {
32 } 35 }
33 36
34 void URLRequestContext::CopyFrom(URLRequestContext* other) { 37 void URLRequestContext::CopyFrom(URLRequestContext* other) {
35 // Copy URLRequestContext parameters. 38 // Copy URLRequestContext parameters.
36 set_net_log(other->net_log()); 39 set_net_log(other->net_log());
37 set_host_resolver(other->host_resolver()); 40 set_host_resolver(other->host_resolver());
38 set_cert_verifier(other->cert_verifier()); 41 set_cert_verifier(other->cert_verifier());
39 set_server_bound_cert_service(other->server_bound_cert_service()); 42 set_server_bound_cert_service(other->server_bound_cert_service());
40 set_fraudulent_certificate_reporter(other->fraudulent_certificate_reporter()); 43 set_fraudulent_certificate_reporter(other->fraudulent_certificate_reporter());
41 set_http_auth_handler_factory(other->http_auth_handler_factory()); 44 set_http_auth_handler_factory(other->http_auth_handler_factory());
(...skipping 14 matching lines...) Expand all
56 59
57 void URLRequestContext::set_cookie_store(CookieStore* cookie_store) { 60 void URLRequestContext::set_cookie_store(CookieStore* cookie_store) {
58 cookie_store_ = cookie_store; 61 cookie_store_ = cookie_store;
59 } 62 }
60 63
61 const std::string& URLRequestContext::GetUserAgent(const GURL& url) const { 64 const std::string& URLRequestContext::GetUserAgent(const GURL& url) const {
62 return EmptyString(); 65 return EmptyString();
63 } 66 }
64 67
65 URLRequestContext::~URLRequestContext() { 68 URLRequestContext::~URLRequestContext() {
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 }
66 } 80 }
67 81
68 } // namespace net 82 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_context.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698