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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
300 struct IPC_EXPORT ParamTraits<double> { | 300 struct IPC_EXPORT ParamTraits<double> { |
301 typedef double param_type; | 301 typedef double param_type; |
302 static void GetSize(base::PickleSizer* sizer, const param_type& p); | 302 static void GetSize(base::PickleSizer* sizer, const param_type& p); |
303 static void Write(base::Pickle* m, const param_type& p); | 303 static void Write(base::Pickle* m, const param_type& p); |
304 static bool Read(const base::Pickle* m, | 304 static bool Read(const base::Pickle* m, |
305 base::PickleIterator* iter, | 305 base::PickleIterator* iter, |
306 param_type* r); | 306 param_type* r); |
307 static void Log(const param_type& p, std::string* l); | 307 static void Log(const param_type& p, std::string* l); |
308 }; | 308 }; |
309 | 309 |
310 template <class P, size_t Size> | |
311 struct ParamTraits<P[Size]> { | |
312 using param_type = P[Size]; | |
313 static void GetSize(base::PickleSizer* sizer, const param_type& p) { | |
314 for (const P& element : p) | |
315 GetParamSize(sizer, element); | |
316 } | |
317 static void Write(base::Pickle* m, const param_type& p) { | |
318 for (const P& element : p) | |
319 WriteParam(m, element); | |
320 } | |
321 static bool Read(const base::Pickle* m, | |
322 base::PickleIterator* iter, | |
323 param_type* r) { | |
324 for (P& element : *r) { | |
325 if (!ReadParam(m, iter, &element)) | |
326 return false; | |
327 } | |
328 return true; | |
329 } | |
330 static void Log(const param_type& p, std::string* l) { | |
331 l->append("["); | |
332 for (size_t i = 0; i < Size; ++i) { | |
ericrk
2017/02/09 22:02:08
Didn't move to range-based-for here, as it makes i
Tom Sepez
2017/02/09 22:39:07
This is fine, but for future reference, I believe
ericrk
2017/02/10 00:15:28
makes sense, done.
| |
333 if (i != 0) | |
334 l->append(" "); | |
335 LogParam((p[i]), l); | |
336 } | |
337 l->append("]"); | |
338 } | |
339 }; | |
340 | |
310 // STL ParamTraits ------------------------------------------------------------- | 341 // STL ParamTraits ------------------------------------------------------------- |
311 | 342 |
312 template <> | 343 template <> |
313 struct ParamTraits<std::string> { | 344 struct ParamTraits<std::string> { |
314 typedef std::string param_type; | 345 typedef std::string param_type; |
315 static void GetSize(base::PickleSizer* sizer, const param_type& p) { | 346 static void GetSize(base::PickleSizer* sizer, const param_type& p) { |
316 sizer->AddString(p); | 347 sizer->AddString(p); |
317 } | 348 } |
318 static void Write(base::Pickle* m, const param_type& p) { m->WriteString(p); } | 349 static void Write(base::Pickle* m, const param_type& p) { m->WriteString(p); } |
319 static bool Read(const base::Pickle* m, | 350 static bool Read(const base::Pickle* m, |
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1139 template <class ReplyParamType> | 1170 template <class ReplyParamType> |
1140 inline void LogReplyParamsToMessage(const ReplyParamType& reply_params, | 1171 inline void LogReplyParamsToMessage(const ReplyParamType& reply_params, |
1141 const Message* msg) {} | 1172 const Message* msg) {} |
1142 | 1173 |
1143 inline void ConnectMessageAndReply(const Message* msg, Message* reply) {} | 1174 inline void ConnectMessageAndReply(const Message* msg, Message* reply) {} |
1144 #endif | 1175 #endif |
1145 | 1176 |
1146 } // namespace IPC | 1177 } // namespace IPC |
1147 | 1178 |
1148 #endif // IPC_IPC_MESSAGE_UTILS_H_ | 1179 #endif // IPC_IPC_MESSAGE_UTILS_H_ |
OLD | NEW |