| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_WEBSOCKETS_WEBSOCKET_THROTTLE_H_ | 5 #ifndef NET_WEBSOCKETS_WEBSOCKET_THROTTLE_H_ |
| 6 #define NET_WEBSOCKETS_WEBSOCKET_THROTTLE_H_ | 6 #define NET_WEBSOCKETS_WEBSOCKET_THROTTLE_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <map> |
| 9 #include <string> | 10 #include <string> |
| 10 | 11 |
| 11 #include "base/hash_tables.h" | 12 #include "net/base/ip_endpoint.h" |
| 12 #include "net/base/net_export.h" | 13 #include "net/base/net_export.h" |
| 13 | 14 |
| 14 template <typename T> struct DefaultSingletonTraits; | 15 template <typename T> struct DefaultSingletonTraits; |
| 15 | 16 |
| 16 namespace net { | 17 namespace net { |
| 17 | 18 |
| 18 class SocketStream; | 19 class SocketStream; |
| 19 class WebSocketJob; | 20 class WebSocketJob; |
| 20 | 21 |
| 21 // SocketStreamThrottle for WebSocket protocol. | 22 // SocketStreamThrottle for WebSocket protocol. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 41 void RemoveFromQueue(WebSocketJob* job); | 42 void RemoveFromQueue(WebSocketJob* job); |
| 42 | 43 |
| 43 // Checks sockets waiting in |queue_| and check the socket is the front of | 44 // Checks sockets waiting in |queue_| and check the socket is the front of |
| 44 // every queue for the destination addresses of |socket|. | 45 // every queue for the destination addresses of |socket|. |
| 45 // If so, the socket can resume estabilshing connection, so wake up | 46 // If so, the socket can resume estabilshing connection, so wake up |
| 46 // the socket. | 47 // the socket. |
| 47 void WakeupSocketIfNecessary(); | 48 void WakeupSocketIfNecessary(); |
| 48 | 49 |
| 49 private: | 50 private: |
| 50 typedef std::deque<WebSocketJob*> ConnectingQueue; | 51 typedef std::deque<WebSocketJob*> ConnectingQueue; |
| 51 typedef base::hash_map<std::string, ConnectingQueue*> ConnectingAddressMap; | 52 typedef std::map<IPEndPoint, ConnectingQueue*> ConnectingAddressMap; |
| 52 | 53 |
| 53 WebSocketThrottle(); | 54 WebSocketThrottle(); |
| 54 virtual ~WebSocketThrottle(); | 55 ~WebSocketThrottle(); |
| 55 friend struct DefaultSingletonTraits<WebSocketThrottle>; | 56 friend struct DefaultSingletonTraits<WebSocketThrottle>; |
| 56 | 57 |
| 57 // Key: string of host's address. Value: queue of sockets for the address. | 58 // Key: string of host's address. Value: queue of sockets for the address. |
| 58 ConnectingAddressMap addr_map_; | 59 ConnectingAddressMap addr_map_; |
| 59 | 60 |
| 60 // Queue of sockets for websockets in opening state. | 61 // Queue of sockets for websockets in opening state. |
| 61 ConnectingQueue queue_; | 62 ConnectingQueue queue_; |
| 63 |
| 64 DISALLOW_COPY_AND_ASSIGN(WebSocketThrottle); |
| 62 }; | 65 }; |
| 63 | 66 |
| 64 } // namespace net | 67 } // namespace net |
| 65 | 68 |
| 66 #endif // NET_WEBSOCKETS_WEBSOCKET_THROTTLE_H_ | 69 #endif // NET_WEBSOCKETS_WEBSOCKET_THROTTLE_H_ |
| OLD | NEW |