| 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.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/debug/alias.h" |
| 9 #include "base/debug/stack_trace.h" | 9 #include "base/debug/stack_trace.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 } | 87 } |
| 88 | 88 |
| 89 void URLRequestContext::AssertNoURLRequests() const { | 89 void URLRequestContext::AssertNoURLRequests() const { |
| 90 int num_requests = url_requests_->size(); | 90 int num_requests = url_requests_->size(); |
| 91 if (num_requests != 0) { | 91 if (num_requests != 0) { |
| 92 // We're leaking URLRequests :( Dump the URL of the first one and record how | 92 // We're leaking URLRequests :( Dump the URL of the first one and record how |
| 93 // many we leaked so we have an idea of how bad it is. | 93 // many we leaked so we have an idea of how bad it is. |
| 94 char url_buf[128]; | 94 char url_buf[128]; |
| 95 const URLRequest* request = *url_requests_->begin(); | 95 const URLRequest* request = *url_requests_->begin(); |
| 96 base::strlcpy(url_buf, request->url().spec().c_str(), arraysize(url_buf)); | 96 base::strlcpy(url_buf, request->url().spec().c_str(), arraysize(url_buf)); |
| 97 bool has_delegate = request->has_delegate(); | |
| 98 int load_flags = request->load_flags(); | 97 int load_flags = request->load_flags(); |
| 99 base::debug::StackTrace stack_trace(NULL, 0); | 98 base::debug::StackTrace stack_trace(NULL, 0); |
| 100 if (request->stack_trace()) | 99 if (request->stack_trace()) |
| 101 stack_trace = *request->stack_trace(); | 100 stack_trace = *request->stack_trace(); |
| 102 base::debug::Alias(url_buf); | 101 base::debug::Alias(url_buf); |
| 103 base::debug::Alias(&num_requests); | 102 base::debug::Alias(&num_requests); |
| 104 base::debug::Alias(&has_delegate); | |
| 105 base::debug::Alias(&load_flags); | 103 base::debug::Alias(&load_flags); |
| 106 base::debug::Alias(&stack_trace); | 104 base::debug::Alias(&stack_trace); |
| 107 CHECK(false) << "Leaked " << num_requests << " URLRequest(s). First URL: " | 105 CHECK(false) << "Leaked " << num_requests << " URLRequest(s). First URL: " |
| 108 << request->url().spec().c_str() << "."; | 106 << request->url().spec().c_str() << "."; |
| 109 } | 107 } |
| 110 } | 108 } |
| 111 | 109 |
| 112 } // namespace net | 110 } // namespace net |
| OLD | NEW |