OLD | NEW |
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" |
11 #include "base/format_macros.h" | 11 #include "base/format_macros.h" |
12 #include "base/location.h" | 12 #include "base/location.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
15 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 17 #include "base/strings/stringprintf.h" |
17 #include "base/threading/thread_task_runner_handle.h" | 18 #include "base/threading/thread_task_runner_handle.h" |
18 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 20 #include "base/trace_event/memory_allocator_dump.h" |
| 21 #include "base/trace_event/process_memory_dump.h" |
19 #include "base/trace_event/trace_event.h" | 22 #include "base/trace_event/trace_event.h" |
20 #include "base/values.h" | 23 #include "base/values.h" |
21 #include "net/base/net_errors.h" | 24 #include "net/base/net_errors.h" |
22 #include "net/log/net_log.h" | 25 #include "net/log/net_log.h" |
23 #include "net/log/net_log_event_type.h" | 26 #include "net/log/net_log_event_type.h" |
24 #include "net/log/net_log_source.h" | 27 #include "net/log/net_log_source.h" |
25 | 28 |
26 using base::TimeDelta; | 29 using base::TimeDelta; |
27 | 30 |
28 namespace net { | 31 namespace net { |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 max_sockets_per_group_)); | 693 max_sockets_per_group_)); |
691 group_dict->SetBoolean("backup_job_timer_is_running", | 694 group_dict->SetBoolean("backup_job_timer_is_running", |
692 group->BackupJobTimerIsRunning()); | 695 group->BackupJobTimerIsRunning()); |
693 | 696 |
694 all_groups_dict->SetWithoutPathExpansion(it->first, group_dict); | 697 all_groups_dict->SetWithoutPathExpansion(it->first, group_dict); |
695 } | 698 } |
696 dict->Set("groups", all_groups_dict); | 699 dict->Set("groups", all_groups_dict); |
697 return dict; | 700 return dict; |
698 } | 701 } |
699 | 702 |
| 703 void ClientSocketPoolBaseHelper::DumpMemoryStats( |
| 704 base::trace_event::ProcessMemoryDump* pmd, |
| 705 const std::string& parent_dump_absolute_name) const { |
| 706 base::trace_event::MemoryAllocatorDump* socket_pool_dump = nullptr; |
| 707 size_t socket_count = 0; |
| 708 for (const auto& kv : group_map_) { |
| 709 for (const auto& socket : kv.second->idle_sockets()) { |
| 710 // Only create a MemoryAllocatorDump if there is at least one idle socket |
| 711 if (!socket_pool_dump) { |
| 712 socket_pool_dump = pmd->CreateAllocatorDump(base::StringPrintf( |
| 713 "%s/socket_pool", parent_dump_absolute_name.c_str())); |
| 714 } |
| 715 socket.socket->DumpMemoryStats(pmd, socket_pool_dump->absolute_name()); |
| 716 ++socket_count; |
| 717 } |
| 718 } |
| 719 if (socket_pool_dump) { |
| 720 socket_pool_dump->AddScalar( |
| 721 base::trace_event::MemoryAllocatorDump::kNameObjectCount, |
| 722 base::trace_event::MemoryAllocatorDump::kUnitsObjects, socket_count); |
| 723 } |
| 724 } |
| 725 |
700 bool ClientSocketPoolBaseHelper::IdleSocket::IsUsable() const { | 726 bool ClientSocketPoolBaseHelper::IdleSocket::IsUsable() const { |
701 if (socket->WasEverUsed()) | 727 if (socket->WasEverUsed()) |
702 return socket->IsConnectedAndIdle(); | 728 return socket->IsConnectedAndIdle(); |
703 return socket->IsConnected(); | 729 return socket->IsConnected(); |
704 } | 730 } |
705 | 731 |
706 void ClientSocketPoolBaseHelper::CleanupIdleSockets(bool force) { | 732 void ClientSocketPoolBaseHelper::CleanupIdleSockets(bool force) { |
707 if (idle_socket_count_ == 0) | 733 if (idle_socket_count_ == 0) |
708 return; | 734 return; |
709 | 735 |
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1381 // If there are no more requests, kill the backup timer. | 1407 // If there are no more requests, kill the backup timer. |
1382 if (pending_requests_.empty()) | 1408 if (pending_requests_.empty()) |
1383 backup_job_timer_.Stop(); | 1409 backup_job_timer_.Stop(); |
1384 request->CrashIfInvalid(); | 1410 request->CrashIfInvalid(); |
1385 return request; | 1411 return request; |
1386 } | 1412 } |
1387 | 1413 |
1388 } // namespace internal | 1414 } // namespace internal |
1389 | 1415 |
1390 } // namespace net | 1416 } // namespace net |
OLD | NEW |