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

Side by Side Diff: mojo/public/cpp/bindings/lib/serialization_util.h

Issue 1966933002: Mojo C++ bindings: switch the existing usage of StructTraits to use the new data view interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@26_reader
Patch Set: Created 4 years, 7 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_UTIL_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_UTIL_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_UTIL_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_UTIL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 95
96 template <typename T> 96 template <typename T>
97 inline void InterfaceDataToPointer(Interface_Data* input, 97 inline void InterfaceDataToPointer(Interface_Data* input,
98 InterfacePtr<T>* output, 98 InterfacePtr<T>* output,
99 SerializationContext* context) { 99 SerializationContext* context) {
100 output->Bind(InterfacePtrInfo<T>( 100 output->Bind(InterfacePtrInfo<T>(
101 context->handles.TakeHandleAs<mojo::MessagePipeHandle>(input->handle), 101 context->handles.TakeHandleAs<mojo::MessagePipeHandle>(input->handle),
102 input->version)); 102 input->version));
103 } 103 }
104 104
105 // TODO(yzshen): Unify StructTraits::Read*() methods and remove
106 // HasReadFromDataViewMethod.
107 template <typename T>
108 struct HasReadFromDataViewMethod {
109 template <typename U>
110 static char Test(decltype(U::ReadFromDataView)*);
111 template <typename U>
112 static int Test(...);
113 static const bool value = sizeof(Test<T>(0)) == sizeof(char);
114
115 private:
116 EnsureTypeIsComplete<T> check_t_;
117 };
118
119 template <typename T> 105 template <typename T>
120 struct HasIsNullMethod { 106 struct HasIsNullMethod {
121 template <typename U> 107 template <typename U>
122 static char Test(decltype(U::IsNull)*); 108 static char Test(decltype(U::IsNull)*);
123 template <typename U> 109 template <typename U>
124 static int Test(...); 110 static int Test(...);
125 static const bool value = sizeof(Test<T>(0)) == sizeof(char); 111 static const bool value = sizeof(Test<T>(0)) == sizeof(char);
126 112
127 private: 113 private:
128 EnsureTypeIsComplete<T> check_t_; 114 EnsureTypeIsComplete<T> check_t_;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 ReturnType CallWithContext(ReturnType (*f)(ParamType), 195 ReturnType CallWithContext(ReturnType (*f)(ParamType),
210 MaybeConstUserType& input, 196 MaybeConstUserType& input,
211 void* context) { 197 void* context) {
212 return f(input); 198 return f(input);
213 } 199 }
214 200
215 } // namespace internal 201 } // namespace internal
216 } // namespace mojo 202 } // namespace mojo
217 203
218 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_UTIL_H_ 204 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | mojo/public/cpp/bindings/tests/rect_blink_traits.h » ('j') | url/mojo/origin_struct_traits.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698