Chromium Code Reviews| Index: net/websockets/websocket_throttle.h |
| diff --git a/net/websockets/websocket_throttle.h b/net/websockets/websocket_throttle.h |
| index aff73051f959f4352d04725ccdbd362efa7a2ef1..68a3d5ce0e826503cae665113094b06a9e668dde 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,18 +36,16 @@ 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 are now resume establishing a |
|
szym
2013/07/12 15:31:05
fix grammar, I think "are" => "can"
tyoshino (SeeGerritForStatus)
2013/07/17 06:58:26
Yes, thanks. Done.
|
| + // 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; |
|
yhirano
2013/07/16 02:08:56
Can we use std::map<IPEndPoint, ConnectingQueue> i
tyoshino (SeeGerritForStatus)
2013/07/17 06:58:26
Done.
|
| @@ -55,6 +54,13 @@ class NET_EXPORT_PRIVATE 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.5D |
|
szym
2013/07/12 15:31:05
5D?
:)
tyoshino (SeeGerritForStatus)
2013/07/17 06:58:26
oh!
|
| + void WakeupSocketIfNecessary( |
| + const std::set<WebSocketJob*>& wakeup_candidates); |
| + |
| // Key: string of host's address. Value: queue of sockets for the address. |
| ConnectingAddressMap addr_map_; |