| 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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 | 339 |
| 340 void EnableConnectBackupJobs(); | 340 void EnableConnectBackupJobs(); |
| 341 | 341 |
| 342 // ConnectJob::Delegate methods: | 342 // ConnectJob::Delegate methods: |
| 343 void OnConnectJobComplete(int result, ConnectJob* job) override; | 343 void OnConnectJobComplete(int result, ConnectJob* job) override; |
| 344 | 344 |
| 345 // NetworkChangeNotifier::IPAddressObserver methods: | 345 // NetworkChangeNotifier::IPAddressObserver methods: |
| 346 void OnIPAddressChanged() override; | 346 void OnIPAddressChanged() override; |
| 347 | 347 |
| 348 private: | 348 private: |
| 349 friend class base::RefCounted<ClientSocketPoolBaseHelper>; | |
| 350 | |
| 351 // Entry for a persistent socket which became idle at time |start_time|. | 349 // Entry for a persistent socket which became idle at time |start_time|. |
| 352 struct IdleSocket { | 350 struct IdleSocket { |
| 353 IdleSocket() : socket(NULL) {} | 351 IdleSocket() : socket(NULL) {} |
| 354 | 352 |
| 355 // An idle socket can't be used if it is disconnected or has been used | 353 // An idle socket can't be used if it is disconnected or has been used |
| 356 // before and has received data unexpectedly (hence no longer idle). The | 354 // before and has received data unexpectedly (hence no longer idle). The |
| 357 // unread data would be mistaken for the beginning of the next response if | 355 // unread data would be mistaken for the beginning of the next response if |
| 358 // we were to use the socket for a new request. | 356 // we were to use the socket for a new request. |
| 359 // | 357 // |
| 360 // Note that a socket that has never been used before (like a preconnected | 358 // Note that a socket that has never been used before (like a preconnected |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 }; | 872 }; |
| 875 | 873 |
| 876 internal::ClientSocketPoolBaseHelper helper_; | 874 internal::ClientSocketPoolBaseHelper helper_; |
| 877 | 875 |
| 878 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); | 876 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); |
| 879 }; | 877 }; |
| 880 | 878 |
| 881 } // namespace net | 879 } // namespace net |
| 882 | 880 |
| 883 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 881 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
| OLD | NEW |