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

Side by Side Diff: net/socket/client_socket_pool_base.cc

Issue 2414883005: TEMP DO NOT LAND (Closed)
Patch Set: tmp Created 4 years, 1 month 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_pool_base.h ('k') | net/socket/client_socket_pool_manager.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"
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/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
18 #include "base/time/time.h" 18 #include "base/time/time.h"
19 #include "base/trace_event/trace_event.h" 19 #include "base/trace_event/trace_event.h"
20 #include "base/values.h" 20 #include "base/values.h"
21 #include "net/base/net_errors.h" 21 #include "net/base/net_errors.h"
22 #include "net/log/net_log.h" 22 #include "net/log/net_log.h"
23 #include "net/log/net_log_event_type.h" 23 #include "net/log/net_log_event_type.h"
24 #include "net/log/net_log_source.h" 24 #include "net/log/net_log_source.h"
25 25
26 #include "base/trace_event/memory_allocator_dump.h"
27 #include "base/trace_event/process_memory_dump.h"
28 #include "base/strings/stringprintf.h"
29
26 using base::TimeDelta; 30 using base::TimeDelta;
27 31
28 namespace net { 32 namespace net {
29 33
30 namespace { 34 namespace {
31 35
32 // Indicate whether or not we should establish a new transport layer connection 36 // Indicate whether or not we should establish a new transport layer connection
33 // after a certain timeout has passed without receiving an ACK. 37 // after a certain timeout has passed without receiving an ACK.
34 bool g_connect_backup_jobs_enabled = true; 38 bool g_connect_backup_jobs_enabled = true;
35 39
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 max_sockets_per_group_)); 648 max_sockets_per_group_));
645 group_dict->SetBoolean("backup_job_timer_is_running", 649 group_dict->SetBoolean("backup_job_timer_is_running",
646 group->BackupJobTimerIsRunning()); 650 group->BackupJobTimerIsRunning());
647 651
648 all_groups_dict->SetWithoutPathExpansion(it->first, group_dict); 652 all_groups_dict->SetWithoutPathExpansion(it->first, group_dict);
649 } 653 }
650 dict->Set("groups", all_groups_dict); 654 dict->Set("groups", all_groups_dict);
651 return dict; 655 return dict;
652 } 656 }
653 657
658 void ClientSocketPoolBaseHelper::PopulateAllocatorDump(
659 base::trace_event::MemoryAllocatorDump* dump) const {
660 base::trace_event::MemoryAllocatorDump* socket_pool_dump =
661 dump->process_memory_dump()->CreateAllocatorDump(base::StringPrintf(
662 "%s/socket_pool", dump->absolute_name().c_str()));
663 size_t socket_count = 0;
664 for (GroupMap::const_iterator it = group_map_.begin(); it != group_map_.end();
665 ++it) {
666 const std::list<IdleSocket> sockets = it->second->idle_sockets();
667 for (auto socket : sockets) {
668 socket.socket->PopulateAllocatorDump(socket_pool_dump);
669 }
670 ++socket_count;
671 }
672 socket_pool_dump->AddScalar(
673 "count", base::trace_event::MemoryAllocatorDump::kUnitsObjects,
674 socket_count);
675 }
676
654 bool ClientSocketPoolBaseHelper::IdleSocket::IsUsable() const { 677 bool ClientSocketPoolBaseHelper::IdleSocket::IsUsable() const {
655 if (socket->WasEverUsed()) 678 if (socket->WasEverUsed())
656 return socket->IsConnectedAndIdle(); 679 return socket->IsConnectedAndIdle();
657 return socket->IsConnected(); 680 return socket->IsConnected();
658 } 681 }
659 682
660 bool ClientSocketPoolBaseHelper::IdleSocket::ShouldCleanup( 683 bool ClientSocketPoolBaseHelper::IdleSocket::ShouldCleanup(
661 base::TimeTicks now, 684 base::TimeTicks now,
662 base::TimeDelta timeout) const { 685 base::TimeDelta timeout) const {
663 bool timed_out = (now - start_time) >= timeout; 686 bool timed_out = (now - start_time) >= timeout;
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 // If there are no more requests, kill the backup timer. 1352 // If there are no more requests, kill the backup timer.
1330 if (pending_requests_.empty()) 1353 if (pending_requests_.empty())
1331 backup_job_timer_.Stop(); 1354 backup_job_timer_.Stop();
1332 request->CrashIfInvalid(); 1355 request->CrashIfInvalid();
1333 return request; 1356 return request;
1334 } 1357 }
1335 1358
1336 } // namespace internal 1359 } // namespace internal
1337 1360
1338 } // namespace net 1361 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/client_socket_pool_base.h ('k') | net/socket/client_socket_pool_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698