| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "net/base/net_log.h" | 43 #include "net/base/net_log.h" |
| 44 #include "net/base/network_change_notifier.h" | 44 #include "net/base/network_change_notifier.h" |
| 45 #include "net/base/request_priority.h" | 45 #include "net/base/request_priority.h" |
| 46 #include "net/socket/client_socket_pool.h" | 46 #include "net/socket/client_socket_pool.h" |
| 47 #include "net/socket/stream_socket.h" | 47 #include "net/socket/stream_socket.h" |
| 48 | 48 |
| 49 namespace net { | 49 namespace net { |
| 50 | 50 |
| 51 class ClientSocketHandle; | 51 class ClientSocketHandle; |
| 52 | 52 |
| 53 // Returns the client socket reuse policy. | |
| 54 int GetSocketReusePolicy(); | |
| 55 | |
| 56 // Sets the client socket reuse policy. | |
| 57 // NOTE: 'policy' should be a valid ClientSocketReusePolicy enum value. | |
| 58 NET_API void SetSocketReusePolicy(int policy); | |
| 59 | |
| 60 // ConnectJob provides an abstract interface for "connecting" a socket. | 53 // ConnectJob provides an abstract interface for "connecting" a socket. |
| 61 // The connection may involve host resolution, tcp connection, ssl connection, | 54 // The connection may involve host resolution, tcp connection, ssl connection, |
| 62 // etc. | 55 // etc. |
| 63 class NET_TEST ConnectJob { | 56 class NET_TEST ConnectJob { |
| 64 public: | 57 public: |
| 65 class NET_TEST Delegate { | 58 class NET_TEST Delegate { |
| 66 public: | 59 public: |
| 67 Delegate() {} | 60 Delegate() {} |
| 68 virtual ~Delegate() {} | 61 virtual ~Delegate() {} |
| 69 | 62 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 public NetworkChangeNotifier::IPAddressObserver { | 160 public NetworkChangeNotifier::IPAddressObserver { |
| 168 public: | 161 public: |
| 169 typedef uint32 Flags; | 162 typedef uint32 Flags; |
| 170 | 163 |
| 171 // Used to specify specific behavior for the ClientSocketPool. | 164 // Used to specify specific behavior for the ClientSocketPool. |
| 172 enum Flag { | 165 enum Flag { |
| 173 NORMAL = 0, // Normal behavior. | 166 NORMAL = 0, // Normal behavior. |
| 174 NO_IDLE_SOCKETS = 0x1, // Do not return an idle socket. Create a new one. | 167 NO_IDLE_SOCKETS = 0x1, // Do not return an idle socket. Create a new one. |
| 175 }; | 168 }; |
| 176 | 169 |
| 177 enum ClientSocketReusePolicy { | |
| 178 // Socket with largest amount of bytes transferred. | |
| 179 USE_WARMEST_SOCKET = 0, | |
| 180 | |
| 181 // Socket which scores highest on large bytes transferred and low idle time. | |
| 182 USE_WARM_SOCKET = 1, | |
| 183 | |
| 184 // Socket which was most recently used. | |
| 185 USE_LAST_ACCESSED_SOCKET = 2, | |
| 186 }; | |
| 187 | |
| 188 class NET_TEST Request { | 170 class NET_TEST Request { |
| 189 public: | 171 public: |
| 190 Request(ClientSocketHandle* handle, | 172 Request(ClientSocketHandle* handle, |
| 191 CompletionCallback* callback, | 173 CompletionCallback* callback, |
| 192 RequestPriority priority, | 174 RequestPriority priority, |
| 193 bool ignore_limits, | 175 bool ignore_limits, |
| 194 Flags flags, | 176 Flags flags, |
| 195 const BoundNetLog& net_log); | 177 const BoundNetLog& net_log); |
| 196 | 178 |
| 197 virtual ~Request(); | 179 virtual ~Request(); |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 // Histograms for the pool | 746 // Histograms for the pool |
| 765 ClientSocketPoolHistograms* const histograms_; | 747 ClientSocketPoolHistograms* const histograms_; |
| 766 internal::ClientSocketPoolBaseHelper helper_; | 748 internal::ClientSocketPoolBaseHelper helper_; |
| 767 | 749 |
| 768 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); | 750 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); |
| 769 }; | 751 }; |
| 770 | 752 |
| 771 } // namespace net | 753 } // namespace net |
| 772 | 754 |
| 773 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 755 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
| OLD | NEW |