| 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> |
| 11 | 11 |
| 12 #include "base/basictypes.h" |
| 12 #include "base/ref_counted.h" | 13 #include "base/ref_counted.h" |
| 14 #include "base/template_util.h" |
| 13 #include "net/base/completion_callback.h" | 15 #include "net/base/completion_callback.h" |
| 14 #include "net/base/host_resolver.h" | 16 #include "net/base/host_resolver.h" |
| 15 #include "net/base/load_states.h" | 17 #include "net/base/load_states.h" |
| 16 #include "net/base/request_priority.h" | 18 #include "net/base/request_priority.h" |
| 17 | 19 |
| 18 namespace net { | 20 namespace net { |
| 19 | 21 |
| 20 class ClientSocket; | 22 class ClientSocket; |
| 21 class ClientSocketHandle; | 23 class ClientSocketHandle; |
| 22 class ClientSocketPoolHistograms; | 24 class ClientSocketPoolHistograms; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 friend class base::RefCounted<ClientSocketPool>; | 114 friend class base::RefCounted<ClientSocketPool>; |
| 113 | 115 |
| 114 DISALLOW_COPY_AND_ASSIGN(ClientSocketPool); | 116 DISALLOW_COPY_AND_ASSIGN(ClientSocketPool); |
| 115 }; | 117 }; |
| 116 | 118 |
| 117 // Declaration, but no definition. ClientSocketPool subclasses should indicate | 119 // Declaration, but no definition. ClientSocketPool subclasses should indicate |
| 118 // valid SocketParams via the REGISTER_SOCKET_PARAMS_FOR_POOL macro below, which | 120 // valid SocketParams via the REGISTER_SOCKET_PARAMS_FOR_POOL macro below, which |
| 119 // will provide a definition of CheckIsValidSocketParamsForPool for the | 121 // will provide a definition of CheckIsValidSocketParamsForPool for the |
| 120 // ClientSocketPool subtype and SocketParams pair. Trying to use a SocketParams | 122 // ClientSocketPool subtype and SocketParams pair. Trying to use a SocketParams |
| 121 // type that has not been registered with the corresponding ClientSocketPool | 123 // type that has not been registered with the corresponding ClientSocketPool |
| 122 // subtype will result in a link time error stating that | 124 // subtype will result in a compile-time error. |
| 123 // CheckIsValidSocketParamsForPool with those template parameters is undefined. | |
| 124 template <typename PoolType, typename SocketParams> | 125 template <typename PoolType, typename SocketParams> |
| 125 void CheckIsValidSocketParamsForPool(); | 126 struct SocketParamTraits : public base::false_type { |
| 127 }; |
| 128 |
| 129 template <typename PoolType, typename SocketParams> |
| 130 void CheckIsValidSocketParamsForPool() { |
| 131 COMPILE_ASSERT(!base::is_pointer<SocketParams>::value, |
| 132 socket_params_cannot_be_pointer); |
| 133 COMPILE_ASSERT((SocketParamTraits<PoolType, SocketParams>::value), |
| 134 invalid_socket_params_for_pool); |
| 135 } |
| 126 | 136 |
| 127 // Provides an empty definition for CheckIsValidSocketParamsForPool() which | 137 // Provides an empty definition for CheckIsValidSocketParamsForPool() which |
| 128 // should be optimized out by the compiler. | 138 // should be optimized out by the compiler. |
| 129 #define REGISTER_SOCKET_PARAMS_FOR_POOL(pool_type, socket_params) \ | 139 #define REGISTER_SOCKET_PARAMS_FOR_POOL(pool_type, socket_params) \ |
| 130 template<> \ | 140 template<> \ |
| 131 inline void CheckIsValidSocketParamsForPool<pool_type, socket_params>() {} | 141 struct SocketParamTraits<pool_type, socket_params> : public base::true_type { \ |
| 142 } |
| 132 | 143 |
| 133 } // namespace net | 144 } // namespace net |
| 134 | 145 |
| 135 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_H_ | 146 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_H_ |
| OLD | NEW |