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 // Sets the client socket reuse policy (using warmest socket vs. last accessed | |
54 // socket). | |
55 // NOTE: 'policy' should be a valid ClientSocketReusePolicy enum value. | |
56 double SetSocketReusePolicy(int policy); | |
willchan no longer on Chromium
2011/06/14 12:01:22
This looks really weird. What does the return valu
Gagan
2011/06/14 18:25:02
Done.
| |
57 | |
53 // ConnectJob provides an abstract interface for "connecting" a socket. | 58 // ConnectJob provides an abstract interface for "connecting" a socket. |
54 // The connection may involve host resolution, tcp connection, ssl connection, | 59 // The connection may involve host resolution, tcp connection, ssl connection, |
55 // etc. | 60 // etc. |
56 class NET_TEST ConnectJob { | 61 class NET_TEST ConnectJob { |
57 public: | 62 public: |
58 class NET_TEST Delegate { | 63 class NET_TEST Delegate { |
59 public: | 64 public: |
60 Delegate() {} | 65 Delegate() {} |
61 virtual ~Delegate() {} | 66 virtual ~Delegate() {} |
62 | 67 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
160 public NetworkChangeNotifier::IPAddressObserver { | 165 public NetworkChangeNotifier::IPAddressObserver { |
161 public: | 166 public: |
162 typedef uint32 Flags; | 167 typedef uint32 Flags; |
163 | 168 |
164 // Used to specify specific behavior for the ClientSocketPool. | 169 // Used to specify specific behavior for the ClientSocketPool. |
165 enum Flag { | 170 enum Flag { |
166 NORMAL = 0, // Normal behavior. | 171 NORMAL = 0, // Normal behavior. |
167 NO_IDLE_SOCKETS = 0x1, // Do not return an idle socket. Create a new one. | 172 NO_IDLE_SOCKETS = 0x1, // Do not return an idle socket. Create a new one. |
168 }; | 173 }; |
169 | 174 |
175 enum ClientSocketReusePolicy { | |
willchan no longer on Chromium
2011/06/14 12:01:22
It's not clear what the difference is between WARM
Gagan
2011/06/14 18:25:02
Done.
| |
176 USE_WARMEST_SOCKET = 0, | |
177 USE_WARM_SOCKET = 1, | |
178 USE_LAST_ACCESSED_SOCKET = 2, | |
179 }; | |
180 | |
170 class NET_TEST Request { | 181 class NET_TEST Request { |
171 public: | 182 public: |
172 Request(ClientSocketHandle* handle, | 183 Request(ClientSocketHandle* handle, |
173 CompletionCallback* callback, | 184 CompletionCallback* callback, |
174 RequestPriority priority, | 185 RequestPriority priority, |
175 bool ignore_limits, | 186 bool ignore_limits, |
176 Flags flags, | 187 Flags flags, |
177 const BoundNetLog& net_log); | 188 const BoundNetLog& net_log); |
178 | 189 |
179 virtual ~Request(); | 190 virtual ~Request(); |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
746 // Histograms for the pool | 757 // Histograms for the pool |
747 ClientSocketPoolHistograms* const histograms_; | 758 ClientSocketPoolHistograms* const histograms_; |
748 internal::ClientSocketPoolBaseHelper helper_; | 759 internal::ClientSocketPoolBaseHelper helper_; |
749 | 760 |
750 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); | 761 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); |
751 }; | 762 }; |
752 | 763 |
753 } // namespace net | 764 } // namespace net |
754 | 765 |
755 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 766 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
OLD | NEW |