Index: net/socket/client_socket_pool_base.cc |
diff --git a/net/socket/client_socket_pool_base.cc b/net/socket/client_socket_pool_base.cc |
index c4307fb2812adde72a826072e9ed990291c2539f..7d7f1add664d6819a0871e69e79cd24834aa74ff 100644 |
--- a/net/socket/client_socket_pool_base.cc |
+++ b/net/socket/client_socket_pool_base.cc |
@@ -14,8 +14,11 @@ |
#include "base/metrics/histogram_macros.h" |
#include "base/single_thread_task_runner.h" |
#include "base/strings/string_util.h" |
+#include "base/strings/stringprintf.h" |
#include "base/threading/thread_task_runner_handle.h" |
#include "base/time/time.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" |
#include "net/base/net_errors.h" |
@@ -697,6 +700,30 @@ ClientSocketPoolBaseHelper::GetInfoAsValue(const std::string& name, |
return dict; |
} |
+void ClientSocketPoolBaseHelper::DumpMemoryStats( |
+ base::trace_event::ProcessMemoryDump* pmd, |
+ const std::string& parent_dump_absolute_name) const { |
+ base::trace_event::MemoryAllocatorDump* socket_pool_dump = nullptr; |
+ size_t socket_count = 0; |
+ for (GroupMap::const_iterator it = group_map_.begin(); it != group_map_.end(); |
Primiano Tucci (use gerrit)
2016/12/06 17:06:28
for (const auto& kv : group_map) might save one li
xunjieli
2016/12/06 18:36:08
Done.
|
+ ++it) { |
+ for (const auto& socket : it->second->idle_sockets()) { |
+ // Only create a MemoryAllocatorDump if there is at least one idle socket |
+ if (!socket_pool_dump) { |
+ socket_pool_dump = pmd->CreateAllocatorDump(base::StringPrintf( |
+ "%s/socket_pool", parent_dump_absolute_name.c_str())); |
+ } |
+ socket.socket->DumpMemoryStats(pmd, socket_pool_dump->absolute_name()); |
+ ++socket_count; |
+ } |
+ } |
+ if (socket_pool_dump) { |
+ socket_pool_dump->AddScalar( |
+ base::trace_event::MemoryAllocatorDump::kNameObjectCount, |
+ base::trace_event::MemoryAllocatorDump::kUnitsObjects, socket_count); |
+ } |
+} |
+ |
bool ClientSocketPoolBaseHelper::IdleSocket::IsUsable() const { |
if (socket->WasEverUsed()) |
return socket->IsConnectedAndIdle(); |