summaryrefslogtreecommitdiffstats
path: root/net/base/client_socket_pool.h
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-25 20:42:55 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-25 20:42:55 +0000
commit725355a29e53a5bc0f37237b9be5023a35e0c09e (patch)
tree89338fa14de0636689c57716f8ffe1485540d3ea /net/base/client_socket_pool.h
parent78c3a37c716807e8f50444da64d6506632e13669 (diff)
downloadchromium_src-725355a29e53a5bc0f37237b9be5023a35e0c09e.zip
chromium_src-725355a29e53a5bc0f37237b9be5023a35e0c09e.tar.gz
chromium_src-725355a29e53a5bc0f37237b9be5023a35e0c09e.tar.bz2
Reverting 12479 which reverted 12470.
This change is the same as 12470, except with HttpRequestInfo::priority initialized in the initializer list, which should fix the purify errors. Review URL: http://codereview.chromium.org/53066 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12490 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/client_socket_pool.h')
-rw-r--r--net/base/client_socket_pool.h54
1 files changed, 32 insertions, 22 deletions
diff --git a/net/base/client_socket_pool.h b/net/base/client_socket_pool.h
index a313a80..dd08c24 100644
--- a/net/base/client_socket_pool.h
+++ b/net/base/client_socket_pool.h
@@ -35,7 +35,8 @@ class ClientSocketPool : public base::RefCounted<ClientSocketPool> {
// handle will be initialized without a socket such that the consumer needs
// to supply a socket, or 3) the handle will be added to a wait list until a
// socket is available to reuse or the opportunity to create a new socket
- // arises. The completion callback is notified in the 3rd case.
+ // arises. The completion callback is notified in the 3rd case. |priority|
+ // will determine the placement into the wait list.
//
// If this function returns OK, then |handle| is initialized upon return.
// The |handle|'s is_initialized method will return true in this case. If a
@@ -47,7 +48,9 @@ class ClientSocketPool : public base::RefCounted<ClientSocketPool> {
// If ERR_IO_PENDING is returned, then the completion callback will be called
// when |handle| has been initialized.
//
- int RequestSocket(ClientSocketHandle* handle, CompletionCallback* callback);
+ int RequestSocket(ClientSocketHandle* handle,
+ int priority,
+ CompletionCallback* callback);
// Called to cancel a RequestSocket call that returned ERR_IO_PENDING. The
// same handle parameter must be passed to this method as was passed to the
@@ -75,30 +78,12 @@ class ClientSocketPool : public base::RefCounted<ClientSocketPool> {
typedef scoped_ptr<ClientSocket> ClientSocketPtr;
- ~ClientSocketPool();
-
- // Closes all idle sockets if |force| is true. Else, only closes idle
- // sockets that timed out or can't be reused.
- void CleanupIdleSockets(bool force);
-
- // Called when the number of idle sockets changes.
- void IncrementIdleCount();
- void DecrementIdleCount();
-
- // Called via PostTask by ReleaseSocket.
- void DoReleaseSocket(const std::string& group_name, ClientSocketPtr* ptr);
-
- // Called when timer_ fires. This method scans the idle sockets removing
- // sockets that timed out or can't be reused.
- void OnCleanupTimerFired() {
- CleanupIdleSockets(false);
- }
-
// A Request is allocated per call to RequestSocket that results in
// ERR_IO_PENDING.
struct Request {
ClientSocketHandle* handle;
CompletionCallback* callback;
+ int priority;
};
// Entry for a persistent socket which became idle at time |start_time|.
@@ -116,16 +101,41 @@ class ClientSocketPool : public base::RefCounted<ClientSocketPool> {
bool ShouldCleanup(base::TimeTicks now) const;
};
+ typedef std::deque<Request> RequestQueue;
+
// A Group is allocated per group_name when there are idle sockets or pending
// requests. Otherwise, the Group object is removed from the map.
struct Group {
Group() : active_socket_count(0) {}
std::deque<IdleSocket> idle_sockets;
- std::deque<Request> pending_requests;
+ RequestQueue pending_requests;
int active_socket_count;
};
typedef std::map<std::string, Group> GroupMap;
+
+ ~ClientSocketPool();
+
+ static void InsertRequestIntoQueue(const Request& r,
+ RequestQueue* pending_requests);
+
+ // Closes all idle sockets if |force| is true. Else, only closes idle
+ // sockets that timed out or can't be reused.
+ void CleanupIdleSockets(bool force);
+
+ // Called when the number of idle sockets changes.
+ void IncrementIdleCount();
+ void DecrementIdleCount();
+
+ // Called via PostTask by ReleaseSocket.
+ void DoReleaseSocket(const std::string& group_name, ClientSocketPtr* ptr);
+
+ // Called when timer_ fires. This method scans the idle sockets removing
+ // sockets that timed out or can't be reused.
+ void OnCleanupTimerFired() {
+ CleanupIdleSockets(false);
+ }
+
GroupMap group_map_;
// Timer used to periodically prune idle sockets that timed out or can't be