| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 5 #ifndef NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
| 6 #define NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 6 #define NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 | 189 |
| 190 typedef std::deque<Request> RequestQueue; | 190 typedef std::deque<Request> RequestQueue; |
| 191 typedef std::map<const ClientSocketHandle*, Request> RequestMap; | 191 typedef std::map<const ClientSocketHandle*, Request> RequestMap; |
| 192 | 192 |
| 193 // A Group is allocated per group_name when there are idle sockets or pending | 193 // A Group is allocated per group_name when there are idle sockets or pending |
| 194 // requests. Otherwise, the Group object is removed from the map. | 194 // requests. Otherwise, the Group object is removed from the map. |
| 195 struct Group { | 195 struct Group { |
| 196 Group() : active_socket_count(0) {} | 196 Group() : active_socket_count(0) {} |
| 197 | 197 |
| 198 bool IsEmpty() const { | 198 bool IsEmpty() const { |
| 199 return active_socket_count == 0 && idle_sockets.empty() && jobs.empty(); | 199 return active_socket_count == 0 && idle_sockets.empty() && jobs.empty() && |
| 200 pending_requests.empty() && connecting_requests.empty(); |
| 200 } | 201 } |
| 201 | 202 |
| 202 bool HasAvailableSocketSlot(int max_sockets_per_group) const { | 203 bool HasAvailableSocketSlot(int max_sockets_per_group) const { |
| 203 return active_socket_count + static_cast<int>(jobs.size()) < | 204 return active_socket_count + static_cast<int>(jobs.size()) < |
| 204 max_sockets_per_group; | 205 max_sockets_per_group; |
| 205 } | 206 } |
| 206 | 207 |
| 207 int TopPendingPriority() const { | 208 int TopPendingPriority() const { |
| 208 return pending_requests.front().priority; | 209 return pending_requests.front().priority; |
| 209 } | 210 } |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 | 327 |
| 327 // Controls whether or not we use late binding of sockets. | 328 // Controls whether or not we use late binding of sockets. |
| 328 static bool g_late_binding; | 329 static bool g_late_binding; |
| 329 | 330 |
| 330 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); | 331 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); |
| 331 }; | 332 }; |
| 332 | 333 |
| 333 } // namespace net | 334 } // namespace net |
| 334 | 335 |
| 335 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 336 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
| OLD | NEW |