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/memory/ptr_util.h" |
14 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
15 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
16 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
17 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
18 #include "base/threading/thread_task_runner_handle.h" | 19 #include "base/threading/thread_task_runner_handle.h" |
19 #include "base/time/time.h" | 20 #include "base/time/time.h" |
20 #include "base/trace_event/memory_allocator_dump.h" | 21 #include "base/trace_event/memory_allocator_dump.h" |
21 #include "base/trace_event/process_memory_dump.h" | 22 #include "base/trace_event/process_memory_dump.h" |
22 #include "base/trace_event/trace_event.h" | 23 #include "base/trace_event/trace_event.h" |
23 #include "base/values.h" | 24 #include "base/values.h" |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 } | 663 } |
663 | 664 |
664 if (group.CanUseAdditionalSocketSlot(max_sockets_per_group_)) | 665 if (group.CanUseAdditionalSocketSlot(max_sockets_per_group_)) |
665 return LOAD_STATE_WAITING_FOR_STALLED_SOCKET_POOL; | 666 return LOAD_STATE_WAITING_FOR_STALLED_SOCKET_POOL; |
666 return LOAD_STATE_WAITING_FOR_AVAILABLE_SOCKET; | 667 return LOAD_STATE_WAITING_FOR_AVAILABLE_SOCKET; |
667 } | 668 } |
668 | 669 |
669 std::unique_ptr<base::DictionaryValue> | 670 std::unique_ptr<base::DictionaryValue> |
670 ClientSocketPoolBaseHelper::GetInfoAsValue(const std::string& name, | 671 ClientSocketPoolBaseHelper::GetInfoAsValue(const std::string& name, |
671 const std::string& type) const { | 672 const std::string& type) const { |
672 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 673 auto dict = base::MakeUnique<base::DictionaryValue>(); |
673 dict->SetString("name", name); | 674 dict->SetString("name", name); |
674 dict->SetString("type", type); | 675 dict->SetString("type", type); |
675 dict->SetInteger("handed_out_socket_count", handed_out_socket_count_); | 676 dict->SetInteger("handed_out_socket_count", handed_out_socket_count_); |
676 dict->SetInteger("connecting_socket_count", connecting_socket_count_); | 677 dict->SetInteger("connecting_socket_count", connecting_socket_count_); |
677 dict->SetInteger("idle_socket_count", idle_socket_count_); | 678 dict->SetInteger("idle_socket_count", idle_socket_count_); |
678 dict->SetInteger("max_socket_count", max_sockets_); | 679 dict->SetInteger("max_socket_count", max_sockets_); |
679 dict->SetInteger("max_sockets_per_group", max_sockets_per_group_); | 680 dict->SetInteger("max_sockets_per_group", max_sockets_per_group_); |
680 dict->SetInteger("pool_generation_number", pool_generation_number_); | 681 dict->SetInteger("pool_generation_number", pool_generation_number_); |
681 | 682 |
682 if (group_map_.empty()) | 683 if (group_map_.empty()) |
683 return dict; | 684 return dict; |
684 | 685 |
685 base::DictionaryValue* all_groups_dict = new base::DictionaryValue(); | 686 auto all_groups_dict = base::MakeUnique<base::DictionaryValue>(); |
686 for (GroupMap::const_iterator it = group_map_.begin(); | 687 for (GroupMap::const_iterator it = group_map_.begin(); |
687 it != group_map_.end(); it++) { | 688 it != group_map_.end(); it++) { |
688 const Group* group = it->second; | 689 const Group* group = it->second; |
689 base::DictionaryValue* group_dict = new base::DictionaryValue(); | 690 auto group_dict = base::MakeUnique<base::DictionaryValue>(); |
690 | 691 |
691 group_dict->SetInteger("pending_request_count", | 692 group_dict->SetInteger("pending_request_count", |
692 group->pending_request_count()); | 693 group->pending_request_count()); |
693 if (group->has_pending_requests()) { | 694 if (group->has_pending_requests()) { |
694 group_dict->SetString( | 695 group_dict->SetString( |
695 "top_pending_priority", | 696 "top_pending_priority", |
696 RequestPriorityToString(group->TopPendingPriority())); | 697 RequestPriorityToString(group->TopPendingPriority())); |
697 } | 698 } |
698 | 699 |
699 group_dict->SetInteger("active_socket_count", group->active_socket_count()); | 700 group_dict->SetInteger("active_socket_count", group->active_socket_count()); |
700 | 701 |
701 base::ListValue* idle_socket_list = new base::ListValue(); | 702 auto idle_socket_list = base::MakeUnique<base::ListValue>(); |
702 std::list<IdleSocket>::const_iterator idle_socket; | 703 std::list<IdleSocket>::const_iterator idle_socket; |
703 for (idle_socket = group->idle_sockets().begin(); | 704 for (idle_socket = group->idle_sockets().begin(); |
704 idle_socket != group->idle_sockets().end(); | 705 idle_socket != group->idle_sockets().end(); |
705 idle_socket++) { | 706 idle_socket++) { |
706 int source_id = idle_socket->socket->NetLog().source().id; | 707 int source_id = idle_socket->socket->NetLog().source().id; |
707 idle_socket_list->AppendInteger(source_id); | 708 idle_socket_list->AppendInteger(source_id); |
708 } | 709 } |
709 group_dict->Set("idle_sockets", idle_socket_list); | 710 group_dict->Set("idle_sockets", std::move(idle_socket_list)); |
710 | 711 |
711 base::ListValue* connect_jobs_list = new base::ListValue(); | 712 auto connect_jobs_list = base::MakeUnique<base::ListValue>(); |
712 for (auto job = group->jobs().begin(); job != group->jobs().end(); job++) { | 713 for (auto job = group->jobs().begin(); job != group->jobs().end(); job++) { |
713 int source_id = (*job)->net_log().source().id; | 714 int source_id = (*job)->net_log().source().id; |
714 connect_jobs_list->AppendInteger(source_id); | 715 connect_jobs_list->AppendInteger(source_id); |
715 } | 716 } |
716 group_dict->Set("connect_jobs", connect_jobs_list); | 717 group_dict->Set("connect_jobs", std::move(connect_jobs_list)); |
717 | 718 |
718 group_dict->SetBoolean("is_stalled", group->CanUseAdditionalSocketSlot( | 719 group_dict->SetBoolean("is_stalled", group->CanUseAdditionalSocketSlot( |
719 max_sockets_per_group_)); | 720 max_sockets_per_group_)); |
720 group_dict->SetBoolean("backup_job_timer_is_running", | 721 group_dict->SetBoolean("backup_job_timer_is_running", |
721 group->BackupJobTimerIsRunning()); | 722 group->BackupJobTimerIsRunning()); |
722 | 723 |
723 all_groups_dict->SetWithoutPathExpansion(it->first, group_dict); | 724 all_groups_dict->SetWithoutPathExpansion(it->first, std::move(group_dict)); |
724 } | 725 } |
725 dict->Set("groups", all_groups_dict); | 726 dict->Set("groups", std::move(all_groups_dict)); |
726 return dict; | 727 return dict; |
727 } | 728 } |
728 | 729 |
729 void ClientSocketPoolBaseHelper::DumpMemoryStats( | 730 void ClientSocketPoolBaseHelper::DumpMemoryStats( |
730 base::trace_event::ProcessMemoryDump* pmd, | 731 base::trace_event::ProcessMemoryDump* pmd, |
731 const std::string& parent_dump_absolute_name) const { | 732 const std::string& parent_dump_absolute_name) const { |
732 size_t socket_count = 0; | 733 size_t socket_count = 0; |
733 size_t total_size = 0; | 734 size_t total_size = 0; |
734 size_t buffer_size = 0; | 735 size_t buffer_size = 0; |
735 size_t cert_count = 0; | 736 size_t cert_count = 0; |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1480 // If there are no more requests, kill the backup timer. | 1481 // If there are no more requests, kill the backup timer. |
1481 if (pending_requests_.empty()) | 1482 if (pending_requests_.empty()) |
1482 backup_job_timer_.Stop(); | 1483 backup_job_timer_.Stop(); |
1483 request->CrashIfInvalid(); | 1484 request->CrashIfInvalid(); |
1484 return request; | 1485 return request; |
1485 } | 1486 } |
1486 | 1487 |
1487 } // namespace internal | 1488 } // namespace internal |
1488 | 1489 |
1489 } // namespace net | 1490 } // namespace net |
OLD | NEW |