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

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: android_dbg build 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
« no previous file with comments | « net/websockets/websocket_job_unittest.cc ('k') | net/websockets/websocket_throttle.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_;
« no previous file with comments | « net/websockets/websocket_job_unittest.cc ('k') | net/websockets/websocket_throttle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698