Chromium Code Reviews| 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 NET_API int GetSocketReusePolicy(); | |
|
willchan no longer on Chromium
2011/06/16 09:52:44
Is this called outside net/? If not, we don't need
Gagan
2011/06/16 11:49:29
Was getting used only in http_stream. Removed NET_
| |
| 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 | |
| 53 // ConnectJob provides an abstract interface for "connecting" a socket. | 60 // ConnectJob provides an abstract interface for "connecting" a socket. |
| 54 // The connection may involve host resolution, tcp connection, ssl connection, | 61 // The connection may involve host resolution, tcp connection, ssl connection, |
| 55 // etc. | 62 // etc. |
| 56 class NET_TEST ConnectJob { | 63 class NET_TEST ConnectJob { |
| 57 public: | 64 public: |
| 58 class NET_TEST Delegate { | 65 class NET_TEST Delegate { |
| 59 public: | 66 public: |
| 60 Delegate() {} | 67 Delegate() {} |
| 61 virtual ~Delegate() {} | 68 virtual ~Delegate() {} |
| 62 | 69 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 public NetworkChangeNotifier::IPAddressObserver { | 167 public NetworkChangeNotifier::IPAddressObserver { |
| 161 public: | 168 public: |
| 162 typedef uint32 Flags; | 169 typedef uint32 Flags; |
| 163 | 170 |
| 164 // Used to specify specific behavior for the ClientSocketPool. | 171 // Used to specify specific behavior for the ClientSocketPool. |
| 165 enum Flag { | 172 enum Flag { |
| 166 NORMAL = 0, // Normal behavior. | 173 NORMAL = 0, // Normal behavior. |
| 167 NO_IDLE_SOCKETS = 0x1, // Do not return an idle socket. Create a new one. | 174 NO_IDLE_SOCKETS = 0x1, // Do not return an idle socket. Create a new one. |
| 168 }; | 175 }; |
| 169 | 176 |
| 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 | |
| 170 class NET_TEST Request { | 188 class NET_TEST Request { |
| 171 public: | 189 public: |
| 172 Request(ClientSocketHandle* handle, | 190 Request(ClientSocketHandle* handle, |
| 173 CompletionCallback* callback, | 191 CompletionCallback* callback, |
| 174 RequestPriority priority, | 192 RequestPriority priority, |
| 175 bool ignore_limits, | 193 bool ignore_limits, |
| 176 Flags flags, | 194 Flags flags, |
| 177 const BoundNetLog& net_log); | 195 const BoundNetLog& net_log); |
| 178 | 196 |
| 179 virtual ~Request(); | 197 virtual ~Request(); |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 746 // Histograms for the pool | 764 // Histograms for the pool |
| 747 ClientSocketPoolHistograms* const histograms_; | 765 ClientSocketPoolHistograms* const histograms_; |
| 748 internal::ClientSocketPoolBaseHelper helper_; | 766 internal::ClientSocketPoolBaseHelper helper_; |
| 749 | 767 |
| 750 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); | 768 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); |
| 751 }; | 769 }; |
| 752 | 770 |
| 753 } // namespace net | 771 } // namespace net |
| 754 | 772 |
| 755 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 773 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
| OLD | NEW |