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

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

Issue 2007813004: Mojo C++ bindings: support attaching context object for StructTraits. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | mojo/public/cpp/bindings/struct_traits.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 } 206 }
207 207
208 static void* GetNext(SerializationContext* context) { return nullptr; } 208 static void* GetNext(SerializationContext* context) { return nullptr; }
209 209
210 template <typename MaybeConstUserType> 210 template <typename MaybeConstUserType>
211 static void TearDown(MaybeConstUserType& input, void* custom_context) { 211 static void TearDown(MaybeConstUserType& input, void* custom_context) {
212 DCHECK(!custom_context); 212 DCHECK(!custom_context);
213 } 213 }
214 }; 214 };
215 215
216 template <typename ReturnType, typename ParamType, typename MaybeConstUserType> 216 template <typename ReturnType, typename ParamType, typename InputUserType>
217 ReturnType CallWithContext(ReturnType (*f)(ParamType, void*), 217 ReturnType CallWithContext(ReturnType (*f)(ParamType, void*),
218 MaybeConstUserType& input, 218 InputUserType&& input,
219 void* context) { 219 void* context) {
220 return f(input, context); 220 return f(std::forward<InputUserType>(input), context);
221 } 221 }
222 222
223 template <typename ReturnType, typename ParamType, typename MaybeConstUserType> 223 template <typename ReturnType, typename ParamType, typename InputUserType>
224 ReturnType CallWithContext(ReturnType (*f)(ParamType), 224 ReturnType CallWithContext(ReturnType (*f)(ParamType),
225 MaybeConstUserType& input, 225 InputUserType&& input,
226 void* context) { 226 void* context) {
227 return f(input); 227 return f(std::forward<InputUserType>(input));
228 } 228 }
229 229
230 } // namespace internal 230 } // namespace internal
231 } // namespace mojo 231 } // namespace mojo
232 232
233 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_UTIL_H_ 233 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | mojo/public/cpp/bindings/struct_traits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698