OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_WEBSOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ | 5 #ifndef NET_SOCKET_WEBSOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ |
6 #define NET_SOCKET_WEBSOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ | 6 #define NET_SOCKET_WEBSOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <memory> | 10 #include <memory> |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 const CompletionCallback& callback, | 202 const CompletionCallback& callback, |
203 const BoundNetLog& net_log); | 203 const BoundNetLog& net_log); |
204 StalledRequest(const StalledRequest& other); | 204 StalledRequest(const StalledRequest& other); |
205 ~StalledRequest(); | 205 ~StalledRequest(); |
206 const scoped_refptr<TransportSocketParams> params; | 206 const scoped_refptr<TransportSocketParams> params; |
207 const RequestPriority priority; | 207 const RequestPriority priority; |
208 ClientSocketHandle* const handle; | 208 ClientSocketHandle* const handle; |
209 const CompletionCallback callback; | 209 const CompletionCallback callback; |
210 const BoundNetLog net_log; | 210 const BoundNetLog net_log; |
211 }; | 211 }; |
| 212 |
212 friend class ConnectJobDelegate; | 213 friend class ConnectJobDelegate; |
| 214 |
213 typedef std::map<const ClientSocketHandle*, WebSocketTransportConnectJob*> | 215 typedef std::map<const ClientSocketHandle*, WebSocketTransportConnectJob*> |
214 PendingConnectsMap; | 216 PendingConnectsMap; |
215 // This is a list so that we can remove requests from the middle, and also | 217 // This is a list so that we can remove requests from the middle, and also |
216 // so that iterators are not invalidated unless the corresponding request is | 218 // so that iterators are not invalidated unless the corresponding request is |
217 // removed. | 219 // removed. |
218 typedef std::list<StalledRequest> StalledRequestQueue; | 220 typedef std::list<StalledRequest> StalledRequestQueue; |
219 typedef std::map<const ClientSocketHandle*, StalledRequestQueue::iterator> | 221 typedef std::map<const ClientSocketHandle*, StalledRequestQueue::iterator> |
220 StalledRequestMap; | 222 StalledRequestMap; |
221 | 223 |
| 224 // Tries to hand out the socket connected by |job|. |result| must be (async) |
| 225 // result of WebSocketTransportConnectJob::Connect(). Returns true iff it has |
| 226 // handed out a socket. |
| 227 bool TryHandOutSocket(int result, WebSocketTransportConnectJob* job); |
222 void OnConnectJobComplete(int result, WebSocketTransportConnectJob* job); | 228 void OnConnectJobComplete(int result, WebSocketTransportConnectJob* job); |
223 void InvokeUserCallbackLater(ClientSocketHandle* handle, | 229 void InvokeUserCallbackLater(ClientSocketHandle* handle, |
224 const CompletionCallback& callback, | 230 const CompletionCallback& callback, |
225 int rv); | 231 int rv); |
226 void InvokeUserCallback(ClientSocketHandle* handle, | 232 void InvokeUserCallback(ClientSocketHandle* handle, |
227 const CompletionCallback& callback, | 233 const CompletionCallback& callback, |
228 int rv); | 234 int rv); |
229 bool ReachedMaxSocketsLimit() const; | 235 bool ReachedMaxSocketsLimit() const; |
230 void HandOutSocket(std::unique_ptr<StreamSocket> socket, | 236 void HandOutSocket(std::unique_ptr<StreamSocket> socket, |
231 const LoadTimingInfo::ConnectTiming& connect_timing, | 237 const LoadTimingInfo::ConnectTiming& connect_timing, |
(...skipping 20 matching lines...) Expand all Loading... |
252 bool flushing_; | 258 bool flushing_; |
253 | 259 |
254 base::WeakPtrFactory<WebSocketTransportClientSocketPool> weak_factory_; | 260 base::WeakPtrFactory<WebSocketTransportClientSocketPool> weak_factory_; |
255 | 261 |
256 DISALLOW_COPY_AND_ASSIGN(WebSocketTransportClientSocketPool); | 262 DISALLOW_COPY_AND_ASSIGN(WebSocketTransportClientSocketPool); |
257 }; | 263 }; |
258 | 264 |
259 } // namespace net | 265 } // namespace net |
260 | 266 |
261 #endif // NET_SOCKET_WEBSOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ | 267 #endif // NET_SOCKET_WEBSOCKET_TRANSPORT_CLIENT_SOCKET_POOL_H_ |
OLD | NEW |