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 PPAPI_PROXY_PPAPI_MESSAGE_UTILS_H_ | 5 #ifndef PPAPI_PROXY_PPAPI_MESSAGE_UTILS_H_ |
6 #define PPAPI_PROXY_PPAPI_MESSAGE_UTILS_H_ | 6 #define PPAPI_PROXY_PPAPI_MESSAGE_UTILS_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
10 #include "base/tuple.h" | 10 #include "base/tuple.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 }; | 60 }; |
61 template <class A, class B, class C, class D, class E> | 61 template <class A, class B, class C, class D, class E> |
62 struct TupleTypeMatch5<Tuple<A, B, C, D, E>, A, B, C, D, E> { | 62 struct TupleTypeMatch5<Tuple<A, B, C, D, E>, A, B, C, D, E> { |
63 static const bool kValue = true; | 63 static const bool kValue = true; |
64 }; | 64 }; |
65 | 65 |
66 } // namespace internal | 66 } // namespace internal |
67 | 67 |
68 template <class MsgClass, class A> | 68 template <class MsgClass, class A> |
69 bool UnpackMessage(const IPC::Message& msg, A* a) { | 69 bool UnpackMessage(const IPC::Message& msg, A* a) { |
70 COMPILE_ASSERT( | 70 static_assert( |
71 (internal::TupleTypeMatch1<typename MsgClass::Param, A>::kValue), | 71 (internal::TupleTypeMatch1<typename MsgClass::Param, A>::kValue), |
72 tuple_types_dont_match); | 72 "tuple types should match"); |
73 | 73 |
74 PickleIterator iter(msg); | 74 PickleIterator iter(msg); |
75 return IPC::ReadParam(&msg, &iter, a); | 75 return IPC::ReadParam(&msg, &iter, a); |
76 } | 76 } |
77 | 77 |
78 template <class MsgClass, class A, class B> | 78 template <class MsgClass, class A, class B> |
79 bool UnpackMessage(const IPC::Message& msg, A* a, B* b) { | 79 bool UnpackMessage(const IPC::Message& msg, A* a, B* b) { |
80 COMPILE_ASSERT( | 80 static_assert( |
81 (internal::TupleTypeMatch2<typename MsgClass::Param, A, B>::kValue), | 81 (internal::TupleTypeMatch2<typename MsgClass::Param, A, B>::kValue), |
82 tuple_types_dont_match); | 82 "tuple types should match"); |
83 | 83 |
84 PickleIterator iter(msg); | 84 PickleIterator iter(msg); |
85 return IPC::ReadParam(&msg, &iter, a) && IPC::ReadParam(&msg, &iter, b); | 85 return IPC::ReadParam(&msg, &iter, a) && IPC::ReadParam(&msg, &iter, b); |
86 } | 86 } |
87 | 87 |
88 template <class MsgClass, class A, class B, class C> | 88 template <class MsgClass, class A, class B, class C> |
89 bool UnpackMessage(const IPC::Message& msg, A* a, B* b, C* c) { | 89 bool UnpackMessage(const IPC::Message& msg, A* a, B* b, C* c) { |
90 COMPILE_ASSERT( | 90 static_assert( |
91 (internal::TupleTypeMatch3<typename MsgClass::Param, A, B, C>::kValue), | 91 (internal::TupleTypeMatch3<typename MsgClass::Param, A, B, C>::kValue), |
92 tuple_types_dont_match); | 92 "tuple types should match"); |
93 | 93 |
94 PickleIterator iter(msg); | 94 PickleIterator iter(msg); |
95 return IPC::ReadParam(&msg, &iter, a) && | 95 return IPC::ReadParam(&msg, &iter, a) && |
96 IPC::ReadParam(&msg, &iter, b) && | 96 IPC::ReadParam(&msg, &iter, b) && |
97 IPC::ReadParam(&msg, &iter, c); | 97 IPC::ReadParam(&msg, &iter, c); |
98 } | 98 } |
99 | 99 |
100 template <class MsgClass, class A, class B, class C, class D> | 100 template <class MsgClass, class A, class B, class C, class D> |
101 bool UnpackMessage(const IPC::Message& msg, A* a, B* b, C* c, D* d) { | 101 bool UnpackMessage(const IPC::Message& msg, A* a, B* b, C* c, D* d) { |
102 COMPILE_ASSERT( | 102 static_assert( |
103 (internal::TupleTypeMatch4<typename MsgClass::Param, A, B, C, D>::kValue), | 103 (internal::TupleTypeMatch4<typename MsgClass::Param, A, B, C, D>::kValue), |
104 tuple_types_dont_match); | 104 "tuple types should match"); |
105 | 105 |
106 PickleIterator iter(msg); | 106 PickleIterator iter(msg); |
107 return IPC::ReadParam(&msg, &iter, a) && | 107 return IPC::ReadParam(&msg, &iter, a) && |
108 IPC::ReadParam(&msg, &iter, b) && | 108 IPC::ReadParam(&msg, &iter, b) && |
109 IPC::ReadParam(&msg, &iter, c) && | 109 IPC::ReadParam(&msg, &iter, c) && |
110 IPC::ReadParam(&msg, &iter, d); | 110 IPC::ReadParam(&msg, &iter, d); |
111 } | 111 } |
112 | 112 |
113 template <class MsgClass, class A, class B, class C, class D, class E> | 113 template <class MsgClass, class A, class B, class C, class D, class E> |
114 bool UnpackMessage(const IPC::Message& msg, A* a, B* b, C* c, D* d, E* e) { | 114 bool UnpackMessage(const IPC::Message& msg, A* a, B* b, C* c, D* d, E* e) { |
115 COMPILE_ASSERT( | 115 static_assert( |
116 (internal::TupleTypeMatch5< | 116 (internal::TupleTypeMatch5< |
117 typename MsgClass::Param, A, B, C, D, E>::kValue), | 117 typename MsgClass::Param, A, B, C, D, E>::kValue), |
118 tuple_types_dont_match); | 118 "tuple types should match"); |
119 | 119 |
120 PickleIterator iter(msg); | 120 PickleIterator iter(msg); |
121 return IPC::ReadParam(&msg, &iter, a) && | 121 return IPC::ReadParam(&msg, &iter, a) && |
122 IPC::ReadParam(&msg, &iter, b) && | 122 IPC::ReadParam(&msg, &iter, b) && |
123 IPC::ReadParam(&msg, &iter, c) && | 123 IPC::ReadParam(&msg, &iter, c) && |
124 IPC::ReadParam(&msg, &iter, d) && | 124 IPC::ReadParam(&msg, &iter, d) && |
125 IPC::ReadParam(&msg, &iter, e); | 125 IPC::ReadParam(&msg, &iter, e); |
126 } | 126 } |
127 | 127 |
128 } // namespace ppapi | 128 } // namespace ppapi |
129 | 129 |
130 #endif // PPAPI_PROXY_PPAPI_MESSAGE_UTILS_H_ | 130 #endif // PPAPI_PROXY_PPAPI_MESSAGE_UTILS_H_ |
OLD | NEW |