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 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 const scoped_refptr<SocketParams>& params, | 734 const scoped_refptr<SocketParams>& params, |
735 RequestPriority priority, | 735 RequestPriority priority, |
736 ClientSocketHandle* handle, | 736 ClientSocketHandle* handle, |
737 const CompletionCallback& callback, | 737 const CompletionCallback& callback, |
738 const BoundNetLog& net_log) { | 738 const BoundNetLog& net_log) { |
739 scoped_ptr<const Request> request( | 739 scoped_ptr<const Request> request( |
740 new Request(handle, callback, priority, | 740 new Request(handle, callback, priority, |
741 internal::ClientSocketPoolBaseHelper::NORMAL, | 741 internal::ClientSocketPoolBaseHelper::NORMAL, |
742 params->ignore_limits(), | 742 params->ignore_limits(), |
743 params, net_log)); | 743 params, net_log)); |
744 return helper_.RequestSocket( | 744 return helper_.RequestSocket(group_name, request.Pass()); |
745 group_name, | |
746 request.template PassAs< | |
747 const internal::ClientSocketPoolBaseHelper::Request>()); | |
748 } | 745 } |
749 | 746 |
750 // RequestSockets bundles up the parameters into a Request and then forwards | 747 // RequestSockets bundles up the parameters into a Request and then forwards |
751 // to ClientSocketPoolBaseHelper::RequestSockets(). Note that it assigns the | 748 // to ClientSocketPoolBaseHelper::RequestSockets(). Note that it assigns the |
752 // priority to DEFAULT_PRIORITY and specifies the NO_IDLE_SOCKETS flag. | 749 // priority to DEFAULT_PRIORITY and specifies the NO_IDLE_SOCKETS flag. |
753 void RequestSockets(const std::string& group_name, | 750 void RequestSockets(const std::string& group_name, |
754 const scoped_refptr<SocketParams>& params, | 751 const scoped_refptr<SocketParams>& params, |
755 int num_sockets, | 752 int num_sockets, |
756 const BoundNetLog& net_log) { | 753 const BoundNetLog& net_log) { |
757 const Request request(NULL /* no handle */, | 754 const Request request(NULL /* no handle */, |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 // Histograms for the pool | 869 // Histograms for the pool |
873 ClientSocketPoolHistograms* const histograms_; | 870 ClientSocketPoolHistograms* const histograms_; |
874 internal::ClientSocketPoolBaseHelper helper_; | 871 internal::ClientSocketPoolBaseHelper helper_; |
875 | 872 |
876 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); | 873 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); |
877 }; | 874 }; |
878 | 875 |
879 } // namespace net | 876 } // namespace net |
880 | 877 |
881 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 878 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
OLD | NEW |