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/pickle.h" | 8 #include "base/pickle.h" |
9 #include "base/tuple.h" | 9 #include "base/tuple.h" |
10 #include "ipc/ipc_message.h" | 10 #include "ipc/ipc_message.h" |
11 #include "ipc/ipc_message_utils.h" | 11 #include "ipc/ipc_message_utils.h" |
12 | 12 |
13 namespace ppapi { | 13 namespace ppapi { |
14 | 14 |
15 namespace internal { | 15 namespace internal { |
16 | 16 |
17 // TupleTypeMatch* check whether a tuple type contains elements of the specified | 17 // TupleTypeMatch* check whether a tuple type contains elements of the specified |
18 // types. They are used to make sure the output parameters of UnpackMessage() | 18 // types. They are used to make sure the output parameters of UnpackMessage() |
19 // match the corresponding message type. | 19 // match the corresponding message type. |
20 template <class TupleType, class A> | 20 template <class TupleType, class A> |
21 struct TupleTypeMatch1 { | 21 struct TupleTypeMatch1 { |
22 static const bool kValue = false; | 22 static const bool kValue = false; |
23 }; | 23 }; |
24 template <class A> | 24 template <class A> |
25 struct TupleTypeMatch1<base::Tuple<A>, A> { | 25 struct TupleTypeMatch1<std::tuple<A>, A> { |
26 static const bool kValue = true; | 26 static const bool kValue = true; |
27 }; | 27 }; |
28 | 28 |
29 template <class TupleType, class A, class B> | 29 template <class TupleType, class A, class B> |
30 struct TupleTypeMatch2 { | 30 struct TupleTypeMatch2 { |
31 static const bool kValue = false; | 31 static const bool kValue = false; |
32 }; | 32 }; |
33 template <class A, class B> | 33 template <class A, class B> |
34 struct TupleTypeMatch2<base::Tuple<A, B>, A, B> { | 34 struct TupleTypeMatch2<std::tuple<A, B>, A, B> { |
35 static const bool kValue = true; | 35 static const bool kValue = true; |
36 }; | 36 }; |
37 | 37 |
38 template <class TupleType, class A, class B, class C> | 38 template <class TupleType, class A, class B, class C> |
39 struct TupleTypeMatch3 { | 39 struct TupleTypeMatch3 { |
40 static const bool kValue = false; | 40 static const bool kValue = false; |
41 }; | 41 }; |
42 template <class A, class B, class C> | 42 template <class A, class B, class C> |
43 struct TupleTypeMatch3<base::Tuple<A, B, C>, A, B, C> { | 43 struct TupleTypeMatch3<std::tuple<A, B, C>, A, B, C> { |
44 static const bool kValue = true; | 44 static const bool kValue = true; |
45 }; | 45 }; |
46 | 46 |
47 template <class TupleType, class A, class B, class C, class D> | 47 template <class TupleType, class A, class B, class C, class D> |
48 struct TupleTypeMatch4 { | 48 struct TupleTypeMatch4 { |
49 static const bool kValue = false; | 49 static const bool kValue = false; |
50 }; | 50 }; |
51 template <class A, class B, class C, class D> | 51 template <class A, class B, class C, class D> |
52 struct TupleTypeMatch4<base::Tuple<A, B, C, D>, A, B, C, D> { | 52 struct TupleTypeMatch4<std::tuple<A, B, C, D>, A, B, C, D> { |
53 static const bool kValue = true; | 53 static const bool kValue = true; |
54 }; | 54 }; |
55 | 55 |
56 template <class TupleType, class A, class B, class C, class D, class E> | 56 template <class TupleType, class A, class B, class C, class D, class E> |
57 struct TupleTypeMatch5 { | 57 struct TupleTypeMatch5 { |
58 static const bool kValue = false; | 58 static const bool kValue = false; |
59 }; | 59 }; |
60 template <class A, class B, class C, class D, class E> | 60 template <class A, class B, class C, class D, class E> |
61 struct TupleTypeMatch5<base::Tuple<A, B, C, D, E>, A, B, C, D, E> { | 61 struct TupleTypeMatch5<std::tuple<A, B, C, D, E>, A, B, C, D, E> { |
62 static const bool kValue = true; | 62 static const bool kValue = true; |
63 }; | 63 }; |
64 | 64 |
65 } // namespace internal | 65 } // namespace internal |
66 | 66 |
67 template <class MsgClass, class A> | 67 template <class MsgClass, class A> |
68 bool UnpackMessage(const IPC::Message& msg, A* a) { | 68 bool UnpackMessage(const IPC::Message& msg, A* a) { |
69 static_assert( | 69 static_assert( |
70 (internal::TupleTypeMatch1<typename MsgClass::Param, A>::kValue), | 70 (internal::TupleTypeMatch1<typename MsgClass::Param, A>::kValue), |
71 "tuple types should match"); | 71 "tuple types should match"); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 return IPC::ReadParam(&msg, &iter, a) && | 120 return IPC::ReadParam(&msg, &iter, a) && |
121 IPC::ReadParam(&msg, &iter, b) && | 121 IPC::ReadParam(&msg, &iter, b) && |
122 IPC::ReadParam(&msg, &iter, c) && | 122 IPC::ReadParam(&msg, &iter, c) && |
123 IPC::ReadParam(&msg, &iter, d) && | 123 IPC::ReadParam(&msg, &iter, d) && |
124 IPC::ReadParam(&msg, &iter, e); | 124 IPC::ReadParam(&msg, &iter, e); |
125 } | 125 } |
126 | 126 |
127 } // namespace ppapi | 127 } // namespace ppapi |
128 | 128 |
129 #endif // PPAPI_PROXY_PPAPI_MESSAGE_UTILS_H_ | 129 #endif // PPAPI_PROXY_PPAPI_MESSAGE_UTILS_H_ |
OLD | NEW |