Index: net/socket/client_socket_pool_base.h |
=================================================================== |
--- net/socket/client_socket_pool_base.h (revision 218769) |
+++ net/socket/client_socket_pool_base.h (working copy) |
@@ -204,6 +204,7 @@ |
}; |
ClientSocketPoolBaseHelper( |
+ HigherLayeredPool* pool, |
int max_sockets, |
int max_sockets_per_group, |
base::TimeDelta unused_idle_socket_timeout, |
@@ -212,11 +213,18 @@ |
virtual ~ClientSocketPoolBaseHelper(); |
- // Adds/Removes layered pools. It is expected in the destructor that no |
- // layered pools remain. |
- void AddLayeredPool(LayeredPool* pool); |
- void RemoveLayeredPool(LayeredPool* pool); |
+ // Adds a lower layered pool to |this|, and adds |pool_| as a higher layered |
+ // pool on top of |lower_pool|. |
+ void AddLowerLayeredPool(LowerLayeredPool* lower_pool); |
+ // See LowerLayeredPool::IsStalled for documentation on this function. |
+ bool IsStalled() const; |
+ |
+ // See LowerLayeredPool for documentation on these functions. It is expected |
+ // in the destructor that no higher layer pools remain. |
+ void AddHigherLayeredPool(HigherLayeredPool* higher_pool); |
+ void RemoveHigherLayeredPool(HigherLayeredPool* higher_pool); |
+ |
// See ClientSocketPool::RequestSocket for documentation on this function. |
// ClientSocketPoolBaseHelper takes ownership of |request|, which must be |
// heap allocated. |
@@ -239,9 +247,6 @@ |
// See ClientSocketPool::FlushWithError for documentation on this function. |
void FlushWithError(int error); |
- // See ClientSocketPool::IsStalled for documentation on this function. |
- bool IsStalled() const; |
- |
// See ClientSocketPool::CloseIdleSockets for documentation on this function. |
void CloseIdleSockets(); |
@@ -298,8 +303,8 @@ |
// I'm not sure if we hit this situation often. |
bool CloseOneIdleSocket(); |
- // Checks layered pools to see if they can close an idle connection. |
- bool CloseOneIdleConnectionInLayeredPool(); |
+ // Checks higher layered pools to see if they can close an idle connection. |
+ bool CloseOneIdleConnectionInHigherLayeredPool(); |
// See ClientSocketPool::GetInfoAsValue for documentation on this function. |
base::DictionaryValue* GetInfoAsValue(const std::string& name, |
@@ -593,8 +598,19 @@ |
// to the pool, we can make sure that they are discarded rather than reused. |
int pool_generation_number_; |
- std::set<LayeredPool*> higher_layer_pools_; |
+ // Used to add |this| as a higher layer pool on top of lower layer pools. May |
+ // be NULL if no lower layer pools will be added. |
+ HigherLayeredPool* pool_; |
+ // Pools that create connections through |this|. |this| will try to close |
+ // their idle sockets when it stalls. Must be empty on destruction. |
+ std::set<HigherLayeredPool*> higher_pools_; |
+ |
+ // Pools that this goes through. Typically there's only one, but not always. |
+ // |this| will check if they're stalled when it has a new idle socket. |this| |
+ // will remove itself from all lower layered pools on destruction. |
+ std::set<LowerLayeredPool*> lower_pools_; |
+ |
base::WeakPtrFactory<ClientSocketPoolBaseHelper> weak_factory_; |
DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBaseHelper); |
@@ -647,6 +663,7 @@ |
// |used_idle_socket_timeout| specifies how long to leave a previously used |
// idle socket open before closing it. |
ClientSocketPoolBase( |
+ HigherLayeredPool* self, |
int max_sockets, |
int max_sockets_per_group, |
ClientSocketPoolHistograms* histograms, |
@@ -654,21 +671,25 @@ |
base::TimeDelta used_idle_socket_timeout, |
ConnectJobFactory* connect_job_factory) |
: histograms_(histograms), |
- helper_(max_sockets, max_sockets_per_group, |
+ helper_(self, max_sockets, max_sockets_per_group, |
unused_idle_socket_timeout, used_idle_socket_timeout, |
new ConnectJobFactoryAdaptor(connect_job_factory)) {} |
virtual ~ClientSocketPoolBase() {} |
// These member functions simply forward to ClientSocketPoolBaseHelper. |
- void AddLayeredPool(LayeredPool* pool) { |
- helper_.AddLayeredPool(pool); |
+ void AddLowerLayeredPool(LowerLayeredPool* lower_pool) { |
+ helper_.AddLowerLayeredPool(lower_pool); |
} |
- void RemoveLayeredPool(LayeredPool* pool) { |
- helper_.RemoveLayeredPool(pool); |
+ void AddHigherLayeredPool(HigherLayeredPool* higher_pool) { |
+ helper_.AddHigherLayeredPool(higher_pool); |
} |
+ void RemoveHigherLayeredPool(HigherLayeredPool* higher_pool) { |
+ helper_.RemoveHigherLayeredPool(higher_pool); |
+ } |
+ |
// RequestSocket bundles up the parameters into a Request and then forwards to |
// ClientSocketPoolBaseHelper::RequestSocket(). |
int RequestSocket(const std::string& group_name, |
@@ -771,8 +792,8 @@ |
bool CloseOneIdleSocket() { return helper_.CloseOneIdleSocket(); } |
- bool CloseOneIdleConnectionInLayeredPool() { |
- return helper_.CloseOneIdleConnectionInLayeredPool(); |
+ bool CloseOneIdleConnectionInHigherLayeredPool() { |
+ return helper_.CloseOneIdleConnectionInHigherLayeredPool(); |
} |
private: |