Chromium Code Reviews| 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" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
| 13 #include "base/trace_event/memory_allocator_dump.h" | 13 #include "base/trace_event/memory_allocator_dump.h" |
| 14 #include "base/trace_event/memory_dump_manager.h" | 14 #include "base/trace_event/memory_dump_manager.h" |
| 15 #include "base/trace_event/memory_dump_request_args.h" | |
| 15 #include "base/trace_event/process_memory_dump.h" | 16 #include "base/trace_event/process_memory_dump.h" |
| 16 #include "net/base/sdch_manager.h" | 17 #include "net/base/sdch_manager.h" |
| 17 #include "net/cookies/cookie_store.h" | 18 #include "net/cookies/cookie_store.h" |
| 18 #include "net/dns/host_resolver.h" | 19 #include "net/dns/host_resolver.h" |
| 19 #include "net/http/http_cache.h" | 20 #include "net/http/http_cache.h" |
| 20 #include "net/http/http_transaction_factory.h" | 21 #include "net/http/http_transaction_factory.h" |
| 21 #include "net/socket/ssl_client_socket_impl.h" | 22 #include "net/socket/ssl_client_socket_impl.h" |
| 22 #include "net/url_request/http_user_agent_settings.h" | 23 #include "net/url_request/http_user_agent_settings.h" |
| 23 #include "net/url_request/url_request.h" | 24 #include "net/url_request/url_request.h" |
| 24 | 25 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 131 CHECK(false) << "Leaked " << num_requests << " URLRequest(s). First URL: " | 132 CHECK(false) << "Leaked " << num_requests << " URLRequest(s). First URL: " |
| 132 << request->url().spec().c_str() << "."; | 133 << request->url().spec().c_str() << "."; |
| 133 } | 134 } |
| 134 } | 135 } |
| 135 | 136 |
| 136 bool URLRequestContext::OnMemoryDump( | 137 bool URLRequestContext::OnMemoryDump( |
| 137 const base::trace_event::MemoryDumpArgs& args, | 138 const base::trace_event::MemoryDumpArgs& args, |
| 138 base::trace_event::ProcessMemoryDump* pmd) { | 139 base::trace_event::ProcessMemoryDump* pmd) { |
| 139 if (name_.empty()) | 140 if (name_.empty()) |
| 140 name_ = "unknown"; | 141 name_ = "unknown"; |
| 141 base::trace_event::MemoryAllocatorDump* dump = pmd->CreateAllocatorDump( | 142 |
| 142 base::StringPrintf("net/url_request_context/%s_%p", name_.c_str(), this)); | 143 SSLClientSocketImpl::DumpSSLClientSessionMemoryStats(pmd); |
| 144 | |
| 145 std::string dump_name = base::StringPrintf( | |
| 146 "net/url_request_context_0x%" PRIxPTR, reinterpret_cast<uintptr_t>(this)); | |
|
ssid
2017/02/23 20:41:01
include inttypes?
xunjieli
2017/02/23 20:48:17
Done.
| |
| 147 base::trace_event::MemoryAllocatorDump* dump = | |
| 148 pmd->CreateAllocatorDump(dump_name); | |
| 143 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameObjectCount, | 149 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameObjectCount, |
| 144 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 150 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 145 url_requests_->size()); | 151 url_requests_->size()); |
| 152 if (args.level_of_detail != | |
| 153 base::trace_event::MemoryDumpLevelOfDetail::BACKGROUND) { | |
| 154 dump->AddString("origin", | |
| 155 base::trace_event::MemoryAllocatorDump::kTypeString, name_); | |
| 156 } | |
| 146 HttpTransactionFactory* transaction_factory = http_transaction_factory(); | 157 HttpTransactionFactory* transaction_factory = http_transaction_factory(); |
| 147 if (transaction_factory) { | 158 if (transaction_factory) { |
| 148 HttpNetworkSession* network_session = transaction_factory->GetSession(); | 159 HttpNetworkSession* network_session = transaction_factory->GetSession(); |
| 149 if (network_session) | 160 if (network_session) |
| 150 network_session->DumpMemoryStats(pmd, dump->absolute_name()); | 161 network_session->DumpMemoryStats(pmd, dump->absolute_name()); |
| 151 HttpCache* http_cache = transaction_factory->GetCache(); | 162 HttpCache* http_cache = transaction_factory->GetCache(); |
| 152 if (http_cache) | 163 if (http_cache) |
| 153 http_cache->DumpMemoryStats(pmd, dump->absolute_name()); | 164 http_cache->DumpMemoryStats(pmd, dump->absolute_name()); |
| 154 } | 165 } |
| 155 SSLClientSocketImpl::DumpSSLClientSessionMemoryStats(pmd); | |
| 156 if (sdch_manager_) | 166 if (sdch_manager_) |
| 157 sdch_manager_->DumpMemoryStats(pmd, dump->absolute_name()); | 167 sdch_manager_->DumpMemoryStats(pmd, dump_name); |
| 158 return true; | 168 return true; |
| 159 } | 169 } |
| 160 | 170 |
| 161 } // namespace net | 171 } // namespace net |
| OLD | NEW |