Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / common / safe_browsing / protobuf_message_read_macros.h
blobaba946fb99b48c11281cedb7417551bb4877d598
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
3 // found in the LICENSE file.
5 #ifndef CHROME_COMMON_SAFE_BROWSING_PROTOBUF_MESSAGE_READ_MACROS_H_
6 #define CHROME_COMMON_SAFE_BROWSING_PROTOBUF_MESSAGE_READ_MACROS_H_
8 // Null out all the macros that need nulling.
9 #include "chrome/common/safe_browsing/ipc_protobuf_message_null_macros.h"
11 // Set up so next include will generate read methods.
12 #undef IPC_PROTOBUF_MESSAGE_TRAITS_BEGIN
13 #undef IPC_PROTOBUF_MESSAGE_TRAITS_OPTIONAL_FUNDAMENTAL_MEMBER
14 #undef IPC_PROTOBUF_MESSAGE_TRAITS_OPTIONAL_COMPLEX_MEMBER
15 #undef IPC_PROTOBUF_MESSAGE_TRAITS_REPEATED_COMPLEX_MEMBER
16 #undef IPC_PROTOBUF_MESSAGE_TRAITS_END
18 #define IPC_PROTOBUF_MESSAGE_TRAITS_BEGIN(message_name) \
19 template <class P> \
20 bool ParamTraits<message_name>::ReadParamF( \
21 const Message* m, base::PickleIterator* iter, param_type* p, \
22 void (param_type::*setter_function)(P)) { \
23 P value; \
24 if (!ReadParam(m, iter, &value)) \
25 return false; \
26 (p->*setter_function)(value); \
27 return true; \
28 } \
29 bool ParamTraits<message_name>::Read(const Message* m, \
30 base::PickleIterator* iter, \
31 param_type* p) {
33 #define IPC_PROTOBUF_MESSAGE_TRAITS_OPTIONAL_FUNDAMENTAL_MEMBER(name) \
34 { \
35 bool is_present; \
36 if (!iter->ReadBool(&is_present)) \
37 return false; \
38 if (!is_present) \
39 p->clear_##name(); \
40 else if (!ReadParamF(m, iter, p, &param_type::set_##name)) \
41 return false; \
44 #define IPC_PROTOBUF_MESSAGE_TRAITS_OPTIONAL_COMPLEX_MEMBER(name) \
45 { \
46 bool is_present; \
47 if (!iter->ReadBool(&is_present)) \
48 return false; \
49 if (!is_present) \
50 p->clear_##name(); \
51 else if (!ReadParam(m, iter, p->mutable_##name())) \
52 return false; \
55 #define IPC_PROTOBUF_MESSAGE_TRAITS_REPEATED_COMPLEX_MEMBER(name) \
56 if (!ReadParam(m, iter, p->mutable_##name())) \
57 return false;
59 #define IPC_PROTOBUF_MESSAGE_TRAITS_END() \
60 return true; \
63 #endif // CHROME_COMMON_SAFE_BROWSING_PROTOBUF_MESSAGE_READ_MACROS_H_