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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "net/base/net_log.h" | 44 #include "net/base/net_log.h" |
45 #include "net/base/network_change_notifier.h" | 45 #include "net/base/network_change_notifier.h" |
46 #include "net/base/request_priority.h" | 46 #include "net/base/request_priority.h" |
47 #include "net/socket/client_socket_pool.h" | 47 #include "net/socket/client_socket_pool.h" |
48 #include "net/socket/stream_socket.h" | 48 #include "net/socket/stream_socket.h" |
49 | 49 |
50 namespace net { | 50 namespace net { |
51 | 51 |
52 class ClientSocketHandle; | 52 class ClientSocketHandle; |
53 | 53 |
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. | 54 // ConnectJob provides an abstract interface for "connecting" a socket. |
62 // The connection may involve host resolution, tcp connection, ssl connection, | 55 // The connection may involve host resolution, tcp connection, ssl connection, |
63 // etc. | 56 // etc. |
64 class NET_EXPORT_PRIVATE ConnectJob { | 57 class NET_EXPORT_PRIVATE ConnectJob { |
65 public: | 58 public: |
66 class NET_EXPORT_PRIVATE Delegate { | 59 class NET_EXPORT_PRIVATE Delegate { |
67 public: | 60 public: |
68 Delegate() {} | 61 Delegate() {} |
69 virtual ~Delegate() {} | 62 virtual ~Delegate() {} |
70 | 63 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 public NetworkChangeNotifier::IPAddressObserver { | 147 public NetworkChangeNotifier::IPAddressObserver { |
155 public: | 148 public: |
156 typedef uint32 Flags; | 149 typedef uint32 Flags; |
157 | 150 |
158 // Used to specify specific behavior for the ClientSocketPool. | 151 // Used to specify specific behavior for the ClientSocketPool. |
159 enum Flag { | 152 enum Flag { |
160 NORMAL = 0, // Normal behavior. | 153 NORMAL = 0, // Normal behavior. |
161 NO_IDLE_SOCKETS = 0x1, // Do not return an idle socket. Create a new one. | 154 NO_IDLE_SOCKETS = 0x1, // Do not return an idle socket. Create a new one. |
162 }; | 155 }; |
163 | 156 |
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 { | 157 class NET_EXPORT_PRIVATE Request { |
176 public: | 158 public: |
177 Request(ClientSocketHandle* handle, | 159 Request(ClientSocketHandle* handle, |
178 const CompletionCallback& callback, | 160 const CompletionCallback& callback, |
179 RequestPriority priority, | 161 RequestPriority priority, |
180 bool ignore_limits, | 162 bool ignore_limits, |
181 Flags flags, | 163 Flags flags, |
182 const BoundNetLog& net_log); | 164 const BoundNetLog& net_log); |
183 | 165 |
184 virtual ~Request(); | 166 virtual ~Request(); |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 // Histograms for the pool | 796 // Histograms for the pool |
815 ClientSocketPoolHistograms* const histograms_; | 797 ClientSocketPoolHistograms* const histograms_; |
816 internal::ClientSocketPoolBaseHelper helper_; | 798 internal::ClientSocketPoolBaseHelper helper_; |
817 | 799 |
818 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); | 800 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); |
819 }; | 801 }; |
820 | 802 |
821 } // namespace net | 803 } // namespace net |
822 | 804 |
823 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 805 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
OLD | NEW |