Chromium Code Reviews| 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 12 matching lines...) Expand all Loading... | |
| 23 #define NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 23 #define NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
| 24 | 24 |
| 25 #include <deque> | 25 #include <deque> |
| 26 #include <list> | 26 #include <list> |
| 27 #include <map> | 27 #include <map> |
| 28 #include <set> | 28 #include <set> |
| 29 #include <string> | 29 #include <string> |
| 30 #include <vector> | 30 #include <vector> |
| 31 | 31 |
| 32 #include "base/basictypes.h" | 32 #include "base/basictypes.h" |
| 33 #include "base/compiler_specific.h" | |
|
wtc
2013/03/26 19:29:16
Just curious: do you need to add this header, or i
mmenke
2013/03/26 19:36:26
I noticed it was missing, and added it. It really
| |
| 33 #include "base/memory/ref_counted.h" | 34 #include "base/memory/ref_counted.h" |
| 34 #include "base/memory/scoped_ptr.h" | 35 #include "base/memory/scoped_ptr.h" |
| 35 #include "base/memory/weak_ptr.h" | 36 #include "base/memory/weak_ptr.h" |
| 36 #include "base/time.h" | 37 #include "base/time.h" |
| 37 #include "base/timer.h" | 38 #include "base/timer.h" |
| 38 #include "net/base/address_list.h" | 39 #include "net/base/address_list.h" |
| 39 #include "net/base/completion_callback.h" | 40 #include "net/base/completion_callback.h" |
| 40 #include "net/base/load_states.h" | 41 #include "net/base/load_states.h" |
| 41 #include "net/base/load_timing_info.h" | 42 #include "net/base/load_timing_info.h" |
| 42 #include "net/base/net_errors.h" | 43 #include "net/base/net_errors.h" |
| 43 #include "net/base/net_export.h" | 44 #include "net/base/net_export.h" |
| 44 #include "net/base/net_log.h" | 45 #include "net/base/net_log.h" |
| 45 #include "net/base/network_change_notifier.h" | 46 #include "net/base/network_change_notifier.h" |
| 46 #include "net/base/request_priority.h" | 47 #include "net/base/request_priority.h" |
| 47 #include "net/socket/client_socket_pool.h" | 48 #include "net/socket/client_socket_pool.h" |
| 48 #include "net/socket/stream_socket.h" | 49 #include "net/socket/stream_socket.h" |
| 49 | 50 |
| 50 namespace net { | 51 namespace net { |
| 51 | 52 |
| 52 class ClientSocketHandle; | 53 class ClientSocketHandle; |
| 53 | 54 |
| 54 // Returns the client socket reuse policy. | |
| 55 NET_EXPORT_PRIVATE int GetSocketReusePolicy(); | |
| 56 | |
| 57 // Sets the client socket reuse policy. | |
| 58 // NOTE: 'policy' should be a valid ClientSocketReusePolicy enum value. | |
| 59 NET_EXPORT void SetSocketReusePolicy(int policy); | |
| 60 | |
| 61 // ConnectJob provides an abstract interface for "connecting" a socket. | 55 // ConnectJob provides an abstract interface for "connecting" a socket. |
| 62 // The connection may involve host resolution, tcp connection, ssl connection, | 56 // The connection may involve host resolution, tcp connection, ssl connection, |
| 63 // etc. | 57 // etc. |
| 64 class NET_EXPORT_PRIVATE ConnectJob { | 58 class NET_EXPORT_PRIVATE ConnectJob { |
| 65 public: | 59 public: |
| 66 class NET_EXPORT_PRIVATE Delegate { | 60 class NET_EXPORT_PRIVATE Delegate { |
| 67 public: | 61 public: |
| 68 Delegate() {} | 62 Delegate() {} |
| 69 virtual ~Delegate() {} | 63 virtual ~Delegate() {} |
| 70 | 64 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 public NetworkChangeNotifier::IPAddressObserver { | 148 public NetworkChangeNotifier::IPAddressObserver { |
| 155 public: | 149 public: |
| 156 typedef uint32 Flags; | 150 typedef uint32 Flags; |
| 157 | 151 |
| 158 // Used to specify specific behavior for the ClientSocketPool. | 152 // Used to specify specific behavior for the ClientSocketPool. |
| 159 enum Flag { | 153 enum Flag { |
| 160 NORMAL = 0, // Normal behavior. | 154 NORMAL = 0, // Normal behavior. |
| 161 NO_IDLE_SOCKETS = 0x1, // Do not return an idle socket. Create a new one. | 155 NO_IDLE_SOCKETS = 0x1, // Do not return an idle socket. Create a new one. |
| 162 }; | 156 }; |
| 163 | 157 |
| 164 enum ClientSocketReusePolicy { | |
| 165 // Socket with largest amount of bytes transferred. | |
| 166 USE_WARMEST_SOCKET = 0, | |
| 167 | |
| 168 // Socket which scores highest on large bytes transferred and low idle time. | |
| 169 USE_WARM_SOCKET = 1, | |
| 170 | |
| 171 // Socket which was most recently used. | |
| 172 USE_LAST_ACCESSED_SOCKET = 2, | |
| 173 }; | |
| 174 | |
| 175 class NET_EXPORT_PRIVATE Request { | 158 class NET_EXPORT_PRIVATE Request { |
| 176 public: | 159 public: |
| 177 Request(ClientSocketHandle* handle, | 160 Request(ClientSocketHandle* handle, |
| 178 const CompletionCallback& callback, | 161 const CompletionCallback& callback, |
| 179 RequestPriority priority, | 162 RequestPriority priority, |
| 180 bool ignore_limits, | 163 bool ignore_limits, |
| 181 Flags flags, | 164 Flags flags, |
| 182 const BoundNetLog& net_log); | 165 const BoundNetLog& net_log); |
| 183 | 166 |
| 184 virtual ~Request(); | 167 virtual ~Request(); |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 814 // Histograms for the pool | 797 // Histograms for the pool |
| 815 ClientSocketPoolHistograms* const histograms_; | 798 ClientSocketPoolHistograms* const histograms_; |
| 816 internal::ClientSocketPoolBaseHelper helper_; | 799 internal::ClientSocketPoolBaseHelper helper_; |
| 817 | 800 |
| 818 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); | 801 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); |
| 819 }; | 802 }; |
| 820 | 803 |
| 821 } // namespace net | 804 } // namespace net |
| 822 | 805 |
| 823 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 806 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
| OLD | NEW |