Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(723)

Unified Diff: net/socket/client_socket_pool.h

Issue 1604042: Improve error messages for bad SocketParams. (Closed)
Patch Set: Address davidben's comments and add to gyp file. Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/template_util.h ('k') | net/socket/client_socket_pool_base_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/client_socket_pool.h
diff --git a/net/socket/client_socket_pool.h b/net/socket/client_socket_pool.h
index e631980d70c70dbdb5914efe1d7b4da5f881b669..c5f6f166100ba9d357acbed03f714481c4ad72de 100644
--- a/net/socket/client_socket_pool.h
+++ b/net/socket/client_socket_pool.h
@@ -9,7 +9,9 @@
#include <map>
#include <string>
+#include "base/basictypes.h"
#include "base/ref_counted.h"
+#include "base/template_util.h"
#include "net/base/completion_callback.h"
#include "net/base/host_resolver.h"
#include "net/base/load_states.h"
@@ -119,16 +121,25 @@ class ClientSocketPool : public base::RefCounted<ClientSocketPool> {
// will provide a definition of CheckIsValidSocketParamsForPool for the
// ClientSocketPool subtype and SocketParams pair. Trying to use a SocketParams
// type that has not been registered with the corresponding ClientSocketPool
-// subtype will result in a link time error stating that
-// CheckIsValidSocketParamsForPool with those template parameters is undefined.
+// subtype will result in a compile-time error.
template <typename PoolType, typename SocketParams>
-void CheckIsValidSocketParamsForPool();
+struct SocketParamTraits : public base::false_type {
+};
+
+template <typename PoolType, typename SocketParams>
+void CheckIsValidSocketParamsForPool() {
+ COMPILE_ASSERT(!base::is_pointer<SocketParams>::value,
+ socket_params_cannot_be_pointer);
+ COMPILE_ASSERT((SocketParamTraits<PoolType, SocketParams>::value),
+ invalid_socket_params_for_pool);
+}
// Provides an empty definition for CheckIsValidSocketParamsForPool() which
// should be optimized out by the compiler.
-#define REGISTER_SOCKET_PARAMS_FOR_POOL(pool_type, socket_params) \
-template<> \
-inline void CheckIsValidSocketParamsForPool<pool_type, socket_params>() {}
+#define REGISTER_SOCKET_PARAMS_FOR_POOL(pool_type, socket_params) \
+template<> \
+struct SocketParamTraits<pool_type, socket_params> : public base::true_type { \
+}
} // namespace net
« no previous file with comments | « base/template_util.h ('k') | net/socket/client_socket_pool_base_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698