| 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 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 CallbackResultPair(const CompletionCallback& callback_in, int result_in); | 436 CallbackResultPair(const CompletionCallback& callback_in, int result_in); |
| 437 ~CallbackResultPair(); | 437 ~CallbackResultPair(); |
| 438 | 438 |
| 439 CompletionCallback callback; | 439 CompletionCallback callback; |
| 440 int result; | 440 int result; |
| 441 }; | 441 }; |
| 442 | 442 |
| 443 typedef std::map<const ClientSocketHandle*, CallbackResultPair> | 443 typedef std::map<const ClientSocketHandle*, CallbackResultPair> |
| 444 PendingCallbackMap; | 444 PendingCallbackMap; |
| 445 | 445 |
| 446 // Inserts the request into the queue based on order they will receive |
| 447 // sockets. Sockets which ignore the socket pool limits are first. Then |
| 448 // requests are sorted by priority, with higher priorities closer to the |
| 449 // front. Older requests are prioritized over requests of equal priority. |
| 446 static void InsertRequestIntoQueue(const Request* r, | 450 static void InsertRequestIntoQueue(const Request* r, |
| 447 RequestQueue* pending_requests); | 451 RequestQueue* pending_requests); |
| 448 static const Request* RemoveRequestFromQueue(const RequestQueue::iterator& it, | 452 static const Request* RemoveRequestFromQueue(const RequestQueue::iterator& it, |
| 449 Group* group); | 453 Group* group); |
| 450 | 454 |
| 451 Group* GetOrCreateGroup(const std::string& group_name); | 455 Group* GetOrCreateGroup(const std::string& group_name); |
| 452 void RemoveGroup(const std::string& group_name); | 456 void RemoveGroup(const std::string& group_name); |
| 453 void RemoveGroup(GroupMap::iterator it); | 457 void RemoveGroup(GroupMap::iterator it); |
| 454 | 458 |
| 455 // Called when the number of idle sockets changes. | 459 // Called when the number of idle sockets changes. |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 // Histograms for the pool | 804 // Histograms for the pool |
| 801 ClientSocketPoolHistograms* const histograms_; | 805 ClientSocketPoolHistograms* const histograms_; |
| 802 internal::ClientSocketPoolBaseHelper helper_; | 806 internal::ClientSocketPoolBaseHelper helper_; |
| 803 | 807 |
| 804 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); | 808 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); |
| 805 }; | 809 }; |
| 806 | 810 |
| 807 } // namespace net | 811 } // namespace net |
| 808 | 812 |
| 809 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 813 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
| OLD | NEW |