Chromium Code Reviews| 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..e303e8a95b0d262fbb4a217ddb0dd5745334df99 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,32 @@ ClientSocketPoolBaseHelper::GetInfoAsValue(const std::string& name, |
| return dict; |
| } |
| +void ClientSocketPoolBaseHelper::DumpMemoryStats( |
| + base::trace_event::MemoryAllocatorDump* parent_dump) 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(); |
| + ++it) { |
| + const std::list<IdleSocket> sockets = it->second->idle_sockets(); |
|
eroman
2016/12/02 00:27:24
Looks like there are some unnecessary copies here.
xunjieli
2016/12/02 15:31:34
oops, sorry. Done.
|
| + for (auto socket : sockets) { |
| + // Only create a MemoryAllocatorDump if there is at least one idle socket |
| + if (!socket_pool_dump) { |
| + socket_pool_dump = |
| + parent_dump->process_memory_dump()->CreateAllocatorDump( |
| + base::StringPrintf("%s/socket_pool", |
| + parent_dump->absolute_name().c_str())); |
| + } |
| + socket.socket->DumpMemoryStats(socket_pool_dump); |
| + ++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(); |