OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 static void LogBoundConnectJobToRequest( | 473 static void LogBoundConnectJobToRequest( |
474 const NetLog::Source& connect_job_source, const Request* request); | 474 const NetLog::Source& connect_job_source, const Request* request); |
475 | 475 |
476 // Closes one idle socket. Picks the first one encountered. | 476 // Closes one idle socket. Picks the first one encountered. |
477 // TODO(willchan): Consider a better algorithm for doing this. Perhaps we | 477 // TODO(willchan): Consider a better algorithm for doing this. Perhaps we |
478 // should keep an ordered list of idle sockets, and close them in order. | 478 // should keep an ordered list of idle sockets, and close them in order. |
479 // Requires maintaining more state. It's not clear if it's worth it since | 479 // Requires maintaining more state. It's not clear if it's worth it since |
480 // I'm not sure if we hit this situation often. | 480 // I'm not sure if we hit this situation often. |
481 void CloseOneIdleSocket(); | 481 void CloseOneIdleSocket(); |
482 | 482 |
| 483 // Same as CloseOneIdleSocket() except it won't close an idle socket in |
| 484 // |group|. If |group| is NULL, it is ignored. Returns true if it closed a |
| 485 // socket. |
| 486 bool CloseOneIdleSocketExceptInGroup(const Group* group); |
| 487 |
483 // Checks if there are stalled socket groups that should be notified | 488 // Checks if there are stalled socket groups that should be notified |
484 // for possible wakeup. | 489 // for possible wakeup. |
485 void CheckForStalledSocketGroups(); | 490 void CheckForStalledSocketGroups(); |
486 | 491 |
487 // Posts a task to call InvokeUserCallback() on the next iteration through the | 492 // Posts a task to call InvokeUserCallback() on the next iteration through the |
488 // current message loop. Inserts |callback| into |pending_callback_map_|, | 493 // current message loop. Inserts |callback| into |pending_callback_map_|, |
489 // keyed by |handle|. | 494 // keyed by |handle|. |
490 void InvokeUserCallbackLater( | 495 void InvokeUserCallbackLater( |
491 ClientSocketHandle* handle, CompletionCallback* callback, int rv); | 496 ClientSocketHandle* handle, CompletionCallback* callback, int rv); |
492 | 497 |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 // Histograms for the pool | 736 // Histograms for the pool |
732 ClientSocketPoolHistograms* const histograms_; | 737 ClientSocketPoolHistograms* const histograms_; |
733 internal::ClientSocketPoolBaseHelper helper_; | 738 internal::ClientSocketPoolBaseHelper helper_; |
734 | 739 |
735 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); | 740 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); |
736 }; | 741 }; |
737 | 742 |
738 } // namespace net | 743 } // namespace net |
739 | 744 |
740 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 745 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
OLD | NEW |