| 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/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 if (num_requests != 0) { | 106 if (num_requests != 0) { |
| 107 // We're leaking URLRequests :( Dump the URL of the first one and record how | 107 // We're leaking URLRequests :( Dump the URL of the first one and record how |
| 108 // many we leaked so we have an idea of how bad it is. | 108 // many we leaked so we have an idea of how bad it is. |
| 109 char url_buf[128]; | 109 char url_buf[128]; |
| 110 const URLRequest* request = *url_requests_->begin(); | 110 const URLRequest* request = *url_requests_->begin(); |
| 111 base::strlcpy(url_buf, request->url().spec().c_str(), arraysize(url_buf)); | 111 base::strlcpy(url_buf, request->url().spec().c_str(), arraysize(url_buf)); |
| 112 int load_flags = request->load_flags(); | 112 int load_flags = request->load_flags(); |
| 113 base::debug::Alias(url_buf); | 113 base::debug::Alias(url_buf); |
| 114 base::debug::Alias(&num_requests); | 114 base::debug::Alias(&num_requests); |
| 115 base::debug::Alias(&load_flags); | 115 base::debug::Alias(&load_flags); |
| 116 CHECK(false) << "Leaked " << num_requests << " URLRequest(s). First URL: " | 116 LOG(FATAL) << "Leaked " << num_requests |
| 117 << request->url().spec().c_str() << "."; | 117 << " URLRequest(s). First URL: " << request->url().spec() << "."; |
| 118 } | 118 } |
| 119 } | 119 } |
| 120 | 120 |
| 121 bool URLRequestContext::OnMemoryDump( | 121 bool URLRequestContext::OnMemoryDump( |
| 122 const base::trace_event::MemoryDumpArgs& args, | 122 const base::trace_event::MemoryDumpArgs& args, |
| 123 base::trace_event::ProcessMemoryDump* pmd) { | 123 base::trace_event::ProcessMemoryDump* pmd) { |
| 124 if (name_.empty()) | 124 if (name_.empty()) |
| 125 name_ = "unknown"; | 125 name_ = "unknown"; |
| 126 base::trace_event::MemoryAllocatorDump* dump = pmd->CreateAllocatorDump( | 126 base::trace_event::MemoryAllocatorDump* dump = pmd->CreateAllocatorDump( |
| 127 base::StringPrintf("net/url_request_context/%s_%p", name_.c_str(), this)); | 127 base::StringPrintf("net/url_request_context/%s_%p", name_.c_str(), this)); |
| 128 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameObjectCount, | 128 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameObjectCount, |
| 129 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 129 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 130 url_requests_->size()); | 130 url_requests_->size()); |
| 131 HttpTransactionFactory* transaction_factory = http_transaction_factory(); | 131 HttpTransactionFactory* transaction_factory = http_transaction_factory(); |
| 132 if (transaction_factory) { | 132 if (transaction_factory) { |
| 133 HttpNetworkSession* network_session = transaction_factory->GetSession(); | 133 HttpNetworkSession* network_session = transaction_factory->GetSession(); |
| 134 if (network_session) | 134 if (network_session) |
| 135 network_session->DumpMemoryStats(pmd, dump->absolute_name()); | 135 network_session->DumpMemoryStats(pmd, dump->absolute_name()); |
| 136 } | 136 } |
| 137 SSLClientSocketImpl::DumpSSLClientSessionMemoryStats(pmd); | 137 SSLClientSocketImpl::DumpSSLClientSessionMemoryStats(pmd); |
| 138 return true; | 138 return true; |
| 139 } | 139 } |
| 140 | 140 |
| 141 } // namespace net | 141 } // namespace net |
| OLD | NEW |