Chromium Code Reviews| Index: net/socket/ssl_client_socket_impl.cc |
| diff --git a/net/socket/ssl_client_socket_impl.cc b/net/socket/ssl_client_socket_impl.cc |
| index 97c67521063c9c9ba8d1545d9499aac6baec277f..64e452806b5660a1c8926e14350e5e19e112816d 100644 |
| --- a/net/socket/ssl_client_socket_impl.cc |
| +++ b/net/socket/ssl_client_socket_impl.cc |
| @@ -25,7 +25,6 @@ |
| #include "base/strings/stringprintf.h" |
| #include "base/synchronization/lock.h" |
| #include "base/threading/thread_local.h" |
| -#include "base/trace_event/memory_allocator_dump.h" |
| #include "base/trace_event/process_memory_dump.h" |
| #include "base/trace_event/trace_event.h" |
| #include "base/values.h" |
| @@ -804,42 +803,20 @@ int64_t SSLClientSocketImpl::GetTotalReceivedBytes() const { |
| return transport_->socket()->GetTotalReceivedBytes(); |
| } |
| -void SSLClientSocketImpl::DumpMemoryStats( |
| - base::trace_event::ProcessMemoryDump* pmd, |
| - const std::string& parent_dump_absolute_name) const { |
| - size_t total_size = 0; |
| - base::trace_event::MemoryAllocatorDump* socket_dump = |
| - pmd->CreateAllocatorDump(base::StringPrintf( |
| - "%s/ssl_socket_%p", parent_dump_absolute_name.c_str(), this)); |
| - if (transport_adapter_) { |
| - size_t bio_buffers_size = transport_adapter_->GetAllocationSize(); |
| - socket_dump->AddScalar("buffer_size", |
| - base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
| - bio_buffers_size); |
| - total_size += bio_buffers_size; |
| - } |
| - size_t total_cert_size = 0; |
| - size_t certs_count = 0; |
| +void SSLClientSocketImpl::DumpMemoryStats(SocketMemoryStats* stats) const { |
| + if (transport_adapter_) |
| + stats->buffer_size = transport_adapter_->GetAllocationSize(); |
| if (server_cert_chain_) { |
| - certs_count = server_cert_chain_->size(); |
| - for (size_t i = 0; i < certs_count; ++i) { |
| + for (size_t i = 0; i < server_cert_chain_->size(); ++i) { |
| X509* cert = server_cert_chain_->Get(i); |
| - total_cert_size += i2d_X509(cert, nullptr); |
| + // This measures the lower bound of the serialized certificate. It doesn't |
| + // measure the actual memory used, which is 4x this amount (see |
| + // crbug.com/671420 for more details). |
| + stats->serialized_cert_size += i2d_X509(cert, nullptr); |
| } |
| + stats->cert_count = server_cert_chain_->size(); |
|
eroman
2017/01/11 02:19:58
What is the expected contract for |stats| -- assig
xunjieli
2017/01/11 20:05:07
Done. Opted for the assignment way throughout.
|
| } |
| - total_size += total_cert_size; |
| - // This measures the lower bound of the serialized certificate. It doesn't |
| - // measure the actual memory used, which is 4x this amount (see |
| - // crbug.com/671420 for more details). |
| - socket_dump->AddScalar("serialized_cert_size", |
| - base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
| - total_cert_size); |
| - socket_dump->AddScalar("cert_count", |
| - base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| - certs_count); |
| - socket_dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
| - base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
| - total_size); |
| + stats->total_size = stats->buffer_size + stats->serialized_cert_size; |
| } |
| // static |