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

Side by Side Diff: ipc/ipc_message_utils.h

Issue 2686503004: Add IPC ParamTraits for c-style arrays (Closed)
Patch Set: nit Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « cc/ipc/cc_param_traits_macros.h ('k') | ppapi/proxy/ppapi_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 (const P& element : p) {
333 if (&element != &p[0])
334 l->append(" ");
335 LogParam(element, 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
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_
OLDNEW
« no previous file with comments | « cc/ipc/cc_param_traits_macros.h ('k') | ppapi/proxy/ppapi_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698