| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_H_ | 5 #ifndef NET_SOCKET_CLIENT_SOCKET_POOL_H_ |
| 6 #define NET_SOCKET_CLIENT_SOCKET_POOL_H_ | 6 #define NET_SOCKET_CLIENT_SOCKET_POOL_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 // same handle parameter must be passed to this method as was passed to the | 60 // same handle parameter must be passed to this method as was passed to the |
| 61 // RequestSocket call being cancelled. The associated CompletionCallback is | 61 // RequestSocket call being cancelled. The associated CompletionCallback is |
| 62 // not run. However, for performance, we will let one ConnectJob complete | 62 // not run. However, for performance, we will let one ConnectJob complete |
| 63 // and go idle. | 63 // and go idle. |
| 64 virtual void CancelRequest(const std::string& group_name, | 64 virtual void CancelRequest(const std::string& group_name, |
| 65 const ClientSocketHandle* handle) = 0; | 65 const ClientSocketHandle* handle) = 0; |
| 66 | 66 |
| 67 // Called to release a socket once the socket is no longer needed. If the | 67 // Called to release a socket once the socket is no longer needed. If the |
| 68 // socket still has an established connection, then it will be added to the | 68 // socket still has an established connection, then it will be added to the |
| 69 // set of idle sockets to be used to satisfy future RequestSocket calls. | 69 // set of idle sockets to be used to satisfy future RequestSocket calls. |
| 70 // Otherwise, the ClientSocket is destroyed. | 70 // Otherwise, the ClientSocket is destroyed. |id| is used to differentiate |
| 71 // between updated versions of the same pool instance. The pool's id will |
| 72 // change when it flushes, so it can use this |id| to discard sockets with |
| 73 // mismatched ids. |
| 71 virtual void ReleaseSocket(const std::string& group_name, | 74 virtual void ReleaseSocket(const std::string& group_name, |
| 72 ClientSocket* socket) = 0; | 75 ClientSocket* socket, |
| 76 int id) = 0; |
| 77 |
| 78 // This flushes all state from the ClientSocketPool. This means that all |
| 79 // idle and connecting sockets are discarded. Active sockets being |
| 80 // held by ClientSocketPool clients will be discarded when released back to |
| 81 // the pool. |
| 82 virtual void Flush() = 0; |
| 73 | 83 |
| 74 // Called to close any idle connections held by the connection manager. | 84 // Called to close any idle connections held by the connection manager. |
| 75 virtual void CloseIdleSockets() = 0; | 85 virtual void CloseIdleSockets() = 0; |
| 76 | 86 |
| 77 // The total number of idle sockets in the pool. | 87 // The total number of idle sockets in the pool. |
| 78 virtual int IdleSocketCount() const = 0; | 88 virtual int IdleSocketCount() const = 0; |
| 79 | 89 |
| 80 // The total number of idle sockets in a connection group. | 90 // The total number of idle sockets in a connection group. |
| 81 virtual int IdleSocketCountInGroup(const std::string& group_name) const = 0; | 91 virtual int IdleSocketCountInGroup(const std::string& group_name) const = 0; |
| 82 | 92 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 126 |
| 117 // Provides an empty definition for CheckIsValidSocketParamsForPool() which | 127 // Provides an empty definition for CheckIsValidSocketParamsForPool() which |
| 118 // should be optimized out by the compiler. | 128 // should be optimized out by the compiler. |
| 119 #define REGISTER_SOCKET_PARAMS_FOR_POOL(pool_type, socket_params) \ | 129 #define REGISTER_SOCKET_PARAMS_FOR_POOL(pool_type, socket_params) \ |
| 120 template<> \ | 130 template<> \ |
| 121 inline void CheckIsValidSocketParamsForPool<pool_type, socket_params>() {} | 131 inline void CheckIsValidSocketParamsForPool<pool_type, socket_params>() {} |
| 122 | 132 |
| 123 } // namespace net | 133 } // namespace net |
| 124 | 134 |
| 125 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_H_ | 135 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_H_ |
| OLD | NEW |