Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: net/websockets/websocket_throttle.h

Issue 12033072: Include destination port for websocket throttling. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // hash_map<> specifies custom hashing functions differently on Windows and
53 // elsewhere, so we use map<> for portability.
Takashi Toyoshima 2013/01/24 09:51:00 As far as I know, comments on something removed is
Adam Rice 2013/01/25 04:07:36 Yes. I removed the comment.
54 typedef std::map<IPEndPoint, ConnectingQueue*> ConnectingAddressMap;
52 55
53 WebSocketThrottle(); 56 WebSocketThrottle();
54 virtual ~WebSocketThrottle(); 57 ~WebSocketThrottle();
Takashi Toyoshima 2013/01/24 09:51:00 Right. Also this class missed DISALLOW_COPY_AND_AS
Adam Rice 2013/01/25 04:07:36 I didn't notice that! Fixed.
55 friend struct DefaultSingletonTraits<WebSocketThrottle>; 58 friend struct DefaultSingletonTraits<WebSocketThrottle>;
56 59
57 // Key: string of host's address. Value: queue of sockets for the address. 60 // Key: string of host's address. Value: queue of sockets for the address.
58 ConnectingAddressMap addr_map_; 61 ConnectingAddressMap addr_map_;
59 62
60 // Queue of sockets for websockets in opening state. 63 // Queue of sockets for websockets in opening state.
61 ConnectingQueue queue_; 64 ConnectingQueue queue_;
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698