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

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

Issue 5634005: Add a new GetInstance() method for singleton classes under chrome/service and /net. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 10 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "base/singleton.h" 13 #include "base/singleton.h"
14 14
15 namespace net { 15 namespace net {
16 16
17 class SocketStream; 17 class SocketStream;
18 class WebSocketJob; 18 class WebSocketJob;
19 19
20 // SocketStreamThrottle for WebSocket protocol. 20 // SocketStreamThrottle for WebSocket protocol.
21 // Implements the client-side requirements in the spec. 21 // Implements the client-side requirements in the spec.
22 // http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol 22 // http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol
23 // 4.1 Handshake 23 // 4.1 Handshake
24 // 1. If the user agent already has a Web Socket connection to the 24 // 1. If the user agent already has a Web Socket connection to the
25 // remote host (IP address) identified by /host/, even if known by 25 // remote host (IP address) identified by /host/, even if known by
26 // another name, wait until that connection has been established or 26 // another name, wait until that connection has been established or
27 // for that connection to have failed. 27 // for that connection to have failed.
28 class WebSocketThrottle { 28 class WebSocketThrottle {
29 public: 29 public:
30 // Returns the singleton instance.
31 static WebSocketThrottle* GetInstance();
32
30 // Puts |job| in |queue_| and queues for the destination addresses 33 // Puts |job| in |queue_| and queues for the destination addresses
31 // of |job|. 34 // of |job|.
32 // If other job is using the same destination address, set |job| waiting. 35 // If other job is using the same destination address, set |job| waiting.
33 void PutInQueue(WebSocketJob* job); 36 void PutInQueue(WebSocketJob* job);
34 37
35 // Removes |job| from |queue_| and queues for the destination addresses 38 // Removes |job| from |queue_| and queues for the destination addresses
36 // of |job|. 39 // of |job|.
37 void RemoveFromQueue(WebSocketJob* job); 40 void RemoveFromQueue(WebSocketJob* job);
38 41
39 // Checks sockets waiting in |queue_| and check the socket is the front of 42 // Checks sockets waiting in |queue_| and check the socket is the front of
(...skipping 13 matching lines...) Expand all
53 // Key: string of host's address. Value: queue of sockets for the address. 56 // Key: string of host's address. Value: queue of sockets for the address.
54 ConnectingAddressMap addr_map_; 57 ConnectingAddressMap addr_map_;
55 58
56 // Queue of sockets for websockets in opening state. 59 // Queue of sockets for websockets in opening state.
57 ConnectingQueue queue_; 60 ConnectingQueue queue_;
58 }; 61 };
59 62
60 } // namespace net 63 } // namespace net
61 64
62 #endif // NET_WEBSOCKETS_WEBSOCKET_THROTTLE_H_ 65 #endif // NET_WEBSOCKETS_WEBSOCKET_THROTTLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698