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

Side by Side Diff: ipc/param_traits_macros.h

Issue 1655333002: Add message sizing to basic IPC traits and struct macros. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@with-pickles
Patch Set: include ArrayHeader in size (oops!) and ensure the buffer doesn't relocate Created 4 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 | « ipc/ipc_message_utils_unittest.cc ('k') | ipc/param_traits_size_macros.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_PARAM_TRAITS_MACROS_H_ 5 #ifndef IPC_PARAM_TRAITS_MACROS_H_
6 #define IPC_PARAM_TRAITS_MACROS_H_ 6 #define IPC_PARAM_TRAITS_MACROS_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 // Traits generation for structs. 10 // Traits generation for structs.
11 #define IPC_STRUCT_TRAITS_BEGIN(struct_name) \ 11 #define IPC_STRUCT_TRAITS_BEGIN(struct_name) \
12 namespace IPC { \ 12 namespace IPC { \
13 template <> \ 13 template <> \
14 struct IPC_MESSAGE_EXPORT ParamTraits<struct_name> { \ 14 struct IPC_MESSAGE_EXPORT ParamTraits<struct_name> { \
15 typedef struct_name param_type; \ 15 typedef struct_name param_type; \
16 static void GetSize(base::PickleSizer* sizer, \
17 const param_type& p); \
16 static void Write(base::Pickle* m, const param_type& p); \ 18 static void Write(base::Pickle* m, const param_type& p); \
17 static bool Read(const base::Pickle* m, \ 19 static bool Read(const base::Pickle* m, \
18 base::PickleIterator* iter, \ 20 base::PickleIterator* iter, \
19 param_type* p); \ 21 param_type* p); \
20 static void Log(const param_type& p, std::string* l); \ 22 static void Log(const param_type& p, std::string* l); \
21 }; \ 23 }; \
22 } 24 }
23 25
24 #define IPC_STRUCT_TRAITS_MEMBER(name) 26 #define IPC_STRUCT_TRAITS_MEMBER(name)
25 #define IPC_STRUCT_TRAITS_PARENT(type) 27 #define IPC_STRUCT_TRAITS_PARENT(type)
(...skipping 20 matching lines...) Expand all
46 IPC_ENUM_TRAITS_VALIDATE( \ 48 IPC_ENUM_TRAITS_VALIDATE( \
47 type, (static_cast<int>(value) >= static_cast<int>(minvalue) && \ 49 type, (static_cast<int>(value) >= static_cast<int>(minvalue) && \
48 static_cast<int>(value) <= static_cast<int>(maxvalue))) 50 static_cast<int>(value) <= static_cast<int>(maxvalue)))
49 51
50 // Traits generation for enums. This macro may be redefined later. 52 // Traits generation for enums. This macro may be redefined later.
51 #define IPC_ENUM_TRAITS_VALIDATE(enum_name, validation_expression) \ 53 #define IPC_ENUM_TRAITS_VALIDATE(enum_name, validation_expression) \
52 namespace IPC { \ 54 namespace IPC { \
53 template <> \ 55 template <> \
54 struct IPC_MESSAGE_EXPORT ParamTraits<enum_name> { \ 56 struct IPC_MESSAGE_EXPORT ParamTraits<enum_name> { \
55 typedef enum_name param_type; \ 57 typedef enum_name param_type; \
58 static void GetSize(base::PickleSizer* sizer, \
59 const param_type& p); \
56 static void Write(base::Pickle* m, const param_type& p); \ 60 static void Write(base::Pickle* m, const param_type& p); \
57 static bool Read(const base::Pickle* m, \ 61 static bool Read(const base::Pickle* m, \
58 base::PickleIterator* iter, \ 62 base::PickleIterator* iter, \
59 param_type* p); \ 63 param_type* p); \
60 static void Log(const param_type& p, std::string* l); \ 64 static void Log(const param_type& p, std::string* l); \
61 }; \ 65 }; \
62 } 66 }
63 67
64 #endif // IPC_PARAM_TRAITS_MACROS_H_ 68 #endif // IPC_PARAM_TRAITS_MACROS_H_
65 69
OLDNEW
« no previous file with comments | « ipc/ipc_message_utils_unittest.cc ('k') | ipc/param_traits_size_macros.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698