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