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

Unified Diff: net/websockets/websocket_throttle.h

Issue 18932005: Reduce the complexity of WebSocketThrottle's wakeup code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment fix Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
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_;

Powered by Google App Engine
This is Rietveld 408576698