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

Unified Diff: net/socket/client_socket_pool_base.h

Issue 160499: Add timeouts for ConnectJobs. Limit ConnectJobs per group to number of Requests per group + 1. (Closed)
Patch Set: Revert the revert. Fix tests. Created 11 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 | « no previous file | net/socket/client_socket_pool_base.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/client_socket_pool_base.h
diff --git a/net/socket/client_socket_pool_base.h b/net/socket/client_socket_pool_base.h
index 21cd642a1fd2a8fc401ffe33a18164ec457a975b..51b2139ba6152b1d076793f311b0dc22000732aa 100644
--- a/net/socket/client_socket_pool_base.h
+++ b/net/socket/client_socket_pool_base.h
@@ -43,8 +43,10 @@ class ConnectJob {
DISALLOW_COPY_AND_ASSIGN(Delegate);
};
+ // A |timeout_duration| of 0 corresponds to no timeout.
ConnectJob(const std::string& group_name,
const ClientSocketHandle* key_handle,
+ base::TimeDelta timeout_duration,
Delegate* delegate);
virtual ~ConnectJob();
@@ -63,7 +65,7 @@ class ConnectJob {
// |delegate_| via OnConnectJobComplete. In both asynchronous and synchronous
// completion, ReleaseSocket() can be called to acquire the connected socket
// if it succeeded.
- virtual int Connect() = 0;
+ int Connect();
protected:
void set_load_state(LoadState load_state) { load_state_ = load_state; }
@@ -72,10 +74,18 @@ class ConnectJob {
Delegate* delegate() { return delegate_; }
private:
+ virtual int ConnectInternal() = 0;
+
+ // Alerts the delegate that the ConnectJob has timed out.
+ void OnTimeout();
+
const std::string group_name_;
// Temporarily needed until we switch to late binding.
const ClientSocketHandle* const key_handle_;
- Delegate* const delegate_;
+ const base::TimeDelta timeout_duration_;
+ // Timer to abort jobs that take too long.
+ base::OneShotTimer<ConnectJob> timer_;
+ Delegate* delegate_;
LoadState load_state_;
scoped_ptr<ClientSocket> socket_;
@@ -168,6 +178,9 @@ class ClientSocketPoolBase
// For testing.
bool may_have_stalled_group() const { return may_have_stalled_group_; }
+ int NumConnectJobsInGroup(const std::string& group_name) const {
+ return group_map_.find(group_name)->second.jobs.size();
+ }
private:
// Entry for a persistent socket which became idle at time |start_time|.
@@ -252,7 +265,7 @@ class ClientSocketPoolBase
// binding is enabled. |job| must be non-NULL when late binding is
// enabled. Also updates |group| if non-NULL.
void RemoveConnectJob(const ClientSocketHandle* handle,
- ConnectJob* job,
+ const ConnectJob* job,
Group* group);
// Same as OnAvailableSocketSlot except it looks up the Group first to see if
« no previous file with comments | « no previous file | net/socket/client_socket_pool_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698