OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 IPC_IPC_MESSAGE_UTILS_H_ | 5 #ifndef IPC_IPC_MESSAGE_UTILS_H_ |
6 #define IPC_IPC_MESSAGE_UTILS_H_ | 6 #define IPC_IPC_MESSAGE_UTILS_H_ |
7 | 7 |
8 #include <limits.h> | 8 #include <limits.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 #include <stdint.h> | 10 #include <stdint.h> |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 std::string params; | 69 std::string params; |
70 }; | 70 }; |
71 | 71 |
72 //----------------------------------------------------------------------------- | 72 //----------------------------------------------------------------------------- |
73 | 73 |
74 // A dummy struct to place first just to allow leading commas for all | 74 // A dummy struct to place first just to allow leading commas for all |
75 // members in the macro-generated constructor initializer lists. | 75 // members in the macro-generated constructor initializer lists. |
76 struct NoParams { | 76 struct NoParams { |
77 }; | 77 }; |
78 | 78 |
79 // Specializations are checked by 'IPC checker' part of find-bad-constructs | |
80 // Clang plugin (see WriteParam() below for the details). | |
81 template <typename... Ts> | |
82 struct CheckedTuple { | |
83 typedef std::tuple<Ts...> Tuple; | |
84 }; | |
85 | |
86 template <class P> | 79 template <class P> |
87 static inline void GetParamSize(base::PickleSizer* sizer, const P& p) { | 80 static inline void GetParamSize(base::PickleSizer* sizer, const P& p) { |
88 typedef typename SimilarTypeTraits<P>::Type Type; | 81 typedef typename SimilarTypeTraits<P>::Type Type; |
89 ParamTraits<Type>::GetSize(sizer, static_cast<const Type&>(p)); | 82 ParamTraits<Type>::GetSize(sizer, static_cast<const Type&>(p)); |
90 } | 83 } |
91 | 84 |
92 // This function is checked by 'IPC checker' part of find-bad-constructs | |
93 // Clang plugin to make it's not called on the following types: | |
94 // 1. long / unsigned long (but not typedefs to) | |
95 // 2. intmax_t, uintmax_t, intptr_t, uintptr_t, wint_t, | |
96 // size_t, rsize_t, ssize_t, ptrdiff_t, dev_t, off_t, clock_t, | |
97 // time_t, suseconds_t (including typedefs to) | |
98 // 3. Any template referencing types above (e.g. std::vector<size_t>) | |
99 template <class P> | 85 template <class P> |
100 static inline void WriteParam(base::Pickle* m, const P& p) { | 86 static inline void WriteParam(base::Pickle* m, const P& p) { |
101 typedef typename SimilarTypeTraits<P>::Type Type; | 87 typedef typename SimilarTypeTraits<P>::Type Type; |
102 ParamTraits<Type>::Write(m, static_cast<const Type& >(p)); | 88 ParamTraits<Type>::Write(m, static_cast<const Type& >(p)); |
103 } | 89 } |
104 | 90 |
105 template <class P> | 91 template <class P> |
106 static inline bool WARN_UNUSED_RESULT ReadParam(const base::Pickle* m, | 92 static inline bool WARN_UNUSED_RESULT ReadParam(const base::Pickle* m, |
107 base::PickleIterator* iter, | 93 base::PickleIterator* iter, |
108 P* p) { | 94 P* p) { |
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1098 template <class ReplyParamType> | 1084 template <class ReplyParamType> |
1099 inline void LogReplyParamsToMessage(const ReplyParamType& reply_params, | 1085 inline void LogReplyParamsToMessage(const ReplyParamType& reply_params, |
1100 const Message* msg) {} | 1086 const Message* msg) {} |
1101 | 1087 |
1102 inline void ConnectMessageAndReply(const Message* msg, Message* reply) {} | 1088 inline void ConnectMessageAndReply(const Message* msg, Message* reply) {} |
1103 #endif | 1089 #endif |
1104 | 1090 |
1105 } // namespace IPC | 1091 } // namespace IPC |
1106 | 1092 |
1107 #endif // IPC_IPC_MESSAGE_UTILS_H_ | 1093 #endif // IPC_IPC_MESSAGE_UTILS_H_ |
OLD | NEW |