OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 // Protobuf Messages over IPC | 5 // Protobuf Messages over IPC |
6 // | 6 // |
7 // Protobuf messages are registered with IPC_PROTOBUF_MESSAGE_TRAITS_BEGIN() and | 7 // Protobuf messages are registered with IPC_PROTOBUF_MESSAGE_TRAITS_BEGIN() and |
8 // friends in much the same way as other externally-defined structs (see | 8 // friends in much the same way as other externally-defined structs (see |
9 // ipc/ipc_message_macros.h). These macros also cause only registration of the | 9 // ipc/ipc_message_macros.h). These macros also cause only registration of the |
10 // protobuf message type IPC with message generation. Within matching calls to | 10 // protobuf message type IPC with message generation. Within matching calls to |
(...skipping 13 matching lines...) Expand all Loading... |
24 // validation expression should be the _IsValid() function provided by the | 24 // validation expression should be the _IsValid() function provided by the |
25 // generated protobuf code. For example: | 25 // generated protobuf code. For example: |
26 // | 26 // |
27 // IPC_ENUM_TRAITS_VALIDATE(MyEnumType, MyEnumType_IsValid(value)) | 27 // IPC_ENUM_TRAITS_VALIDATE(MyEnumType, MyEnumType_IsValid(value)) |
28 | 28 |
29 #ifndef CHROME_COMMON_SAFE_BROWSING_IPC_PROTOBUF_MESSAGE_MACROS_H_ | 29 #ifndef CHROME_COMMON_SAFE_BROWSING_IPC_PROTOBUF_MESSAGE_MACROS_H_ |
30 #define CHROME_COMMON_SAFE_BROWSING_IPC_PROTOBUF_MESSAGE_MACROS_H_ | 30 #define CHROME_COMMON_SAFE_BROWSING_IPC_PROTOBUF_MESSAGE_MACROS_H_ |
31 | 31 |
32 #include <string> | 32 #include <string> |
33 | 33 |
34 #define IPC_PROTOBUF_MESSAGE_TRAITS_BEGIN(message_name) \ | 34 #define IPC_PROTOBUF_MESSAGE_TRAITS_BEGIN(message_name) \ |
35 namespace IPC { \ | 35 namespace IPC { \ |
36 template <> \ | 36 template <> \ |
37 struct IPC_MESSAGE_EXPORT ParamTraits<message_name> { \ | 37 struct IPC_MESSAGE_EXPORT ParamTraits<message_name> { \ |
38 typedef message_name param_type; \ | 38 typedef message_name param_type; \ |
39 static void Write(Message* m, const param_type& p); \ | 39 static void Write(base::Pickle* m, const param_type& p); \ |
40 static bool Read(const Message* m, base::PickleIterator* iter, \ | 40 static bool Read(const base::Pickle* m, \ |
41 param_type* p); \ | 41 base::PickleIterator* iter, \ |
42 static void Log(const param_type& p, std::string* l); \ | 42 param_type* p); \ |
43 \ | 43 static void Log(const param_type& p, std::string* l); \ |
44 private: \ | 44 \ |
45 template <class P> \ | 45 private: \ |
46 static bool ReadParamF(const Message* m, \ | 46 template <class P> \ |
47 base::PickleIterator* iter, \ | 47 static bool ReadParamF(const base::Pickle* m, \ |
48 param_type* p, \ | 48 base::PickleIterator* iter, \ |
49 void (param_type::*setter_function)(P)); \ | 49 param_type* p, \ |
50 }; \ | 50 void (param_type::*setter_function)(P)); \ |
| 51 }; \ |
51 } // namespace IPC | 52 } // namespace IPC |
52 | 53 |
53 #define IPC_PROTOBUF_MESSAGE_TRAITS_OPTIONAL_FUNDAMENTAL_MEMBER(name) | 54 #define IPC_PROTOBUF_MESSAGE_TRAITS_OPTIONAL_FUNDAMENTAL_MEMBER(name) |
54 #define IPC_PROTOBUF_MESSAGE_TRAITS_OPTIONAL_COMPLEX_MEMBER(name) | 55 #define IPC_PROTOBUF_MESSAGE_TRAITS_OPTIONAL_COMPLEX_MEMBER(name) |
55 #define IPC_PROTOBUF_MESSAGE_TRAITS_REPEATED_COMPLEX_MEMBER(name) | 56 #define IPC_PROTOBUF_MESSAGE_TRAITS_REPEATED_COMPLEX_MEMBER(name) |
56 #define IPC_PROTOBUF_MESSAGE_TRAITS_END() | 57 #define IPC_PROTOBUF_MESSAGE_TRAITS_END() |
57 | 58 |
58 #endif // CHROME_COMMON_SAFE_BROWSING_IPC_PROTOBUF_MESSAGE_MACROS_H_ | 59 #endif // CHROME_COMMON_SAFE_BROWSING_IPC_PROTOBUF_MESSAGE_MACROS_H_ |
OLD | NEW |