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 // A ClientSocketPoolBase is used to restrict the number of sockets open at | 5 // A ClientSocketPoolBase is used to restrict the number of sockets open at |
6 // a time. It also maintains a list of idle persistent sockets for reuse. | 6 // a time. It also maintains a list of idle persistent sockets for reuse. |
7 // Subclasses of ClientSocketPool should compose ClientSocketPoolBase to handle | 7 // Subclasses of ClientSocketPool should compose ClientSocketPoolBase to handle |
8 // the core logic of (1) restricting the number of active (connected or | 8 // the core logic of (1) restricting the number of active (connected or |
9 // connecting) sockets per "group" (generally speaking, the hostname), (2) | 9 // connecting) sockets per "group" (generally speaking, the hostname), (2) |
10 // maintaining a per-group list of idle, persistent sockets for reuse, and (3) | 10 // maintaining a per-group list of idle, persistent sockets for reuse, and (3) |
(...skipping 28 matching lines...) Expand all Loading... |
39 #include "net/base/address_list.h" | 39 #include "net/base/address_list.h" |
40 #include "net/base/completion_callback.h" | 40 #include "net/base/completion_callback.h" |
41 #include "net/base/load_states.h" | 41 #include "net/base/load_states.h" |
42 #include "net/base/load_timing_info.h" | 42 #include "net/base/load_timing_info.h" |
43 #include "net/base/net_errors.h" | 43 #include "net/base/net_errors.h" |
44 #include "net/base/net_export.h" | 44 #include "net/base/net_export.h" |
45 #include "net/base/net_log.h" | 45 #include "net/base/net_log.h" |
46 #include "net/base/network_change_notifier.h" | 46 #include "net/base/network_change_notifier.h" |
47 #include "net/base/priority_queue.h" | 47 #include "net/base/priority_queue.h" |
48 #include "net/base/request_priority.h" | 48 #include "net/base/request_priority.h" |
| 49 #include "net/socket/client_socket_handle.h" |
49 #include "net/socket/client_socket_pool.h" | 50 #include "net/socket/client_socket_pool.h" |
50 #include "net/socket/stream_socket.h" | 51 #include "net/socket/stream_socket.h" |
51 | 52 |
52 namespace net { | 53 namespace net { |
53 | 54 |
54 class ClientSocketHandle; | 55 class ClientSocketHandle; |
55 | 56 |
56 // ConnectJob provides an abstract interface for "connecting" a socket. | 57 // ConnectJob provides an abstract interface for "connecting" a socket. |
57 // The connection may involve host resolution, tcp connection, ssl connection, | 58 // The connection may involve host resolution, tcp connection, ssl connection, |
58 // etc. | 59 // etc. |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 void RemoveConnectJob(ConnectJob* job, Group* group); | 522 void RemoveConnectJob(ConnectJob* job, Group* group); |
522 | 523 |
523 // Tries to see if we can handle any more requests for |group|. | 524 // Tries to see if we can handle any more requests for |group|. |
524 void OnAvailableSocketSlot(const std::string& group_name, Group* group); | 525 void OnAvailableSocketSlot(const std::string& group_name, Group* group); |
525 | 526 |
526 // Process a pending socket request for a group. | 527 // Process a pending socket request for a group. |
527 void ProcessPendingRequest(const std::string& group_name, Group* group); | 528 void ProcessPendingRequest(const std::string& group_name, Group* group); |
528 | 529 |
529 // Assigns |socket| to |handle| and updates |group|'s counters appropriately. | 530 // Assigns |socket| to |handle| and updates |group|'s counters appropriately. |
530 void HandOutSocket(scoped_ptr<StreamSocket> socket, | 531 void HandOutSocket(scoped_ptr<StreamSocket> socket, |
531 bool reused, | 532 ClientSocketHandle::SocketReuseType reuse_type, |
532 const LoadTimingInfo::ConnectTiming& connect_timing, | 533 const LoadTimingInfo::ConnectTiming& connect_timing, |
533 ClientSocketHandle* handle, | 534 ClientSocketHandle* handle, |
534 base::TimeDelta time_idle, | 535 base::TimeDelta time_idle, |
535 Group* group, | 536 Group* group, |
536 const BoundNetLog& net_log); | 537 const BoundNetLog& net_log); |
537 | 538 |
538 // Adds |socket| to the list of idle sockets for |group|. | 539 // Adds |socket| to the list of idle sockets for |group|. |
539 void AddIdleSocket(scoped_ptr<StreamSocket> socket, Group* group); | 540 void AddIdleSocket(scoped_ptr<StreamSocket> socket, Group* group); |
540 | 541 |
541 // Iterates through |group_map_|, canceling all ConnectJobs and deleting | 542 // Iterates through |group_map_|, canceling all ConnectJobs and deleting |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 // Histograms for the pool | 867 // Histograms for the pool |
867 ClientSocketPoolHistograms* const histograms_; | 868 ClientSocketPoolHistograms* const histograms_; |
868 internal::ClientSocketPoolBaseHelper helper_; | 869 internal::ClientSocketPoolBaseHelper helper_; |
869 | 870 |
870 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); | 871 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); |
871 }; | 872 }; |
872 | 873 |
873 } // namespace net | 874 } // namespace net |
874 | 875 |
875 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 876 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
OLD | NEW |