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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/url_request/url_request_context.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_context.cc
diff --git a/net/url_request/url_request_context.cc b/net/url_request/url_request_context.cc
index e42d46536b0c5e052e51143d654283de0ce3fdf8..51a6dbf7366d6fc292d49763c3a3c7032b9eb2b6 100644
--- a/net/url_request/url_request_context.cc
+++ b/net/url_request/url_request_context.cc
@@ -5,11 +5,13 @@
#include "net/url_request/url_request_context.h"
#include "base/compiler_specific.h"
+#include "base/debug/alias.h"
#include "base/string_util.h"
#include "net/base/host_resolver.h"
#include "net/cookies/cookie_store.h"
#include "net/ftp/ftp_transaction_factory.h"
#include "net/http/http_transaction_factory.h"
+#include "net/url_request/url_request.h"
namespace net {
@@ -28,7 +30,8 @@ URLRequestContext::URLRequestContext()
ftp_auth_cache_(new FtpAuthCache),
http_transaction_factory_(NULL),
ftp_transaction_factory_(NULL),
- job_factory_(NULL) {
+ job_factory_(NULL),
+ url_requests_(new std::set<const URLRequest*>) {
}
void URLRequestContext::CopyFrom(URLRequestContext* other) {
@@ -63,6 +66,17 @@ const std::string& URLRequestContext::GetUserAgent(const GURL& url) const {
}
URLRequestContext::~URLRequestContext() {
+ int num_requests = url_requests_->size();
+ if (num_requests != 0) {
+ // We're leaking URLRequests :( Dump the URL of the first one and record how
+ // many we leaked so we have an idea of how bad it is.
+ char url_buf[128];
+ const URLRequest* request = *url_requests_->begin();
+ base::strlcpy(url_buf, request->url().spec().c_str(), arraysize(url_buf));
+ base::debug::Alias(url_buf);
+ base::debug::Alias(&num_requests);
+ CHECK(false);
+ }
}
} // namespace net
« 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