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

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

Issue 1955123003: Mojo C++ bindings: switch the remaining callsites of the old serialization interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@24_union_and_others
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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_FORWARD_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_FORWARD_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_FORWARD_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_FORWARD_H_
7 7
8 #include <stddef.h>
9
10 #include "mojo/public/cpp/bindings/array_traits.h" 8 #include "mojo/public/cpp/bindings/array_traits.h"
11 #include "mojo/public/cpp/bindings/lib/wtf_string_serialization.h"
12 #include "mojo/public/cpp/bindings/native_struct.h"
13 #include "mojo/public/cpp/bindings/string_traits.h" 9 #include "mojo/public/cpp/bindings/string_traits.h"
14 #include "mojo/public/cpp/bindings/struct_traits.h" 10 #include "mojo/public/cpp/bindings/struct_traits.h"
15 11
16 // This file is included by serialization implementation files to avoid circular 12 // This file is included by serialization implementation files to avoid circular
17 // includes. 13 // includes.
18 // Users of the serialization funtions should include serialization.h (and also 14 // Users of the serialization funtions should include serialization.h (and also
19 // wtf_serialization.h if necessary). 15 // wtf_serialization.h if necessary).
20 16
21 namespace mojo { 17 namespace mojo {
22 namespace internal { 18 namespace internal {
23 19
24 class Buffer;
25
26 class NativeStruct_Data;
27
28 struct SerializationContext;
29
30 template <typename MojomType, typename MaybeConstUserType> 20 template <typename MojomType, typename MaybeConstUserType>
31 struct Serializer; 21 struct Serializer;
32 22
33 // PrepareToSerialize() must be matched by a Serialize() for the same input 23 // PrepareToSerialize() must be matched by a Serialize() for the same input
34 // later. Moreover, within the same SerializationContext if PrepareToSerialize() 24 // later. Moreover, within the same SerializationContext if PrepareToSerialize()
35 // is called for |input_1|, ..., |input_n|, Serialize() must be called for 25 // is called for |input_1|, ..., |input_n|, Serialize() must be called for
36 // those objects in the exact same order. 26 // those objects in the exact same order.
37 template <typename MojomType, typename InputUserType, typename... Args> 27 template <typename MojomType, typename InputUserType, typename... Args>
38 size_t PrepareToSerialize(InputUserType&& input, Args&&... args) { 28 size_t PrepareToSerialize(InputUserType&& input, Args&&... args) {
39 return Serializer<MojomType, 29 return Serializer<MojomType,
(...skipping 12 matching lines...) Expand all
52 template <typename MojomType, 42 template <typename MojomType,
53 typename DataType, 43 typename DataType,
54 typename InputUserType, 44 typename InputUserType,
55 typename... Args> 45 typename... Args>
56 bool Deserialize(DataType&& input, InputUserType* output, Args&&... args) { 46 bool Deserialize(DataType&& input, InputUserType* output, Args&&... args) {
57 return Serializer<MojomType, InputUserType>::Deserialize( 47 return Serializer<MojomType, InputUserType>::Deserialize(
58 std::forward<DataType>(input), output, std::forward<Args>(args)...); 48 std::forward<DataType>(input), output, std::forward<Args>(args)...);
59 } 49 }
60 50
61 } // namespace internal 51 } // namespace internal
62
63 // TODO(yzshen): The following functions eventually will become simple wrappers
64 // of the Serializer interface. Remove them.
65
66 // -----------------------------------------------------------------------------
67 // Forward declaration for native types.
68
69 size_t GetSerializedSize_(const NativeStructPtr& input,
70 internal::SerializationContext* context);
71
72 void Serialize_(NativeStructPtr input,
73 internal::Buffer* buffer,
74 internal::NativeStruct_Data** output,
75 internal::SerializationContext* context);
76
77 bool Deserialize_(internal::NativeStruct_Data* input,
78 NativeStructPtr* output,
79 internal::SerializationContext* context);
80
81 // -----------------------------------------------------------------------------
82 // Forward declaration for String.
83
84 size_t GetSerializedSize_(const String& input,
85 internal::SerializationContext* context);
86 void Serialize_(const String& input,
87 internal::Buffer* buffer,
88 internal::String_Data** output,
89 internal::SerializationContext* context);
90 bool Deserialize_(internal::String_Data* input,
91 String* output,
92 internal::SerializationContext* context);
93
94 } // namespace mojo 52 } // namespace mojo
95 53
96 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_FORWARD_H_ 54 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_SERIALIZATION_FORWARD_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/serialization_context.cc ('k') | mojo/public/cpp/bindings/lib/serialization_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698