| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // A ClientSocketPoolBase is used to restrict the number of sockets open at | 5 // A ClientSocketPoolBase is used to restrict the number of sockets open at |
| 6 // a time. It also maintains a list of idle persistent sockets for reuse. | 6 // a time. It also maintains a list of idle persistent sockets for reuse. |
| 7 // Subclasses of ClientSocketPool should compose ClientSocketPoolBase to handle | 7 // Subclasses of ClientSocketPool should compose ClientSocketPoolBase to handle |
| 8 // the core logic of (1) restricting the number of active (connected or | 8 // the core logic of (1) restricting the number of active (connected or |
| 9 // connecting) sockets per "group" (generally speaking, the hostname), (2) | 9 // connecting) sockets per "group" (generally speaking, the hostname), (2) |
| 10 // maintaining a per-group list of idle, persistent sockets for reuse, and (3) | 10 // maintaining a per-group list of idle, persistent sockets for reuse, and (3) |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 // See ClientSocketPool::CancelRequest for documentation on this function. | 236 // See ClientSocketPool::CancelRequest for documentation on this function. |
| 237 void CancelRequest(const std::string& group_name, | 237 void CancelRequest(const std::string& group_name, |
| 238 ClientSocketHandle* handle); | 238 ClientSocketHandle* handle); |
| 239 | 239 |
| 240 // See ClientSocketPool::ReleaseSocket for documentation on this function. | 240 // See ClientSocketPool::ReleaseSocket for documentation on this function. |
| 241 void ReleaseSocket(const std::string& group_name, | 241 void ReleaseSocket(const std::string& group_name, |
| 242 StreamSocket* socket, | 242 StreamSocket* socket, |
| 243 int id); | 243 int id); |
| 244 | 244 |
| 245 // See ClientSocketPool::Flush for documentation on this function. | 245 // See ClientSocketPool::Flush for documentation on this function. |
| 246 void Flush(); | 246 void Flush(int error); |
| 247 | 247 |
| 248 // See ClientSocketPool::IsStalled for documentation on this function. | 248 // See ClientSocketPool::IsStalled for documentation on this function. |
| 249 bool IsStalled() const; | 249 bool IsStalled() const; |
| 250 | 250 |
| 251 // See ClientSocketPool::CloseIdleSockets for documentation on this function. | 251 // See ClientSocketPool::CloseIdleSockets for documentation on this function. |
| 252 void CloseIdleSockets(); | 252 void CloseIdleSockets(); |
| 253 | 253 |
| 254 // See ClientSocketPool::IdleSocketCount() for documentation on this function. | 254 // See ClientSocketPool::IdleSocketCount() for documentation on this function. |
| 255 int idle_socket_count() const { | 255 int idle_socket_count() const { |
| 256 return idle_socket_count_; | 256 return idle_socket_count_; |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 Group* group, | 498 Group* group, |
| 499 const BoundNetLog& net_log); | 499 const BoundNetLog& net_log); |
| 500 | 500 |
| 501 // Adds |socket| to the list of idle sockets for |group|. | 501 // Adds |socket| to the list of idle sockets for |group|. |
| 502 void AddIdleSocket(StreamSocket* socket, Group* group); | 502 void AddIdleSocket(StreamSocket* socket, Group* group); |
| 503 | 503 |
| 504 // Iterates through |group_map_|, canceling all ConnectJobs and deleting | 504 // Iterates through |group_map_|, canceling all ConnectJobs and deleting |
| 505 // groups if they are no longer needed. | 505 // groups if they are no longer needed. |
| 506 void CancelAllConnectJobs(); | 506 void CancelAllConnectJobs(); |
| 507 | 507 |
| 508 // Iterates through |group_map_|, posting ERR_ABORTED callbacks for all | 508 // Iterates through |group_map_|, posting |error| callbacks for all |
| 509 // requests, and then deleting groups if they are no longer needed. | 509 // requests, and then deleting groups if they are no longer needed. |
| 510 void AbortAllRequests(); | 510 void AbortAllRequests(int error); |
| 511 | 511 |
| 512 // Returns true if we can't create any more sockets due to the total limit. | 512 // Returns true if we can't create any more sockets due to the total limit. |
| 513 bool ReachedMaxSocketsLimit() const; | 513 bool ReachedMaxSocketsLimit() const; |
| 514 | 514 |
| 515 // This is the internal implementation of RequestSocket(). It differs in that | 515 // This is the internal implementation of RequestSocket(). It differs in that |
| 516 // it does not handle logging into NetLog of the queueing status of | 516 // it does not handle logging into NetLog of the queueing status of |
| 517 // |request|. | 517 // |request|. |
| 518 int RequestSocketInternal(const std::string& group_name, | 518 int RequestSocketInternal(const std::string& group_name, |
| 519 const Request* request); | 519 const Request* request); |
| 520 | 520 |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 void CancelRequest(const std::string& group_name, | 701 void CancelRequest(const std::string& group_name, |
| 702 ClientSocketHandle* handle) { | 702 ClientSocketHandle* handle) { |
| 703 return helper_.CancelRequest(group_name, handle); | 703 return helper_.CancelRequest(group_name, handle); |
| 704 } | 704 } |
| 705 | 705 |
| 706 void ReleaseSocket(const std::string& group_name, StreamSocket* socket, | 706 void ReleaseSocket(const std::string& group_name, StreamSocket* socket, |
| 707 int id) { | 707 int id) { |
| 708 return helper_.ReleaseSocket(group_name, socket, id); | 708 return helper_.ReleaseSocket(group_name, socket, id); |
| 709 } | 709 } |
| 710 | 710 |
| 711 void Flush() { helper_.Flush(); } | 711 void Flush() { helper_.Flush(ERR_ABORTED); } |
| 712 | 712 |
| 713 bool IsStalled() const { return helper_.IsStalled(); } | 713 bool IsStalled() const { return helper_.IsStalled(); } |
| 714 | 714 |
| 715 void CloseIdleSockets() { return helper_.CloseIdleSockets(); } | 715 void CloseIdleSockets() { return helper_.CloseIdleSockets(); } |
| 716 | 716 |
| 717 int idle_socket_count() const { return helper_.idle_socket_count(); } | 717 int idle_socket_count() const { return helper_.idle_socket_count(); } |
| 718 | 718 |
| 719 int IdleSocketCountInGroup(const std::string& group_name) const { | 719 int IdleSocketCountInGroup(const std::string& group_name) const { |
| 720 return helper_.IdleSocketCountInGroup(group_name); | 720 return helper_.IdleSocketCountInGroup(group_name); |
| 721 } | 721 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 // Histograms for the pool | 805 // Histograms for the pool |
| 806 ClientSocketPoolHistograms* const histograms_; | 806 ClientSocketPoolHistograms* const histograms_; |
| 807 internal::ClientSocketPoolBaseHelper helper_; | 807 internal::ClientSocketPoolBaseHelper helper_; |
| 808 | 808 |
| 809 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); | 809 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); |
| 810 }; | 810 }; |
| 811 | 811 |
| 812 } // namespace net | 812 } // namespace net |
| 813 | 813 |
| 814 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 814 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
| OLD | NEW |