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

Side by Side Diff: net/socket/client_socket_pool_base.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 unified diff | Download patch
« no previous file with comments | « net/socket/client_socket_handle.cc ('k') | net/socket/ssl_client_socket_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/socket/client_socket_pool_base.h" 5 #include "net/socket/client_socket_pool_base.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 697
698 all_groups_dict->SetWithoutPathExpansion(it->first, group_dict); 698 all_groups_dict->SetWithoutPathExpansion(it->first, group_dict);
699 } 699 }
700 dict->Set("groups", all_groups_dict); 700 dict->Set("groups", all_groups_dict);
701 return dict; 701 return dict;
702 } 702 }
703 703
704 void ClientSocketPoolBaseHelper::DumpMemoryStats( 704 void ClientSocketPoolBaseHelper::DumpMemoryStats(
705 base::trace_event::ProcessMemoryDump* pmd, 705 base::trace_event::ProcessMemoryDump* pmd,
706 const std::string& parent_dump_absolute_name) const { 706 const std::string& parent_dump_absolute_name) const {
707 base::trace_event::MemoryAllocatorDump* socket_pool_dump = nullptr;
708 size_t socket_count = 0; 707 size_t socket_count = 0;
708 size_t total_size = 0;
709 size_t buffer_size = 0;
710 size_t cert_count = 0;
711 size_t serialized_cert_size = 0;
709 for (const auto& kv : group_map_) { 712 for (const auto& kv : group_map_) {
710 for (const auto& socket : kv.second->idle_sockets()) { 713 for (const auto& socket : kv.second->idle_sockets()) {
711 // Only create a MemoryAllocatorDump if there is at least one idle socket 714 StreamSocket::SocketMemoryStats stats;
712 if (!socket_pool_dump) { 715 socket.socket->DumpMemoryStats(&stats);
713 socket_pool_dump = pmd->CreateAllocatorDump(base::StringPrintf( 716 total_size += stats.total_size;
714 "%s/socket_pool", parent_dump_absolute_name.c_str())); 717 buffer_size += stats.buffer_size;
715 } 718 cert_count += stats.cert_count;
716 socket.socket->DumpMemoryStats(pmd, socket_pool_dump->absolute_name()); 719 serialized_cert_size += stats.serialized_cert_size;
717 ++socket_count; 720 ++socket_count;
718 } 721 }
719 } 722 }
720 if (socket_pool_dump) { 723 // Only create a MemoryAllocatorDump if there is at least one idle socket
724 if (socket_count > 0) {
725 base::trace_event::MemoryAllocatorDump* socket_pool_dump =
726 pmd->CreateAllocatorDump(base::StringPrintf(
727 "%s/socket_pool", parent_dump_absolute_name.c_str()));
728 socket_pool_dump->AddScalar(
729 base::trace_event::MemoryAllocatorDump::kNameSize,
730 base::trace_event::MemoryAllocatorDump::kUnitsBytes, total_size);
721 socket_pool_dump->AddScalar( 731 socket_pool_dump->AddScalar(
722 base::trace_event::MemoryAllocatorDump::kNameObjectCount, 732 base::trace_event::MemoryAllocatorDump::kNameObjectCount,
723 base::trace_event::MemoryAllocatorDump::kUnitsObjects, socket_count); 733 base::trace_event::MemoryAllocatorDump::kUnitsObjects, socket_count);
734 socket_pool_dump->AddScalar(
735 "buffer_size", base::trace_event::MemoryAllocatorDump::kUnitsBytes,
736 buffer_size);
737 socket_pool_dump->AddScalar(
738 "cert_count", base::trace_event::MemoryAllocatorDump::kUnitsObjects,
739 cert_count);
740 socket_pool_dump->AddScalar(
741 "serialized_cert_size",
742 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
743 serialized_cert_size);
724 } 744 }
725 } 745 }
726 746
727 bool ClientSocketPoolBaseHelper::IdleSocket::IsUsable() const { 747 bool ClientSocketPoolBaseHelper::IdleSocket::IsUsable() const {
728 if (socket->WasEverUsed()) 748 if (socket->WasEverUsed())
729 return socket->IsConnectedAndIdle(); 749 return socket->IsConnectedAndIdle();
730 return socket->IsConnected(); 750 return socket->IsConnected();
731 } 751 }
732 752
733 void ClientSocketPoolBaseHelper::CleanupIdleSockets(bool force) { 753 void ClientSocketPoolBaseHelper::CleanupIdleSockets(bool force) {
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 // If there are no more requests, kill the backup timer. 1428 // If there are no more requests, kill the backup timer.
1409 if (pending_requests_.empty()) 1429 if (pending_requests_.empty())
1410 backup_job_timer_.Stop(); 1430 backup_job_timer_.Stop();
1411 request->CrashIfInvalid(); 1431 request->CrashIfInvalid();
1412 return request; 1432 return request;
1413 } 1433 }
1414 1434
1415 } // namespace internal 1435 } // namespace internal
1416 1436
1417 } // namespace net 1437 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/client_socket_handle.cc ('k') | net/socket/ssl_client_socket_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698