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 #ifndef NET_SOCKET_CLIENT_SOCKET_POOL_H_ | 5 #ifndef NET_SOCKET_CLIENT_SOCKET_POOL_H_ |
6 #define NET_SOCKET_CLIENT_SOCKET_POOL_H_ | 6 #define NET_SOCKET_CLIENT_SOCKET_POOL_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 // | 99 // |
100 // Profiling information for the request is saved to |net_log| if non-NULL. | 100 // Profiling information for the request is saved to |net_log| if non-NULL. |
101 // | 101 // |
102 // If |respect_limits| is DISABLED, priority must be HIGHEST. | 102 // If |respect_limits| is DISABLED, priority must be HIGHEST. |
103 virtual int RequestSocket(const std::string& group_name, | 103 virtual int RequestSocket(const std::string& group_name, |
104 const void* params, | 104 const void* params, |
105 RequestPriority priority, | 105 RequestPriority priority, |
106 RespectLimits respect_limits, | 106 RespectLimits respect_limits, |
107 ClientSocketHandle* handle, | 107 ClientSocketHandle* handle, |
108 const CompletionCallback& callback, | 108 const CompletionCallback& callback, |
109 const BoundNetLog& net_log) = 0; | 109 const NetLogWithSource& net_log) = 0; |
110 | 110 |
111 // RequestSockets is used to request that |num_sockets| be connected in the | 111 // RequestSockets is used to request that |num_sockets| be connected in the |
112 // connection group for |group_name|. If the connection group already has | 112 // connection group for |group_name|. If the connection group already has |
113 // |num_sockets| idle sockets / active sockets / currently connecting sockets, | 113 // |num_sockets| idle sockets / active sockets / currently connecting sockets, |
114 // then this function doesn't do anything. Otherwise, it will start up as | 114 // then this function doesn't do anything. Otherwise, it will start up as |
115 // many connections as necessary to reach |num_sockets| total sockets for the | 115 // many connections as necessary to reach |num_sockets| total sockets for the |
116 // group. It uses |params| to control how to connect the sockets. The | 116 // group. It uses |params| to control how to connect the sockets. The |
117 // ClientSocketPool will assign a priority to the new connections, if any. | 117 // ClientSocketPool will assign a priority to the new connections, if any. |
118 // This priority will probably be lower than all others, since this method | 118 // This priority will probably be lower than all others, since this method |
119 // is intended to make sure ahead of time that |num_sockets| sockets are | 119 // is intended to make sure ahead of time that |num_sockets| sockets are |
120 // available to talk to a host. | 120 // available to talk to a host. |
121 virtual void RequestSockets(const std::string& group_name, | 121 virtual void RequestSockets(const std::string& group_name, |
122 const void* params, | 122 const void* params, |
123 int num_sockets, | 123 int num_sockets, |
124 const BoundNetLog& net_log) = 0; | 124 const NetLogWithSource& net_log) = 0; |
125 | 125 |
126 // Called to cancel a RequestSocket call that returned ERR_IO_PENDING. The | 126 // Called to cancel a RequestSocket call that returned ERR_IO_PENDING. The |
127 // same handle parameter must be passed to this method as was passed to the | 127 // same handle parameter must be passed to this method as was passed to the |
128 // RequestSocket call being cancelled. The associated CompletionCallback is | 128 // RequestSocket call being cancelled. The associated CompletionCallback is |
129 // not run. However, for performance, we will let one ConnectJob complete | 129 // not run. However, for performance, we will let one ConnectJob complete |
130 // and go idle. | 130 // and go idle. |
131 virtual void CancelRequest(const std::string& group_name, | 131 virtual void CancelRequest(const std::string& group_name, |
132 ClientSocketHandle* handle) = 0; | 132 ClientSocketHandle* handle) = 0; |
133 | 133 |
134 // Called to release a socket once the socket is no longer needed. If the | 134 // Called to release a socket once the socket is no longer needed. If the |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 private: | 190 private: |
191 DISALLOW_COPY_AND_ASSIGN(ClientSocketPool); | 191 DISALLOW_COPY_AND_ASSIGN(ClientSocketPool); |
192 }; | 192 }; |
193 | 193 |
194 template <typename PoolType> | 194 template <typename PoolType> |
195 void RequestSocketsForPool( | 195 void RequestSocketsForPool( |
196 PoolType* pool, | 196 PoolType* pool, |
197 const std::string& group_name, | 197 const std::string& group_name, |
198 const scoped_refptr<typename PoolType::SocketParams>& params, | 198 const scoped_refptr<typename PoolType::SocketParams>& params, |
199 int num_sockets, | 199 int num_sockets, |
200 const BoundNetLog& net_log) { | 200 const NetLogWithSource& net_log) { |
201 pool->RequestSockets(group_name, ¶ms, num_sockets, net_log); | 201 pool->RequestSockets(group_name, ¶ms, num_sockets, net_log); |
202 } | 202 } |
203 | 203 |
204 } // namespace net | 204 } // namespace net |
205 | 205 |
206 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_H_ | 206 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_H_ |
OLD | NEW |