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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <deque> | 9 #include <deque> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/hash_tables.h" | 12 #include "base/hash_tables.h" |
13 #include "net/base/net_api.h" | 13 #include "net/base/net_export.h" |
14 | 14 |
15 template <typename T> struct DefaultSingletonTraits; | 15 template <typename T> struct DefaultSingletonTraits; |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 | 18 |
19 class SocketStream; | 19 class SocketStream; |
20 class WebSocketJob; | 20 class WebSocketJob; |
21 | 21 |
22 // SocketStreamThrottle for WebSocket protocol. | 22 // SocketStreamThrottle for WebSocket protocol. |
23 // Implements the client-side requirements in the spec. | 23 // Implements the client-side requirements in the spec. |
24 // http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol | 24 // http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol |
25 // 4.1 Handshake | 25 // 4.1 Handshake |
26 // 1. If the user agent already has a Web Socket connection to the | 26 // 1. If the user agent already has a Web Socket connection to the |
27 // remote host (IP address) identified by /host/, even if known by | 27 // remote host (IP address) identified by /host/, even if known by |
28 // another name, wait until that connection has been established or | 28 // another name, wait until that connection has been established or |
29 // for that connection to have failed. | 29 // for that connection to have failed. |
30 class NET_TEST WebSocketThrottle { | 30 class NET_EXPORT_PRIVATE WebSocketThrottle { |
31 public: | 31 public: |
32 // Returns the singleton instance. | 32 // Returns the singleton instance. |
33 static WebSocketThrottle* GetInstance(); | 33 static WebSocketThrottle* GetInstance(); |
34 | 34 |
35 // Puts |job| in |queue_| and queues for the destination addresses | 35 // Puts |job| in |queue_| and queues for the destination addresses |
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 |
(...skipping 17 matching lines...) Expand all Loading... |
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 | 64 |
65 } // namespace net | 65 } // namespace net |
66 | 66 |
67 #endif // NET_WEBSOCKETS_WEBSOCKET_THROTTLE_H_ | 67 #endif // NET_WEBSOCKETS_WEBSOCKET_THROTTLE_H_ |
OLD | NEW |