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 <map> |
10 #include <string> | 10 #include <string> |
(...skipping 25 matching lines...) Expand all Loading... |
36 // of |job|. | 36 // of |job|. |
37 // If other job is using the same destination address, set |job| waiting. | 37 // If other job is using the same destination address, set |job| waiting. |
38 void PutInQueue(WebSocketJob* job); | 38 void PutInQueue(WebSocketJob* job); |
39 | 39 |
40 // Removes |job| from |queue_| and queues for the destination addresses | 40 // Removes |job| from |queue_| and queues for the destination addresses |
41 // of |job|. | 41 // of |job|. |
42 void RemoveFromQueue(WebSocketJob* job); | 42 void RemoveFromQueue(WebSocketJob* job); |
43 | 43 |
44 // 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 |
45 // every queue for the destination addresses of |socket|. | 45 // every queue for the destination addresses of |socket|. |
46 // If so, the socket can resume estabilshing connection, so wake up | 46 // If so, the socket can resume establishing connection, so wake up |
47 // the socket. | 47 // the socket. |
48 void WakeupSocketIfNecessary(); | 48 void WakeupSocketIfNecessary(); |
49 | 49 |
50 private: | 50 private: |
51 typedef std::deque<WebSocketJob*> ConnectingQueue; | 51 typedef std::deque<WebSocketJob*> ConnectingQueue; |
52 typedef std::map<IPEndPoint, ConnectingQueue*> ConnectingAddressMap; | 52 typedef std::map<IPEndPoint, ConnectingQueue*> ConnectingAddressMap; |
53 | 53 |
54 WebSocketThrottle(); | 54 WebSocketThrottle(); |
55 ~WebSocketThrottle(); | 55 ~WebSocketThrottle(); |
56 friend struct DefaultSingletonTraits<WebSocketThrottle>; | 56 friend struct DefaultSingletonTraits<WebSocketThrottle>; |
57 | 57 |
58 // 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. |
59 ConnectingAddressMap addr_map_; | 59 ConnectingAddressMap addr_map_; |
60 | 60 |
61 // Queue of sockets for websockets in opening state. | 61 // Queue of sockets for websockets in opening state. |
62 ConnectingQueue queue_; | 62 ConnectingQueue queue_; |
63 | 63 |
64 DISALLOW_COPY_AND_ASSIGN(WebSocketThrottle); | 64 DISALLOW_COPY_AND_ASSIGN(WebSocketThrottle); |
65 }; | 65 }; |
66 | 66 |
67 } // namespace net | 67 } // namespace net |
68 | 68 |
69 #endif // NET_WEBSOCKETS_WEBSOCKET_THROTTLE_H_ | 69 #endif // NET_WEBSOCKETS_WEBSOCKET_THROTTLE_H_ |
OLD | NEW |