Index: net/websockets/websocket_throttle.h |
diff --git a/net/websockets/websocket_throttle.h b/net/websockets/websocket_throttle.h |
index aff73051f959f4352d04725ccdbd362efa7a2ef1..0b7a39f3b6baf3b3bdbb594c84620b34963a7299 100644 |
--- a/net/websockets/websocket_throttle.h |
+++ b/net/websockets/websocket_throttle.h |
@@ -7,6 +7,7 @@ |
#include <deque> |
#include <map> |
+#include <set> |
#include <string> |
#include "net/base/ip_endpoint.h" |
@@ -35,26 +36,31 @@ class NET_EXPORT_PRIVATE WebSocketThrottle { |
// Puts |job| in |queue_| and queues for the destination addresses |
// of |job|. |
// If other job is using the same destination address, set |job| waiting. |
- void PutInQueue(WebSocketJob* job); |
+ // |
+ // Returns true if successful. If the number of pending jobs will exceed |
+ // the limit, does nothing and returns false. |
+ bool PutInQueue(WebSocketJob* job); |
// Removes |job| from |queue_| and queues for the destination addresses |
- // of |job|. |
+ // of |job|, and then wakes up jobs that can now resume establishing a |
+ // connection. |
void RemoveFromQueue(WebSocketJob* job); |
- // Checks sockets waiting in |queue_| and check the socket is the front of |
- // every queue for the destination addresses of |socket|. |
- // If so, the socket can resume establishing connection, so wake up |
- // the socket. |
- void WakeupSocketIfNecessary(); |
- |
private: |
typedef std::deque<WebSocketJob*> ConnectingQueue; |
- typedef std::map<IPEndPoint, ConnectingQueue*> ConnectingAddressMap; |
+ typedef std::map<IPEndPoint, ConnectingQueue> ConnectingAddressMap; |
WebSocketThrottle(); |
~WebSocketThrottle(); |
friend struct DefaultSingletonTraits<WebSocketThrottle>; |
+ // Examines if any of the given jobs can resume establishing a connection. If |
+ // for all per-address queues for each resolved addresses |
+ // (job->address_list()) of a job, the job is at the front of the queues, the |
+ // job can resume establishing a connection, so wakes up the job. |
+ void WakeupSocketIfNecessary( |
+ const std::set<WebSocketJob*>& wakeup_candidates); |
+ |
// Key: string of host's address. Value: queue of sockets for the address. |
ConnectingAddressMap addr_map_; |