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

Unified Diff: net/socket/ssl_client_socket_impl.cc

Issue 2623803002: Avoid creating MemoryAllocatorDump for individual sockets (Closed)
Patch Set: Address Eric's comments Created 3 years, 11 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/socket/ssl_client_socket_impl.h ('k') | net/socket/ssl_client_socket_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4e3f71311c7c2a4974e2337bc0f583724f3b8a46..4e01ea2eb85840a75350d40a6b79229cc595a934 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"
@@ -811,42 +810,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();
}
- 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
« no previous file with comments | « net/socket/ssl_client_socket_impl.h ('k') | net/socket/ssl_client_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698